Package org.opt4j.operator.crossover
Class CrossoverPermutationOnePoint
- java.lang.Object
-
- org.opt4j.operator.crossover.CrossoverPermutationOnePoint
-
- All Implemented Interfaces:
Operator<PermutationGenotype<?>>,Crossover<PermutationGenotype<?>>,CrossoverPermutation
- Direct Known Subclasses:
CrossoverPermutationDefault
public class CrossoverPermutationOnePoint extends 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 8and8 7 6 5 4 3 2 1.
This results, for instance, in
1 2 3 4 5 8 7 6or1 2 8 7 6 5 4 3.Additionally, a
rotationvalue defines if the initial permutation are randomly rotated. With therotationpossible results would be
4 5 6 8 7 3 2 1and7 8 1 2 4 3 6 5.
-
-
Constructor Summary
Constructors Constructor Description CrossoverPermutationOnePoint(Rand random, boolean rotation)Constructs a newCrossoverPermutationOnePoint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pair<PermutationGenotype<?>>crossover(PermutationGenotype<?> p1, PermutationGenotype<?> p2)Performs a crossover for twoGenotypeparents.
-
-
-
Field Detail
-
random
protected final Random random
-
rotation
protected final boolean rotation
-
-
Constructor Detail
-
CrossoverPermutationOnePoint
@Inject public CrossoverPermutationOnePoint(Rand random, boolean rotation)
Constructs a newCrossoverPermutationOnePoint.- Parameters:
random- the random number generatorrotation- use rotation
-
-
Method Detail
-
crossover
public Pair<PermutationGenotype<?>> crossover(PermutationGenotype<?> p1, PermutationGenotype<?> p2)
Description copied from interface:CrossoverPerforms a crossover for twoGenotypeparents. The resulting pair ofGenotypeoffspring is returned.- Specified by:
crossoverin interfaceCrossover<PermutationGenotype<?>>- Parameters:
p1- The first parent genotype for the crossoverp2- The second parents genotype for the crossover- Returns:
- The resulting pair of offspring genotypes
-
-