Package io.jenetics
Class Mutator<G extends Gene<?,G>,C extends Comparable<? super C>>
- java.lang.Object
-
- io.jenetics.AbstractAlterer<G,C>
-
- io.jenetics.Mutator<G,C>
-
- All Implemented Interfaces:
Alterer<G,C>
- Direct Known Subclasses:
GaussianMutator
,SwapMutator
public class Mutator<G extends Gene<?,G>,C extends Comparable<? super C>> extends AbstractAlterer<G,C>
This class is for mutating a chromosomes of an given population. There are two distinct roles mutation plays- Exploring the search space. By making small moves mutation allows a population to explore the search space. This exploration is often slow compared to crossover, but in problems where crossover is disruptive this can be an important way to explore the landscape.
- Maintaining diversity. Mutation prevents a population from correlating. Even if most of the search is being performed by crossover, mutation can be vital to provide the diversity which crossover needs.
The mutation probability is the parameter that must be optimized. The optimal value of the mutation rate depends on the role mutation plays. If mutation is the only source of exploration (if there is no crossover) then the mutation rate should be set so that a reasonable neighborhood of solutions is explored.
The mutation probability P(m) is the probability that a specific gene over the whole population is mutated. The number of available genes of an population is- Since:
- 1.0
- Version:
- 4.0
- Author:
- Franz Wilhelmstötter
-
-
Field Summary
-
Fields inherited from class io.jenetics.AbstractAlterer
_probability
-
Fields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AltererResult<G,C>
alter(Seq<Phenotype<G,C>> population, long generation)
Concrete implementation of the alter method.protected G
mutate(G gene, Random random)
Mutates the given gene.protected MutatorResult<Chromosome<G>>
mutate(Chromosome<G> chromosome, double p, Random random)
Mutates the given chromosome.protected MutatorResult<Genotype<G>>
mutate(Genotype<G> genotype, double p, Random random)
Mutates the given genotype.protected MutatorResult<Phenotype<G,C>>
mutate(Phenotype<G,C> phenotype, long generation, double p, Random random)
Mutates the given phenotype.String
toString()
-
Methods inherited from class io.jenetics.AbstractAlterer
probability
-
-
-
-
Constructor Detail
-
Mutator
public Mutator(double probability)
Construct a Mutation object which a given mutation probability.- Parameters:
probability
- Mutation probability. The given probability is divided by the number of chromosomes of the genotype to form the concrete mutation probability.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
.
-
Mutator
public Mutator()
Default constructor, with probability = 0.01.
-
-
Method Detail
-
alter
public AltererResult<G,C> alter(Seq<Phenotype<G,C>> population, long generation)
Concrete implementation of the alter method. It uses the following mutation methods:mutate(Phenotype, long, double, Random)
,mutate(Genotype, double, Random)
,mutate(Chromosome, double, Random)
,mutate(Gene, Random)
, in this specific order.- Parameters:
population
- The Population to be altered. If thepopulation
isnull
or empty, nothing is altered.generation
- the date of birth (generation) of the altered phenotypes.- Returns:
- the alter-result object, which contains the altered population and the alteration count
- See Also:
mutate(Phenotype, long, double, Random)
,mutate(Genotype, double, Random)
,mutate(Chromosome, double, Random)
,mutate(Gene, Random)
-
mutate
protected MutatorResult<Phenotype<G,C>> mutate(Phenotype<G,C> phenotype, long generation, double p, Random random)
Mutates the given phenotype.- Parameters:
phenotype
- the phenotype to mutategeneration
- the actual generationp
- the mutation probability for the underlying genetic objectsrandom
- the random engine used for the phenotype mutation- Returns:
- the mutation result
- See Also:
mutate(Genotype, double, Random)
,mutate(Chromosome, double, Random)
,mutate(Gene, Random)
-
mutate
protected MutatorResult<Genotype<G>> mutate(Genotype<G> genotype, double p, Random random)
Mutates the given genotype.- Parameters:
genotype
- the genotype to mutatep
- the mutation probability for the underlying genetic objectsrandom
- the random engine used for the genotype mutation- Returns:
- the mutation result
- See Also:
mutate(Chromosome, double, Random)
,mutate(Gene, Random)
-
mutate
protected MutatorResult<Chromosome<G>> mutate(Chromosome<G> chromosome, double p, Random random)
Mutates the given chromosome.- 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:
mutate(Gene, Random)
-
mutate
protected G mutate(G gene, Random random)
Mutates the given gene.- Parameters:
gene
- the gene to mutaterandom
- the random engine used for the genotype mutation- Returns:
- the mutation result
-
-