Implementing Chromosome Repairment

Learn what chromosome repairment is and how it can be implemented.

What is chromosome repairment?

Sometimes, we’re limited in the crossover strategy we can use. In the lesson Optimizing Cargo Loads, we explored a solution to the N-queens problem that wouldn’t work because we used single-point crossover.

One approach that works around limitations in crossover strategies is the concept of chromosome repairment. Chromosome repairment is the process of ensuring solutions remain valid after crossover or mutation. In the case of N-queens, using single-point crossover ruins the integrity of the permutation. This means after crossover takes place, we have to go in and individually repair every chromosome.

Chromosome repairment isn’t necessary if we choose a crossover strategy that maintains the integrity of your permutation; however, if we’re restricted to using specific crossover strategies, then it will be necessary.

Implementation procedure

To implement chromosome repairment into your genetic algorithm, add the following to crossover/1 in lib/genetic.ex:

Get hands-on with 1200+ tech skills courses.