Class TheTerminator<T>
java.lang.Object
org.cicirello.search.evo.TheTerminator<T>
- Type Parameters:
T- The type of object under optimization.
- All Implemented Interfaces:
TerminationStrategy<T>
TheTerminator enables composition of multiple terminator strategies, terminating an evolutionary
algorithm if any of the component
TerminationStrategy instance's termination criteria are
met.
Note that it is unnecessary to include maximum number of generations as that is a required
parameter of the PopulationMetaheuristic.optimize(int,TerminationStrategy) method, and
is always a termination criteria. It is also unnecessary to include a termination criteria for
the case when a solution matches a lower bound detectable by the definition of the optimization
problem you are solving via the OptimizationProblem.minCost()
or IntegerCostOptimizationProblem.minCost() methods. The
library automatically terminates any of the evolutionary algorithms or other metaheuristics in
this case.
-
Nested Class Summary
Nested classes/interfaces inherited from interface TerminationStrategy
TerminationStrategy.ExecutionState<T> -
Constructor Summary
ConstructorsConstructorDescriptionTheTerminator(Collection<TerminationStrategy<T>> terminators) Initializes TheTerminator. -
Method Summary
Modifier and TypeMethodDescriptionbooleanPredicate method to determine whether or not to terminate the current run of the evolutionary algorithm.
-
Constructor Details
-
TheTerminator
Initializes TheTerminator.- Parameters:
terminators- a collection of TerminationStrategy interfaces. The evolutionary algorithm will terminate if any of the terminators signal to terminate. We recommend that you order the terminators with the least costly computationally first in the collection and the most costly last. Theterminate(TerminationStrategy.ExecutionState)method short-circuits on the first signal to terminate.
-
-
Method Details
-
terminate
Description copied from interface:TerminationStrategyPredicate method to determine whether or not to terminate the current run of the evolutionary algorithm.- Specified by:
terminatein interfaceTerminationStrategy<T>- Parameters:
state- the state of the evolutionary algorithm prior to the start of a generation- Returns:
- true if and only if the evolutionary algorithm should terminate
-