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. 7 * Selection policies determine how individuals are chosen from the population for reproduction, 8 * directly influencing the evolutionary 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 DoubleTournament}: Two-stage tournament for multi-objective optimization</li> 24 * <li>{@link ProportionalTournament}: Tournament with proportional selection pressure</li> 25 * <li>{@link MultiSelections}: Combination of multiple selection strategies</li> 26 * <li>{@link SelectAll}: Selects all individuals (useful for specific algorithms)</li> 27 * </ul> 28 * 29 * <p>Selection strategies vary in their characteristics: 30 * <ul> 31 * <li><strong>Selection pressure</strong>: How strongly the algorithm favors high-fitness individuals</li> 32 * <li><strong>Diversity preservation</strong>: How well the strategy maintains population diversity</li> 33 * <li><strong>Computational complexity</strong>: Efficiency of the selection process</li> 34 * <li><strong>Scalability</strong>: Performance with different population sizes</li> 35 * </ul> 36 * 37 * <p>Common selection patterns: 38 * <ul> 39 * <li><strong>Exploitative strategies</strong>: High selection pressure (large tournaments, elitism)</li> 40 * <li><strong>Explorative strategies</strong>: Low selection pressure (small tournaments, random)</li> 41 * <li><strong>Balanced strategies</strong>: Moderate pressure with diversity preservation</li> 42 * <li><strong>Adaptive strategies</strong>: Selection pressure that changes during evolution</li> 43 * </ul> 44 * 45 * <p>Selection policy design considerations: 46 * <ul> 47 * <li><strong>Problem characteristics</strong>: Multimodal vs unimodal, deceptive problems</li> 48 * <li><strong>Population size</strong>: Small populations may need lower selection pressure</li> 49 * <li><strong>Fitness landscape</strong>: Rugged landscapes benefit from diversity preservation</li> 50 * <li><strong>Convergence requirements</strong>: Balance between speed and solution quality</li> 51 * </ul> 52 * 53 * <p>Example usage in genetic algorithm configuration: 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 * // Multi-objective selection with double tournament 62 * SelectionPolicy doubleTournament = DoubleTournament.of( 63 * firstCriteria: 3, 64 * secondCriteria: 2 65 * ); 66 * 67 * // Combined selection strategies 68 * SelectionPolicy multiSelection = MultiSelections.of( 69 * Tuple.of(0.7, tournament), 70 * Tuple.of(0.3, roulette) 71 * ); 72 * 73 * // Use in EA configuration 74 * EAConfiguration<Double> config = EAConfigurationBuilder.<Double>builder() 75 * .chromosomeSpecs(chromosomeSpec) 76 * .parentSelectionPolicy(tournament) 77 * .build(); 78 * }</pre> 79 * 80 * @see net.bmahe.genetics4j.core.selection.Selector 81 * @see net.bmahe.genetics4j.core.selection.SelectionPolicyHandler 82 * @see Tournament 83 * @see RouletteWheel 84 * @see RandomSelection 85 * @see DoubleTournament 86 * @see ProportionalTournament 87 * @see MultiSelections 88 */ 89 public interface SelectionPolicy { 90 91 }