liveBook · Manning

Genetic operation

As explained in Evolutionary Deep Learning: Genetic algorithms and neural networks

A genetic operator is a computational transformation, such as crossover or mutation, that changes or combines candidate solutions in an evolutionary algorithm.

A genetic operation is a registered step in an evolutionary workflow that evaluates, selects, recombines, or mutates candidate individuals from one generation to the next. Crossover combines parent material; mutation alters an individual; selection chooses parents or survivors according to fitness. The useful operation depends on how a solution is encoded: bit strings, permutations, symbolic sequences, or neural-network layer descriptions need different ways to change without breaking their structure. section 3.1.1 section 3.4

In DEAP, operations are placed in a toolbox under conventional names such as evaluate, mate, mutate, and select. An evolution routine then invokes those registrations while evolving a population. This makes experimentation direct: keep the evolutionary loop and fitness function fixed, replace an operator or adjust its probability, and inspect how the population changes. section 3.1.1 section 3.4

Common operator roles include:

  • Evaluation assigns fitness to an individual, supplying the signal used by selection and stopping conditions. section 3.1.1 section 3.2
  • Crossover, registered as mate, takes two parents and produces altered offspring. Two-point crossover is used for binary individuals, while partially matched crossover is used for queen-position permutations. section 3.1.1 section 3.2
  • Mutation makes local random changes. Bit-flip mutation changes Boolean genes; index-shuffle mutation is specialized for permutation-style individuals. section 3.1.1 section 3.2
  • Selection uses fitness to choose candidates; tournament selection compares randomly paired candidates and retains fitter choices. section 3.1.1

Registering operations for OneMax

A Boolean individual of length 100 can use a custom two-point mate function, DEAP's mutFlipBit mutation with per-gene probability 0.05, and tournament selection with tournament size 3. An eaSimple run can then apply crossover with probability 0.5 and mutation with probability 0.2 for 40 generations. These settings are parameters to test, not universal defaults. section 3.1.1

Operator choice is part of problem design rather than a cosmetic setting. DEAP operators can often be swapped, but some require a particular gene or individual type. A traveling-salesperson experiment exposes selectable crossover and selection options through a form-based interface, then compares diversity and crossover genealogies. Mutation remains fixed there because the representation requires an index-swapping mutation. section 3.4

Figure 3.6 The Google Colab forms interface to select genetic operators

Use the operator-selection interface to vary evolutionary options and compare their effects on population diversity and lineage plots. section 3.4

When candidates encode model architectures, built-in operations may no longer preserve required structure. Custom autoencoder crossover swaps corresponding convolution, up-convolution, batch-normalization, and dropout layer segments between two parents. Custom mutation changes selected convolution, up-convolution, or dropout parameters while deliberately omitting batch-normalization layers, which have no additional parameters in this encoding. section 8.3

Experiment systematically: alter population size, crossover and mutation rates, selection parameters, or the available operations; rerun; then compare resulting individuals and fitness behavior. Removing operators or widening gene ranges can reveal how much variation the representation and problem need, while also showing that an operator configuration that works for one target may not transfer unchanged to another. section 3.3.2 section 4.1.2 section 7.2.1

How Evolutionary Deep Learning: Genetic algorithms and neural networks covers it

How deep it goes
Walks through toolbox registration, probabilities, representation-specific choices, visual comparisons, and custom autoencoder implementations.
Examples
Uses OneMax bit strings, N-Queens permutations, traveling-salesperson comparisons, and autoencoder architecture genes.
What it assumes
Assumes runnable Python and DEAP setup while demonstrating toolbox-based operator registration from concrete examples.
What you can do after
Apply it via DEAP by registering, swapping, and tuning evaluation, crossover, mutation, and selection operations.
How it connects
Connects crossover, mutation, selection, fitness evaluation, population diversity, gene sequences, and autoencoders.

Also explained in

Compare how 2 books explain genetic operation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Evolutionary Deep Learning: Genetic algorithms and neural networks. The section links point to the parts of the book it draws on.