A DEAP toolbox is a registry and configuration container for evolutionary-algorithm building blocks. It stores construction functions, hyperparameters, evaluation logic, and genetic operators under names that the evolutionary algorithm can call. section 3.1.1 section 3.6
A practical setup usually grows from representation to population: register a gene-producing function, use it to create individuals, and use individuals to create populations. Register evaluation, crossover, mutation, and selection afterward. section 3.1.1
A toolbox can coordinate:
- Representation: Boolean genes, individuals, and populations. section 3.1.1
- Operators: evaluation, crossover, mutation, and selection. section 3.1.1
- Architecture search: variable-length network individuals, custom offspring creation, crossover, and mutation. section 7.5
- Failure handling: evaluation functions can catch invalid models and return a bounded fallback fitness. section 7.5
OneMax registration
A Boolean OneMax configuration registers random genes, 100-gene individuals, list-based populations, two-point crossover, bit-flip mutation, tournament selection, and a custom fitness evaluator before calling the evolutionary algorithm. section 3.1.1
Evolutionary CNN registration
For convolutional architecture search, register a network-generation function, create variable-length individuals with initIterate, register custom crossover and mutation, and evaluate each individual by building, training, and testing a model. section 7.5
Listing 3.2 EDL_3_1_OneMax_DEAP.ipynb: The toolbox
toolbox = base.Toolbox() #1
toolbox.register("attr_bool", random.randint, 0, 1) #2
toolbox.register("individual", #3
tools.initRepeat, creator.Individual, toolbox.attr_bool, n=100)
toolbox.register("population", tools.initRepeat,
list, toolbox.individual) #4
Inspect the compact pattern for creating a toolbox and registering genes, individuals, and populations. section 3.1.1
Listing 3.3 EDL_3_1_OneMax_DEAP.ipynb: Genetic operators
toolbox.register("evaluate", evalOneMax) #1
toolbox.register("mate", cxTwoPointCopy) #2
toolbox.register("mutate", tools.mutFlipBit,
indpb=0.05) #3
toolbox.register("select", tools.selTournament,
tournsize=3) #4
Inspect the operator registrations that connect evaluation, crossover, mutation, and tournament selection to the evolutionary loop. section 3.1.1
