AForge.Genetic.PermutationChromosome.Crossover C# (CSharp) Метод

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

Crossover operator.

The method performs crossover between two chromosomes – interchanging some parts between these chromosomes.

public Crossover ( IChromosome pair ) : void
pair IChromosome Pair chromosome to crossover with.
Результат void
		public override void Crossover( IChromosome pair )
		{
			PermutationChromosome p = (PermutationChromosome) pair;

			// check for correct pair
			if ( ( p != null ) && ( p.length == length ) )
			{
				ushort[] child1 = new ushort[length];
				ushort[] child2 = new ushort[length];

				// create two children
				CreateChildUsingCrossover( this.val, p.val, child1 );
				CreateChildUsingCrossover( p.val, this.val, child2 );

				// replace parents with children
				this.val = child1;
				p.val    = child2;
			}
		}