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
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_ALTER_PROBABILITYThe 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 thethisalterer to its input, and then applies theafteralterer to the result.default Alterer<G,C>compose(Alterer<G,C> before)Returns a composed alterer that first applies thebeforealterer to its input, and then appliesthisalterer 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 thepopulationis empty, nothing is altered. The altered population is part of the returnedAlterResultobject.- Parameters:
population- The Population to be altered. If thepopulationisnullor 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 givenpopulationisnull.
-
compose
default Alterer<G,C> compose(Alterer<G,C> before)
Returns a composed alterer that first applies thebeforealterer to its input, and then appliesthisalterer 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 thethisalterer to its input, and then applies theafteralterer 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.
-
-