Selection, Crossover, Mutation and Termination

Learn about the selection, crossover, mutation, and termination processes involved in developing genetic algorithms.

Selecting parents

With a sorted population, we can begin to select parents for reproduction.

Remember, selection is responsible for matching parents that will produce strong children. Later on, we’ll implement different selection methods to achieve this effect.

For now, the selection method should only pair adjacent chromosomes in the population. Because the population is sorted, the strongest chromosomes will reproduce with other strong chromosomes. This is referred to as “elitism selection.”

One additional goal of the selection function is to make it easy for the crossover function to transform the population into a new population. We can do this by transforming the population of chromosomes into tuples like we did in the previous chapter.

Therefore, the rules for selection are:

  • The selection step must take a population as input.

  • The selection step must produce a transformed population that’s easy to work with during crossover, such as a list of tuples which are pairs of parents.

Creating children

Remember that crossover is analogous to reproduction. The goal of crossover is to exploit the strengths of current solutions to find new, better solutions. Crossover is one of the last steps before starting a new generation and should create a population that looks and feels identical to the one we started with, albeit with new solutions.

Remember from the last step that the transformed population is a list of tuples, which are pairs of adjacent parents. We need to take these parents and transform the population into a brand-new population.

The following figure might help illustrate this step better:

Get hands-on with 1400+ tech skills courses.