AForge.Genetic.GEPChromosome.RecombinationTwoPoint C# (CSharp) Метод

RecombinationTwoPoint() публичный Метод

Two point recombination (crossover).
public RecombinationTwoPoint ( GEPChromosome pair ) : void
pair GEPChromosome Pair chromosome to crossover with.
Результат void
		public void RecombinationTwoPoint( GEPChromosome pair )
		{
			// check for correct pair
			if ( ( pair.length == length ) )
			{
				// crossover point
				int crossOverPoint = rand.Next( length - 1 ) + 1;
				// length of chromosome to be crossed
				int crossOverLength = length - crossOverPoint;

				// if crossover length already equals to 1, then it becomes
				// usual one point crossover. otherwise crossover length
				// also randomly chosen
				if ( crossOverLength != 1 )
				{
					crossOverLength = rand.Next( crossOverLength - 1 ) + 1;
				}

				// swap parts of chromosomes
				Recombine( genes, pair.genes, crossOverPoint, crossOverLength );
			}
		}