1 package net.bmahe.genetics4j.core.spec.selection; 2 3 /** 4 * Marker interface for selection policy specifications in evolutionary algorithms. 5 * 6 * <p>SelectionPolicy defines the contract for specifying selection strategies and their parameters. Selection policies 7 * determine how individuals are chosen from the population for reproduction, directly influencing the evolutionary 8 * pressure and convergence characteristics of the algorithm. 9 * 10 * <p>Selection policies are used by: 11 * <ul> 12 * <li><strong>EA Configuration</strong>: To specify the parent selection strategy</li> 13 * <li><strong>Selection handlers</strong>: To create appropriate selector implementations</li> 14 * <li><strong>Strategy resolution</strong>: To match policies with their corresponding handlers</li> 15 * <li><strong>Parameter configuration</strong>: To define selection pressure and tournament sizes</li> 16 * </ul> 17 * 18 * <p>The framework provides several concrete selection policy implementations: 19 * <ul> 20 * <li>{@link Tournament}: Tournament selection with configurable tournament size</li> 21 * <li>{@link RouletteWheel}: Fitness-proportionate selection (roulette wheel)</li> 22 * <li>{@link RandomSelection}: Uniform random selection without fitness bias</li> 23 * <li>{@link ProportionalTournament}: Tournament with proportional selection pressure</li> 24 * <li>{@link MultiSelections}: Combination of multiple selection strategies</li> 25 * <li>{@link SelectAll}: Selects all individuals (useful for specific algorithms)</li> 26 * </ul> 27 * 28 * <p>Selection strategies vary in their characteristics: 29 * <ul> 30 * <li><strong>Selection pressure</strong>: How strongly the algorithm favors high-fitness individuals</li> 31 * <li><strong>Diversity preservation</strong>: How well the strategy maintains population diversity</li> 32 * <li><strong>Computational complexity</strong>: Efficiency of the selection process</li> 33 * <li><strong>Scalability</strong>: Performance with different population sizes</li> 34 * </ul> 35 * 36 * <p>Common selection patterns: 37 * <ul> 38 * <li><strong>Exploitative strategies</strong>: High selection pressure (large tournaments, elitism)</li> 39 * <li><strong>Explorative strategies</strong>: Low selection pressure (small tournaments, random)</li> 40 * <li><strong>Balanced strategies</strong>: Moderate pressure with diversity preservation</li> 41 * <li><strong>Adaptive strategies</strong>: Selection pressure that changes during evolution</li> 42 * </ul> 43 * 44 * <p>Selection policy design considerations: 45 * <ul> 46 * <li><strong>Problem characteristics</strong>: Multimodal vs unimodal, deceptive problems</li> 47 * <li><strong>Population size</strong>: Small populations may need lower selection pressure</li> 48 * <li><strong>Fitness landscape</strong>: Rugged landscapes benefit from diversity preservation</li> 49 * <li><strong>Convergence requirements</strong>: Balance between speed and solution quality</li> 50 * </ul> 51 * 52 * <p>Example usage in genetic algorithm configuration: 53 * 54 * <pre>{@code 55 * // Tournament selection with moderate pressure 56 * SelectionPolicy tournament = Tournament.of(3); 57 * 58 * // Roulette wheel for fitness-proportionate selection 59 * SelectionPolicy roulette = RouletteWheel.build(); 60 * 61 * // Combined selection strategies 62 * SelectionPolicy multiSelection = MultiSelections.of(Tuple.of(0.7, tournament), Tuple.of(0.3, roulette)); 63 * 64 * // Use in EA configuration 65 * EAConfiguration<Double> config = EAConfigurationBuilder.<Double>builder() 66 * .chromosomeSpecs(chromosomeSpec) 67 * .parentSelectionPolicy(tournament) 68 * .build(); 69 * }</pre> 70 * 71 * @see net.bmahe.genetics4j.core.selection.Selector 72 * @see net.bmahe.genetics4j.core.selection.SelectionPolicyHandler 73 * @see Tournament 74 * @see RouletteWheel 75 * @see RandomSelection 76 * @see ProportionalTournament 77 * @see MultiSelections 78 */ 79 public interface SelectionPolicy { 80 81 }