-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathev1.py
More file actions
115 lines (66 loc) · 1.9 KB
/
ev1.py
File metadata and controls
115 lines (66 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import sys
sys.path.append('./classes')
from EPANN import EPANN
from Population import Population
import RunTools as rt
from GymAgent import GymAgent
from time import time
import numpy as np
ea = EPANN(agent_class=GymAgent, env_name='CartPole')
#ea.plotNetwork()
ea.addConnectingWeight((0,4))
ea.addConnectingWeight((1,4))
ea.addNodeInBetween(1,4)
ea.addConnectingWeight((2,5))
ea.addNode()
ea.addConnectingWeight((2,6))
ea.addConnectingWeight((3,4))
ea.addConnectingWeight((3,5))
ea.addConnectingWeight((6,5))
#ea.addAtomInBetween((2,5))
N_tests = 100000
inputs = np.random.random((N_tests, 4))
st = time()
for i in range(N_tests):
ea.forwardPass(inputs[i])
print('time elapsed:', time() - st)
#ea.plotNetwork()
exit()
p1 = Population(agent_class=GymAgent, env_name='CartPole', N_pop=64, mut_type='change_topo', std=1.0, render_type='gym')
p1.evolve(N_gen=128, N_episode_steps=200, N_trials_per_agent=2, N_runs_with_best=2, record_final_runs=False, show_final_runs=False)
exit(0)
evolve_params = {
'N_runs' : 3,
'agent_class' : GymAgent,
'env_name' : 'LunarLander',
'N_pop' : 64,
'mut_type' : 'change_topo',
'std' : [0.01, 0.1, 1, 10],
'N_gen' : 256,
'N_trials_per_agent' : 2,
'N_runs_with_best' : 9,
'record_final_runs' : True,
'show_final_runs' : False
}
rt.varyParam(object_class=Population, run_fn=Population.evolve, run_result_var='best_individ_avg_score', **evolve_params)
exit()
evolve_params = {
'N_runs' : 3,
'agent_class' : GymAgent,
'env_name' : 'LunarLander',
'N_pop' : 64,
'mut_type' : 'change_topo',
'std' : [0.01, 0.1, 1.0, 10.0],
'N_gen' : 256,
'N_trials_per_agent' : 2,
'N_runs_with_best' : 9,
'record_final_runs' : True,
'show_final_runs' : False
}
e = EPANN(agent_class=PendulumAgent)
e.loadNetworkFromFile(
'/home/declan/Documents/code/evo1/misc_runs/evolve_22-01-2019_18-01-04__PendulumAgent' +
'/' + 'bestNN_PendulumAgent_22-01-2019_18-01-04' + '.json'
)
exit(0)
#