本文整理匯總了Golang中github.com/handcraftsman/GeneticGo.Solver.NumberOfConcurrentEvolvers方法的典型用法代碼示例。如果您正苦於以下問題:Golang Solver.NumberOfConcurrentEvolvers方法的具體用法?Golang Solver.NumberOfConcurrentEvolvers怎麽用?Golang Solver.NumberOfConcurrentEvolvers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/handcraftsman/GeneticGo.Solver
的用法示例。
在下文中一共展示了Solver.NumberOfConcurrentEvolvers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
clearImages()
startX := fieldWidth / 2
startY := fieldHeight / 2
flowerPoints := createFlowerPoints()
calc := func(candidate string) int {
field := NewField(fieldWidth, fieldHeight, flowerPoints)
bee := NewBee(startX, startY)
program := evaluate(candidate, bee, field, startX, startY)
fitness := getFitness(field.numberOfFlowersFound, program.numberOfInstructions())
return fitness
}
start := time.Now()
disp := func(candidate string) {
field := NewField(fieldWidth, fieldHeight, flowerPoints)
bee := NewBee(startX, startY)
program := evaluate(candidate, bee, field, startX, startY)
fitness := getFitness(field.numberOfFlowersFound, program.numberOfInstructions())
display(bee, flowerPoints, program, fitness, startX, startY, time.Since(start))
}
var solver = new(genetic.Solver)
solver.MaxSecondsToRunWithoutImprovement = 3
solver.MaxRoundsWithoutImprovement = 3
solver.PrintDiagnosticInfo = true
solver.NumberOfConcurrentEvolvers = 1 // 3
// solver.MaxProcs = 12
var best = solver.GetBestUsingHillClimbing(calc, disp, geneSet, maxBeeActions, 4, maxFitness)
fmt.Print("\nFinal: ")
disp(best)
}