Package io.jenetics

Class Crossover<G extends Gene<?,G>,C extends Comparable<? super C>>

Type Parameters:
G - the gene type.
All Implemented Interfaces:
Alterer<G,C>
Direct Known Subclasses:
IntermediateCrossover, LineCrossover, MultiPointCrossover, PartiallyMatchedCrossover, SimulatedBinaryCrossover, UniformCrossover, UniformOderBasedCrossover

public abstract class Crossover<G extends Gene<?,G>,C extends Comparable<? super C>> extends Recombinator<G,C>

Performs a Crossover of two Chromosome. This crossover implementation can handle genotypes with different length (different number of chromosomes). It is guaranteed that chromosomes with the the same (genotype) index are chosen for crossover.

The order (Recombinator.order()) of this Recombination implementation is two.

Since:
1.0
Version:
4.0
  • Constructor Details

    • Crossover

      protected Crossover(double probability)
      Constructs an alterer with a given recombination probability.
      Parameters:
      probability - the recombination probability
      Throws:
      IllegalArgumentException - if the probability is not in the valid range of [0, 1]
  • Method Details

    • recombine

      protected final int recombine(MSeq<Phenotype<G,C>> population, int[] individuals, long generation)
      Description copied from class: Recombinator
      Recombination template method. This method is called 0 to n times. It is guaranteed that this method is only called by one thread.
      Specified by:
      recombine in class Recombinator<G extends Gene<?,G>,C extends Comparable<? super C>>
      Parameters:
      population - the population to recombine
      individuals - the array with the indexes of the individuals which are involved in the recombination step. The length of the array is Recombinator.order(). The first individual is the primary individual.
      generation - the current generation.
      Returns:
      the number of genes that has been altered.
    • crossover

      protected abstract int crossover(MSeq<G> that, MSeq<G> other)
      Template method which performs the crossover. The arguments given are mutable non-null arrays of the same length.
      Parameters:
      that - the genes of the first chromosome
      other - the genes of the other chromosome
      Returns:
      the number of altered genes