Class ImmutableFitnessSharing.Builder<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.postevaluationprocess.ImmutableFitnessSharing.Builder<T>
- Enclosing class:
ImmutableFitnessSharing<T extends Comparable<T>>
Builds instances of type
ImmutableFitnessSharing
.
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 BiFunction
<Genotype, Genotype, Double> private static final long
private static final long
private static final long
private long
private BiFunction
<Individual<T>, Double, T> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableFitnessSharing
.final ImmutableFitnessSharing.Builder
<T> distance
(BiFunction<Genotype, Genotype, Double> distance) Initializes the value for thedistance
attribute.private String
final ImmutableFitnessSharing.Builder
<T> from
(FitnessSharing<T> instance) Fill a builder with attribute values from the providedFitnessSharing
instance.final ImmutableFitnessSharing.Builder
<T> scaleFitness
(BiFunction<Individual<T>, Double, T> scaleFitness) Initializes the value for thescaleFitness
attribute.final ImmutableFitnessSharing.Builder
<T> Initializes the value for thesharing
attribute.
-
Field Details
-
INIT_BIT_DISTANCE
private static final long INIT_BIT_DISTANCE- See Also:
-
INIT_BIT_SHARING
private static final long INIT_BIT_SHARING- See Also:
-
INIT_BIT_SCALE_FITNESS
private static final long INIT_BIT_SCALE_FITNESS- See Also:
-
initBits
private long initBits -
distance
-
sharing
-
scaleFitness
-
-
Constructor Details
-
Builder
private Builder()
-
-
Method Details
-
from
Fill a builder with attribute values from the providedFitnessSharing
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
-
distance
public final ImmutableFitnessSharing.Builder<T> distance(BiFunction<Genotype, Genotype, Double> distance) Initializes the value for thedistance
attribute.- Parameters:
distance
- The value for distance- Returns:
this
builder for use in a chained invocation
-
sharing
Initializes the value for thesharing
attribute.- Parameters:
sharing
- The value for sharing- Returns:
this
builder for use in a chained invocation
-
scaleFitness
public final ImmutableFitnessSharing.Builder<T> scaleFitness(BiFunction<Individual<T>, Double, T> scaleFitness) Initializes the value for thescaleFitness
attribute.- Parameters:
scaleFitness
- The value for scaleFitness- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableFitnessSharing
.- Returns:
- An immutable instance of FitnessSharing
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-