From fade62f0b82320f209c5ed2bdb3e3d531e3f9e40 Mon Sep 17 00:00:00 2001
From: Armin <armin.co@hs-bochum.de>
Date: Sat, 20 Feb 2021 19:49:25 +0100
Subject: [PATCH] Benchmarks for the OpenAiGym environment.

---
 run_scripts/benchmarks.py | 125 ++++++++++++++++++++++++++++++++++++++
 run_scripts/cartpole.py   |  20 ++++++
 2 files changed, 145 insertions(+)
 create mode 100644 run_scripts/benchmarks.py
 create mode 100644 run_scripts/cartpole.py

diff --git a/run_scripts/benchmarks.py b/run_scripts/benchmarks.py
new file mode 100644
index 0000000..77c6391
--- /dev/null
+++ b/run_scripts/benchmarks.py
@@ -0,0 +1,125 @@
+import main
+import environment_wrapper as ew
+import gym
+import copy
+import threading
+from agents import QAgent, DQAgent
+
+c = ew.Config()
+
+c.name = 'Base'
+c.render = False
+c.env = gym.make('LunarLander-v2')
+c.env_type = 'Lunar'
+c.net_layout = [256, 128]
+c.eps_decay = 0.9996
+c.learn_rate= 0.001
+c.run_episodes = 300
+c.save_to = 'benchmarks/'
+
+smallNet = copy.deepcopy(c)
+smallNet.name = 'SmallNet'
+smallNet.net_layout = [128, 32]
+smallNet.conf_to_name()
+# smallNet.agent = QAgent(smallNet)
+
+smallNetDeep = copy.deepcopy(c)
+smallNetDeep.name = 'SmallNetDeep'
+smallNetDeep.net_layout = [128, 32, 32]
+smallNetDeep.conf_to_name()
+
+smallNetDeepSlowLearn = copy.deepcopy(c)
+smallNetDeepSlowLearn.name = 'SmallNetDeep'
+smallNetDeepSlowLearn.net_layout = [128, 32, 32]
+smallNetDeepSlowLearn.learn_rate = 0.0005
+smallNetDeepSlowLearn.conf_to_name()
+
+normalNet = copy.deepcopy(c)
+normalNet.name = 'NormalNet'
+normalNet.net_layout = [256, 128]
+normalNet.conf_to_name()
+
+normalSlowDecay = copy.deepcopy(c)
+normalSlowDecay.name = 'NormalSlowDecay'
+normalSlowDecay.net_layout = [256, 128]
+normalSlowDecay.eps_decay = 0.99995
+normalSlowDecay.conf_to_name()
+
+normalSlowLearn = copy.deepcopy(c)
+normalSlowLearn.name = 'NormalSlowLearn'
+normalSlowLearn.net_layout = [256, 128]
+normalSlowLearn.learn_rate = 0.0005
+normalSlowLearn.conf_to_name()
+
+largeNet = copy.deepcopy(c)
+largeNet.name = 'LargeNet'
+largeNet.net_layout = [512, 256]
+largeNet.conf_to_name()
+
+deepNet = copy.deepcopy(c)
+deepNet.name = 'DeppNet'
+deepNet.net_layout = [256, 128, 128]
+deepNet.conf_to_name()
+
+deepNetSlowLearn = copy.deepcopy(c)
+deepNetSlowLearn.name = 'DeppNet'
+deepNetSlowLearn.net_layout = [256, 128, 128]
+deepNetSlowLearn.learn_rate = 0.0005
+deepNetSlowLearn.conf_to_name()
+
+deepNetSmaller = copy.deepcopy(c)
+deepNetSmaller.name = 'DeppNetSmaller'
+deepNetSmaller.net_layout = [256, 128, 32]
+deepNetSmaller.conf_to_name()
+
+littleNet = copy.deepcopy(c)
+littleNet.name = 'LittleNet'
+littleNet.net_layout = [64, 64]
+littleNet.conf_to_name()
+
+verryLittleNet = copy.deepcopy(c)
+verryLittleNet.name = 'VerryLittleNet'
+verryLittleNet.net_layout = [64, 32]
+verryLittleNet.conf_to_name()
+
+verryLittleNetDeep = copy.deepcopy(c)
+verryLittleNetDeep.name = 'VerryLittleNetDeep'
+verryLittleNetDeep.net_layout = [64, 32, 32]
+verryLittleNetDeep.conf_to_name()
+
+lun = copy.deepcopy(c)
+lun.run_episodes = 500
+lun.name = 'NormalLunarDoubleNotSoMoreLearn'
+lun.net_layout = [256, 128]
+lun.conf_to_name()
+# lun.agent = QAgent(lun)
+
+# configuration = smallNet
+# configuration = smallNetDeep
+configuration = normalNet
+# configuration = normalSlowDecay
+# configuration = normalSlowLearn
+# configuration = largeNet
+# configuration = deepNet
+# configuration = deepNetSmaller
+# configuration = verryLittleNet
+# configuration = littleNet
+# configuration = verryLittleNetDeep
+# configuration = deepNetSlowLearn
+# configuration = smallNetDeepSlowLearn
+# configuration = lun
+print(configuration.name)
+configuration.agent = QAgent(configuration)
+main.run(configuration)
+
+# configurations = [smallNet, smallNetDeep, normalNet, normalSlowDecay, normalSlowLearn, largeNet, deepNet, verryLittleNet, littleNet, verryLittleNetDeep, smallNetDeepSlowLearn, deepNetSlowLearn]
+
+# threads = []
+# for conf in configurations:
+#     threads.append(threading.Thread(target=main.run, args=[conf]))
+
+# for thread in threads:
+#     thread.start()
+
+# for thread in threads:
+#     thread.join()
\ No newline at end of file
diff --git a/run_scripts/cartpole.py b/run_scripts/cartpole.py
new file mode 100644
index 0000000..ad2bb1d
--- /dev/null
+++ b/run_scripts/cartpole.py
@@ -0,0 +1,20 @@
+import main
+import environment_wrapper as ew
+import gym
+from agents import DQAgent, QAgent
+
+c = ew.Config()
+
+c.name = 'DoubleCartPole'
+c.render = False
+c.env = gym.make('CartPole-v0')
+c.env_type = 'CartPole'
+c.net_layout = [128, 64, 32]
+c.eps_decay = 0.9991
+c.learn_rate= 0.001
+c.run_episodes = 300
+c.save_to = 'benchmarks/'
+c.conf_to_name()
+c.agent = QAgent(c)
+
+main.run(c)
-- 
GitLab