Class Stagnation
- java.lang.Object
-
- org.uncommons.watchmaker.framework.termination.Stagnation
-
- All Implemented Interfaces:
TerminationCondition
public class Stagnation extends Object implements TerminationCondition
ATerminationCondition
that halts evolution if no improvement in fitness is observed within a specified number of generations.
-
-
Constructor Summary
Constructors Constructor Description Stagnation(int generationLimit, boolean naturalFitness)
Creates aTerminationCondition
that will halt evolution after the specified number of generations passes without any improvement in the population's fittest individual.Stagnation(int generationLimit, boolean naturalFitness, boolean usePopulationAverage)
Creates aTerminationCondition
that will halt evolution after the specified number of generations passes without any improvement in the population's fitness (either the fittest individual or the mean fitness of the entire population, depending on the final parameter).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
shouldTerminate(PopulationData<?> populationData)
The condition is queried via this method to determine whether or not evolution should finish at the current point.
-
-
-
Constructor Detail
-
Stagnation
public Stagnation(int generationLimit, boolean naturalFitness)
Creates aTerminationCondition
that will halt evolution after the specified number of generations passes without any improvement in the population's fittest individual.- Parameters:
generationLimit
- The number of generations without improvement that will lead to termination.naturalFitness
- True if higher fitness scores are better, false otherwise.
-
Stagnation
public Stagnation(int generationLimit, boolean naturalFitness, boolean usePopulationAverage)
Creates aTerminationCondition
that will halt evolution after the specified number of generations passes without any improvement in the population's fitness (either the fittest individual or the mean fitness of the entire population, depending on the final parameter).- Parameters:
generationLimit
- The number of generations without improvement that will lead to termination.naturalFitness
- True if higher fitness scores are better, false otherwise.usePopulationAverage
- If true uses the mean fitness of the population as the criteria, otherwise uses the fittest individual.
-
-
Method Detail
-
shouldTerminate
public boolean shouldTerminate(PopulationData<?> populationData)
The condition is queried via this method to determine whether or not evolution should finish at the current point.- Specified by:
shouldTerminate
in interfaceTerminationCondition
- Parameters:
populationData
- Information about the current state of evolution. This may be used to determine whether evolution should continue or not.- Returns:
- true if evolution should be terminated, false otherwise.
-
-