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
7    * into the population to form the next generation. Replacement strategies determine which
8    * individuals survive from one generation to the next, balancing exploration of new solutions
9    * with preservation of good existing solutions.
10   * 
11   * <p>Replacement strategies are used by:
12   * <ul>
13   * <li><strong>EA Configuration</strong>: To specify the survival strategy for generations</li>
14   * <li><strong>Replacement handlers</strong>: To create appropriate replacement implementations</li>
15   * <li><strong>Population management</strong>: To control population size and composition</li>
16   * <li><strong>Algorithm flow</strong>: To determine generational vs steady-state evolution</li>
17   * </ul>
18   * 
19   * <p>The framework provides several concrete replacement strategy implementations:
20   * <ul>
21   * <li>{@link GenerationalReplacement}: Complete replacement of parent generation</li>
22   * <li>{@link Elitism}: Preserve best individuals while replacing others</li>
23   * <li>{@link DeleteNLast}: Remove worst N individuals from combined population</li>
24   * </ul>
25   * 
26   * <p>Replacement strategies vary in their characteristics:
27   * <ul>
28   * <li><strong>Selection pressure</strong>: How aggressively poor solutions are eliminated</li>
29   * <li><strong>Diversity preservation</strong>: How well genetic diversity is maintained</li>
30   * <li><strong>Convergence speed</strong>: How quickly the algorithm converges to solutions</li>
31   * <li><strong>Population dynamics</strong>: How population composition changes over time</li>
32   * </ul>
33   * 
34   * <p>Common replacement patterns:
35   * <ul>
36   * <li><strong>Generational</strong>: All parents replaced by offspring each generation</li>
37   * <li><strong>Steady-state</strong>: Only a few individuals replaced per iteration</li>
38   * <li><strong>Elitist</strong>: Best individuals always survive to next generation</li>
39   * <li><strong>Tournament replacement</strong>: Compete offspring against existing individuals</li>
40   * </ul>
41   * 
42   * <p>Replacement strategy design considerations:
43   * <ul>
44   * <li><strong>Population size</strong>: Maintain constant population size across generations</li>
45   * <li><strong>Selection pressure</strong>: Balance exploitation with exploration</li>
46   * <li><strong>Premature convergence</strong>: Prevent loss of genetic diversity too early</li>
47   * <li><strong>Solution preservation</strong>: Ensure good solutions are not lost</li>
48   * </ul>
49   * 
50   * <p>Interaction with other EA components:
51   * <ul>
52   * <li><strong>Selection policies</strong>: Work together to control evolutionary pressure</li>
53   * <li><strong>Offspring ratio</strong>: Number of offspring affects replacement decisions</li>
54   * <li><strong>Population size</strong>: Determines how many individuals can be replaced</li>
55   * <li><strong>Fitness evaluation</strong>: Required for fitness-based replacement decisions</li>
56   * </ul>
57   * 
58   * <p>Example usage in genetic algorithm configuration:
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  }