This repository was archived by the owner on Dec 11, 2018. It is now read-only.
File tree 6 files changed +7
-32
lines changed
6 files changed +7
-32
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,7 @@ type Config struct {
55
55
CoeffUnmatching float64 `json:"coeffUnmatching"` // unmatching genes
56
56
CoeffMatching float64 `json:"coeffMatching"` // matching genes
57
57
58
- // Miscellaneous settings
59
- Lamarckian bool `json:"lamarckian"` // Lamarckian evolution
58
+ // CPPN settings
60
59
CPPNActivations []string `json:"cppnActivations"` // additional activations
61
60
}
62
61
@@ -112,8 +111,7 @@ func (c *Config) Summarize() {
112
111
fmt .Fprintf (w , "+ Unmatching connection genes\t %.3f\t \n " , c .CoeffUnmatching )
113
112
fmt .Fprintf (w , "+ Matching connection genes\t %.3f\t \n \n " , c .CoeffMatching )
114
113
115
- fmt .Fprintf (w , "Miscellaneous settings\t \n " )
116
- fmt .Fprintf (w , "+ Lamarckian evolution\t %t\t \n " , c .Lamarckian )
114
+ fmt .Fprintf (w , "CPPN settings\t \n " )
117
115
fmt .Fprintf (w , "+ CPPN Activation functions\t %s\t \n " , c .CPPNActivations )
118
116
119
117
w .Flush ()
Original file line number Diff line number Diff line change 4
4
"numInputs" : 4 ,
5
5
"numOutputs" : 2 ,
6
6
"fullyConnected" : false ,
7
- "numGenerations" : 50 ,
7
+ "numGenerations" : 30 ,
8
8
"populationSize" : 100 ,
9
9
"initFitness" : 0.0 ,
10
10
"minimizeFitness" : false ,
Original file line number Diff line number Diff line change 9
9
"minimizeFitness" : false ,
10
10
"survivalRate" : 0.0 ,
11
11
"stagnationLimit" : 0 ,
12
- "hallOfFameSize" : 0 ,
13
12
"ratePerturb" : 0.0 ,
14
13
"rateAddNode" : 0.0 ,
15
14
"rateAddConn" : 0.0 ,
Original file line number Diff line number Diff line change 3
3
"verbose" : true ,
4
4
"numInputs" : 3 ,
5
5
"numOutputs" : 1 ,
6
+ "fullyConnected" : true ,
6
7
"numGenerations" : 50 ,
7
8
"populationSize" : 50 ,
8
9
"initFitness" : 9999.0 ,
Original file line number Diff line number Diff line change @@ -193,27 +193,13 @@ func (g *Genome) String() string {
193
193
// Evaluate takes an evaluation function and evaluates its fitness. Only perform
194
194
// the evaluation if it hasn't yet. If the lamarckian indicator is true, encode
195
195
// the phenotype neural network back into the genome.
196
- func (g * Genome ) Evaluate (evaluate EvaluationFunc , lamarckian bool ) {
196
+ func (g * Genome ) Evaluate (evaluate EvaluationFunc ) {
197
197
if g .evaluated {
198
198
return
199
199
}
200
200
nn := NewNeuralNetwork (g )
201
201
g .Fitness = evaluate (nn )
202
202
g .evaluated = true
203
-
204
- // for Lamarckian evolution, any changes to the neural network's weights are
205
- // encoded back to the genome's connection genes.
206
- if lamarckian {
207
- for _ , to := range nn .Neurons {
208
- for from , weight := range to .Synapses {
209
- for _ , conn := range g .ConnGenes {
210
- if from .ID == conn .From && to .ID == conn .To {
211
- conn .Weight = weight
212
- }
213
- }
214
- }
215
- }
216
- }
217
203
}
218
204
219
205
// ExportJSON exports a JSON file that contains this genome's information. If
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import (
22
22
"math"
23
23
"math/rand"
24
24
"sort"
25
- "sync"
26
25
)
27
26
28
27
// NEAT is the implementation of NeuroEvolution of Augmenting Topology (NEAT).
@@ -122,17 +121,9 @@ func (n *NEAT) Summarize(gen int) {
122
121
// Evaluate evaluates fitness of every genome in the population. After the
123
122
// evaluation, their fitness scores are recored in each genome.
124
123
func (n * NEAT ) Evaluate () {
125
- var wg sync.WaitGroup
126
-
127
- for i := range n .Population {
128
- wg .Add (1 )
129
- go func (j int ) {
130
- defer wg .Done ()
131
- n .Population [j ].Evaluate (n .Evaluation , n .Config .Lamarckian )
132
- }(i )
124
+ for _ , genome := range n .Population {
125
+ genome .Evaluate (n .Evaluation )
133
126
}
134
-
135
- wg .Wait ()
136
127
}
137
128
138
129
// Speciate performs speciation of each genome. The speciation mechanism is as
You can’t perform that action at this time.
0 commit comments