Search⌘ K

Selection, Crossover, Mutation and Termination

Explore the core genetic algorithm processes in Elixir including selecting strong parent chromosomes, performing crossover to create new populations, applying mutation to avoid premature convergence, and setting termination criteria based on problem needs. Understand how these elements work together to evolve solutions through generations.

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 ...