Class GenerationalReplacement<T>
java.lang.Object
org.cicirello.search.evo.GenerationalReplacement<T>
- Type Parameters:
T- the representation of population members
- All Implemented Interfaces:
Splittable<ReplacementStrategy<T>>, ReplacementStrategy<T>
Generational replacement replaces the entire population each generation. This is the classic
replacement strategy of the simple genetic algorithm and other generational models.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ReplacementStrategy
ReplacementStrategy.Replacements -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidreplace(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.split()Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ReplacementStrategy
init
-
Constructor Details
-
GenerationalReplacement
public GenerationalReplacement()Constructs the replacement strategy.
-
-
Method Details
-
replace
public void replace(PopulationCandidates.IntegerFitness<T> parentPopulation, PopulationCandidates.IntegerFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize) Description copied from interface:ReplacementStrategyChooses 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.- Specified by:
replacein interfaceReplacementStrategy<T>- 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
public void replace(PopulationCandidates.DoubleFitness<T> parentPopulation, PopulationCandidates.DoubleFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize) Description copied from interface:ReplacementStrategyChooses 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.- Specified by:
replacein interfaceReplacementStrategy<T>- 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
-
split
Description copied from interface:SplittableGenerates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms. The state of the object that is returned may or may not be identical to that of the original. Thus, this is a distinct concept from the functionality of theCopyableinterface. Classes that implement this interface must ensure that the object returned performs the same functionality, and that it does not share any state data that would be either unsafe or inefficient for concurrent access by multiple threads. The split method is allowed to simply return the this reference, provided that it is both safe and efficient for multiple threads to share a single copy of the Splittable object. The intention is to provide a multithreaded search with the capability to provide spawned threads with their own distinct search operators. Such multithreaded algorithms can call the split method for each thread it spawns to generate a functionally identical copy of the operator, but with independent state.- Specified by:
splitin interfaceSplittable<T>- Returns:
- A functionally identical copy of the object, or a reference to this if it is both safe and efficient for multiple threads to share a single instance of this Splittable object.
-