AbstractListChromosomes for crossover
-C- denotes a crossover point
-C- -C- -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 VV (*) VV
/----\ /--------\ /-----\ /----\ /--------\ /-----\
c1 = (1 0 | 1 0 1 0 | 0 1 1) X c2 = (0 1 | 1 0 0 1 | 0 1 1)
This policy works only on AbstractListChromosome, and therefore it
is parameterized by T. Moreover, the chromosomes must have same lengths.
| Modifier and Type | Field and Description |
|---|---|
| private final int | crossoverPoints
The number of crossover points. |
| Access | Constructor and Description |
|---|---|
| public | NPointCrossover(final int
the number of crossover points crossoverPoints)Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public ChromosomePair | Returns: pair of two children (c1,c2)first parent (p1) first, final Chromosome second parent (p2) second)Implements org. Performs a N-point crossover. |
| public int | Returns: the number of crossover pointsReturns the number of crossover points used by this |
| private ChromosomePair | Returns: the pair of new chromosomes that resulted from the crossoverthe first chromosome first, final AbstractListChromosome<T> the second chromosome second)Helper for |
| crossoverPoints | back to summary |
|---|---|
| private final int crossoverPoints The number of crossover points. | |
| NPointCrossover | back to summary |
|---|---|
| public NPointCrossover(final int crossoverPoints) throws NotStrictlyPositiveException Creates a new Note the number of crossover points must be <
| |
| crossover | back to summary |
|---|---|
| public ChromosomePair crossover(final Chromosome first, final Chromosome second) throws DimensionMismatchException, MathIllegalArgumentException Implements org. Performs a N-point crossover. N random crossover points are selected and are used to divide the parent chromosomes into segments. The segments are copied in alternate order from the two parents to the corresponding child chromosomes. Example (2-point crossover):
-C- denotes a crossover point
-C- -C- -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 VV (*) VV
/----\ /--------\ /-----\ /----\ /--------\ /-----\
c1 = (1 0 | 1 0 1 0 | 0 1 1) X c2 = (0 1 | 1 0 0 1 | 0 1 1)
| |
| getCrossoverPoints | back to summary |
|---|---|
| public int getCrossoverPoints() Returns the number of crossover points used by this
| |
| mate | back to summary |
|---|---|
| private ChromosomePair mate(final AbstractListChromosome<T> first, final AbstractListChromosome<T> second) throws DimensionMismatchException, NumberIsTooLargeException Helper for
| |