Assembly: AForge.Genetic (in AForge.Genetic.dll) Version: 22.214.171.124 (126.96.36.199)
public override void Crossover( IChromosome pair )
- Type: AForge.Genetic..::.IChromosome
Pair chromosome to crossover with.
The method performs crossover between two chromosomes, selecting randomly the exact type of crossover to perform, which depends on CrossoverBalancer. Before crossover is done a random number is generated in [0, 1] range - if the random number is smaller than CrossoverBalancer, then the first crossover type is used, otherwise second type is used.
The first crossover type is based on interchanging range of genes (array elements) between these chromosomes and is known as one point crossover. A crossover point is selected randomly and chromosomes interchange genes, which start from the selected point.
The second crossover type is aimed to produce one child, which genes' values are between corresponding genes of parents, and another child, which genes' values are outside of the range formed by corresponding genes of parents. Let take, for example, two genes with 1.0 and 3.0 valueы (of course chromosomes have more genes, but for simplicity lets think about one). First of all we randomly choose a factor in the [0, 1] range, let's take 0.4. Then, for each pair of genes (we have one pair) we calculate difference value, which is 2.0 in our case. In the result we’ll have two children – one between and one outside of the range formed by parents genes' values. We may have 1.8 and 3.8 children, or we may have 0.2 and 2.2 children. As we can see we add/subtract (chosen randomly) difference * factor. So, this gives us exploration in between and in near outside. The randomly chosen factor is applied to all genes of the chromosomes participating in crossover.