Skip to content

Commit

Permalink
More work parallel GA. Still terrible performance
Browse files Browse the repository at this point in the history
  • Loading branch information
thoj committed May 17, 2010
1 parent 4c74693 commit 165fd8b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ga_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,26 @@ func (ga *GAParallel) Optimize(gen int) {
for i := 0; i < ga.numproc; i++ {
<-c
}
nselect := gen * 2
children := make([]GAGenomes, ga.numproc)
for i := 0; i < ga.numproc; i++ {
children[i] = make(GAGenomes, nselect)
for j := 0; j < nselect; j++ {
children[i][j] = ga.ga[i].Parameter.Selector.SelectOne(ga.ga[i].pop)
}
}
j := ga.numproc - 1
for i := 0; i < ga.numproc; i++ {
ga.ga[i].pop = AppendGenomes(ga.ga[i].pop, children[j])
j--
}
}


func (ga *GAParallel) OptimizeUntil(stop func(best GAGenome) bool) {
for !stop(ga.Best()) {
ga.Optimize(10)
}
for !stop(ga.Best()) {
ga.Optimize(1)
}
}


Expand Down

0 comments on commit 165fd8b

Please sign in to comment.