From e4c15d30f9fe4fcd1a6e45041dcaf19346481312 Mon Sep 17 00:00:00 2001 From: pytlab Date: Tue, 12 Dec 2017 22:06:52 +0800 Subject: [PATCH] Fix example 2. --- examples/ex02/ex02.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/ex02/ex02.py b/examples/ex02/ex02.py index 95e4562..b27038a 100644 --- a/examples/ex02/ex02.py +++ b/examples/ex02/ex02.py @@ -8,7 +8,7 @@ from math import sin, cos, pi from gaft import GAEngine -from gaft.components import GAIndividual +from gaft.components import BinaryIndividual from gaft.components import GAPopulation from gaft.operators import TournamentSelection from gaft.operators import UniformCrossover @@ -19,9 +19,7 @@ from gaft.analysis.console_output import ConsoleOutput # Define population. -indv_template = GAIndividual(ranges=[(-2, 2), (-2, 2)], - encoding='binary', - eps=0.001) +indv_template = BinaryIndividual(ranges=[(-2, 2), (-2, 2)], eps=0.001) population = GAPopulation(indv_template=indv_template, size=50).init() # Create genetic operators. @@ -39,7 +37,7 @@ # Define fitness function. @engine.fitness_register def fitness(indv): - x, y = indv.variants + x, y = indv.solution return y*sin(2*pi*x) + x*cos(2*pi*y) if '__main__' == __name__: