public final class GaussianMutator<G extends NumberGene<?,G>> extends Mutator<G> implements Immutable
NumberGene.
This mutator picks a new value based on a Gaussian distribution around the
current value of the gene. The variance of the new value (before clipping to
the allowed gene range) will be
_probability, DEFAULT_ALTER_PROBABILITY| Constructor and Description |
|---|
GaussianMutator() |
GaussianMutator(double probability) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
protected int |
mutate(MSeq<G> genes,
double p)
Template method which gives an (re)implementation of the mutation class the
possibility to perform its own mutation operation, based on a writable
gene array and the gene mutation probability p.
|
String |
toString() |
getProbability, Nullpublic GaussianMutator()
public GaussianMutator(double probability)
protected int mutate(MSeq<G> genes, double p)
Mutator protected int mutate(final MSeq<G> genes, final double p) {
final Random random = RandomRegistry.getRandom();
final ProbabilityIndexIterator it =
new ProbabilityIndexIterator(genes.length(), p, random);
int alterations = 0;
for (int i = it.next(); i != -1; i = it.next()) {
genes.set(i, genes.get(i).newInstance());
++alterations;
}
return alterations;
}mutate in class Mutator<G extends NumberGene<?,G>>genes - the genes to mutate.p - the gene mutation probability.public boolean equals(Object obj)
equals in class Mutator<G extends NumberGene<?,G>>© 2007-2013 Franz Wilhelmstötter (2013-03-25 23:36)