Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 1.01 KB

ga_onemax_numpy.rst

File metadata and controls

30 lines (21 loc) · 1.01 KB

One Max Problem: Using Numpy

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.