eaSimple runs a configured generational genetic algorithm in DEAP. It receives a population, toolbox, statistics, HallOfFame, crossover probability, mutation probability, and generation count, then reports evolutionary progress. section 3.1.1
A typical DEAP setup supplies:
- A toolbox that creates individuals and populations and registers evaluation, crossover, mutation, and selection operators. section 3.1.1
- A HallOfFame container for retaining the best individual and a Statistics object for tracking average, standard deviation, minimum, and maximum fitness. section 3.1.1
- Hyperparameters such as cxpb=0.5, mutpb=0.2, and ngen=40, which control crossover, mutation, and the number of generations. section 3.1.1
OneMax and Queen’s Gambit
For OneMax, eaSimple evolves a population of 300 binary individuals for up to 40 generations using tournament selection, two-point crossover, bit-flip mutation, statistics, and a one-item HallOfFame. A customized copy applies the same pattern to N-Queens, removes noisy logging, prints the best individual, and stops when maximum fitness is reached; one run solved the problem after 67 generations. section 3.1.1 section 3.2
Listing 3.6 EDL_3_1_OneMax_DEAP.ipynb: Evolving
algorithms.eaSimple(pop, toolbox, cxpb=0.5, mutpb=0.2, ngen=40, stats=stats,
halloffame=hof,verbose=None)
Inspect the executable eaSimple call and its crossover, mutation, generation, statistics, and HallOfFame parameters. section 3.1.1
