LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
solver_options.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_SOLVERS_SOLVER_OPTIONS_H
6#define LINE_SOLVERS_SOLVER_OPTIONS_H
7
8/**
9 * @file
10 * @ingroup line_solvers
11 * @ingroup line_public
12 * The keyword arguments a solver takes, as one struct.
13 *
14 * Python builds a solver as `MVA(model, method='lin')` or
15 * `CTMC(model, cutoff=3, seed=23000)` -- one shared keyword surface across
16 * every solver, narrowed per solver by which keywords it reads. This is that
17 * surface: a field per keyword, and a fluent `set_*` per field so a C++ call
18 * reads like the Python one it was ported from.
19 *
20 * SolverOptions().set_cutoff(3).set_seed(23000)
21 *
22 * A field left at its default is NOT forwarded, so the engine's own default
23 * stands: that is what the negative/empty sentinels below mean. This mirrors
24 * MATLAB's `Solver.defaultOptions` merge rather than overwriting it.
25 */
26
27#include <cstddef>
28#include <string>
29#include <vector>
30
31namespace line {
32
33/** The knobs a solver reads; a negative or empty field keeps the engine default. */
35 std::string method = "default";
36 double tol = -1.0;
37 double iter_tol = -1.0;
38 int iter_max = -1;
39 std::size_t samples = 0;
40 unsigned long seed = 0;
41 /** CTMC `options.cutoff`, scalar or per class. */
42 double cutoff = -1.0;
43 std::vector<std::size_t> cutoff_vec;
44 /** CTMC refusal threshold on the state-space size. */
45 std::size_t state_max = 0;
46 /** Fluid `options.timespan(2)` and warm start. */
47 double timespan_end = -1.0;
48 std::vector<double> init_sol;
49 bool stiff = false;
50 /** The `options.config` fields of the MVA / NC / fluid families. */
51 std::string multiserver;
52 std::string highvar;
53 std::string np_priority;
54 /** MVA / NC `options.config.fork_join`: 'default'/'mmt'/'fjt' or 'ht'. */
55 std::string fork_join;
56 /** SSA `options.config.state_space_gen`. */
57 std::string state_space_gen;
58 /**
59 * `options.config.symbolic`: the computer-algebra backend to resolve.
60 *
61 * Empty keeps the engine default, which is `auto`. Other values are a URL,
62 * an image name, or `none` to stay local. Hoisted out of `config` like
63 * every other field here: this struct is flat by design.
64 */
65 std::string symbolic;
66 /**
67 * `options.config.symbolic_timeout`, seconds per symbolic request.
68 *
69 * Non-positive keeps the engine default of 300. It is a real knob and not
70 * a formality: a symbolic solve grows superpolynomially in the state count,
71 * and the fluid equilibria of a smoothed softmin drift are transcendental
72 * in exp(-pstar*x) and outrun 300 s on models that are otherwise ordinary.
73 */
75 /**
76 * `options.config.map_env`: `"default"` lets a model whose ONLY unsupported
77 * features are non-renewal processes fall back to its random-environment
78 * image, `"off"` keeps the plain rejection.
79 *
80 * CALLER-FACING ONLY, and deliberately not on `MvaOptions`, `NcSolverOptions`
81 * or `FluidOptions`: no `runAnalyzer` reads it in the reference either. The
82 * fallback happens ABOVE the runner, in `getAvg`'s place, because the runner
83 * must go on refusing the model it cannot consume.
84 */
85 std::string map_env;
86 /** `options.config.map_env_method`: `auto`, `meanfield`, `dec` or `avg`. */
87 std::string map_env_method;
88 /** `options.config.map_env_maxstages`: 0 keeps `map2renv`'s own cap of 64. */
89 std::size_t map_env_maxstages = 0;
90 /** SolverBA `options.level`. */
91 int level = 2;
92 /**
93 * JMT `options.config.replications`: the independent JSIM runs the transient ensemble of
94 * `default` averages over a finite timespan. Non-positive keeps the engine default of 10.
95 */
96 int replications = -1;
97 /** JMT `options.keep`: leave the scratch directory in place after the solve. */
98 bool keep = false;
99 bool verbose = false;
100
101 SolverOptions& set_method(const std::string& v) { method = v; return *this; }
102 SolverOptions& set_tol(double v) { tol = v; return *this; }
103 SolverOptions& set_iter_tol(double v) { iter_tol = v; return *this; }
104 SolverOptions& set_iter_max(int v) { iter_max = v; return *this; }
105 SolverOptions& set_replications(int v) { replications = v; return *this; }
106 SolverOptions& set_samples(std::size_t v) { samples = v; return *this; }
107 SolverOptions& set_seed(unsigned long v) { seed = v; return *this; }
108 SolverOptions& set_cutoff(double v) { cutoff = v; return *this; }
109 SolverOptions& set_cutoff_vec(const std::vector<std::size_t>& v) { cutoff_vec = v; return *this; }
110 SolverOptions& set_state_max(std::size_t v) { state_max = v; return *this; }
111 SolverOptions& set_timespan_end(double v) { timespan_end = v; return *this; }
112 SolverOptions& set_init_sol(const std::vector<double>& v) { init_sol = v; return *this; }
113 SolverOptions& set_stiff(bool v) { stiff = v; return *this; }
114 SolverOptions& set_multiserver(const std::string& v) { multiserver = v; return *this; }
115 SolverOptions& set_highvar(const std::string& v) { highvar = v; return *this; }
116 SolverOptions& set_np_priority(const std::string& v) { np_priority = v; return *this; }
117 SolverOptions& set_fork_join(const std::string& v) { fork_join = v; return *this; }
118 SolverOptions& set_state_space_gen(const std::string& v) { state_space_gen = v; return *this; }
119 SolverOptions& set_symbolic(const std::string& v) { symbolic = v; return *this; }
121 SolverOptions& set_map_env(const std::string& v) { map_env = v; return *this; }
122 SolverOptions& set_map_env_method(const std::string& v) { map_env_method = v; return *this; }
123 SolverOptions& set_map_env_maxstages(std::size_t v) { map_env_maxstages = v; return *this; }
124 SolverOptions& set_level(int v) { level = v; return *this; }
125 SolverOptions& set_keep(bool v) { keep = v; return *this; }
126 SolverOptions& set_verbose(bool v) { verbose = v; return *this; }
127};
128
129} // namespace line
130
131#endif // LINE_SOLVERS_SOLVER_OPTIONS_H
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
The knobs a solver reads; a negative or empty field keeps the engine default.
bool keep
JMT options.keep: leave the scratch directory in place after the solve.
std::vector< std::size_t > cutoff_vec
std::string multiserver
The options.config fields of the MVA / NC / fluid families.
SolverOptions & set_cutoff(double v)
SolverOptions & set_iter_max(int v)
SolverOptions & set_replications(int v)
SolverOptions & set_init_sol(const std::vector< double > &v)
std::size_t state_max
CTMC refusal threshold on the state-space size.
SolverOptions & set_timespan_end(double v)
std::vector< double > init_sol
SolverOptions & set_keep(bool v)
double cutoff
CTMC options.cutoff, scalar or per class.
std::size_t map_env_maxstages
options.config.map_env_maxstages: 0 keeps map2renv's own cap of 64.
SolverOptions & set_samples(std::size_t v)
SolverOptions & set_multiserver(const std::string &v)
SolverOptions & set_stiff(bool v)
SolverOptions & set_verbose(bool v)
SolverOptions & set_fork_join(const std::string &v)
std::string symbolic
options.config.symbolic: the computer-algebra backend to resolve.
SolverOptions & set_state_space_gen(const std::string &v)
SolverOptions & set_symbolic(const std::string &v)
int level
SolverBA options.level.
SolverOptions & set_highvar(const std::string &v)
SolverOptions & set_map_env_method(const std::string &v)
std::string map_env_method
options.config.map_env_method: auto, meanfield, dec or avg.
std::string np_priority
SolverOptions & set_iter_tol(double v)
SolverOptions & set_symbolic_timeout(int v)
SolverOptions & set_tol(double v)
SolverOptions & set_cutoff_vec(const std::vector< std::size_t > &v)
SolverOptions & set_map_env_maxstages(std::size_t v)
std::string fork_join
MVA / NC options.config.fork_join: 'default'/'mmt'/'fjt' or 'ht'.
double timespan_end
Fluid options.timespan(2) and warm start.
SolverOptions & set_method(const std::string &v)
std::string map_env
options.config.map_env: "default" lets a model whose ONLY unsupported features are non-renewal proces...
SolverOptions & set_state_max(std::size_t v)
int replications
JMT options.config.replications: the independent JSIM runs the transient ensemble of default averages...
int symbolic_timeout
options.config.symbolic_timeout, seconds per symbolic request.
std::string state_space_gen
SSA options.config.state_space_gen.
SolverOptions & set_level(int v)
SolverOptions & set_seed(unsigned long v)
SolverOptions & set_map_env(const std::string &v)
SolverOptions & set_np_priority(const std::string &v)