Package net.bmahe.genetics4j.core.spec
Class ImmutableEAConfigurationBulkAsync.Builder<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.spec.ImmutableEAConfigurationBulkAsync.Builder<T>
- Direct Known Subclasses:
EAConfigurationBulkAsync.Builder
- Enclosing class:
ImmutableEAConfigurationBulkAsync<T extends Comparable<T>>
public static class ImmutableEAConfigurationBulkAsync.Builder<T extends Comparable<T>>
extends Object
Builds instances of type
ImmutableEAConfigurationBulkAsync
.
Initialize attributes and then invoke the build()
method to create an
immutable instance.
Builder
is not thread-safe and generally should not be stored in a field or collection,
but instead used immediately to create instances.
-
Field Summary
Modifier and TypeFieldDescriptionprivate List
<ChromosomeSpec> private CombinationPolicy
private FitnessBulkAsync
<T> private GenotypeCombinator
private static final long
private static final long
private static final long
private static final long
private long
private List
<MutationPolicy> private double
private static final long
private long
private Optimization
private SelectionPolicy
private Function
<Population<T>, Population<T>> private ReplacementStrategy
private Collection
<Genotype> private Termination
<T> -
Constructor Summary
ConstructorDescriptionBuilder()
Creates a builder forImmutableEAConfigurationBulkAsync
instances. -
Method Summary
Modifier and TypeMethodDescriptionaddAllChromosomeSpecs
(Iterable<? extends ChromosomeSpec> elements) Adds elements tochromosomeSpecs
list.addAllMutationPolicies
(Iterable<? extends MutationPolicy> elements) Adds elements tomutationPolicies
list.addChromosomeSpecs
(ChromosomeSpec element) Adds one element tochromosomeSpecs
list.addChromosomeSpecs
(ChromosomeSpec... elements) Adds elements tochromosomeSpecs
list.addMutationPolicies
(MutationPolicy element) Adds one element tomutationPolicies
list.addMutationPolicies
(MutationPolicy... elements) Adds elements tomutationPolicies
list.build()
Builds a newImmutableEAConfigurationBulkAsync
.chromosomeSpecs
(Iterable<? extends ChromosomeSpec> elements) Sets or replaces all elements forchromosomeSpecs
list.combinationPolicy
(CombinationPolicy combinationPolicy) Initializes the value for thecombinationPolicy
attribute.fitness
(FitnessBulkAsync<T> fitness) Initializes the value for thefitness
attribute.private String
from
(EAConfigurationBulkAsync<T> instance) Fill a builder with attribute values from the providedEAConfigurationBulkAsync
instance.genotypeCombinator
(GenotypeCombinator genotypeCombinator) Initializes the value for thegenotypeCombinator
attribute.genotypeGenerator
(Supplier<Genotype> genotypeGenerator) Initializes the optional valuegenotypeGenerator
to genotypeGenerator.genotypeGenerator
(Optional<? extends Supplier<Genotype>> genotypeGenerator) Initializes the optional valuegenotypeGenerator
to genotypeGenerator.mutationPolicies
(Iterable<? extends MutationPolicy> elements) Sets or replaces all elements formutationPolicies
list.offspringGeneratedRatio
(double offspringGeneratedRatio) Initializes the value for theoffspringGeneratedRatio
attribute.private boolean
optimization
(Optimization optimization) Initializes the value for theoptimization
attribute.parentSelectionPolicy
(SelectionPolicy parentSelectionPolicy) Initializes the value for theparentSelectionPolicy
attribute.postEvaluationProcessor
(Function<Population<T>, Population<T>> postEvaluationProcessor) Initializes the optional valuepostEvaluationProcessor
to postEvaluationProcessor.postEvaluationProcessor
(Optional<? extends Function<Population<T>, Population<T>>> postEvaluationProcessor) Initializes the optional valuepostEvaluationProcessor
to postEvaluationProcessor.replacementStrategy
(ReplacementStrategy replacementStrategy) Initializes the value for thereplacementStrategy
attribute.seedPopulation
(Collection<Genotype> seedPopulation) Initializes the value for theseedPopulation
attribute.termination
(Termination<T> termination) Initializes the value for thetermination
attribute.
-
Field Details
-
INIT_BIT_PARENT_SELECTION_POLICY
private static final long INIT_BIT_PARENT_SELECTION_POLICY- See Also:
-
INIT_BIT_COMBINATION_POLICY
private static final long INIT_BIT_COMBINATION_POLICY- See Also:
-
INIT_BIT_TERMINATION
private static final long INIT_BIT_TERMINATION- See Also:
-
INIT_BIT_FITNESS
private static final long INIT_BIT_FITNESS- See Also:
-
OPT_BIT_OFFSPRING_GENERATED_RATIO
private static final long OPT_BIT_OFFSPRING_GENERATED_RATIO- See Also:
-
initBits
private long initBits -
optBits
private long optBits -
chromosomeSpecs
-
parentSelectionPolicy
-
combinationPolicy
-
mutationPolicies
-
replacementStrategy
-
postEvaluationProcessor
private Function<Population<T extends Comparable<T>>,Population<T extends Comparable<T>>> postEvaluationProcessor -
termination
-
genotypeGenerator
-
seedPopulation
-
genotypeCombinator
-
offspringGeneratedRatio
private double offspringGeneratedRatio -
optimization
-
fitness
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableEAConfigurationBulkAsync
instances.new EAConfigurationBulkAsync.Builder<T>() .addChromosomeSpecs|addAllChromosomeSpecs(net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec) //
chromosomeSpecs
elements .parentSelectionPolicy(net.bmahe.genetics4j.core.spec.selection.SelectionPolicy) // requiredparentSelectionPolicy
.combinationPolicy(net.bmahe.genetics4j.core.spec.combination.CombinationPolicy) // requiredcombinationPolicy
.addMutationPolicies|addAllMutationPolicies(net.bmahe.genetics4j.core.spec.mutation.MutationPolicy) //mutationPolicies
elements .replacementStrategy(net.bmahe.genetics4j.core.spec.replacement.ReplacementStrategy) // optionalreplacementStrategy
.postEvaluationProcessor(function.Function<net.bmahe.genetics4j.core.Population<T>, net.bmahe.genetics4j.core.Population<T>>) // optionalpostEvaluationProcessor
.termination(net.bmahe.genetics4j.core.termination.Termination<T>) // requiredtermination
.genotypeGenerator(function.Supplier<net.bmahe.genetics4j.core.Genotype>) // optionalgenotypeGenerator
.seedPopulation(Collection<net.bmahe.genetics4j.core.Genotype>) // optionalseedPopulation
.genotypeCombinator(net.bmahe.genetics4j.core.combination.GenotypeCombinator) // optionalgenotypeCombinator
.offspringGeneratedRatio(double) // optionaloffspringGeneratedRatio
.optimization(net.bmahe.genetics4j.core.spec.Optimization) // optionaloptimization
.fitness(net.bmahe.genetics4j.core.FitnessBulkAsync<T>) // requiredfitness
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedEAConfigurationBulkAsync
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
addChromosomeSpecs
Adds one element tochromosomeSpecs
list.- Parameters:
element
- A chromosomeSpecs element- Returns:
this
builder for use in a chained invocation
-
addChromosomeSpecs
Adds elements tochromosomeSpecs
list.- Parameters:
elements
- An array of chromosomeSpecs elements- Returns:
this
builder for use in a chained invocation
-
chromosomeSpecs
public final EAConfigurationBulkAsync.Builder<T> chromosomeSpecs(Iterable<? extends ChromosomeSpec> elements) Sets or replaces all elements forchromosomeSpecs
list.- Parameters:
elements
- An iterable of chromosomeSpecs elements- Returns:
this
builder for use in a chained invocation
-
addAllChromosomeSpecs
public final EAConfigurationBulkAsync.Builder<T> addAllChromosomeSpecs(Iterable<? extends ChromosomeSpec> elements) Adds elements tochromosomeSpecs
list.- Parameters:
elements
- An iterable of chromosomeSpecs elements- Returns:
this
builder for use in a chained invocation
-
parentSelectionPolicy
public final EAConfigurationBulkAsync.Builder<T> parentSelectionPolicy(SelectionPolicy parentSelectionPolicy) Initializes the value for theparentSelectionPolicy
attribute.- Parameters:
parentSelectionPolicy
- The value for parentSelectionPolicy- Returns:
this
builder for use in a chained invocation
-
combinationPolicy
public final EAConfigurationBulkAsync.Builder<T> combinationPolicy(CombinationPolicy combinationPolicy) Initializes the value for thecombinationPolicy
attribute.- Parameters:
combinationPolicy
- The value for combinationPolicy- Returns:
this
builder for use in a chained invocation
-
addMutationPolicies
Adds one element tomutationPolicies
list.- Parameters:
element
- A mutationPolicies element- Returns:
this
builder for use in a chained invocation
-
addMutationPolicies
Adds elements tomutationPolicies
list.- Parameters:
elements
- An array of mutationPolicies elements- Returns:
this
builder for use in a chained invocation
-
mutationPolicies
public final EAConfigurationBulkAsync.Builder<T> mutationPolicies(Iterable<? extends MutationPolicy> elements) Sets or replaces all elements formutationPolicies
list.- Parameters:
elements
- An iterable of mutationPolicies elements- Returns:
this
builder for use in a chained invocation
-
addAllMutationPolicies
public final EAConfigurationBulkAsync.Builder<T> addAllMutationPolicies(Iterable<? extends MutationPolicy> elements) Adds elements tomutationPolicies
list.- Parameters:
elements
- An iterable of mutationPolicies elements- Returns:
this
builder for use in a chained invocation
-
replacementStrategy
public final EAConfigurationBulkAsync.Builder<T> replacementStrategy(ReplacementStrategy replacementStrategy) Initializes the value for thereplacementStrategy
attribute.If not set, this attribute will have a default value as returned by the initializer of
replacementStrategy
.- Parameters:
replacementStrategy
- The value for replacementStrategy- Returns:
this
builder for use in a chained invocation
-
postEvaluationProcessor
public final EAConfigurationBulkAsync.Builder<T> postEvaluationProcessor(Function<Population<T>, Population<T>> postEvaluationProcessor) Initializes the optional valuepostEvaluationProcessor
to postEvaluationProcessor.- Parameters:
postEvaluationProcessor
- The value for postEvaluationProcessor- Returns:
this
builder for chained invocation
-
postEvaluationProcessor
public final EAConfigurationBulkAsync.Builder<T> postEvaluationProcessor(Optional<? extends Function<Population<T>, Population<T>>> postEvaluationProcessor) Initializes the optional valuepostEvaluationProcessor
to postEvaluationProcessor.- Parameters:
postEvaluationProcessor
- The value for postEvaluationProcessor- Returns:
this
builder for use in a chained invocation
-
termination
Initializes the value for thetermination
attribute.- Parameters:
termination
- The value for termination- Returns:
this
builder for use in a chained invocation
-
genotypeGenerator
public final EAConfigurationBulkAsync.Builder<T> genotypeGenerator(Supplier<Genotype> genotypeGenerator) Initializes the optional valuegenotypeGenerator
to genotypeGenerator.- Parameters:
genotypeGenerator
- The value for genotypeGenerator- Returns:
this
builder for chained invocation
-
genotypeGenerator
public final EAConfigurationBulkAsync.Builder<T> genotypeGenerator(Optional<? extends Supplier<Genotype>> genotypeGenerator) Initializes the optional valuegenotypeGenerator
to genotypeGenerator.- Parameters:
genotypeGenerator
- The value for genotypeGenerator- Returns:
this
builder for use in a chained invocation
-
seedPopulation
public final EAConfigurationBulkAsync.Builder<T> seedPopulation(Collection<Genotype> seedPopulation) Initializes the value for theseedPopulation
attribute.If not set, this attribute will have a default value as returned by the initializer of
seedPopulation
.- Parameters:
seedPopulation
- The value for seedPopulation- Returns:
this
builder for use in a chained invocation
-
genotypeCombinator
public final EAConfigurationBulkAsync.Builder<T> genotypeCombinator(GenotypeCombinator genotypeCombinator) Initializes the value for thegenotypeCombinator
attribute.If not set, this attribute will have a default value as returned by the initializer of
genotypeCombinator
.- Parameters:
genotypeCombinator
- The value for genotypeCombinator- Returns:
this
builder for use in a chained invocation
-
offspringGeneratedRatio
public final EAConfigurationBulkAsync.Builder<T> offspringGeneratedRatio(double offspringGeneratedRatio) Initializes the value for theoffspringGeneratedRatio
attribute.If not set, this attribute will have a default value as returned by the initializer of
offspringGeneratedRatio
.- Parameters:
offspringGeneratedRatio
- The value for offspringGeneratedRatio- Returns:
this
builder for use in a chained invocation
-
optimization
Initializes the value for theoptimization
attribute.If not set, this attribute will have a default value as returned by the initializer of
optimization
.- Parameters:
optimization
- The value for optimization- Returns:
this
builder for use in a chained invocation
-
fitness
Initializes the value for thefitness
attribute.- Parameters:
fitness
- The value for fitness- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableEAConfigurationBulkAsync
.- Returns:
- An immutable instance of EAConfigurationBulkAsync
- Throws:
IllegalStateException
- if any required attributes are missing
-
offspringGeneratedRatioIsSet
private boolean offspringGeneratedRatioIsSet() -
formatRequiredAttributesMessage
-