1 package net.bmahe.genetics4j.core.spec.mutation; 2 3 /** 4 * Marker interface for mutation policy specifications in evolutionary algorithms. 5 * 6 * <p>MutationPolicy defines the contract for specifying mutation strategies and their parameters. Mutation policies 7 * determine how genetic variation is introduced into the population by making random changes to individual genotypes. 8 * Different mutation policies implement various strategies for balancing exploration and exploitation during the 9 * evolutionary process. 10 * 11 * <p>Mutation policies are used by: 12 * <ul> 13 * <li><strong>EA Configuration</strong>: To specify the mutation strategy for the algorithm</li> 14 * <li><strong>Mutation handlers</strong>: To create appropriate mutator implementations</li> 15 * <li><strong>Strategy resolution</strong>: To select chromosome-specific mutation operators</li> 16 * <li><strong>Parameter configuration</strong>: To define mutation rates and other parameters</li> 17 * </ul> 18 * 19 * <p>The framework provides several concrete mutation policy implementations: 20 * <ul> 21 * <li>{@link RandomMutation}: Randomly changes allele values with specified probability</li> 22 * <li>{@link CreepMutation}: Makes small incremental changes to numeric values</li> 23 * <li>{@link SwapMutation}: Exchanges positions of alleles (useful for permutations)</li> 24 * <li>{@link PartialMutation}: Applies mutation to only a subset of chromosomes</li> 25 * <li>{@link MultiMutations}: Combines multiple mutation strategies</li> 26 * </ul> 27 * 28 * <p>Mutation strategies vary by chromosome type and problem domain: 29 * <ul> 30 * <li><strong>Binary chromosomes</strong>: Bit flip mutations</li> 31 * <li><strong>Numeric chromosomes</strong>: Gaussian noise, uniform perturbation, creep mutation</li> 32 * <li><strong>Permutation chromosomes</strong>: Swap, insert, inversion mutations</li> 33 * <li><strong>Tree chromosomes</strong>: Node replacement, subtree mutation, growth/pruning</li> 34 * </ul> 35 * 36 * <p>Key considerations for mutation policy design: 37 * <ul> 38 * <li><strong>Mutation rate</strong>: Balance between exploration and exploitation</li> 39 * <li><strong>Chromosome compatibility</strong>: Ensure mutation respects chromosome constraints</li> 40 * <li><strong>Problem-specific operations</strong>: Adapt mutation to problem characteristics</li> 41 * <li><strong>Adaptive strategies</strong>: Allow mutation parameters to evolve during the run</li> 42 * </ul> 43 * 44 * <p>Example usage in genetic algorithm configuration: 45 * 46 * <pre>{@code 47 * // Random mutation with 5% probability per allele 48 * MutationPolicy randomMutation = RandomMutation.of(0.05); 49 * 50 * // Creep mutation for numeric optimization 51 * MutationPolicy creepMutation = CreepMutation.of(0.1, 1.0); 52 * 53 * // Combination of multiple mutation strategies 54 * MutationPolicy multiMutation = MultiMutations.of(Tuple.of(0.7, randomMutation), Tuple.of(0.3, creepMutation)); 55 * 56 * // Use in EA configuration 57 * EAConfiguration<Double> config = EAConfigurationBuilder.<Double>builder() 58 * .chromosomeSpecs(chromosomeSpec) 59 * .mutationPolicy(randomMutation) 60 * .build(); 61 * }</pre> 62 * 63 * @see net.bmahe.genetics4j.core.mutation.Mutator 64 * @see net.bmahe.genetics4j.core.mutation.MutationPolicyHandler 65 * @see RandomMutation 66 * @see CreepMutation 67 * @see SwapMutation 68 * @see PartialMutation 69 * @see MultiMutations 70 */ 71 public interface MutationPolicy { 72 73 }