3
===============================
4
Short One Max Genetic Algorithm
5
===============================
7
The short one max genetic algorithm example is very similar to one max
8
example. The only difference is that it makes use of the
9
:mod:`~deap.algorithms` module that implements some basic evolutionary
10
algorithms. The initialization are the same so we will skip this phase. The
11
algorithms impemented use specific functions from the toolbox, in this case
12
:func:`evaluate`, :func:`mate`, :func:`mutate` and :func:`~deap.Toolbox.select`
16
toolbox.register("evaluate", evalOneMax)
17
toolbox.register("mate", tools.cxTwoPoints)
18
toolbox.register("mutate", tools.mutFlipBit, indpb=0.05)
19
toolbox.register("select", tools.selTournament, tournsize=3)
21
The toolbox is then passed to the algorithm and the algorithm uses the
25
pop = toolbox.population()
26
hof = tools.HallOfFame(1)
28
algorithms.eaSimple(toolbox, pop, cxpb=0.5, mutpb=0.2, ngen=40, halloffame=hof)
30
The short GA One max example makes use of a
31
:class:`~deap.tools.HallOfFame` in order to keep track of the best
32
individual to appear in the evolution (it keeps it even in the case it
33
extinguishes). All algorithms from the :mod:`~deap.algorithms` module do take
34
a *halloffame* argument that gets updated after every evaluation section.=======
35
The short GA One max example makes use of a :class:`~eap.halloffame.HallOfFame` in order to keep track of the best individual to appear in the evolution (it keeps them even in the case they extinguish). All algorithms from the :mod:`eap.algorithms` module do take a *halloffame* argument that gets updated after every evaluation section of the basic algorithms.