File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
mlp-ea-decentralized/common/ga Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,9 @@ type PoolModel struct {
4545 BestCallback func (* PoolModel )
4646 GenerationCallback func (* PoolModel )
4747
48- CrossRate float64
49- MutRate float64
48+ NCandidates int
49+ CrossRate float64
50+ MutRate float64
5051
5152 PopSize int
5253 MaxEvaluations int
@@ -85,6 +86,7 @@ func MakePool(
8586 pool := & PoolModel {
8687 Rnd : rnd ,
8788 PopSize : popSize ,
89+ NCandidates : 4 ,
8890 population : MakePopulation (),
8991 popSemaphore : make (semaphore , popSize ),
9092 evaluations : 0 ,
@@ -150,10 +152,10 @@ func (pool *PoolModel) Minimize() {
150152
151153 // At least nOffsprings shold be available in the population
152154 // tu run this operator
153- pool .popSemaphore .Acquire (4 )
155+ pool .popSemaphore .Acquire (pool . NCandidates )
154156
155157 // take here randomly from population
156- offsprings = pool .selection (4 , 4 )
158+ offsprings = pool .selection (4 , pool . NCandidates )
157159 offsprings = pool .crossover (offsprings )
158160 offsprings = pool .mutate (offsprings )
159161
You can’t perform that action at this time.
0 commit comments