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>

public final class TheTerminator<T> extends Object implements 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.

  • Constructor Details

    • TheTerminator

      public TheTerminator(Collection<TerminationStrategy<T>> terminators)
      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. The terminate(TerminationStrategy.ExecutionState) method short-circuits on the first signal to terminate.
  • Method Details

    • terminate

      public boolean terminate(TerminationStrategy.ExecutionState<T> state)
      Description copied from interface: TerminationStrategy
      Predicate method to determine whether or not to terminate the current run of the evolutionary algorithm.
      Specified by:
      terminate in interface TerminationStrategy<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