Interface ReplacementStrategy<T>
- Type Parameters:
T- the representation of population members
- All Superinterfaces:
Splittable<ReplacementStrategy<T>>
- All Known Implementing Classes:
GenerationalElitistReplacement, GenerationalReplacement
Implement this interface to provide a replacement strategy for use by genetic algorithms and
other forms of evolutionary computation.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInterface forReplacementStrategyimplementations to specify which members of the parent and child populations serve as replacements into the next generation. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidinit(int generations) Perform any initialization necessary for the replacement strategy at the start of the run of the evolutionary algorithm.voidreplace(PopulationCandidates.DoubleFitness<T> parentPopulation, PopulationCandidates.DoubleFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize) Chooses the members of the population of the next generation from among those currently in the population and the pool of candidates formed from crossover and mutation.voidreplace(PopulationCandidates.IntegerFitness<T> parentPopulation, PopulationCandidates.IntegerFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize) Chooses the members of the population of the next generation from among those currently in the population and the pool of candidates formed from crossover and mutation.Methods inherited from interface Splittable
split
-
Method Details
-
replace
void replace(PopulationCandidates.IntegerFitness<T> parentPopulation, PopulationCandidates.IntegerFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize) Chooses the members of the population of the next generation from among those currently in the population and the pool of candidates formed from crossover and mutation. Implementations must not attempt to further manipulate the state of the individuals in these sets. Doing so can lead to undefined behavior.- Parameters:
parentPopulation- the current populationchildPopulation- the members of the population chosen by the selection operator which have already gone through crossover, mutation, both, or neither (based on crossover rates, mutation rates, etc)replacements- records which members of the parent and child populations serve as replacementstargetPopulationSize- the size of the target population for the next generation. In most cases this will likely be the same as parentPopulation.size(). But, do not make that assumption in your implementation to allow less common EA structures where population size may vary
-
replace
void replace(PopulationCandidates.DoubleFitness<T> parentPopulation, PopulationCandidates.DoubleFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize) Chooses the members of the population of the next generation from among those currently in the population and the pool of candidates formed from crossover and mutation. Implementations must not attempt to further manipulate the state of the individuals in these sets. Doing so can lead to undefined behavior.- Parameters:
parentPopulation- the current populationchildPopulation- the members of the population chosen by the selection operator which have already gone through crossover, mutation, both, or neither (based on crossover rates, mutation rates, etc)replacements- records which members of the parent and child populations serve as replacementstargetPopulationSize- the size of the target population for the next generation. In most cases this will likely be the same as parentPopulation.size(). But, do not make that assumption in your implementation to allow less common EA structures where population size may vary
-
init
default void init(int generations) Perform any initialization necessary for the replacement strategy at the start of the run of the evolutionary algorithm. This method is called by the evolutionary algorithm at the start of a run (i.e., whenever an EA's optimize or reoptimize methods are called. The default implementation of this method does nothing, which is appropriate for most replacement strategies since the behavior of most standard replacement strategies doesn't change during runs. However, if you imlement a custom replacement strategy that adapts in some way (e.g., some parameter should change each generation), then the init method enables reinitializing such parameters at the start of runs.- Parameters:
generations- The number of generations for the run of the evolutionary algorithm about to commence.
-