Class NeatConnectionWeightPolicyHandler<T extends Comparable<T>>

java.lang.Object
net.bmahe.genetics4j.neat.mutation.NeatConnectionWeightPolicyHandler<T>
Type Parameters:
T - the fitness value type (typically Double)
All Implemented Interfaces:
MutationPolicyHandler<T>

public class NeatConnectionWeightPolicyHandler<T extends Comparable<T>> extends Object implements MutationPolicyHandler<T>
Mutation policy handler for NEAT (NeuroEvolution of Augmenting Topologies) connection weight mutations.

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 Details

  • Constructor Details

    • NeatConnectionWeightPolicyHandler

      public NeatConnectionWeightPolicyHandler(RandomGenerator _randomGenerator)
      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 interface MutationPolicyHandler<T extends Comparable<T>>
      Parameters:
      mutationPolicyHandlerResolver - resolver for nested mutation policies
      mutationPolicy - 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:

      1. Extract population mutation probability from the policy
      2. Resolve chromosome-specific mutation handlers
      3. Create generic mutator with resolved components
      4. Return configured mutator ready for population application
      Specified by:
      createMutator in interface MutationPolicyHandler<T extends Comparable<T>>
      Parameters:
      eaExecutionContext - execution context containing NEAT-specific components
      eaConfiguration - evolutionary algorithm configuration
      mutationPolicyHandlerResolver - resolver for chromosome mutation handlers
      mutationPolicy - the connection weight mutation policy
      Returns:
      a configured mutator for applying weight mutations
      Throws:
      IllegalArgumentException - if any parameter is null