public class CrossoverPermutationOnePoint extends java.lang.Object implements CrossoverPermutation
Crossover for the PermutationGenotype
.
This operator takes sublist of the first permutation from the beginning to a random cut point and fills the remaining elements from the second permutation.
Given two permutations
1 2 3 4 5 6 7 8
and 8 7 6 5 4 3 2 1
.
This results, for instance, in
1 2 3 4 5 8 7 6
or 1 2 8 7 6 5 4 3
.
Additionally, a rotation
value defines if the initial permutation are
randomly rotated. With the rotation
possible results would be
4 5 6 8 7 3 2 1
and 7 8 1 2 4 3 6 5
.
Modifier and Type | Field and Description |
---|---|
protected java.util.Random |
random |
protected boolean |
rotation |
Constructor and Description |
---|
CrossoverPermutationOnePoint(org.opt4j.core.common.random.Rand random,
boolean rotation)
Constructs a new
CrossoverPermutationOnePoint . |
Modifier and Type | Method and Description |
---|---|
Pair<org.opt4j.core.genotype.PermutationGenotype<?>> |
crossover(org.opt4j.core.genotype.PermutationGenotype<?> p1,
org.opt4j.core.genotype.PermutationGenotype<?> p2)
Performs a crossover for two
Genotype parents. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOperatorType
protected final java.util.Random random
protected final boolean rotation
@Inject public CrossoverPermutationOnePoint(org.opt4j.core.common.random.Rand random, boolean rotation)
CrossoverPermutationOnePoint
.random
- the random number generatorrotation
- use rotationpublic Pair<org.opt4j.core.genotype.PermutationGenotype<?>> crossover(org.opt4j.core.genotype.PermutationGenotype<?> p1, org.opt4j.core.genotype.PermutationGenotype<?> p2)
Crossover
Genotype
parents. The resulting pair
of Genotype
offspring is returned.