Exemplo n.º 1
0
Arquivo: fit.go Projeto: tomzhang/gago
func main() {
	// Instantiate a GA with 3 variables and the fitness function
	var ga = presets.Float(3, leastSquares)
	ga.Initialize()
	// Enhancement
	for i := 0; i < 1000; i++ {
		fmt.Println(ga.Best.Fitness)
		ga.Enhance()
	}
}
Exemplo n.º 2
0
func main() {
	// Instantiate a GA with 2 variables and the fitness function
	var ga = presets.Float(2, rastrigin)
	ga.Initialize()
	// Enhancement
	for i := 0; i < 40; i++ {
		ga.Enhance()
	}
	// Display the best obtained solution
	fmt.Printf("The best obtained solution is %f\n", ga.Best.Fitness)
}