|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.math3.genetics.CycleCrossover<T>
T - generic type of the AbstractListChromosomes for crossoverpublic class CycleCrossover<T>
Cycle Crossover [CX] builds offspring from ordered chromosomes by identifying cycles between two parent chromosomes. To form the children, the cycles are copied from the respective parents.
To form a cycle the following procedure is applied:
p1 = (8 4 7 3 6 2 5 1 9 0) X c1 = (8 1 2 3 4 5 6 7 9 0) p2 = (0 1 2 3 4 5 6 7 8 9) X c2 = (0 4 7 3 6 2 5 1 8 9) cycle 1: 8 0 9 cycle 2: 4 1 7 2 5 6 cycle 3: 3This policy works only on
AbstractListChromosome, and therefore it
is parameterized by T. Moreover, the chromosomes must have same lengths.
| Constructor Summary | |
|---|---|
CycleCrossover()
Creates a new CycleCrossover policy. |
|
CycleCrossover(boolean randomStart)
Creates a new CycleCrossover policy using the given randomStart behavior. |
|
| Method Summary | |
|---|---|
ChromosomePair |
crossover(Chromosome first,
Chromosome second)
Perform a crossover operation on the given chromosomes. |
boolean |
isRandomStart()
Returns whether the starting index is chosen randomly or set to zero. |
protected ChromosomePair |
mate(AbstractListChromosome<T> first,
AbstractListChromosome<T> second)
Helper for crossover(Chromosome, Chromosome). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CycleCrossover()
CycleCrossover policy.
public CycleCrossover(boolean randomStart)
CycleCrossover policy using the given randomStart behavior.
randomStart - whether the start index shall be chosen randomly or be set to 0| Method Detail |
|---|
public boolean isRandomStart()
true if the starting index is chosen randomly, false otherwise
public ChromosomePair crossover(Chromosome first,
Chromosome second)
throws DimensionMismatchException,
MathIllegalArgumentException
crossover in interface CrossoverPolicyfirst - the first chromosome.second - the second chromosome.
MathIllegalArgumentException - if the chromosomes are not an instance of AbstractListChromosome
DimensionMismatchException - if the length of the two chromosomes is different
protected ChromosomePair mate(AbstractListChromosome<T> first,
AbstractListChromosome<T> second)
throws DimensionMismatchException
crossover(Chromosome, Chromosome). Performs the actual crossover.
first - the first chromosomesecond - the second chromosome
DimensionMismatchException - if the length of the two chromosomes is different
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||