Class AddNodePolicyHandler<T extends Comparable<T>>
- Type Parameters:
T
- the fitness value type (typically Double)
- All Implemented Interfaces:
MutationPolicyHandler<T>
AddNodePolicyHandler manages the structural mutation that adds new hidden nodes to NEAT neural networks by splitting existing connections. This is one of the most important structural mutations in NEAT as it enables the evolution of increasingly complex network topologies.
Add-node mutation process:
- Connection selection: Choose an existing enabled connection to split
- Connection disabling: Disable the original connection
- Node creation: Create a new hidden node between the connection endpoints
- Connection replacement: Create two new connections through the new node
- Innovation tracking: Assign innovation numbers to new connections
- Weight preservation: Set weights to preserve network function
Key characteristics:
- Topology complexity: Increases network depth and node count
- Function preservation: Maintains network behavior through careful weight setting
- Innovation tracking: New connections receive unique innovation numbers
- Gradual growth: Incrementally increases network complexity
Network transformation:
- Before: Direct connection A → B with weight W
- After: Path A → NewNode → B with weights W₁ and W₂
- Weight strategy: Often W₁ = 1.0, W₂ = W to preserve function
- Node placement: New node gets next available index
Common usage patterns:
// Create add-node mutation policy
AddNode addNodePolicy = AddNode.of(0.05); // 5% mutation rate
// Create policy handler
RandomGenerator randomGen = RandomGenerator.getDefault();
AddNodePolicyHandler<Double> handler = new AddNodePolicyHandler<>(randomGen);
// Check if handler can process the policy
boolean canHandle = handler.canHandle(resolver, addNodePolicy);
// Create mutator for the policy
Mutator mutator = handler.createMutator(
executionContext, configuration, resolver, addNodePolicy
);
// Apply mutation to population
List<Individual<Double>> mutatedPopulation = mutator.mutate(
configuration, population
);
Integration with NEAT algorithm:
- Innovation management: Coordinates with InnovationManager for new connections
- Chromosome mutation: Delegates to NeatChromosomeAddNodeMutationHandler
- Population evolution: Applied based on configured mutation probability
- Complexity growth: Primary mechanism for increasing network complexity
Structural impact:
- Hidden layer growth: Creates new hidden nodes that can form layers
- Computational depth: Increases potential computational complexity
- Feature detection: New nodes can detect intermediate features
- Representation power: Enhances network's representational capacity
Performance considerations:
- Conservative application: Typically applied less frequently than weight mutations
- Innovation caching: Leverages InnovationManager for efficient tracking
- Memory efficiency: Minimal allocation during mutation operations
- Function preservation: Weight setting strategies maintain network behavior
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAddNodePolicyHandler
(RandomGenerator _randomGenerator) Constructs a new add-node policy handler with the specified random generator. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, MutationPolicy mutationPolicy) Determines whether this handler can process the given mutation policy.createMutator
(AbstractEAExecutionContext<T> eaExecutionContext, AbstractEAConfiguration<T> eaConfiguration, MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, MutationPolicy mutationPolicy) Creates a concrete mutator for add-node mutations.
-
Field Details
-
randomGenerator
-
-
Constructor Details
-
AddNodePolicyHandler
Constructs a new add-node policy handler with the specified random generator.The random generator is used for stochastic decisions during mutation application, including selection of individuals to mutate and selection of connections to split.
- Parameters:
_randomGenerator
- random number generator for stochastic mutation operations- Throws:
IllegalArgumentException
- if randomGenerator is null
-
-
Method Details
-
canHandle
public boolean canHandle(MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, MutationPolicy mutationPolicy) Determines whether this handler can process the given mutation policy.This handler specifically processes AddNode mutation policies, which configure the parameters for adding new hidden nodes to NEAT neural networks.
- Specified by:
canHandle
in interfaceMutationPolicyHandler<T extends Comparable<T>>
- Parameters:
mutationPolicyHandlerResolver
- resolver for nested mutation policiesmutationPolicy
- the mutation policy to check- Returns:
- true if the policy is an AddNode instance, false otherwise
- Throws:
IllegalArgumentException
- if any parameter is null
-
createMutator
public Mutator createMutator(AbstractEAExecutionContext<T> eaExecutionContext, AbstractEAConfiguration<T> eaConfiguration, MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, MutationPolicy mutationPolicy) Creates a concrete mutator for add-node mutations.This method resolves the appropriate chromosome mutation handlers for NEAT chromosomes and creates a generic mutator that applies add-node mutations according to the specified policy parameters.
Mutator creation process:
- Extract population mutation probability from the policy
- Resolve chromosome-specific mutation handlers
- Create generic mutator with resolved components
- Return configured mutator ready for population application
- Specified by:
createMutator
in interfaceMutationPolicyHandler<T extends Comparable<T>>
- Parameters:
eaExecutionContext
- execution context containing NEAT-specific componentseaConfiguration
- evolutionary algorithm configurationmutationPolicyHandlerResolver
- resolver for chromosome mutation handlersmutationPolicy
- the add-node mutation policy- Returns:
- a configured mutator for applying add-node mutations
- Throws:
IllegalArgumentException
- if any parameter is null
-