Package io.jenetics
Class SwapMutator<G extends Gene<?,G>,C extends Comparable<? super C>>
- java.lang.Object
-
- io.jenetics.AbstractAlterer<G,C>
-
- io.jenetics.Mutator<G,C>
-
- io.jenetics.SwapMutator<G,C>
-
- All Implemented Interfaces:
Alterer<G,C>
public class SwapMutator<G extends Gene<?,G>,C extends Comparable<? super C>> extends Mutator<G,C>
TheSwapMutation
changes the order of genes in a chromosome, with the hope of bringing related genes closer together, thereby facilitating the production of building blocks. This mutation operator can also be used for combinatorial problems, where no duplicated genes within a chromosome are allowed, e.g. for the TSP.This mutator is also known as Partial Shuffle Mutator (PSM).
- Since:
- 1.0
- Version:
- 5.0
- Author:
- Franz Wilhelmstötter
- See Also:
- Analyzing the Performance of Mutation Operators to Solve the Travelling Salesman Problem
-
-
Field Summary
-
Fields inherited from class io.jenetics.AbstractAlterer
_probability
-
Fields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY
-
-
Constructor Summary
Constructors Constructor Description SwapMutator()
Default constructor, with default mutation probability (Alterer.DEFAULT_ALTER_PROBABILITY
).SwapMutator(double probability)
Constructs an alterer with a given recombination probability.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MutatorResult<Chromosome<G>>
mutate(Chromosome<G> chromosome, double p, Random random)
Swaps the genes in the given array, with the mutation probability of this mutation.-
Methods inherited from class io.jenetics.AbstractAlterer
probability
-
-
-
-
Constructor Detail
-
SwapMutator
public SwapMutator(double probability)
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]
.
-
SwapMutator
public SwapMutator()
Default constructor, with default mutation probability (Alterer.DEFAULT_ALTER_PROBABILITY
).
-
-
Method Detail
-
mutate
protected MutatorResult<Chromosome<G>> mutate(Chromosome<G> chromosome, double p, Random random)
Swaps the genes in the given array, with the mutation probability of this mutation.- Overrides:
mutate
in classMutator<G extends Gene<?,G>,C extends Comparable<? super C>>
- Parameters:
chromosome
- the chromosome to mutatep
- the mutation probability for the underlying genetic objectsrandom
- the random engine used for the genotype mutation- Returns:
- the mutation result
- See Also:
Mutator.mutate(Gene, Random)
-
-