Package org.opt4j.operator.mutate
Class MutatePermutationSwap
- java.lang.Object
-
- org.opt4j.operator.mutate.MutatePermutationSwap
-
- All Implemented Interfaces:
Operator<PermutationGenotype<?>>
,Mutate<PermutationGenotype<?>>
,MutatePermutation
public class MutatePermutationSwap extends Object implements MutatePermutation
Mutate operator for the
PermutationGenotype
. With a given mutation rate 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 MutatePermutationSwap(Rand random)
Constructs a newMutatePermutation
with the given mutation rate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
mutate(PermutationGenotype<?> genotype, double p)
Performs a mutation for aGenotype
.
-
-
-
Field Detail
-
random
protected final Random random
-
-
Constructor Detail
-
MutatePermutationSwap
@Inject public MutatePermutationSwap(Rand random)
Constructs a newMutatePermutation
with the given mutation rate.- Parameters:
random
- the random number generator
-
-
Method Detail
-
mutate
public void mutate(PermutationGenotype<?> genotype, double p)
Description copied from interface:Mutate
Performs a mutation for aGenotype
.- Specified by:
mutate
in interfaceMutate<PermutationGenotype<?>>
- Parameters:
genotype
- the genotype to be mutatedp
- the mutation rate
-
-