Module io.jenetics.base
Package io.jenetics
Class ShuffleMutator<G extends Gene<?,G>,C extends Comparable<? super C>>
java.lang.Object
io.jenetics.AbstractAlterer<G,C>
io.jenetics.Mutator<G,C>
io.jenetics.ShuffleMutator<G,C>
- All Implemented Interfaces:
Alterer<G,
C>
public class ShuffleMutator<G extends Gene<?,G>,C extends Comparable<? super C>>
extends Mutator<G,C>
The shuffle mutation, changes the order of the genes between two randomly
chosen positions. The genes between the positions are shuffled. This mutation
operator can also 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
Represents the chromosome range which will be shuffledstatic interface
Functional interface for creating random range objects for shuffling 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
).ShuffleMutator
(double probability) Constructs an alterer with a given recombination probability.ShuffleMutator
(ShuffleMutator.RangeRandom random, double probability) Constructs an alterer with a given recombination probability and random range generator. -
Method Summary
Modifier and TypeMethodDescriptionprotected MutatorResult
<Chromosome<G>> mutate
(Chromosome<G> chromosome, double p, RandomGenerator random) Changes the order of the genes between two points randomly.Methods inherited from class io.jenetics.AbstractAlterer
probability
-
Constructor Details
-
ShuffleMutator
Constructs an alterer with a given recombination probability and random range generator.- Parameters:
random
- the random range generator used by the mutatorprobability
- the crossover probability.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
.
-
ShuffleMutator
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]
.
-
ShuffleMutator
public ShuffleMutator()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) Changes the order of the genes between two points randomly.
-