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.
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 MethodsModifier and TypeMethodDescriptionstatic StopCriterionmaxFrontierSize(int maxNodes) Creates a memory limit that terminates the search when the frontier (or the open list) reaches a specified size.static StopCriterionmaxIter(int maxIter) Creates a stop criterion that terminates the search when the number of iterations exceeds a specified limit.static StopCriterionmaxIterSinceLastImprovement(int maxIter) Creates a stop criterion that terminates the search if no improvement has been found for a certain number of iterations.static StopCriterionmaxIterWithoutGapImprovement(int maxIter) Creates a stop criterion that terminates the search when the number of iterations without any gap improvement exceeds a specified limit.static StopCriterionmaxTime(long maxTimeMs) Creates a stop criterion that terminates the search when the total runtime exceeds a specified limit.static StopCriterionmaxTimeSinceLastImprovement(long maxTimeMs) Creates a stop criterion that terminates the search if no improvement has been found for a certain amount of time.static StopCriterionminGap(double gapPercent) Creates a stop criterion that terminates the search when the optimality gap is less than or equal to a specified threshold.static StopCriterionminRelativeImprovement(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.
-
Method Details
-
maxTime
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
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
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
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
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
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
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 statusSearchStatus.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 instancemaxTime(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
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
-