Package net.bmahe.genetics4j.neat.spec
Class ImmutableNeatChromosomeSpec.Builder
java.lang.Object
net.bmahe.genetics4j.neat.spec.ImmutableNeatChromosomeSpec.Builder
- Direct Known Subclasses:
NeatChromosomeSpec.Builder
- Enclosing class:
ImmutableNeatChromosomeSpec
Builds instances of type
ImmutableNeatChromosomeSpec
.
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 static final long
private static final long
private long
private float
private float
private int
private int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableNeatChromosomeSpec
.private String
from
(NeatChromosomeSpec instance) Fill a builder with attribute values from the providedNeatChromosomeSpec
instance.maxWeightValue
(float maxWeightValue) Initializes the value for themaxWeightValue
attribute.minWeightValue
(float minWeightValue) Initializes the value for theminWeightValue
attribute.numInputs
(int numInputs) Initializes the value for thenumInputs
attribute.numOutputs
(int numOutputs) Initializes the value for thenumOutputs
attribute.
-
Field Details
-
INIT_BIT_NUM_INPUTS
private static final long INIT_BIT_NUM_INPUTS- See Also:
-
INIT_BIT_NUM_OUTPUTS
private static final long INIT_BIT_NUM_OUTPUTS- See Also:
-
INIT_BIT_MIN_WEIGHT_VALUE
private static final long INIT_BIT_MIN_WEIGHT_VALUE- See Also:
-
INIT_BIT_MAX_WEIGHT_VALUE
private static final long INIT_BIT_MAX_WEIGHT_VALUE- See Also:
-
initBits
private long initBits -
numInputs
private int numInputs -
numOutputs
private int numOutputs -
minWeightValue
private float minWeightValue -
maxWeightValue
private float maxWeightValue
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableNeatChromosomeSpec
instances.new NeatChromosomeSpec.Builder() .numInputs(int) // required
numInputs
.numOutputs(int) // requirednumOutputs
.minWeightValue(float) // requiredminWeightValue
.maxWeightValue(float) // requiredmaxWeightValue
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedNeatChromosomeSpec
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
-
numInputs
Initializes the value for thenumInputs
attribute.- Parameters:
numInputs
- The value for numInputs- Returns:
this
builder for use in a chained invocation
-
numOutputs
Initializes the value for thenumOutputs
attribute.- Parameters:
numOutputs
- The value for numOutputs- Returns:
this
builder for use in a chained invocation
-
minWeightValue
Initializes the value for theminWeightValue
attribute.- Parameters:
minWeightValue
- The value for minWeightValue- Returns:
this
builder for use in a chained invocation
-
maxWeightValue
Initializes the value for themaxWeightValue
attribute.- Parameters:
maxWeightValue
- The value for maxWeightValue- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableNeatChromosomeSpec
.- Returns:
- An immutable instance of NeatChromosomeSpec
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-