Interface StopCriterion

All Superinterfaces:
Predicate<SearchStatistics>
All Known Subinterfaces:
AstarStopCriterion, DdoStopCriterion
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 StopCriterion extends Predicate<SearchStatistics>
Interface representing a criterion to stop the search process in a solver.

A StopCriterion is a Predicate that takes SearchStatistics as input and returns true if the search should be terminated.

  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    maxFrontierSize(int maxNodes)
    Creates a memory limit that terminates the search when the frontier (or the open list) reaches a specified size.
    maxIter(int maxIter)
    Creates a stop criterion that terminates the search when the number of iterations exceeds a specified limit.
    Creates a stop criterion that terminates the search if no improvement has been found for a certain number of iterations.
    Creates a stop criterion that terminates the search when the number of iterations without any gap improvement exceeds a specified limit.
    maxTime(long maxTimeMs)
    Creates a stop criterion that terminates the search when the total runtime exceeds a specified limit.
    Creates a stop criterion that terminates the search if no improvement has been found for a certain amount of time.
    minGap(double gapPercent)
    Creates a stop criterion that terminates the search when the optimality gap is less than or equal to a specified threshold.
    minRelativeImprovement(double threshold)
    Creates a stop criterion that terminates the search when the relative improvement between the current incumbent and the previous incumbent is less than or equal to a threshold.

    Methods inherited from interface java.util.function.Predicate

    and, negate, or, test
  • Method Details

    • maxTime

      static StopCriterion maxTime(long maxTimeMs)
      Creates a stop criterion that terminates the search when the total runtime exceeds a specified limit.
      Parameters:
      maxTimeMs - the maximum allowed runtime in milliseconds
      Returns:
      a StopCriterion for maximum runtime
    • maxIter

      static StopCriterion maxIter(int maxIter)
      Creates a stop criterion that terminates the search when the number of iterations exceeds a specified limit.
      Parameters:
      maxIter - the maximum allowed number of iterations
      Returns:
      a StopCriterion for maximum iterations
    • maxTimeSinceLastImprovement

      static StopCriterion maxTimeSinceLastImprovement(long maxTimeMs)
      Creates a stop criterion that terminates the search if no improvement has been found for a certain amount of time.
      Parameters:
      maxTimeMs - the maximum allowed time since the last improvement (in milliseconds)
      Returns:
      a StopCriterion based on time since last improvement
    • maxIterSinceLastImprovement

      static StopCriterion maxIterSinceLastImprovement(int maxIter)
      Creates a stop criterion that terminates the search if no improvement has been found for a certain number of iterations.
      Parameters:
      maxIter - the maximum allowed number of iterations since the last improvement
      Returns:
      a StopCriterion based on iterations since last improvement
    • minRelativeImprovement

      static StopCriterion minRelativeImprovement(double threshold)
      Creates a stop criterion that terminates the search when the relative improvement between the current incumbent and the previous incumbent is less than or equal to a threshold.
      Parameters:
      threshold - the minimum relative improvement required to continue the search in percent
      Returns:
      a StopCriterion based on the relative improvement
    • minGap

      static StopCriterion minGap(double gapPercent)
      Creates a stop criterion that terminates the search when the optimality gap is less than or equal to a specified threshold.
      Parameters:
      gapPercent - the maximum allowed optimality gap in percent
      Returns:
      a StopCriterion for minimum optimality gap
    • maxFrontierSize

      static StopCriterion maxFrontierSize(int maxNodes)
      Creates a memory limit that terminates the search when the frontier (or the open list) reaches a specified size. The solver then returns the best solution found so far with the status SearchStatus.MEMOUT.

      The limit is signaled by throwing a MemoryLimitException, so that the solver can tell it from the other criteria, even when it is combined with them (for instance maxTime(t).or(maxFrontierSize(n))). The solvers catch this exception: it is only seen when the criterion is tested outside of a solver.

      Parameters:
      maxNodes - the maximum allowed size of the frontier
      Returns:
      a StopCriterion for maximum frontier size
    • maxIterWithoutGapImprovement

      static StopCriterion maxIterWithoutGapImprovement(int maxIter)
      Creates a stop criterion that terminates the search when the number of iterations without any gap improvement exceeds a specified limit.
      Parameters:
      maxIter - the maximum allowed number of iterations since the last gap improvement
      Returns:
      a StopCriterion based on iterations since last gap improvement