Class NeatChromosomeSpec
- All Implemented Interfaces:
ChromosomeSpec
- Direct Known Subclasses:
ImmutableNeatChromosomeSpec
NeatChromosomeSpec defines the structural parameters and constraints for creating NEAT neural network chromosomes. This specification is used by chromosome factories to generate initial network topologies and by genetic operators to understand network boundaries and weight constraints.
Key parameters:
- Network topology: Defines the number of input and output nodes
- Weight constraints: Specifies minimum and maximum connection weight values
- Network structure: Establishes the foundation for topology evolution
- Genetic boundaries: Provides constraints for mutation and crossover operations
NEAT network architecture:
- Input layer: Fixed number of input nodes (indices 0 to numInputs-1)
- Output layer: Fixed number of output nodes (indices numInputs to numInputs+numOutputs-1)
- Hidden layers: Variable number of hidden nodes added through evolution
- Connections: Weighted links between nodes with enable/disable states
Common usage patterns:
// Simple XOR problem specification
NeatChromosomeSpec xorSpec = NeatChromosomeSpec.of(
2, // 2 inputs (A, B)
1, // 1 output (A XOR B)
-1.0f, // minimum weight
1.0f // maximum weight
);
// Complex classification problem
NeatChromosomeSpec classificationSpec = NeatChromosomeSpec.of(
784, // 28x28 pixel inputs
10, // 10 class outputs
-2.0f, // wider weight range
2.0f
);
// Builder pattern for complex construction
NeatChromosomeSpec spec = new NeatChromosomeSpec.Builder()
.numInputs(5)
.numOutputs(3)
.minWeightValue(-1.5f)
.maxWeightValue(1.5f)
.build();
Integration with NEAT ecosystem:
- Chromosome factories: Used by NeatConnectedChromosomeFactory for initial network generation
- Genetic operators: Provides constraints for weight mutations and structural changes
- Network evaluation: Defines input/output interfaces for fitness computation
- Evolution configuration: Establishes network parameters for entire evolutionary run
Weight constraint management:
- Mutation boundaries: Weight mutations respect min/max bounds
- Initial generation: New connections use weights within specified range
- Crossover inheritance: Parent weights may be clipped to child bounds
- Network stability: Bounded weights help prevent gradient explosion/vanishing
Validation and constraints:
- Positive node counts: Both input and output counts must be greater than zero
- Weight ordering: Minimum weight value should be less than maximum (not enforced)
- Reasonable bounds: Weight ranges should be appropriate for the problem domain
- Network capacity: Input/output counts should match problem requirements
Problem domain considerations:
- Classification: Output count should match number of classes
- Regression: Single or multiple outputs for continuous value prediction
- Control problems: Outputs correspond to control signals or actions
- Feature extraction: Input count should match feature dimensionality
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
check()
abstract float
Returns the maximum allowed connection weight value.abstract float
Returns the minimum allowed connection weight value.abstract int
Returns the number of input nodes for the neural network.abstract int
Returns the number of output nodes for the neural network.static NeatChromosomeSpec
of
(int numInputs, int numOutputs, float minWeightValue, float maxWeightValue) Creates a new NEAT chromosome specification with the given parameters.
-
Constructor Details
-
NeatChromosomeSpec
public NeatChromosomeSpec()
-
-
Method Details
-
numInputs
@Parameter public abstract 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.
- Returns:
- the number of input nodes (must be positive)
-
numOutputs
@Parameter public abstract 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.
- Returns:
- the number of output nodes (must be positive)
-
minWeightValue
@Parameter public abstract 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.
- Returns:
- the minimum connection weight value
-
maxWeightValue
@Parameter public abstract 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.
- Returns:
- the maximum connection weight value
-
check
@Check protected void check() -
of
public static NeatChromosomeSpec of(int numInputs, int numOutputs, float minWeightValue, float maxWeightValue) Creates a new NEAT chromosome specification with the given parameters.This is a convenience factory method for creating chromosome specifications with all required parameters. The specification will be validated to ensure positive input and output counts.
- Parameters:
numInputs
- number of input nodes (must be positive)numOutputs
- number of output nodes (must be positive)minWeightValue
- minimum allowed connection weightmaxWeightValue
- maximum allowed connection weight- Returns:
- a new chromosome specification with the specified parameters
- Throws:
IllegalArgumentException
- if numInputs <= 0 or numOutputs <= 0
-