Package io.jenetics.engine
Class EvolutionParams.Builder<G extends Gene<?,G>,C extends Comparable<? super C>>
- java.lang.Object
-
- io.jenetics.engine.EvolutionParams.Builder<G,C>
-
- Type Parameters:
G- the gene typeC- the fitness function result type
- Enclosing class:
- EvolutionParams<G extends Gene<?,G>,C extends Comparable<? super C>>
public static final class EvolutionParams.Builder<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object
Builder class for the evolution parameter.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Alterer<G,C>alterer()Return the usedAltererof the GA.EvolutionParams.Builder<G,C>alterers(Alterer<G,C> first, Alterer<G,C>... rest)The alterers used for alter the offspring population.EvolutionParams<G,C>build()Builds an newEvolutionParamsinstance from the set properties.EvolutionParams.Builder<G,C>evolutionParams(EvolutionParams<G,C> params)longmaximalPhenotypeAge()Return the maximal allowed phenotype age.EvolutionParams.Builder<G,C>maximalPhenotypeAge(long age)The maximal allowed age of a phenotype.doubleoffspringFraction()Return the offspring fraction.EvolutionParams.Builder<G,C>offspringFraction(double fraction)The offspring fraction.Selector<G,C>offspringSelector()Return the used offspringSelectorof the GA.EvolutionParams.Builder<G,C>offspringSelector(Selector<G,C> selector)The selector used for selecting the offspring population.intoffspringSize()Return the number of offspring.intpopulationSize()Return the number of individuals of a population.EvolutionParams.Builder<G,C>populationSize(int size)The number of individuals which form the population.EvolutionParams.Builder<G,C>selector(Selector<G,C> selector)The selector used for selecting the survivors and offspring population.Selector<G,C>survivorsSelector()Return the used survivorSelectorof the GA.EvolutionParams.Builder<G,C>survivorsSelector(Selector<G,C> selector)The selector used for selecting the survivors population.intsurvivorsSize()Return the number of survivors.
-
-
-
Method Detail
-
evolutionParams
public EvolutionParams.Builder<G,C> evolutionParams(EvolutionParams<G,C> params)
-
offspringSelector
public EvolutionParams.Builder<G,C> offspringSelector(Selector<G,C> selector)
The selector used for selecting the offspring population. Default values is set toTournamentSelector<>(3).- Parameters:
selector- used for selecting the offspring population- Returns:
thisbuilder, for command chaining
-
survivorsSelector
public EvolutionParams.Builder<G,C> survivorsSelector(Selector<G,C> selector)
The selector used for selecting the survivors population. Default values is set toTournamentSelector<>(3).- Parameters:
selector- used for selecting survivors population- Returns:
thisbuilder, for command chaining
-
selector
public EvolutionParams.Builder<G,C> selector(Selector<G,C> selector)
The selector used for selecting the survivors and offspring population. Default values is set toTournamentSelector<>(3).- Parameters:
selector- used for selecting survivors and offspring population- Returns:
thisbuilder, for command chaining
-
alterers
@SafeVarargs public final EvolutionParams.Builder<G,C> alterers(Alterer<G,C> first, Alterer<G,C>... rest)
The alterers used for alter the offspring population. Default values is set tonew SinglePointCrossover<>(0.2)followed bynew Mutator<>(0.15).- Parameters:
first- the first alterer used for alter the offspring populationrest- the rest of the alterers used for alter the offspring population- Returns:
thisbuilder, for command chaining- Throws:
NullPointerException- if one of the alterers isnull.
-
populationSize
public EvolutionParams.Builder<G,C> populationSize(int size)
The number of individuals which form the population. Default values is set to50.- Parameters:
size- the number of individuals of a population- Returns:
thisbuilder, for command chaining- Throws:
IllegalArgumentException- ifsize < 1
-
offspringFraction
public EvolutionParams.Builder<G,C> offspringFraction(double fraction)
The offspring fraction.- Parameters:
fraction- the offspring fraction- Returns:
thisbuilder, for command chaining- Throws:
IllegalArgumentException- if the fraction is not within the range [0, 1].
-
maximalPhenotypeAge
public EvolutionParams.Builder<G,C> maximalPhenotypeAge(long age)
The maximal allowed age of a phenotype. Default values is set to70.- Parameters:
age- the maximal phenotype age- Returns:
thisbuilder, for command chaining- Throws:
IllegalArgumentException- ifage < 1
-
build
public EvolutionParams<G,C> build()
Builds an newEvolutionParamsinstance from the set properties.- Returns:
- an new
EvolutionParamsinstance from the set properties
-
alterer
public Alterer<G,C> alterer()
Return the usedAltererof the GA.- Returns:
- the used
Altererof the GA.
-
maximalPhenotypeAge
public long maximalPhenotypeAge()
Return the maximal allowed phenotype age.- Returns:
- the maximal allowed phenotype age
-
offspringSelector
public Selector<G,C> offspringSelector()
Return the used offspringSelectorof the GA.- Returns:
- the used offspring
Selectorof the GA.
-
survivorsSelector
public Selector<G,C> survivorsSelector()
Return the used survivorSelectorof the GA.- Returns:
- the used survivor
Selectorof the GA.
-
populationSize
public int populationSize()
Return the number of individuals of a population.- Returns:
- the number of individuals of a population
-
offspringFraction
public double offspringFraction()
Return the offspring fraction.- Returns:
- the offspring fraction.
-
offspringSize
public int offspringSize()
Return the number of offspring. This is a derived property.- Returns:
- the offspring count.
-
survivorsSize
public int survivorsSize()
Return the number of survivors. This is a derived property.- Returns:
- the number of survivors
-
-