Module genetic_algorithm::crossover
source · Expand description
The crossover phase where every two parent chromosomes create two children chromosomes. The selection phase determines the order and the amount of the parent pairing (overall with fitter first).
If the selection dropped some chromosomes due to the selection_rate, the crossover will restore the population towards the target_population_size by keeping the best parents alive. Excess parents are dropped.
Structs§
- Children are clones of the parents. The population is restored towards the target_population_size by keeping the best parents alive. Excess parents are dropped.
- Crossover multiple genes between the parents. The gene positions are chosen with uniform probability. Choose between allowing duplicate crossovers of the same gene or not (~2x slower). The population is restored towards the target_population_size by keeping the best parents alive. Excess parents are dropped.
- Crossover multiple gene positions from which on the rest of the genes are taken from the other parent. This goes back and forth. The gene positions are chosen with uniform probability. Choose between allowing duplicate crossovers on the same point or not (not much slower, as crossover itself is relatively expensive). The population is restored towards the target_population_size by keeping the best parents alive. Excess parents are dropped.
- Multithreaded version of CrossoverMultiPoint as it is the worst performing crossover. Only more efficient for large genes_sizes and number_of_crossovers, so don’t just default to this version. It is more of an implementation example.
- Crossover a single gene between the parents. The gene position is chosen with uniform probability. The population is restored towards the target_population_size by keeping the best parents alive. Excess parents are dropped.
- Crossover a single gene position from which on the rest of the genes are taken from the other parent. The gene position is chosen with uniform probability. The population is restored towards the target_population_size by keeping the best parents alive. Excess parents are dropped.
- Crossover with 50% probability for each gene to come from one of the two parents. Actually implemented as
CrossoverMultiGene::new(<genes_size> / 2, allow_duplicates=true)