Skip to content

Commit

Permalink
Fix example 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
PytLab committed Dec 12, 2017
1 parent a42e4c8 commit e4c15d3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions examples/ex02/ex02.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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__:
Expand Down

0 comments on commit e4c15d3

Please sign in to comment.