@@ -44,36 +44,43 @@ overfitting.
44
44
## Optimization Functions
45
45
46
46
There are three objective functions:
47
- * Maximize mean match score over all opponents with ` objective_match_score `
48
- * Maximize mean match score difference over all opponents with ` objective_match_score_difference `
49
- * Maximize Moran process fixation probability with ` objective_match_moran_win `
47
+ * Maximize mean match score over all opponents with ` objective_score `
48
+ * Maximize mean match score difference over all opponents with ` objective_score_difference `
49
+ * Maximize Moran process fixation probability with ` objective_moran_win `
50
+
51
+ Parameters for the objective functions can be specified in the command line
52
+ arguments for each evolver.
50
53
51
54
## Running
52
55
53
56
### Look up Tables
54
57
55
58
``` bash
56
59
$ python lookup_evolve.py -h
57
- Lookup Evolve.
60
+ Lookup Table Evolver
58
61
59
62
Usage:
60
- lookup_evolve.py [-h] [-p PLAYS] [-o OPP_PLAYS] [-s STARTING_PLAYS]
61
- [-g GENERATIONS] [-k STARTING_POPULATION] [-u MUTATION_RATE] [-b BOTTLENECK]
62
- [-i PROCESSORS] [-f OUTPUT_FILE] [-z INITIAL_POPULATION_FILE] [-n NOISE]
63
+ lookup_evolve.py [-h] [--generations GENERATIONS] [--population POPULATION]
64
+ [--mu MUTATION_RATE] [--bottleneck BOTTLENECK] [--processes PROCESSORS]
65
+ [--output OUTPUT_FILE] [--objective OBJECTIVE] [--repetitions REPETITIONS]
66
+ [--noise NOISE] [--nmoran NMORAN]
67
+ [--plays PLAYS] [--op_plays OP_PLAYS] [--op_start_plays OP_START_PLAYS]
63
68
64
69
Options:
65
- -h --help show this
66
- -p PLAYS number of recent plays in the lookup table [default: 2]
67
- -o OPP_PLAYS number of recent plays in the lookup table [default: 2]
68
- -s STARTING_PLAYS number of opponent starting plays in the lookup table [default: 2]
69
- -g GENERATIONS how many generations to run the program for [default: 500]
70
- -k STARTING_POPULATION starting population size for the simulation [default: 20]
71
- -u MUTATION_RATE mutation rate i.e. probability that a given value will flip [default: 0.1]
72
- -b BOTTLENECK number of individuals to keep from each generation [default: 10]
73
- -i PROCESSORS number of processors to use [default: 1]
74
- -f OUTPUT_FILE file to write data to [default: tables.csv]
75
- -z INITIAL_POPULATION_FILE file to read an initial population from [default: None]
76
- -n NOISE match noise [default: 0.00]
70
+ -h --help Show help
71
+ --generations GENERATIONS Generations to run the EA [default: 500]
72
+ --population POPULATION Starting population size [default: 10]
73
+ --mu MUTATION_RATE Mutation rate [default: 0.1]
74
+ --bottleneck BOTTLENECK Number of individuals to keep from each generation [default: 5]
75
+ --processes PROCESSES Number of processes to use [default: 1]
76
+ --output OUTPUT_FILE File to write data to [default: lookup_tables.csv]
77
+ --objective OBJECTIVE Objective function [default: score]
78
+ --repetitions REPETITIONS Repetitions in objective [default: 100]
79
+ --noise NOISE Match noise [default: 0.00]
80
+ --nmoran NMORAN Moran Population Size, if Moran objective [default: 4]
81
+ --plays PLAYS Number of recent plays in the lookup table [default: 2]
82
+ --op_plays OP_PLAYS Number of recent plays in the lookup table [default: 2]
83
+ --op_start_plays OP_START_PLAYS Number of opponent starting plays in the lookup table [default: 2]
77
84
` ` `
78
85
79
86
There are a number of options and you' ll want to set the
@@ -87,17 +94,32 @@ so that there's enough variation introduced.
87
94
$ python pso_evolve.py -h
88
95
Particle Swarm strategy training code.
89
96
97
+ Original version by Georgios Koutsovoulos @GDKO :
98
+ https://gist.github.com/GDKO/60c3d0fd423598f3c4e4
99
+ Based on Martin Jones @mojones original LookerUp code
100
+
90
101
Usage:
91
- pso_evolve.py [-h] [-p PLAYS] [-s STARTING_PLAYS] [-g GENERATIONS]
92
- [-i PROCESSORS] [-o OPP_PLAYS] [-n NOISE]
102
+ pso_evolve.py [-h] [--generations GENERATIONS] [--population POPULATION]
103
+ [--mu MUTATION_RATE] [--bottleneck BOTTLENECK] [--processes PROCESSORS]
104
+ [--output OUTPUT_FILE] [--objective OBJECTIVE] [--repetitions REPETITIONS]
105
+ [--noise NOISE] [--nmoran NMORAN]
106
+ [--plays PLAYS] [--op_plays OP_PLAYS] [--op_start_plays OP_START_PLAYS]
93
107
94
108
Options:
95
- -h --help show help
96
- -p PLAYS number of recent plays in the lookup table [default: 2]
97
- -o OPP_PLAYS number of recent opponent' s plays in the lookup table [default: 2]
98
- -s STARTING_PLAYS number of opponent starting plays in the lookup table [default: 2]
99
- -i PROCESSORS number of processors to use [default: 1]
100
- -n NOISE match noise [default: 0.0]
109
+ -h --help Show help
110
+ --generations GENERATIONS Generations to run the EA [default: 500]
111
+ --population POPULATION Starting population size [default: 10]
112
+ --mu MUTATION_RATE Mutation rate [default: 0.1]
113
+ --bottleneck BOTTLENECK Number of individuals to keep from each generation [default: 5]
114
+ --processes PROCESSES Number of processes to use [default: 1]
115
+ --output OUTPUT_FILE File to write data to [default: pso_tables.csv]
116
+ --objective OBJECTIVE Objective function [default: score]
117
+ --repetitions REPETITIONS Repetitions in objective [default: 100]
118
+ --noise NOISE Match noise [default: 0.00]
119
+ --nmoran NMORAN Moran Population Size, if Moran objective [default: 4]
120
+ --plays PLAYS Number of recent plays in the lookup table [default: 2]
121
+ --op_plays OP_PLAYS Number of recent plays in the lookup table [default: 2]
122
+ --op_start_plays OP_START_PLAYS Number of opponent starting plays in the lookup table [default: 2]
101
123
` ` `
102
124
103
125
Note that to use the multiprocessor version you' ll need to install pyswarm 0.70
@@ -107,46 +129,62 @@ directly (pip installs 0.60 which lacks mutiprocessing support).
107
129
108
130
```bash
109
131
$ python ann_evolve.py -h
110
- Training ANN strategies with an evolutionary algorithm.
132
+ ANN evolver.
133
+ Trains ANN strategies with an evolutionary algorithm.
134
+
135
+ Original version by Martin Jones @mojones:
136
+ https://gist.github.com/mojones/b809ba565c93feb8d44becc7b93e37c6
111
137
112
138
Usage:
113
- ann_evolve.py [-h] [-g GENERATIONS] [-u MUTATION_RATE] [-b BOTTLENECK]
114
- [-d MUTATION_DISTANCE] [-i PROCESSORS] [-o OUTPUT_FILE]
115
- [-k STARTING_POPULATION] [-n NOISE]
139
+ ann_evolve.py [-h] [--generations GENERATIONS] [--population POPULATION]
140
+ [--mu MUTATION_RATE] [--bottleneck BOTTLENECK] [--processes PROCESSORS]
141
+ [--output OUTPUT_FILE] [--objective OBJECTIVE] [--repetitions REPETITIONS]
142
+ [--noise NOISE] [--nmoran NMORAN]
143
+ [--features FEATURES] [--hidden HIDDEN] [--mu_distance DISTANCE]
116
144
117
145
Options:
118
- -h --help show this
119
- -g GENERATIONS how many generations to run the program for [default: 10000]
120
- -u MUTATION_RATE mutation rate i.e. probability that a given value will flip [default: 0.4]
121
- -d MUTATION_DISTANCE amount of change a mutation will cause [default: 10]
122
- -b BOTTLENECK number of individuals to keep from each generation [default: 6]
123
- -i PROCESSORS number of processors to use [default: 4]
124
- -o OUTPUT_FILE file to write statistics to [default: weights.csv]
125
- -k STARTING_POPULATION starting population size for the simulation [default: 5]
126
- -n NOISE match noise [default: 0.0]
146
+ -h --help Show help
147
+ --generations GENERATIONS Generations to run the EA [default: 500]
148
+ --population POPULATION Starting population size [default: 10]
149
+ --mu MUTATION_RATE Mutation rate [default: 0.1]
150
+ --bottleneck BOTTLENECK Number of individuals to keep from each generation [default: 5]
151
+ --processes PROCESSES Number of processes to use [default: 1]
152
+ --output OUTPUT_FILE File to write data to [default: ann_weights.csv]
153
+ --objective OBJECTIVE Objective function [default: score]
154
+ --repetitions REPETITIONS Repetitions in objective [default: 100]
155
+ --noise NOISE Match noise [default: 0.00]
156
+ --nmoran NMORAN Moran Population Size, if Moran objective [default: 4]
157
+ --features FEATURES Number of ANN features [default: 17]
158
+ --hidden HIDDEN Number of hidden nodes [default: 10]
159
+ --mu_distance DISTANCE Delta max for weights updates [default: 5]
127
160
```
128
161
129
162
### Finite State Machines
130
163
131
164
```bash
132
165
$ python fsm_evolve.py -h
133
- FSM Evolve.
166
+ Finite State Machine Evolver
134
167
135
168
Usage:
136
- fsm_evolve.py [-h] [-s NUM_STATES] [-g GENERATIONS]
137
- [-k STARTING_POPULATION] [-u MUTATION_RATE] [-b BOTTLENECK]
138
- [-i PROCESSORS] [-f OUTPUT_FILE] [-n NOISE]
169
+ fsm_evolve.py [-h] [--generations GENERATIONS] [--population POPULATION]
170
+ [--mu MUTATION_RATE] [--bottleneck BOTTLENECK] [--processes PROCESSORS]
171
+ [--output OUTPUT_FILE] [--objective OBJECTIVE] [--repetitions REPETITIONS]
172
+ [--noise NOISE] [--nmoran NMORAN]
173
+ [--states NUM_STATES]
139
174
140
175
Options:
141
- -h --help show this
142
- -s NUM_STATES number FSM states [default: 16]
143
- -g GENERATIONS how many generations to run the program for [default: 500]
144
- -k STARTING_POPULATION starting population size for the simulation [default: 20]
145
- -u MUTATION_RATE mutation rate i.e. probability that a given value will flip [default: 0.1]
146
- -b BOTTLENECK number of individuals to keep from each generation [default: 10]
147
- -i PROCESSORS number of processors to use [default: 1]
148
- -f OUTPUT_FILE file to write data to [default: fsm_tables.csv]
149
- -n NOISE match noise [default: 0.00]
176
+ -h --help Show help
177
+ --generations GENERATIONS Generations to run the EA [default: 500]
178
+ --population POPULATION Starting population size [default: 10]
179
+ --mu MUTATION_RATE Mutation rate [default: 0.1]
180
+ --bottleneck BOTTLENECK Number of individuals to keep from each generation [default: 5]
181
+ --processes PROCESSES Number of processes to use [default: 1]
182
+ --output OUTPUT_FILE File to write data to [default: fsm_tables.csv]
183
+ --objective OBJECTIVE Objective function [default: score]
184
+ --repetitions REPETITIONS Repetitions in objective [default: 100]
185
+ --noise NOISE Match noise [default: 0.00]
186
+ --nmoran NMORAN Moran Population Size, if Moran objective [default: 4]
187
+ --states NUM_STATES Number of FSM states [default: 8]
150
188
```
151
189
152
190
## Open questions
0 commit comments