![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Namespaces | |
| namespace | timeout_detail |
Classes | |
| class | LineConsole |
| struct | ProcResult |
| Outcome of a captured command. More... | |
| class | Sha256 |
| Incremental SHA-256. More... | |
| class | TempDir |
| class | TimeoutScope |
| The RAII frame timeout_arm returns. More... | |
Enumerations | |
| enum class | VerboseLevel { SILENT = 0 , STD = 1 , DEBUG = 2 } |
| Session verbosity, the twin of MATLAB's VerboseLevel, jline.VerboseLevel and python's line_solver.constants.VerboseLevel. More... | |
Functions | |
| double | timeout_remaining () |
| Seconds left on the innermost armed budget; +Inf when none is armed. | |
| bool | timeout_armed () |
| Whether any budget is armed on this thread. | |
| bool | timeout_exceeded () |
| The checkpoint: true when the innermost budget has run out, marking it tripped. | |
| bool | timeout_tripped () |
| Whether the innermost budget was tripped by a checkpoint or by timeout_trip. | |
| void | 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 | 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 | 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 | 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 | 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 | timeout_arm (double budget) |
| Arm budget seconds for the scope's lifetime, capped by the outer frame's remaining time. | |
| void | 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. | |
| std::string | method_type (const std::string &solvername, const std::string &method) |
| Banner classification of a solution method. | |
| std::string | sha256_hex (const std::string &data) |
| The digest of a byte string, as 64 lowercase hex characters. | |
| std::string | sha256_file_hex (const std::string &path) |
| The digest of a file's contents, streamed. | |
| ProcResult | capture (const std::vector< std::string > &argv, int timeoutSeconds, bool mergeStderr=false) |
| Runs a command, capturing stdout and discarding stderr. | |
| int | run_inherit (const std::vector< std::string > &argv) |
| Runs a command with the parent's stdout and stderr, e.g. | |
| std::string | trim (const std::string &s) |
| Trims ASCII whitespace from both ends, as Java's String.trim() does. | |
| std::string | make_temp_dir (const std::string &prefix, bool mountable=false) |
| Create a private scratch directory named after its caller. | |
|
strong |
Session verbosity, the twin of MATLAB's VerboseLevel, jline.VerboseLevel and python's line_solver.constants.VerboseLevel.
The ordering matters and matches theirs: SILENT < STD < DEBUG.
This port had none until the console became DEBUG. A per-run bool verbose still travels with each solver's options and still means STD-or-SILENT; DEBUG is a SESSION level, because the console must also narrate the model compile, which happens before any solver options exist.
| Enumerator | |
|---|---|
| SILENT | |
| STD | |
| DEBUG | |
Definition at line 57 of file line_console.h.
|
inline |
Runs a command, capturing stdout and discarding stderr.
mergeStderr sends the child's stderr down the SAME pipe instead, which is what MATLAB's [status, cmdout] = system(cmd) does and what a wrapper needs on the failure path: an external engine reports why it refused on stderr, and dropping it leaves the wrapper reporting an exit code and nothing else.
| argv | the command and its arguments, argv[0] resolved on PATH |
| timeoutSeconds | deadline; not positive waits indefinitely |
| mergeStderr | capture stderr too, interleaved with stdout |
Definition at line 82 of file subprocess.h.
References capture(), line::util::ProcResult::exitCode, line::util::ProcResult::out, and line::util::ProcResult::timedOut.
Referenced by capture(), line::io::tikz_detail::compile_pdf(), line::io::docker_daemon_available(), line::io::docker_has_local_image(), line::io::wfcommons_detail::fetch_https(), line::jmt::jmt_run(), line::jmt::jmt_run_docker(), line::jmt::jmt_version(), line::lqns::qnsolver_is_available(), line::ldes::solver_ldes_text(), line::sym::sym_stop_container(), line::io::tikz_export_png(), and line::io::tikz_pdflatex_available().
|
inline |
Create a private scratch directory named after its caller.
LINE_WORKSPACE_ROOT RELOCATES EVERY STAGED MODEL, exactly as it does in lineTempName.m, SysUtils.lineTempName and the native-Python wrappers. run-tests.sh sets it when it wraps lqns, lqsim or qnsolver in a container: the shim bind-mounts that root and nothing else, so a model left under TMPDIR is invisible to the binary, which then writes no result and is reported as having rejected the model. No wrapper here needs to know a container is involved.
mountable is the second argument of lineTempName: a snap-confined Docker daemon bind-mounts neither the system temp dir nor a dot-directory, so a caller that hands the directory to a container asks for a HOME-rooted one.
| prefix | a short tag naming the caller, as lineTempName('qns') does |
| mountable | root under $HOME/.line rather than TMPDIR |
Definition at line 84 of file tempdir.h.
References line::InputError::InputError(), and make_temp_dir().
Referenced by make_temp_dir(), line::io::qn2jsimg(), and line::util::TempDir::TempDir().
|
inline |
Banner classification of a solution method.
Lookup order: "<solver>.<method>", "<method>", the tail after each dot of the method (longest suffix first), the head before its first dot, "#<solver>", then "approximate,deterministic". The unknown-method default is the conservative one: claiming exactness a method does not have is the costlier error.
| solvername | banner solver name, with or without the "Solver" prefix |
| method | resolved method label, possibly carrying a "default/" prefix |
Definition at line 211 of file method_type.h.
References method_type().
Referenced by method_type().
|
inline |
Runs a command with the parent's stdout and stderr, e.g.
so a docker pull streams its progress. There is no deadline: a pull is long by nature and the user can see it working.
| argv | the command and its arguments |
Definition at line 170 of file subprocess.h.
References run_inherit().
Referenced by line::io::docker_pull(), and run_inherit().
|
inline |
The digest of a file's contents, streamed.
Definition at line 188 of file sha256.h.
References line::util::Sha256::hex(), sha256_file_hex(), and line::util::Sha256::update().
Referenced by sha256_file_hex().
|
inline |
The digest of a byte string, as 64 lowercase hex characters.
Definition at line 175 of file sha256.h.
References line::util::Sha256::hex(), sha256_hex(), and line::util::Sha256::update().
Referenced by sha256_hex().
|
inline |
Arm budget seconds for the scope's lifetime, capped by the outer frame's remaining time.
A non-finite or non-positive budget arms nothing.
Definition at line 214 of file line_timeout.h.
References line::util::timeout_detail::Frame::budget, line::util::timeout_detail::stack(), line::util::timeout_detail::Frame::start, timeout_arm(), timeout_remaining(), line::util::TimeoutScope::TimeoutScope(), and line::util::timeout_detail::Frame::tripped.
Referenced by line::NetworkSolver::avg_table(), line::ldes::ldes_engine_solve(), line::ldes::ldes_engine_solve_one(), line::ldes::ldes_ln_engine_solve(), run_invocation(), line::ldes::solver_ldes_text(), and timeout_arm().
|
inline |
Whether any budget is armed on this thread.
Definition at line 85 of file line_timeout.h.
References line::util::timeout_detail::stack(), and timeout_armed().
Referenced by timeout_armed().
|
inline |
The raising checkpoint, for a computation with no valid partial result: throws LINE:numerical:Timeout naming where when the budget has run out.
Definition at line 124 of file line_timeout.h.
References line::NumericError::NumericError(), timeout_check(), and timeout_exceeded().
Referenced by line::qn::cartesian(), line::ssa::NrmSpaceEngine< T >::enumerate_space(), line::pfqn::pfqn_mva(), line::pfqn::pfqn_mva_ilock(), line::pfqn::pfqn_mvald(), line::pfqn::pfqn_mvaldmx(), line::ctmc::reachable_space_generator(), line::qn::space_generator(), and timeout_check().
|
inline |
The checkpoint: true when the innermost budget has run out, marking it tripped.
Cheap (one steady_clock::now()), but a tight loop should still call it on a stride (1024 iterations is the convention here).
Definition at line 92 of file line_timeout.h.
References line::util::timeout_detail::Frame::budget, line::util::timeout_detail::elapsed(), line::util::timeout_detail::stack(), timeout_exceeded(), and line::util::timeout_detail::Frame::tripped.
Referenced by line::ldes::ldes_ln_engine_solve(), line::ssa::NrmEngine< T >::run(), line::ssa::NrmSpaceEngine< T >::run(), line::ssa::NrmSpnEngine< T >::run(), line::ssa::SsaSerialEngine< T >::run(), line::mva::solver_amvald(), line::mam::solver_mam_basic(), line::mam::solver_mam_basic_mmap_closed(), line::mam::solver_mam_bgchain(), line::nc::solver_nc(), line::nc::solver_ncld(), timeout_check(), timeout_exceeded(), and timeout_raise_if_killed_on_budget().
|
inline |
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.
Definition at line 148 of file line_timeout.h.
References timeout_kill_bound(), and timeout_kill_seconds().
Referenced by line::jmt::jmt_run(), line::jmt::jmt_run_docker(), line::jmt::jmt_solve_rest(), and timeout_kill_bound().
|
inline |
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).
0 (wait indefinitely) when nothing is armed.
Definition at line 137 of file line_timeout.h.
References timeout_kill_seconds(), and timeout_remaining().
Referenced by line::ldes::solver_ldes_text(), timeout_kill_bound(), and timeout_kill_seconds().
|
inline |
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.
Definition at line 159 of file line_timeout.h.
References line::NumericError::NumericError(), timeout_exceeded(), and timeout_raise_if_killed_on_budget().
Referenced by line::jmt::jmt_run(), line::jmt::jmt_run_docker(), line::jmt::jmt_solve_rest(), line::ldes::ldes_solve_rest(), line::ldes::solver_ldes_text(), and timeout_raise_if_killed_on_budget().
|
inline |
Seconds left on the innermost armed budget; +Inf when none is armed.
Definition at line 77 of file line_timeout.h.
References line::util::timeout_detail::elapsed(), line::util::timeout_detail::stack(), and timeout_remaining().
Referenced by line::ldes::ldes_engine_solve(), line::ldes::ldes_ln_engine_solve(), line::ldes::solver_ldes_text(), timeout_arm(), timeout_kill_seconds(), and timeout_remaining().
|
inline |
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).
A no-op when nothing is armed.
Definition at line 115 of file line_timeout.h.
References line::util::timeout_detail::stack(), and timeout_trip().
Referenced by line::ldes::ldes_engine_solve(), line::ldes::parse_ldes_result(), line::ldes::solver_ldes_text(), and timeout_trip().
|
inline |
Whether the innermost budget was tripped by a checkpoint or by timeout_trip.
Definition at line 105 of file line_timeout.h.
References line::util::timeout_detail::stack(), and timeout_tripped().
Referenced by line::NetworkSolver::avg_table(), line::ldes::solver_ldes_text(), timeout_tripped(), and CliTimeoutReport::~CliTimeoutReport().
|
inline |
The one warning a solve that stopped on its budget prints, MATLAB's flagTimeout text, on stderr as every other [LINE] Warning here.
Definition at line 230 of file line_timeout.h.
References timeout_warn().
Referenced by line::NetworkSolver::avg_table(), timeout_warn(), and CliTimeoutReport::~CliTimeoutReport().
|
inline |
Trims ASCII whitespace from both ends, as Java's String.trim() does.
Definition at line 181 of file subprocess.h.
References trim().
Referenced by line::io::docker_has_local_image(), line::io::wfcommons_detail::fetch_https(), line::jmt::jmt_version(), line::ldes::solver_ldes_text(), line::sym::sym_resolve(), and trim().