Package edu.cnu.mdi.sim.ga
Interface ReplacementOperator<T extends GASolution<T>>
- All Known Implementing Classes:
ElitistReplacement
public interface ReplacementOperator<T extends GASolution<T>>
Interface for replacement operators in genetic algorithms. A replacement operator defines how the next
generation of the population is formed from the current population and the offspring.
The GA will call this interface to determine which individuals survive to the next generation
based on their fitness.
-
Method Summary
Modifier and TypeMethodDescriptiondefault intoffspringCount(int populationSize) Return the number of offspring required to form a population of the given size.replace(List<T> population, List<T> offspring, double[] popFitness, double[] offFitness, Random rng) Form the next generation from the current population and its offspring.
-
Method Details
-
offspringCount
default int offspringCount(int populationSize) Return the number of offspring required to form a population of the given size. Replacement policies that retain current individuals may request fewer offspring.- Parameters:
populationSize- current population size- Returns:
- required offspring count in
[0, populationSize]
-
replace
List<T> replace(List<T> population, List<T> offspring, double[] popFitness, double[] offFitness, Random rng) 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.- Parameters:
population- current populationoffspring- newly created offspringpopFitness- current-population fitness valuesoffFitness- offspring fitness valuesrng- source of randomness- Returns:
- complete next generation
-