Class ImmutableNeatSelection.Builder<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.neat.spec.selection.ImmutableNeatSelection.Builder<T>
- Direct Known Subclasses:
NeatSelection.Builder
- Enclosing class:
ImmutableNeatSelection<T extends Comparable<T>>
Builds instances of type
ImmutableNeatSelection
.
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 static final long
private static final long
private long
private int
private static final long
private static final long
private long
private float
private BiPredicate
<Individual<T>, Individual<T>> private SelectionPolicy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableNeatSelection
.private String
final NeatSelection.Builder
<T> from
(NeatSelection<T> instance) Fill a builder with attribute values from the providedNeatSelection
instance.final NeatSelection.Builder
<T> minSpeciesSize
(int minSpeciesSize) Initializes the value for theminSpeciesSize
attribute.private boolean
final NeatSelection.Builder
<T> perSpeciesKeepRatio
(float perSpeciesKeepRatio) Initializes the value for theperSpeciesKeepRatio
attribute.private boolean
final NeatSelection.Builder
<T> speciesPredicate
(BiPredicate<Individual<T>, Individual<T>> speciesPredicate) Initializes the value for thespeciesPredicate
attribute.final NeatSelection.Builder
<T> speciesSelection
(SelectionPolicy speciesSelection) Initializes the value for thespeciesSelection
attribute.
-
Field Details
-
INIT_BIT_SPECIES_PREDICATE
private static final long INIT_BIT_SPECIES_PREDICATE- See Also:
-
INIT_BIT_SPECIES_SELECTION
private static final long INIT_BIT_SPECIES_SELECTION- See Also:
-
OPT_BIT_PER_SPECIES_KEEP_RATIO
private static final long OPT_BIT_PER_SPECIES_KEEP_RATIO- See Also:
-
OPT_BIT_MIN_SPECIES_SIZE
private static final long OPT_BIT_MIN_SPECIES_SIZE- See Also:
-
initBits
private long initBits -
optBits
private long optBits -
perSpeciesKeepRatio
private float perSpeciesKeepRatio -
minSpeciesSize
private int minSpeciesSize -
speciesPredicate
private BiPredicate<Individual<T extends Comparable<T>>,Individual<T extends Comparable<T>>> speciesPredicate -
speciesSelection
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableNeatSelection
instances.new NeatSelection.Builder<T>() .perSpeciesKeepRatio(float) // optional
perSpeciesKeepRatio
.minSpeciesSize(int) // optionalminSpeciesSize
.speciesPredicate(function.BiPredicate<net.bmahe.genetics4j.core.Individual<T>, net.bmahe.genetics4j.core.Individual<T>>) // requiredspeciesPredicate
.speciesSelection(net.bmahe.genetics4j.core.spec.selection.SelectionPolicy) // requiredspeciesSelection
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedNeatSelection
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
perSpeciesKeepRatio
Initializes the value for theperSpeciesKeepRatio
attribute.If not set, this attribute will have a default value as returned by the initializer of
perSpeciesKeepRatio
.- Parameters:
perSpeciesKeepRatio
- The value for perSpeciesKeepRatio- Returns:
this
builder for use in a chained invocation
-
minSpeciesSize
Initializes the value for theminSpeciesSize
attribute.If not set, this attribute will have a default value as returned by the initializer of
minSpeciesSize
.- Parameters:
minSpeciesSize
- The value for minSpeciesSize- Returns:
this
builder for use in a chained invocation
-
speciesPredicate
public final NeatSelection.Builder<T> speciesPredicate(BiPredicate<Individual<T>, Individual<T>> speciesPredicate) Initializes the value for thespeciesPredicate
attribute.- Parameters:
speciesPredicate
- The value for speciesPredicate- Returns:
this
builder for use in a chained invocation
-
speciesSelection
Initializes the value for thespeciesSelection
attribute.- Parameters:
speciesSelection
- The value for speciesSelection- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableNeatSelection
.- Returns:
- An immutable instance of NeatSelection
- Throws:
IllegalStateException
- if any required attributes are missing
-
perSpeciesKeepRatioIsSet
private boolean perSpeciesKeepRatioIsSet() -
minSpeciesSizeIsSet
private boolean minSpeciesSizeIsSet() -
formatRequiredAttributesMessage
-