Package io.jenetics
Interface Alterer<G extends Gene<?,G>,C extends Comparable<? super C>>
-
- Type Parameters:
G
- the gene typeC
- the fitness function result type
- All Known Implementing Classes:
AbstractAlterer
,CombineAlterer
,Crossover
,GaussianMutator
,IntermediateCrossover
,LineCrossover
,MeanAlterer
,MultiPointCrossover
,Mutator
,PartialAlterer
,PartiallyMatchedCrossover
,Recombinator
,SinglePointCrossover
,SwapMutator
,UniformCrossover
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Alterer<G extends Gene<?,G>,C extends Comparable<? super C>>
The Alterer is responsible for the changing/recombining the Population. Alterers can be chained by appending a list of alterers with theEngine.Builder.alterers(Alterer, Alterer[])
method.The order of the alterer calls is: Crossover, Mutation and MeanAlterer.final Engine<DoubleGene, Double> engine = Engine .builder(gtf, ff) .alterers( new Crossover<>(0.1), new Mutator<>(0.05), new MeanAlterer<>(0.2)) .build(); final EvolutionStream<DoubleGene, Double> stream = engine.stream();
- Since:
- 1.0
- Version:
- 4.0
- Author:
- Franz Wilhelmstötter
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_ALTER_PROBABILITY
The default alter probability: 0.2
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description AltererResult<G,C>
alter(Seq<Phenotype<G,C>> population, long generation)
Alters (recombine) a given population.default Alterer<G,C>
andThen(Alterer<G,C> after)
Returns a composed alterer that applies thethis
alterer to its input, and then applies theafter
alterer to the result.default Alterer<G,C>
compose(Alterer<G,C> before)
Returns a composed alterer that first applies thebefore
alterer to its input, and then appliesthis
alterer to the result.static <G extends Gene<?,G>,C extends Comparable<? super C>>
Alterer<G,C>of(Alterer<G,C>... alterers)
Combine the given alterers.
-
-
-
Field Detail
-
DEFAULT_ALTER_PROBABILITY
static final double DEFAULT_ALTER_PROBABILITY
The default alter probability: 0.2- See Also:
- Constant Field Values
-
-
Method Detail
-
alter
AltererResult<G,C> alter(Seq<Phenotype<G,C>> population, long generation)
Alters (recombine) a given population. If thepopulation
is empty, nothing is altered. The altered population is part of the returnedAlterResult
object.- 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
- Throws:
NullPointerException
- if the givenpopulation
isnull
.
-
compose
default Alterer<G,C> compose(Alterer<G,C> before)
Returns a composed alterer that first applies thebefore
alterer to its input, and then appliesthis
alterer to the result.- Parameters:
before
- the alterer to apply first- Returns:
- the new composed alterer
-
andThen
default Alterer<G,C> andThen(Alterer<G,C> after)
Returns a composed alterer that applies thethis
alterer to its input, and then applies theafter
alterer to the result.- Parameters:
after
- the alterer to apply first- Returns:
- the new composed alterer
-
of
@SafeVarargs static <G extends Gene<?,G>,C extends Comparable<? super C>> Alterer<G,C> of(Alterer<G,C>... alterers)
Combine the given alterers.- Type Parameters:
G
- the gene typeC
- the fitness function result type- Parameters:
alterers
- the alterers to combine.- Returns:
- a new alterer which consists of the given one
- Throws:
NullPointerException
- if one of the alterers isnull
.
-
-