Interface TerminationStrategy<T>

Type Parameters:
T - The type of object under optimization.
All Known Implementing Classes:
MaximumFitnessEvaluationsTerminator, StagnationTerminator, TargetFitnessTerminator, TheTerminator
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TerminationStrategy<T>
This interface is used to define a termination strategy. Note that it is unnecessary to use this interface to specify termination by 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 specify 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
    Modifier and Type
    Interface
    Description
    static final record 
    The state of the evolutionary algorithm prior to the start of a generation.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Predicate method to determine whether or not to terminate the current run of the evolutionary algorithm.
  • Method Details

    • terminate

      boolean terminate(TerminationStrategy.ExecutionState<T> state)
      Predicate method to determine whether or not to terminate the current run of the evolutionary algorithm.
      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