T
- generic type of the AbstractListChromosome
s for crossoverpublic class OnePointCrossover<T> extends java.lang.Object implements CrossoverPolicy
-C- denotes a crossover point -C- -C- p1 = (1 0 1 0 0 1 | 0 1 1) X p2 = (0 1 1 0 1 0 | 1 1 1) \------------/ \-----/ \------------/ \-----/ || (*) || (**) VV (**) VV (*) /------------\ /-----\ /------------\ /-----\ c1 = (1 0 1 0 0 1 | 1 1 1) X c2 = (0 1 1 0 1 0 | 0 1 1)This policy works only on
AbstractListChromosome
, and therefore it
is parameterized by T. Moreover, the chromosomes must have same lengths.Constructor and Description |
---|
OnePointCrossover() |
Modifier and Type | Method and Description |
---|---|
private ChromosomePair |
crossover(AbstractListChromosome<T> first,
AbstractListChromosome<T> second)
Helper for
crossover(Chromosome, Chromosome) . |
ChromosomePair |
crossover(Chromosome first,
Chromosome second)
Performs one point crossover.
|
public ChromosomePair crossover(Chromosome first, Chromosome second) throws DimensionMismatchException, MathIllegalArgumentException
-C- denotes a crossover point -C- -C- p1 = (1 0 1 0 0 1 | 0 1 1) X p2 = (0 1 1 0 1 0 | 1 1 1) \------------/ \-----/ \------------/ \-----/ || (*) || (**) VV (**) VV (*) /------------\ /-----\ /------------\ /-----\ c1 = (1 0 1 0 0 1 | 1 1 1) X c2 = (0 1 1 0 1 0 | 0 1 1)
crossover
in interface CrossoverPolicy
first
- first parent (p1)second
- second parent (p2)MathIllegalArgumentException
- iff one of the chromosomes is
not an instance of AbstractListChromosome
DimensionMismatchException
- if the length of the two chromosomes is differentprivate ChromosomePair crossover(AbstractListChromosome<T> first, AbstractListChromosome<T> second) throws DimensionMismatchException
crossover(Chromosome, Chromosome)
. Performs the actual crossover.first
- the first chromosome.second
- the second chromosome.DimensionMismatchException
- if the length of the two chromosomes is different