The numpy version one max genetic algorithm example is very similar to one max short example. The individual class is inherited from the numpy.ndarray
.
/../examples/ga/onemax_numpy.py
The first major difference is the crossover function that implements the copying mechanism mentionned in the /tutorials/advanced/numpy
tutorial.
/../examples/ga/onemax_numpy.py
This crossover function is added to the toolbox instead of the original deap.tools.cxTwoPoint
crossover.
/../examples/ga/onemax_numpy.py
The second major difference is the use of the similar function in the ~deap.tools.HallOfFame
that has to be set to a numpy.array_equal
or numpy.allclose
/../examples/ga/onemax_numpy.py
The complete source code: ga/onemax_numpy
.