Class NeatConnectedChromosomeFactory
- All Implemented Interfaces:
ChromosomeFactory<NeatChromosome>
NeatConnectedChromosomeFactory generates initial neural network chromosomes with direct connections between all input and output nodes. This provides a minimal starting topology that ensures all inputs can influence all outputs, creating a foundation for structural evolution through the NEAT algorithm.
Generated network characteristics:
- Full connectivity: Every input node connected to every output node
- No hidden nodes: Initial networks contain only input and output layers
- Random weights: Connection weights uniformly distributed within specified bounds
- Innovation tracking: All connections assigned unique innovation numbers
Network topology structure:
- Input layer: Nodes 0 to (numInputs - 1)
- Output layer: Nodes numInputs to (numInputs + numOutputs - 1)
- Connections: numInputs × numOutputs fully-connected bipartite graph
- Enabled state: All initial connections are enabled
Common usage patterns:
// Create factory with innovation manager
RandomGenerator randomGen = RandomGenerator.getDefault();
InnovationManager innovationManager = new InnovationManager();
NeatConnectedChromosomeFactory factory = new NeatConnectedChromosomeFactory(
randomGen, innovationManager
);
// Define network specification
NeatChromosomeSpec spec = NeatChromosomeSpec.of(
3, // 3 input nodes
2, // 2 output nodes
-1.0f, // minimum weight
1.0f // maximum weight
);
// Generate initial chromosome
NeatChromosome chromosome = factory.generate(spec);
// Result: 3×2 = 6 connections with random weights
// Connections: (0→3), (0→4), (1→3), (1→4), (2→3), (2→4)
Integration with NEAT evolution:
- Population initialization: Creates diverse initial population with same topology
- Weight diversity: Random weights provide behavioral variation
- Structural foundation: Minimal topology allows maximum structural exploration
- Innovation consistency: Same connection types get same innovation numbers across population
Innovation number management:
- Deterministic assignment: Same input-output pairs get same innovation numbers
- Population consistency: All individuals use same innovation numbers for same connections
- Crossover compatibility: Enables meaningful genetic recombination from generation 0
- Historical tracking: Foundation for tracking structural evolution
Weight initialization strategy:
- Uniform distribution: Weights uniformly sampled from [minWeight, maxWeight]
- Behavioral diversity: Different weight combinations create different behaviors
- Network stability: Bounded weights prevent extreme activation values
- Evolution readiness: Initial weights suitable for gradient-based optimization
Performance considerations:
- Linear time complexity: O(numInputs × numOutputs) generation time
- Memory efficiency: Minimal memory allocation during generation
- Innovation caching: InnovationManager provides O(1) innovation number lookup
- Thread safety: Safe for concurrent chromosome generation
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNeatConnectedChromosomeFactory
(RandomGenerator _randomGenerator, InnovationManager _innovationManager) Constructs a new connected chromosome factory with the specified components. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(ChromosomeSpec chromosomeSpec) Determines whether this factory can generate chromosomes for the given specification.generate
(ChromosomeSpec chromosomeSpec) Generates a fully-connected NEAT chromosome based on the given specification.
-
Field Details
-
randomGenerator
-
innovationManager
-
-
Constructor Details
-
NeatConnectedChromosomeFactory
public NeatConnectedChromosomeFactory(RandomGenerator _randomGenerator, InnovationManager _innovationManager) Constructs a new connected chromosome factory with the specified components.The random generator is used for weight initialization, providing behavioral diversity in the initial population. The innovation manager ensures consistent innovation number assignment across all generated chromosomes.
- Parameters:
_randomGenerator
- random number generator for weight initialization_innovationManager
- innovation manager for tracking structural innovations- Throws:
IllegalArgumentException
- if randomGenerator or innovationManager is null
-
-
Method Details
-
canHandle
Determines whether this factory can generate chromosomes for the given specification.This factory specifically handles NeatChromosomeSpec specifications, which define the input/output structure and weight bounds for NEAT neural networks.
- Specified by:
canHandle
in interfaceChromosomeFactory<NeatChromosome>
- Parameters:
chromosomeSpec
- the chromosome specification to check- Returns:
- true if chromosomeSpec is a NeatChromosomeSpec, false otherwise
- Throws:
IllegalArgumentException
- if chromosomeSpec is null
-
generate
Generates a fully-connected NEAT chromosome based on the given specification.This method creates a neural network chromosome with direct connections between all input and output nodes. Each connection is initialized with a random weight within the specified bounds and assigned a unique innovation number for genetic tracking.
Generation process:
- Extract network parameters from the chromosome specification
- Create connections between all input-output node pairs
- Assign innovation numbers to each connection type
- Initialize connection weights randomly within bounds
- Enable all connections for immediate network functionality
- Construct and return the complete chromosome
- Specified by:
generate
in interfaceChromosomeFactory<NeatChromosome>
- Parameters:
chromosomeSpec
- the NEAT chromosome specification defining network structure- Returns:
- a new fully-connected NEAT chromosome
- Throws:
IllegalArgumentException
- if chromosomeSpec is null or not a NeatChromosomeSpec
-