Module io.jenetics.base
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
,HPRMutator
,IntermediateCrossover
,LineCrossover
,MathRewriteAlterer
,MeanAlterer
,MultiPointCrossover
,Mutator
,PartialAlterer
,PartiallyMatchedCrossover
,Recombinator
,RSMutator
,ShiftMutator
,ShuffleMutator
,SimulatedBinaryCrossover
,SingleNodeCrossover
,SinglePointCrossover
,SwapMutator
,TreeCrossover
,TreeMutator
,TreeRewriteAlterer
,UniformCrossover
,UniformOderBasedCrossover
,WeaselMutator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The Alterer is responsible for the changing/recombining the Population.
Alterers can be chained by appending a list of alterers with the
The order of the alterer calls is: Crossover, Mutation and MeanAlterer.
Engine.Builder.alterers(Alterer, Alterer[])
method.
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
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The default alter probability: 0.2 -
Method Summary
Modifier and TypeMethodDescriptionAlters (recombine) a given population.Returns a composed alterer that applies thethis
alterer to its input, and then applies theafter
alterer to the result.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> Combine the given alterers.
-
Field Details
-
DEFAULT_ALTER_PROBABILITY
The default alter probability: 0.2- See Also:
-
-
Method Details
-
alter
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 counts
- Throws:
NullPointerException
- if the givenpopulation
isnull
.
-
compose
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
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>, Alterer<G,C extends Comparable<? super C>> 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
.
-