public class SwapMutator<G extends Gene<?,G>,C extends Comparable<? super C>> extends Mutator<G,C>
SwapMutation
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).
_probability
DEFAULT_ALTER_PROBABILITY
Constructor and Description |
---|
SwapMutator()
Default constructor, with default mutation probability
(
Alterer.DEFAULT_ALTER_PROBABILITY ). |
SwapMutator(double probability)
Constructs an alterer with a given recombination probability.
|
Modifier and Type | Method and 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.
|
getProbability
public SwapMutator(double probability)
probability
- the crossover probability.IllegalArgumentException
- if the probability
is not in the
valid range of [0, 1]
.public SwapMutator()
Alterer.DEFAULT_ALTER_PROBABILITY
).protected MutatorResult<Chromosome<G>> mutate(Chromosome<G> chromosome, double p, Random random)
mutate
in class Mutator<G extends Gene<?,G>,C extends Comparable<? super C>>
chromosome
- the chromosome to mutatep
- the mutation probability for the underlying genetic objectsrandom
- the random engine used for the genotype mutationMutator.mutate(Gene, Random)
© 2007-2019 Franz Wilhelmstötter (2019-06-23 15:39)