Class ImmutableNeatChromosomeSpec
- All Implemented Interfaces:
ChromosomeSpec
NeatChromosomeSpec.
Use the builder to create immutable instances:
new NeatChromosomeSpec.Builder().
Use the static factory method to create immutable instances:
ImmutableNeatChromosomeSpec.of().
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final floatprivate final floatprivate final intprivate final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableNeatChromosomeSpec(int numInputs, int numOutputs, float minWeightValue, float maxWeightValue) -
Method Summary
Modifier and TypeMethodDescriptionstatic NeatChromosomeSpeccopyOf(NeatChromosomeSpec instance) Creates an immutable copy of aNeatChromosomeSpecvalue.booleanThis instance is equal to all instances ofImmutableNeatChromosomeSpecthat have equal attribute values.private booleanequalsByValue(ImmutableNeatChromosomeSpec another) inthashCode()Computes a hash code from attributes:numInputs,numOutputs,minWeightValue,maxWeightValue.floatReturns the maximum allowed connection weight value.floatReturns the minimum allowed connection weight value.intReturns the number of input nodes for the neural network.intReturns the number of output nodes for the neural network.static NeatChromosomeSpecof(int numInputs, int numOutputs, float minWeightValue, float maxWeightValue) Construct a new immutableNeatChromosomeSpecinstance.toString()Prints the immutable valueNeatChromosomeSpecwith attribute values.private static ImmutableNeatChromosomeSpecvalidate(ImmutableNeatChromosomeSpec instance) withMaxWeightValue(float value) Copy the current immutable object by setting a value for themaxWeightValueattribute.withMinWeightValue(float value) Copy the current immutable object by setting a value for theminWeightValueattribute.withNumInputs(int value) Copy the current immutable object by setting a value for thenumInputsattribute.withNumOutputs(int value) Copy the current immutable object by setting a value for thenumOutputsattribute.Methods inherited from class net.bmahe.genetics4j.neat.spec.NeatChromosomeSpec
check
-
Field Details
-
numInputs
private final int numInputs -
numOutputs
private final int numOutputs -
minWeightValue
private final float minWeightValue -
maxWeightValue
private final float maxWeightValue
-
-
Constructor Details
-
ImmutableNeatChromosomeSpec
private ImmutableNeatChromosomeSpec(int numInputs, int numOutputs, float minWeightValue, float maxWeightValue)
-
-
Method Details
-
numInputs
public int numInputs()Returns the number of input nodes for the neural network.Input nodes receive external data and form the first layer of the network. They are assigned indices 0 through numInputs-1 and do not apply activation functions to their values.
- Specified by:
numInputsin classNeatChromosomeSpec- Returns:
- the number of input nodes (must be positive)
-
numOutputs
public int numOutputs()Returns the number of output nodes for the neural network.Output nodes produce the final results of network computation and form the last layer of the network. They are assigned indices numInputs through numInputs+numOutputs-1 and apply activation functions to their weighted sums.
- Specified by:
numOutputsin classNeatChromosomeSpec- Returns:
- the number of output nodes (must be positive)
-
minWeightValue
public float minWeightValue()Returns the minimum allowed connection weight value.This constraint is used by genetic operators to bound weight mutations and ensure network stability. New connections and weight perturbations should respect this lower bound.
- Specified by:
minWeightValuein classNeatChromosomeSpec- Returns:
- the minimum connection weight value
-
maxWeightValue
public float maxWeightValue()Returns the maximum allowed connection weight value.This constraint is used by genetic operators to bound weight mutations and ensure network stability. New connections and weight perturbations should respect this upper bound.
- Specified by:
maxWeightValuein classNeatChromosomeSpec- Returns:
- the maximum connection weight value
-
withNumInputs
Copy the current immutable object by setting a value for thenumInputsattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for numInputs- Returns:
- A modified copy or the
thisobject
-
withNumOutputs
Copy the current immutable object by setting a value for thenumOutputsattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for numOutputs- Returns:
- A modified copy or the
thisobject
-
withMinWeightValue
Copy the current immutable object by setting a value for theminWeightValueattribute. A value strict bits equality used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for minWeightValue- Returns:
- A modified copy or the
thisobject
-
withMaxWeightValue
Copy the current immutable object by setting a value for themaxWeightValueattribute. A value strict bits equality used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for maxWeightValue- Returns:
- A modified copy or the
thisobject
-
equals
This instance is equal to all instances ofImmutableNeatChromosomeSpecthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:numInputs,numOutputs,minWeightValue,maxWeightValue. -
toString
Prints the immutable valueNeatChromosomeSpecwith attribute values. -
of
public static NeatChromosomeSpec of(int numInputs, int numOutputs, float minWeightValue, float maxWeightValue) Construct a new immutableNeatChromosomeSpecinstance.- Parameters:
numInputs- The value for thenumInputsattributenumOutputs- The value for thenumOutputsattributeminWeightValue- The value for theminWeightValueattributemaxWeightValue- The value for themaxWeightValueattribute- Returns:
- An immutable NeatChromosomeSpec instance
-
validate
-
copyOf
Creates an immutable copy of aNeatChromosomeSpecvalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance- The instance to copy- Returns:
- A copied immutable NeatChromosomeSpec instance
-