# Why do we apply the mutation operation after generating the offspring?

Why do we apply the mutation operation after generating the offspring, in genetic algorithms?

The mutation operation is (usually) needed to introduce new genes not found in the population.

For example, suppose that you have 4 possible genes $$A$$, $$B$$, $$C$$, and $$D$$, and that your chromosomes have a non-binary encoding. In that case, if no member of your population has the gene $$D$$, then no amount of crossover operations will result in the introduction of that gene.

However, if your chromosomes use a binary encoding, then new genes could be introduced as a side effect of crossover operations. But it is always safer to have some kind of mutation to ensure that all genes can be accessed.

See also the paper Genetic Algorithm for Traveling Salesman Problem with Modified Cycle Crossover Operator, which mentions several non-binary encodings for the TSP.

Mutation is used to maintain diversity in the solutions. Crossover alone cannot do this.

• This might be correct, but you should provide more details about why that is the case, because it's not obvious why the cross-over alone doesn't introduce diversity. In fact, it does, but to what degree? The other answer actually provide an example of when the mutation could be useful, but you should also extend this answer to provide more details. Right now, this answer looks like a comment, so it should be converted to a comment.
– nbro
Jun 15, 2022 at 13:52