Class NeatConnectionWeightPolicyHandler<T extends Comparable<T>>
- Type Parameters:
T
- the fitness value type (typically Double)
- All Implemented Interfaces:
MutationPolicyHandler<T>
NeatConnectionWeightPolicyHandler manages weight mutations for NEAT neural network connections, which are essential for fine-tuning network behavior and optimizing performance. Weight mutations are typically the most frequent type of mutation in NEAT evolution, applied to existing connections to improve network functionality.
Weight mutation strategies:
- Gaussian perturbation: Add small random values to existing weights
- Random replacement: Replace weights with new random values
- Creep mutation: Small incremental changes to weights
- Uniform perturbation: Add uniform random noise to weights
Key characteristics:
- Behavioral optimization: Fine-tunes network behavior without changing topology
- High frequency: Applied more often than structural mutations
- Bounded values: Respects chromosome weight bounds during mutation
- Continuous evolution: Enables continuous improvement of network performance
Integration with NEAT algorithm:
- Chromosome mutation: Delegates to NEAT chromosome weight mutation handlers
- Population evolution: Applied based on configured mutation probability
- Performance optimization: Primary mechanism for network performance tuning
- Genetic diversity: Maintains behavioral diversity in the population
Common usage patterns:
// Create weight mutation policy
NeatConnectionWeight weightPolicy = NeatConnectionWeight.builder()
.populationMutationProbability(0.8) // 80% of population
.chromosomeMutationProbability(0.9) // 90% of connections per chromosome
.mutationStandardDeviation(0.1) // Standard deviation for Gaussian perturbation
.build();
// Create policy handler
RandomGenerator randomGen = RandomGenerator.getDefault();
NeatConnectionWeightPolicyHandler<Double> handler =
new NeatConnectionWeightPolicyHandler<>(randomGen);
// Check if handler can process the policy
boolean canHandle = handler.canHandle(resolver, weightPolicy);
// Create mutator for the policy
Mutator mutator = handler.createMutator(
executionContext, configuration, resolver, weightPolicy
);
Weight mutation effects:
- Performance tuning: Optimizes network output for better fitness
- Exploration vs exploitation: Balances exploration of weight space with convergence
- Gradient-like behavior: Can simulate gradient-based optimization
- Population diversity: Maintains diverse behavioral patterns
Mutation policy configuration:
- Population probability: Fraction of population to apply mutations to
- Chromosome probability: Fraction of connections to mutate per chromosome
- Mutation magnitude: Size of weight perturbations
- Mutation type: Strategy for weight modification (Gaussian, uniform, etc.)
Performance considerations:
- High frequency application: Efficient implementation for frequent use
- Memory efficiency: Minimal allocation during weight modification
- Numerical stability: Maintains weight values within valid ranges
- Concurrent safety: Thread-safe for parallel mutation application
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNeatConnectionWeightPolicyHandler
(RandomGenerator _randomGenerator) Constructs a new connection weight 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 connection weight mutations.
-
Field Details
-
randomGenerator
-
-
Constructor Details
-
NeatConnectionWeightPolicyHandler
Constructs a new connection weight 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 generation of weight perturbations.
- 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 NeatConnectionWeight mutation policies, which configure the parameters for mutating connection weights in 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 a NeatConnectionWeight 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 connection weight mutations.This method resolves the appropriate chromosome mutation handlers for NEAT chromosomes and creates a generic mutator that applies weight 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 connection weight mutation policy- Returns:
- a configured mutator for applying weight mutations
- Throws:
IllegalArgumentException
- if any parameter is null
-