Class ElitistReplacement<C extends GASolution<C>>

java.lang.Object
edu.cnu.mdi.sim.ga.triimage.ElitistReplacement<C>
All Implemented Interfaces:
ReplacementOperator<C>

public final class ElitistReplacement<C extends GASolution<C>> extends Object implements ReplacementOperator<C>
Elitist replacement operator for genetic algorithms. This operator preserves a specified number of the best individuals (eliteCount) from the current population and fills the rest of the next generation with offspring. The elite individuals are selected based on their fitness, ensuring that the best solutions are retained across generations.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ElitistReplacement(int eliteCount)
    Create an elitist replacement operator with the given number of elite individuals to preserve.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    offspringCount(int populationSize)
    Return the number of offspring required to form a population of the given size.
    replace(List<C> population, List<C> offspring, double[] popFitness, double[] offFitness, Random rng)
    Form the next generation from the current population and its offspring.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ElitistReplacement

      public ElitistReplacement(int eliteCount)
      Create an elitist replacement operator with the given number of elite individuals to preserve.
      Parameters:
      eliteCount - the number of best individuals to preserve from the current population
  • Method Details

    • offspringCount

      public int offspringCount(int populationSize)
      Description copied from interface: ReplacementOperator
      Return the number of offspring required to form a population of the given size. Replacement policies that retain current individuals may request fewer offspring.
      Specified by:
      offspringCount in interface ReplacementOperator<C extends GASolution<C>>
      Parameters:
      populationSize - current population size
      Returns:
      required offspring count in [0, populationSize]
    • replace

      public List<C> replace(List<C> population, List<C> offspring, double[] popFitness, double[] offFitness, Random rng)
      Description copied from interface: ReplacementOperator
      Form the next generation from the current population and its offspring. Fitness arrays are aligned with their corresponding lists. The returned ordering is unrestricted, but its size must equal the current population.
      Specified by:
      replace in interface ReplacementOperator<C extends GASolution<C>>
      Parameters:
      population - current population
      offspring - newly created offspring
      popFitness - current-population fitness values
      offFitness - offspring fitness values
      rng - source of randomness
      Returns:
      complete next generation