T
- generic type of the AbstractListChromosome
s for crossoverpublic class OrderedCrossover<T> extends Object implements CrossoverPolicy
This policy works by applying the following rules:
Example (random sublist from index 3 to 7, underlined):
p1 = (8 4 7 3 6 2 5 1 9 0) X c1 = (0 4 7 3 6 2 5 1 8 9) --------- --------- p2 = (0 1 2 3 4 5 6 7 8 9) X c2 = (8 1 2 3 4 5 6 7 9 0)
This policy works only on AbstractListChromosome
, and therefore it is parameterized by T. Moreover, the
chromosomes must have same lengths.
Constructor and Description |
---|
OrderedCrossover() |
Modifier and Type | Method and Description |
---|---|
ChromosomePair |
crossover(Chromosome first,
Chromosome second)
Perform a crossover operation on the given chromosomes.
|
protected ChromosomePair |
mate(AbstractListChromosome<T> first,
AbstractListChromosome<T> second)
Helper for
crossover(Chromosome, Chromosome) . |
public ChromosomePair crossover(Chromosome first, Chromosome second)
crossover
in interface CrossoverPolicy
first
- the first chromosome.second
- the second chromosome.MathIllegalArgumentException
- iff one of the chromosomes is
not an instance of AbstractListChromosome
DimensionMismatchException
- if the length of the two chromosomes is differentprotected ChromosomePair mate(AbstractListChromosome<T> first, AbstractListChromosome<T> second)
crossover(Chromosome, Chromosome)
. Performs the actual crossover.first
- the first chromosomesecond
- the second chromosomeDimensionMismatchException
- if the length of the two chromosomes is differentCopyright © 2019 CNES. All rights reserved.