Package org.opt4j.operator.neighbor
Class NeighborPermutationSwap
- java.lang.Object
-
- org.opt4j.operator.neighbor.NeighborPermutationSwap
-
- All Implemented Interfaces:
Operator<PermutationGenotype<?>>
,Neighbor<PermutationGenotype<?>>
,NeighborPermutation
public class NeighborPermutationSwap extends Object implements NeighborPermutation
Neighbor operator for the
PermutationGenotype
. Two elements are selected and swapped.Given a permutation
1 2 3 4 5 6 7 8
, this might result in1 2 7 4 5 6 3 8
.
-
-
Constructor Summary
Constructors Constructor Description NeighborPermutationSwap(Rand random)
Constructs aNeighborPermutationSwap
operator for thePermutationGenotype
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
neighbor(PermutationGenotype<?> genotype)
Moves theGenotype
to a neighbor.
-
-
-
Field Detail
-
random
protected final Random random
-
-
Constructor Detail
-
NeighborPermutationSwap
@Inject public NeighborPermutationSwap(Rand random)
Constructs aNeighborPermutationSwap
operator for thePermutationGenotype
.- Parameters:
random
- the random number generator
-
-
Method Detail
-
neighbor
public void neighbor(PermutationGenotype<?> genotype)
Description copied from interface:Neighbor
Moves theGenotype
to a neighbor.- Specified by:
neighbor
in interfaceNeighbor<PermutationGenotype<?>>
- Parameters:
genotype
- theGenotype
to be changed
-
-