Understanding Mutation

Genetic Algorithms in Elixir — by Sean Moriarity (58 / 101)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Breaking Codes with Genetic Algorithms | TOC | Customizing Mutation in Your Framework 👉

As with most of the other aspects of a genetic algorithm, mutation has a loose analogy to a real biological process. In biology, mutation is a random change in an individual’s DNA sequence that often manifests itself in physical traits. For example, if you have blue eyes, you can thank genetic mutation.

Mutation in genetic algorithms works in much the same way. It’s a random change to some or all of the genes in a chromosome. The purpose of mutation is to introduce genetic diversity into the population.

If you recall from Chapter 1, Writing Your First Genetic Algorithm, the algorithm you wrote to solve the One-Max problem struggled to find the best solution until you added mutation. When dealing with binary genotypes, premature convergence is more common because genes can only take on one of two values. The possibility of premature convergence increases when dealing with small population sizes relative to your search space.

Stimulating Change

Mutation works by stimulating change — it prevents your algorithm from becoming complacent. Imagine you roll a ball down a small hill. Halfway down the hill there’s a slight rise in elevation, but afterwards, the hill declines again very sharply. You roll the ball down the hill, but it doesn’t have…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.