當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Solver.NumberOfConcurrentEvolvers方法代碼示例

本文整理匯總了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)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:36,代碼來源:main.go


注:本文中的github.com/handcraftsman/GeneticGo.Solver.NumberOfConcurrentEvolvers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。