Stopping criteria¶
The pyvrp.stop
module contains the various stopping criteria the pyvrp
package ships with.
These can be used to stop the GeneticAlgorithm
’s’ search whenever some criterion is met: for example, when some maximum number of iterations or run-time is exceeded.
All stopping criteria implement the StoppingCriterion
protocol.
- class StoppingCriterion(*args, **kwargs)[source]¶
Protocol that stopping criteria must implement.
Methods
__call__
(best_cost)When called, this stopping criterion should return True if the algorithm should stop, and False otherwise.
- class FirstFeasible[source]¶
Terminates the search after a feasible solution has been observed.
Methods
__call__
(best_cost)Call self as a function.
- class MaxIterations(max_iterations: int)[source]¶
Criterion that stops after a maximum number of iterations.
Methods
__call__
(best_cost)Call self as a function.
- class MaxRuntime(max_runtime: float)[source]¶
Criterion that stops after a specified maximum runtime (in seconds).
Methods
__call__
(best_cost)Call self as a function.
- class MultipleCriteria(criteria: list[StoppingCriterion])[source]¶
Simple aggregate class that manages multiple stopping criteria at once.
Methods
__call__
(best_cost)Call self as a function.