G
- the gene typeC
- the fitness function result typepublic static final class Engine.Builder<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object implements Copyable<Engine.Builder<G,C>>
Engine
instances.Engine
Constructor and Description |
---|
Builder(Evaluator<G,C> evaluator,
Factory<Genotype<G>> genotypeFactory)
Create a new evolution
Engine.Builder with the given fitness
evaluator and genotype factory. |
Modifier and Type | Method and Description |
---|---|
Alterer<G,C> |
alterer()
Return the used
Alterer of the GA. |
Engine.Builder<G,C> |
alterers(Alterer<G,C> first,
Alterer<G,C>... rest)
The alterers used for alter the offspring population.
|
Engine<G,C> |
build()
Builds an new
Engine instance from the set properties. |
Clock |
clock()
Return the
Clock the engine is using for measuring the execution
time. |
Engine.Builder<G,C> |
clock(Clock clock)
The clock used for calculating the execution durations.
|
Constraint<G,C> |
constraint()
Return the constraint of the evolution problem.
|
Engine.Builder<G,C> |
constraint(Constraint<G,C> constraint)
The phenotype constraint is used for detecting invalid individuals
and repairing them.
|
Engine.Builder<G,C> |
copy()
Create a new builder, with the current configuration.
|
EvolutionParams<G,C> |
evolutionParams()
Return the currently set evolution parameters.
|
Engine.Builder<G,C> |
evolutionParams(EvolutionParams<G,C> params)
Set the evolution parameters used by the engine.
|
Executor |
executor()
Return the
Executor the engine is using for executing the
evolution steps. |
Engine.Builder<G,C> |
executor(Executor executor)
The executor used by the engine.
|
Factory<Genotype<G>> |
genotypeFactory()
Return the used genotype
Factory of the GA. |
Alterer<G,C> |
getAlterers()
Deprecated.
Use
alterer() instead |
Clock |
getClock()
Deprecated.
Use
clock() instead |
Constraint<G,C> |
getConstraint()
Deprecated.
Use
constraint() instead |
Executor |
getExecutor()
Deprecated.
Use
executor() instead |
Factory<Genotype<G>> |
getGenotypeFactory()
Deprecated.
Use
genotypeFactory() instead |
UnaryOperator<EvolutionResult<G,C>> |
getMapper()
Deprecated.
Use
mapper() instead |
long |
getMaximalPhenotypeAge()
Deprecated.
USe
maximalPhenotypeAge() instead |
double |
getOffspringFraction()
Deprecated.
Use
offspringFraction() instead |
Selector<G,C> |
getOffspringSelector()
Deprecated.
Use
offspringSelector() instead |
Optimize |
getOptimize()
Deprecated.
Use
optimize() instead |
int |
getPopulationSize()
Deprecated.
Use
populationSize() instead |
Selector<G,C> |
getSurvivorsSelector()
Deprecated.
Use
survivorsSelector() instead |
UnaryOperator<EvolutionResult<G,C>> |
mapper()
Return the evolution result mapper.
|
Engine.Builder<G,C> |
mapping(Function<? super EvolutionResult<G,C>,EvolutionResult<G,C>> mapper)
The result mapper, which allows to change the evolution result after
each generation.
|
long |
maximalPhenotypeAge()
Return the maximal allowed phenotype age.
|
Engine.Builder<G,C> |
maximalPhenotypeAge(long age)
The maximal allowed age of a phenotype.
|
Engine.Builder<G,C> |
maximizing()
Set to a fitness maximizing strategy.
|
Engine.Builder<G,C> |
minimizing()
Set to a fitness minimizing strategy.
|
double |
offspringFraction()
Return the offspring fraction.
|
Engine.Builder<G,C> |
offspringFraction(double fraction)
The offspring fraction.
|
Selector<G,C> |
offspringSelector()
Return the used offspring
Selector of the GA. |
Engine.Builder<G,C> |
offspringSelector(Selector<G,C> selector)
The selector used for selecting the offspring population.
|
Engine.Builder<G,C> |
offspringSize(int size)
The number of offspring individuals.
|
Optimize |
optimize()
Return the optimization strategy.
|
Engine.Builder<G,C> |
optimize(Optimize optimize)
The optimization strategy used by the engine.
|
int |
populationSize()
Return the number of individuals of a population.
|
Engine.Builder<G,C> |
populationSize(int size)
The number of individuals which form the population.
|
Engine.Builder<G,C> |
selector(Selector<G,C> selector)
The selector used for selecting the survivors and offspring
population.
|
Engine.Builder<G,C> |
survivorsFraction(double fraction)
The survivors fraction.
|
Selector<G,C> |
survivorsSelector()
Return the used survivor
Selector of the GA. |
Engine.Builder<G,C> |
survivorsSelector(Selector<G,C> selector)
The selector used for selecting the survivors population.
|
Engine.Builder<G,C> |
survivorsSize(int size)
The number of survivors.
|
public Builder(Evaluator<G,C> evaluator, Factory<Genotype<G>> genotypeFactory)
Engine.Builder
with the given fitness
evaluator and genotype factory. This is the most general way for
creating an engine builder.evaluator
- the fitness evaluatorgenotypeFactory
- the genotype factoryNullPointerException
- if one of the arguments is null
.Engine.builder(Function, Codec)
,
Engine.builder(Function, Factory)
,
Engine.builder(Problem)
,
Engine.builder(Function, Chromosome, Chromosome[])
public Engine.Builder<G,C> evolutionParams(EvolutionParams<G,C> params)
params
- the evolution parameterthis
builder, for command chainingNullPointerException
- if the params
is null
.public Engine.Builder<G,C> offspringSelector(Selector<G,C> selector)
TournamentSelector<>(3)
.selector
- used for selecting the offspring populationthis
builder, for command chainingNullPointerException
- if one of the selector
is
null
.public Engine.Builder<G,C> survivorsSelector(Selector<G,C> selector)
TournamentSelector<>(3)
.selector
- used for selecting survivors populationthis
builder, for command chainingNullPointerException
- if one of the selector
is
null
.public Engine.Builder<G,C> selector(Selector<G,C> selector)
TournamentSelector<>(3)
.selector
- used for selecting survivors and offspring populationthis
builder, for command chainingNullPointerException
- if one of the selector
is
null
.@SafeVarargs public final Engine.Builder<G,C> alterers(Alterer<G,C> first, Alterer<G,C>... rest)
new SinglePointCrossover<>(0.2)
followed by
new Mutator<>(0.15)
.first
- the first alterer used for alter the offspring
populationrest
- the rest of the alterers used for alter the offspring
populationthis
builder, for command chainingNullPointerException
- if one of the alterers is null
.public Engine.Builder<G,C> constraint(Constraint<G,C> constraint)
Default implementation uses Phenotype::isValid
for
validating the phenotype.
constraint
- phenotype constraint which can override the default
implementation the Phenotype.isValid()
method and repairs
invalid phenotypes when needed.this
builder, for command chainingNullPointerException
- if one of the constraint
is
null
.public Engine.Builder<G,C> optimize(Optimize optimize)
Optimize.MAXIMUM
.optimize
- the optimization strategy used by the enginethis
builder, for command chainingNullPointerException
- if one of the optimize
is
null
.public Engine.Builder<G,C> maximizing()
this
builder, for command chainingpublic Engine.Builder<G,C> minimizing()
this
builder, for command chainingpublic Engine.Builder<G,C> offspringFraction(double fraction)
0.6
.
This method call is equivalent to
survivorsFraction(1 - offspringFraction)
and will override
any previously set survivors-fraction.fraction
- the offspring fractionthis
builder, for command chainingIllegalArgumentException
- if the fraction is not
within the range [0, 1].survivorsFraction(double)
public Engine.Builder<G,C> survivorsFraction(double fraction)
0.4
.
This method call is equivalent to
offspringFraction(1 - survivorsFraction)
and will override
any previously set offspring-fraction.fraction
- the survivors fractionthis
builder, for command chainingIllegalArgumentException
- if the fraction is not
within the range [0, 1].offspringFraction(double)
public Engine.Builder<G,C> offspringSize(int size)
size
- the number of offspring individuals.this
builder, for command chainingIllegalArgumentException
- if the size is not
within the range [0, population-size].public Engine.Builder<G,C> survivorsSize(int size)
size
- the number of survivors.this
builder, for command chainingIllegalArgumentException
- if the size is not
within the range [0, population-size].public Engine.Builder<G,C> populationSize(int size)
50
.size
- the number of individuals of a populationthis
builder, for command chainingIllegalArgumentException
- if size < 1
public Engine.Builder<G,C> maximalPhenotypeAge(long age)
70
.age
- the maximal phenotype agethis
builder, for command chainingIllegalArgumentException
- if age < 1
public Engine.Builder<G,C> executor(Executor executor)
executor
- the executor used by the enginethis
builder, for command chainingpublic Engine.Builder<G,C> clock(Clock clock)
clock
- the clock used for calculating the execution durationsthis
builder, for command chainingpublic Engine.Builder<G,C> mapping(Function<? super EvolutionResult<G,C>,EvolutionResult<G,C>> mapper)
mapper
- the evolution result mapperthis
builder, for command chainingNullPointerException
- if the given resultMapper
is
null
EvolutionResult.toUniquePopulation()
public Engine<G,C> build()
Engine
instance from the set properties.Engine
instance from the set propertiespublic Alterer<G,C> alterer()
Alterer
of the GA.Alterer
of the GA.@Deprecated public Alterer<G,C> getAlterers()
alterer()
insteadAlterer
of the GA.Alterer
of the GA.public Clock clock()
Clock
the engine is using for measuring the execution
time.@Deprecated public Clock getClock()
clock()
insteadClock
the engine is using for measuring the execution
time.public Executor executor()
Executor
the engine is using for executing the
evolution steps.@Deprecated public Executor getExecutor()
executor()
insteadExecutor
the engine is using for executing the
evolution steps.public Factory<Genotype<G>> genotypeFactory()
Factory
of the GA. The genotype factory
is used for creating the initial population and new, random individuals
when needed (as replacement for invalid and/or died genotypes).Factory
of the GA.@Deprecated public Factory<Genotype<G>> getGenotypeFactory()
genotypeFactory()
insteadFactory
of the GA. The genotype factory
is used for creating the initial population and new, random individuals
when needed (as replacement for invalid and/or died genotypes).Factory
of the GA.public Constraint<G,C> constraint()
@Deprecated public Constraint<G,C> getConstraint()
constraint()
insteadpublic EvolutionParams<G,C> evolutionParams()
public long maximalPhenotypeAge()
@Deprecated public long getMaximalPhenotypeAge()
maximalPhenotypeAge()
insteadpublic double offspringFraction()
@Deprecated public double getOffspringFraction()
offspringFraction()
insteadpublic Selector<G,C> offspringSelector()
Selector
of the GA.Selector
of the GA.@Deprecated public Selector<G,C> getOffspringSelector()
offspringSelector()
insteadSelector
of the GA.Selector
of the GA.public Selector<G,C> survivorsSelector()
Selector
of the GA.Selector
of the GA.@Deprecated public Selector<G,C> getSurvivorsSelector()
survivorsSelector()
insteadSelector
of the GA.Selector
of the GA.public Optimize optimize()
@Deprecated public Optimize getOptimize()
optimize()
insteadpublic int populationSize()
@Deprecated public int getPopulationSize()
populationSize()
insteadpublic UnaryOperator<EvolutionResult<G,C>> mapper()
@Deprecated public UnaryOperator<EvolutionResult<G,C>> getMapper()
mapper()
insteadpublic Engine.Builder<G,C> copy()
copy
in interface Copyable<Engine.Builder<G extends Gene<?,G>,C extends Comparable<? super C>>>
© 2007-2020 Franz Wilhelmstötter (2020-02-18 20:01)