Module io.jenetics.base
Package io.jenetics
Class ShiftMutator<G extends Gene<?,G>,C extends Comparable<? super C>>
java.lang.Object
io.jenetics.AbstractAlterer<G,C>
io.jenetics.Mutator<G,C>
io.jenetics.ShiftMutator<G,C>
- All Implemented Interfaces:
Alterer<G,
C>
The shift mutation applies mutation between two randomly chosen points. A
random value between the two points splits the sequences of genes between the
positions. The second sequence is then shifted in front of the first one.
This mutation operator can be used for combinatorial problems, where no
duplicated genes within a chromosome are allowed, e.g., for the TSP.
- Since:
- 8.0
- Version:
- 8.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
This class defines theChromosome
shift indexes.static interface
Functional interface for creating random shift ranges objects for shifting sequences of a given length. -
Field Summary
Fields inherited from class io.jenetics.AbstractAlterer
_probability
Fields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY
-
Constructor Summary
ConstructorDescriptionDefault constructor, with default mutation probability (Alterer.DEFAULT_ALTER_PROBABILITY
).ShiftMutator
(double probability) Constructs an alterer with a given recombination probability.ShiftMutator
(ShiftMutator.RangeRandom random) Constructs an alterer with a given shifter-random.ShiftMutator
(ShiftMutator.RangeRandom random, double probability) Constructs an alterer with a given shifter-random and recombination probability. -
Method Summary
Modifier and TypeMethodDescriptionprotected MutatorResult
<Chromosome<G>> mutate
(Chromosome<G> chromosome, double p, RandomGenerator random) Splits the values between two points into two sequences and shifts the second one in front of the first one.Methods inherited from class io.jenetics.AbstractAlterer
probability
-
Constructor Details
-
ShiftMutator
Constructs an alterer with a given shifter-random and recombination probability.- Parameters:
random
- theShiftMutator.Range
generator.probability
- the crossover probability.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
.
-
ShiftMutator
Constructs an alterer with a given shifter-random.- Parameters:
random
- theShiftMutator.Range
generator.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
.
-
ShiftMutator
Constructs an alterer with a given recombination probability.- Parameters:
probability
- the crossover probability.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
.
-
ShiftMutator
public ShiftMutator()Default constructor, with default mutation probability (Alterer.DEFAULT_ALTER_PROBABILITY
).
-
-
Method Details
-
mutate
protected MutatorResult<Chromosome<G>> mutate(Chromosome<G> chromosome, double p, RandomGenerator random) Splits the values between two points into two sequences and shifts the second one in front of the first one.
-