liveBook · Manning

Mutation

As explained in Grokking AI Algorithms, Second Edition

Mutation is an evolutionary algorithm operation that introduces small random changes into a candidate solution to create variation.

Mutation makes a small random change to an offspring candidate in an evolutionary algorithm. Think of offspring that resemble their parents but are not exact copies: the change gives the population another possibility to try. Crossover mixes genes from parents; mutation changes an offspring after that mixing. section 4.1 section 4.11

Mutation helps preserve diversity, which can keep a search from getting stuck at a locally best solution. Its method depends on how candidates are encoded. The mutation rate controls how likely mutation is, but more is not always better: excessive change can damage good solutions. section 4.14 section 4.20

Flip one bit

Suppose an offspring has a binary chromosome such as 1011. Select one gene position at random. If it holds 1, change it to 0; if it holds 0, change it to 1. Selecting the second position turns 1011 into 1111. The candidate differs by just one bit, so it can be evaluated alongside other offspring. section 4.15 section 5.1

Figure 4.23 Bit-string mutation
04_23

The bit-string diagram shows the small change made to a binary-encoded chromosome. section 4.15

Choose a mutation method that still produces valid candidates. Binary bit-flipping is one method, not a rule for every problem; other encodings need other changes. A practical genetic-algorithm cycle evaluates candidates, selects parents, creates varied offspring, and chooses which individuals continue to the next generation. section 4.20 section 5.1

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Defines mutation and its rate, demonstrates a binary bit flip in Python, and defers nonbinary mechanisms.
Examples
Demonstrates a single-gene bit flip and situates alternative approaches in Knapsack Problem variations.
What you can do after
Build it from scratch by flipping a randomly selected bit in a binary offspring chromosome while keeping solutions valid.
How it connects
Links mutation to crossover, binary encoding, population diversity, and local optima.

Also explained in

Compare how 12 books explain mutation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.