![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
options.timeout: one wall-clock budget per top-level solve, on a per-THREAD deadline stack. More...
#include <chrono>#include <cmath>#include <cstdio>#include <limits>#include <string>#include <vector>#include "line/util/error.h"Go to the source code of this file.
Classes | |
| struct | line::util::timeout_detail::Frame |
| class | line::util::TimeoutScope |
| The RAII frame timeout_arm returns. More... | |
Namespaces | |
| namespace | line |
| Conservation laws of a layered queueing network, enumerated from its structure. | |
| namespace | line::util |
| namespace | line::util::timeout_detail |
Functions | |
| std::vector< Frame > & | line::util::timeout_detail::stack () |
| double | line::util::timeout_detail::elapsed (const Frame &f) |
| double | line::util::timeout_remaining () |
| Seconds left on the innermost armed budget; +Inf when none is armed. | |
| bool | line::util::timeout_armed () |
| Whether any budget is armed on this thread. | |
| bool | line::util::timeout_exceeded () |
| The checkpoint: true when the innermost budget has run out, marking it tripped. | |
| bool | line::util::timeout_tripped () |
| Whether the innermost budget was tripped by a checkpoint or by timeout_trip. | |
| void | line::util::timeout_trip () |
| Mark the innermost budget tripped without reading the clock: for an external engine that REPORTS it stopped on the budget (LDES stoppingReason ==
"max_time", a JSIM run given -maxtime). | |
| void | line::util::timeout_check (const char *where) |
| The raising checkpoint, for a computation with no valid partial result: throws LINE:numerical:Timeout naming where when the budget has run out. | |
| int | line::util::timeout_kill_seconds (double grace=30.0) |
| The hard kill bound of a child process under the armed budget: the remaining seconds plus grace, rounded up, as MATLAB's lineTimeoutKillPrefix builds timeout -k 5 ceil(remaining+30). | |
| int | line::util::timeout_kill_bound (int explicit_seconds, double grace=30.0) |
| The kill bound of a child that also has a bound of its OWN (explicit_seconds, not positive = none): the tighter of the two, 0 when neither is set. | |
| void | line::util::timeout_raise_if_killed_on_budget (const std::string &who) |
| A child process was killed on its bound: raise LINE:numerical:Timeout when the armed budget is what ran out (a killed child wrote no result, so there is no partial one), and return otherwise so the caller reports its own bound. | |
| TimeoutScope | line::util::timeout_arm (double budget) |
| Arm budget seconds for the scope's lifetime, capped by the outer frame's remaining time. | |
| void | line::util::timeout_warn (const std::string &solver, double budget) |
| The one warning a solve that stopped on its budget prints, MATLAB's flagTimeout text, on stderr as every other [LINE] Warning here. | |
options.timeout: one wall-clock budget per top-level solve, on a per-THREAD deadline stack.
The C++ twin of MATLAB's lineTimeoutArm / lineTimeoutRemaining / lineTimeoutExceeded / lineTimeoutTripped / lineTimeoutTrip, the JAR's jline.util.LineTimeout and Python's line_solver._timeutil. The contract:
THREAD-LOCAL, NOT GLOBAL: two solves on two threads with different budgets never read each other's deadline (the JAR's static deadline did). A worker thread a solver spawns starts with an EMPTY stack, so a solver that fans out hands each worker the remaining budget explicitly (see ldes_engine_solve).
The clock is steady_clock, compared as an elapsed double against a double budget, so neither a clock step nor a huge budget can overflow it.
timeout_check(where) is the raising form, for the computations that have NO valid partial result – a state space cut short, an exact recursion stopped mid-population – and it raises LINE:numerical:Timeout.
Definition in file line_timeout.h.