MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / MaxRuntime

Class MaxRuntime

pyvrp/stop/MaxRuntime.py:4–20  ·  view source on GitHub ↗

Criterion that stops after a specified maximum runtime (in seconds).

Source from the content-addressed store, hash-verified

2
3
4class MaxRuntime:
5 """
6 Criterion that stops after a specified maximum runtime (in seconds).
7 """
8
9 def __init__(self, max_runtime: float):
10 if max_runtime < 0:
11 raise ValueError("max_runtime < 0 not understood.")
12
13 self._max_runtime = max_runtime
14 self._start_runtime: float | None = None
15
16 def __call__(self, best_cost: float) -> bool:
17 if self._start_runtime is None:
18 self._start_runtime = time.perf_counter()
19
20 return time.perf_counter() - self._start_runtime > self._max_runtime

Callers 8

_solveFunction · 0.90
test_valid_parametersFunction · 0.90
test_before_max_runtimeFunction · 0.90
test_after_max_runtimeFunction · 0.90
test_before_max_runtimeFunction · 0.90
test_after_max_runtimeFunction · 0.90

Calls

no outgoing calls

Tested by 7

test_valid_parametersFunction · 0.72
test_before_max_runtimeFunction · 0.72
test_after_max_runtimeFunction · 0.72
test_before_max_runtimeFunction · 0.72
test_after_max_runtimeFunction · 0.72