View Javadoc
1   package net.bmahe.genetics4j.core.spec.replacement;
2   
3   /**
4    * Marker interface for replacement strategy specifications in evolutionary algorithms.
5    * 
6    * <p>ReplacementStrategy defines the contract for specifying how offspring are integrated into the population to form
7    * the next generation. Replacement strategies determine which individuals survive from one generation to the next,
8    * balancing exploration of new solutions with preservation of good existing solutions.
9    * 
10   * <p>Replacement strategies are used by:
11   * <ul>
12   * <li><strong>EA Configuration</strong>: To specify the survival strategy for generations</li>
13   * <li><strong>Replacement handlers</strong>: To create appropriate replacement implementations</li>
14   * <li><strong>Population management</strong>: To control population size and composition</li>
15   * <li><strong>Algorithm flow</strong>: To determine generational vs steady-state evolution</li>
16   * </ul>
17   * 
18   * <p>The framework provides several concrete replacement strategy implementations:
19   * <ul>
20   * <li>{@link GenerationalReplacement}: Complete replacement of parent generation</li>
21   * <li>{@link Elitism}: Preserve best individuals while replacing others</li>
22   * <li>{@link DeleteNLast}: Remove worst N individuals from combined population</li>
23   * </ul>
24   * 
25   * <p>Replacement strategies vary in their characteristics:
26   * <ul>
27   * <li><strong>Selection pressure</strong>: How aggressively poor solutions are eliminated</li>
28   * <li><strong>Diversity preservation</strong>: How well genetic diversity is maintained</li>
29   * <li><strong>Convergence speed</strong>: How quickly the algorithm converges to solutions</li>
30   * <li><strong>Population dynamics</strong>: How population composition changes over time</li>
31   * </ul>
32   * 
33   * <p>Common replacement patterns:
34   * <ul>
35   * <li><strong>Generational</strong>: All parents replaced by offspring each generation</li>
36   * <li><strong>Steady-state</strong>: Only a few individuals replaced per iteration</li>
37   * <li><strong>Elitist</strong>: Best individuals always survive to next generation</li>
38   * <li><strong>Tournament replacement</strong>: Compete offspring against existing individuals</li>
39   * </ul>
40   * 
41   * <p>Replacement strategy design considerations:
42   * <ul>
43   * <li><strong>Population size</strong>: Maintain constant population size across generations</li>
44   * <li><strong>Selection pressure</strong>: Balance exploitation with exploration</li>
45   * <li><strong>Premature convergence</strong>: Prevent loss of genetic diversity too early</li>
46   * <li><strong>Solution preservation</strong>: Ensure good solutions are not lost</li>
47   * </ul>
48   * 
49   * <p>Interaction with other EA components:
50   * <ul>
51   * <li><strong>Selection policies</strong>: Work together to control evolutionary pressure</li>
52   * <li><strong>Offspring ratio</strong>: Number of offspring affects replacement decisions</li>
53   * <li><strong>Population size</strong>: Determines how many individuals can be replaced</li>
54   * <li><strong>Fitness evaluation</strong>: Required for fitness-based replacement decisions</li>
55   * </ul>
56   * 
57   * <p>Example usage in genetic algorithm configuration:
58   * 
59   * <pre>{@code
60   * // Generational replacement (all parents replaced)
61   * ReplacementStrategy generational = GenerationalReplacement.build();
62   * 
63   * // Elitist replacement preserving top 10% of individuals
64   * ReplacementStrategy elitist = Elitism.builder()
65   * 		.offspringSelectionPolicy(Tournament.of(3))
66   * 		.offspringRatio(0.9) // Replace 90% of population
67   * 		.build();
68   * 
69   * // Delete worst N individuals from combined population
70   * ReplacementStrategy deleteNLast = DeleteNLast.builder()
71   * 		.offspringSelectionPolicy(Tournament.of(2))
72   * 		.offspringRatio(0.5) // Generate 50% offspring
73   * 		.build();
74   * 
75   * // Use in EA configuration
76   * EAConfiguration<Double> config = EAConfigurationBuilder.<Double>builder()
77   * 		.chromosomeSpecs(chromosomeSpec)
78   * 		.parentSelectionPolicy(Tournament.of(3))
79   * 		.replacementStrategy(elitist)
80   * 		.build();
81   * }</pre>
82   * 
83   * <p>Performance implications:
84   * <ul>
85   * <li><strong>Computational cost</strong>: Some strategies require sorting or complex selection</li>
86   * <li><strong>Memory usage</strong>: Combined populations may temporarily increase memory needs</li>
87   * <li><strong>Convergence rate</strong>: Affects how quickly the algorithm finds good solutions</li>
88   * <li><strong>Solution quality</strong>: Influences the final quality of evolved solutions</li>
89   * </ul>
90   * 
91   * @see net.bmahe.genetics4j.core.replacement.ReplacementStrategyImplementor
92   * @see net.bmahe.genetics4j.core.replacement.ReplacementStrategyHandler
93   * @see GenerationalReplacement
94   * @see Elitism
95   * @see DeleteNLast
96   */
97  public interface ReplacementStrategy {
98  
99  }