Package org.opt4j.operator.crossover
Class CrossoverPermutationBucket
- java.lang.Object
-
- org.opt4j.operator.crossover.CrossoverPermutationBucket
-
- All Implemented Interfaces:
Operator<PermutationGenotype<?>>
,Crossover<PermutationGenotype<?>>
,CrossoverPermutation
public class CrossoverPermutationBucket extends Object implements CrossoverPermutation
Crossover for the
PermutationGenotype
.The bucket operator randomly runs through to permutation from the beginning to the end, and fill the current element into the new permutation if not existent.
Given two permutations
1 2 3 4 5 6 7 8
and8 7 6 5 4 3 2 1
this results, for instance, in
1 8 2 7 3 6 4 5
or8 7 1 2 3 6 5 4
.
-
-
Constructor Summary
Constructors Constructor Description CrossoverPermutationBucket(Rand random)
Constructs a newCrossoverPermutationBucket
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pair<PermutationGenotype<?>>
crossover(PermutationGenotype<?> p1, PermutationGenotype<?> p2)
Performs a crossover for twoGenotype
parents.
-
-
-
Field Detail
-
random
protected final Random random
-
-
Constructor Detail
-
CrossoverPermutationBucket
@Inject public CrossoverPermutationBucket(Rand random)
Constructs a newCrossoverPermutationBucket
.- Parameters:
random
- the random number generator
-
-
Method Detail
-
crossover
public Pair<PermutationGenotype<?>> crossover(PermutationGenotype<?> p1, PermutationGenotype<?> p2)
Description copied from interface:Crossover
Performs a crossover for twoGenotype
parents. The resulting pair ofGenotype
offspring is returned.- Specified by:
crossover
in 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
-
-