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
31#include "line/util/matrix.h"
32
33namespace line {
34
35/** The knobs a solver reads; a negative or empty field keeps the engine default. */
37 std::string method = "default";
38 double tol = -1.0;
39 double iter_tol = -1.0;
40 int iter_max = -1;
41 std::size_t samples = 0;
42 unsigned long seed = 0;
43 /** CTMC `options.cutoff`, scalar or per class. */
44 double cutoff = -1.0;
45 std::vector<std::size_t> cutoff_vec;
46 /** CTMC refusal threshold on the state-space size. */
47 std::size_t state_max = 0;
48 /** Fluid `options.timespan(2)` and warm start. */
49 double timespan_end = -1.0;
50 std::vector<double> init_sol;
51 bool stiff = false;
52 /** The `options.config` fields of the MVA / NC / fluid families. */
53 std::string multiserver;
54 std::string highvar;
55 std::string np_priority;
56 /** MVA / NC `options.config.fork_join`: 'default'/'mmt'/'fjt' or 'ht'. */
57 std::string fork_join;
58 /** SSA `options.config.state_space_gen`. */
59 std::string state_space_gen;
60 /**
61 * `options.config.symbolic`: the computer-algebra backend to resolve.
62 *
63 * Empty keeps the engine default, which is `auto`. Other values are a URL,
64 * an image name, or `none` to stay local. Hoisted out of `config` like
65 * every other field here: this struct is flat by design.
66 */
67 std::string symbolic;
68 /**
69 * `options.config.symbolic_timeout`, seconds per symbolic request.
70 *
71 * Non-positive keeps the engine default of 300. It is a real knob and not
72 * a formality: a symbolic solve grows superpolynomially in the state count,
73 * and the fluid equilibria of a smoothed softmin drift are transcendental
74 * in exp(-pstar*x) and outrun 300 s on models that are otherwise ordinary.
75 */
77 /**
78 * `options.config.map_env`: `"auto"` (or `"default"`) lets a model whose ONLY unsupported
79 * features are non-renewal processes fall back to its random-environment
80 * image, `"off"` keeps the plain rejection.
81 *
82 * CALLER-FACING ONLY, and deliberately not on `MvaOptions`, `NcSolverOptions`
83 * or `FluidOptions`: no `runAnalyzer` reads it in the reference either. The
84 * fallback happens ABOVE the runner, in `getAvg`'s place, because the runner
85 * must go on refusing the model it cannot consume.
86 */
87 std::string map_env;
88 /** `options.config.map_env_method`: `auto`, `meanfield`, `dec` or `avg`. */
89 std::string map_env_method;
90 /** `options.config.map_env_maxstages`: 0 keeps `map2renv`'s own cap of 64. */
91 std::size_t map_env_maxstages = 0;
92 /** SolverBA `options.level`. */
93 int level = 2;
94 /**
95 * JMT `options.config.replications`: the independent JSIM runs the transient ensemble of
96 * `default` averages over a finite timespan. Non-positive keeps the engine default of 10.
97 */
98 int replications = -1;
99 /**
100 * `options.cache`: reuse the solved tables on later calls to the same solver object.
101 *
102 * True, the reference default, returns the stored result from `avg_table` and everything
103 * built on it; false re-runs the analysis on every call, as MATLAB's and the JAR's getAvg
104 * do under `~options.cache`, so edits to the model are picked up without `reset()`.
105 */
106 bool cache = true;
107 /** JMT `options.keep`: leave the scratch directory in place after the solve. */
108 bool keep = false;
109 bool verbose = false;
110 /** `options.force`: CTMC downgrades its memory pre-gate refusal to a warning. */
111 bool force = false;
112 /** `options.timestep`: CTMC fixed transient output step, fluid diffusion step; <= 0 keeps the default. */
113 double timestep = -1.0;
114 /** `options.timeout`, seconds: the cooperative wall-clock budget LDES polls; <= 0 keeps none. */
115 double timeout = -1.0;
116 /** `options.events`: the SSA / LDES event budget, overriding `samples` when set; 0 = not given. */
117 std::size_t events = 0;
118 /**
119 * `options.confint`: the confidence level of the half-widths JMT and LDES report, in (0,1).
120 *
121 * 0 is the reference's `false`: no interval columns in `AvgTable`. A level fills `QLenCI` and
122 * its siblings, which `AvgTable::print` shows as `mean +- half-width`. SSA reports no interval.
123 */
124 double confint = 0.0;
125 /** LDES `options.cimethod`: obm | bm | spectral | none; empty keeps obm. */
126 std::string cimethod;
127 /** LDES `options.ciminbatch` / `ciminobs`; negative keeps the engine's 10 / 100. */
128 int ciminbatch = -1;
129 int ciminobs = -1;
130 /** LDES `options.obmoverlap`, in [0,1]; negative keeps 0.5. */
131 double obmoverlap = -1.0;
132 /** LDES `options.spectralLowFreqFrac`, in (0,1]; non-positive keeps 0.25. */
134 /** LDES `options.tranfilter`: mser5 | fixed | none; empty keeps mser5. */
135 std::string tranfilter;
136 /** LDES `options.mserbatch`; non-positive keeps 5. */
137 int mserbatch = -1;
138 /** `options.warmupfrac`, in [0,1): LDES under tranfilter=fixed, and SSA's discarded prefix. */
139 double warmupfrac = -1.0;
140 /**
141 * LDES `options.init_jobs`: one row per job, [station, class, remaining, elapsed, qage, sage,
142 * order, id] with 0-based indexes; takes precedence over the model state and `init_sol`.
143 */
145 /** LDES `options.track_jobs`: return the end-of-run job state; implied by `init_jobs`. */
146 bool track_jobs = false;
147 /** LDES convergence stopping: `cnvgon`, `cnvgtol`, `cnvgbatch`, `cnvgchk`; negative keeps the default. */
148 bool cnvgon = false;
149 double cnvgtol = -1.0;
150 int cnvgbatch = -1;
151 int cnvgchk = -1;
152
153 SolverOptions& set_method(const std::string& v) { method = v; return *this; }
154 SolverOptions& set_tol(double v) { tol = v; return *this; }
155 SolverOptions& set_iter_tol(double v) { iter_tol = v; return *this; }
156 SolverOptions& set_iter_max(int v) { iter_max = v; return *this; }
157 SolverOptions& set_replications(int v) { replications = v; return *this; }
158 SolverOptions& set_samples(std::size_t v) { samples = v; return *this; }
159 SolverOptions& set_seed(unsigned long v) { seed = v; return *this; }
160 SolverOptions& set_cutoff(double v) { cutoff = v; return *this; }
161 SolverOptions& set_cutoff_vec(const std::vector<std::size_t>& v) { cutoff_vec = v; return *this; }
162 SolverOptions& set_state_max(std::size_t v) { state_max = v; return *this; }
163 SolverOptions& set_timespan_end(double v) { timespan_end = v; return *this; }
164 SolverOptions& set_init_sol(const std::vector<double>& v) { init_sol = v; return *this; }
165 SolverOptions& set_stiff(bool v) { stiff = v; return *this; }
166 SolverOptions& set_multiserver(const std::string& v) { multiserver = v; return *this; }
167 SolverOptions& set_highvar(const std::string& v) { highvar = v; return *this; }
168 SolverOptions& set_np_priority(const std::string& v) { np_priority = v; return *this; }
169 SolverOptions& set_fork_join(const std::string& v) { fork_join = v; return *this; }
170 SolverOptions& set_state_space_gen(const std::string& v) { state_space_gen = v; return *this; }
171 SolverOptions& set_symbolic(const std::string& v) { symbolic = v; return *this; }
173 SolverOptions& set_map_env(const std::string& v) { map_env = v; return *this; }
174 SolverOptions& set_map_env_method(const std::string& v) { map_env_method = v; return *this; }
175 SolverOptions& set_map_env_maxstages(std::size_t v) { map_env_maxstages = v; return *this; }
176 SolverOptions& set_level(int v) { level = v; return *this; }
177 SolverOptions& set_cache(bool v) { cache = v; return *this; }
178 SolverOptions& set_keep(bool v) { keep = v; return *this; }
179 SolverOptions& set_verbose(bool v) { verbose = v; return *this; }
180 SolverOptions& set_force(bool v) { force = v; return *this; }
181 SolverOptions& set_timestep(double v) { timestep = v; return *this; }
182 SolverOptions& set_timeout(double v) { timeout = v; return *this; }
183 SolverOptions& set_events(std::size_t v) { events = v; return *this; }
184 SolverOptions& set_confint(double v) { confint = v; return *this; }
185 SolverOptions& set_cimethod(const std::string& v) { cimethod = v; return *this; }
186 SolverOptions& set_ciminbatch(int v) { ciminbatch = v; return *this; }
187 SolverOptions& set_ciminobs(int v) { ciminobs = v; return *this; }
188 SolverOptions& set_obmoverlap(double v) { obmoverlap = v; return *this; }
190 SolverOptions& set_tranfilter(const std::string& v) { tranfilter = v; return *this; }
191 SolverOptions& set_mserbatch(int v) { mserbatch = v; return *this; }
192 SolverOptions& set_warmupfrac(double v) { warmupfrac = v; return *this; }
193 SolverOptions& set_init_jobs(const Matrix<double>& v) { init_jobs = v; return *this; }
194 SolverOptions& set_track_jobs(bool v) { track_jobs = v; return *this; }
195 SolverOptions& set_cnvgon(bool v) { cnvgon = v; return *this; }
196 SolverOptions& set_cnvgtol(double v) { cnvgtol = v; return *this; }
197 SolverOptions& set_cnvgbatch(int v) { cnvgbatch = v; return *this; }
198 SolverOptions& set_cnvgchk(int v) { cnvgchk = v; return *this; }
199};
200
201} // namespace line
202
203#endif // LINE_SOLVERS_SOLVER_OPTIONS_H
Dense matrix and non-owning view.
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.
SolverOptions & set_cnvgon(bool v)
bool keep
JMT options.keep: leave the scratch directory in place after the solve.
std::vector< std::size_t > cutoff_vec
SolverOptions & set_timeout(double v)
double spectral_low_freq_frac
LDES options.spectralLowFreqFrac, in (0,1]; non-positive keeps 0.25.
int ciminbatch
LDES options.ciminbatch / ciminobs; negative keeps the engine's 10 / 100.
SolverOptions & set_cache(bool v)
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)
bool force
options.force: CTMC downgrades its memory pre-gate refusal to a warning.
SolverOptions & set_cnvgbatch(int v)
SolverOptions & set_init_sol(const std::vector< double > &v)
std::size_t state_max
CTMC refusal threshold on the state-space size.
bool cnvgon
LDES convergence stopping: cnvgon, cnvgtol, cnvgbatch, cnvgchk; negative keeps the default.
double warmupfrac
options.warmupfrac, in [0,1): LDES under tranfilter=fixed, and SSA's discarded prefix.
SolverOptions & set_tranfilter(const std::string &v)
SolverOptions & set_timespan_end(double v)
int mserbatch
LDES options.mserbatch; non-positive keeps 5.
std::size_t events
options.events: the SSA / LDES event budget, overriding samples when set; 0 = not given.
std::vector< double > init_sol
SolverOptions & set_keep(bool v)
double cutoff
CTMC options.cutoff, scalar or per class.
SolverOptions & set_ciminobs(int v)
std::string cimethod
LDES options.cimethod: obm | bm | spectral | none; empty keeps obm.
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)
Matrix< double > init_jobs
LDES options.init_jobs: one row per job, [station, class, remaining, elapsed, qage,...
double obmoverlap
LDES options.obmoverlap, in [0,1]; negative keeps 0.5.
SolverOptions & set_verbose(bool v)
SolverOptions & set_force(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_init_jobs(const Matrix< double > &v)
double timeout
options.timeout, seconds: the cooperative wall-clock budget LDES polls; <= 0 keeps none.
SolverOptions & set_timestep(double v)
SolverOptions & set_cnvgtol(double v)
SolverOptions & set_symbolic(const std::string &v)
int level
SolverBA options.level.
SolverOptions & set_cnvgchk(int v)
SolverOptions & set_highvar(const std::string &v)
SolverOptions & set_map_env_method(const std::string &v)
SolverOptions & set_events(std::size_t v)
SolverOptions & set_cimethod(const std::string &v)
std::string map_env_method
options.config.map_env_method: auto, meanfield, dec or avg.
SolverOptions & set_mserbatch(int v)
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)
SolverOptions & set_ciminbatch(int v)
std::string map_env
options.config.map_env: "auto" (or "default") lets a model whose ONLY unsupported features are non-re...
SolverOptions & set_state_max(std::size_t v)
SolverOptions & set_spectral_low_freq_frac(double v)
int replications
JMT options.config.replications: the independent JSIM runs the transient ensemble of default averages...
SolverOptions & set_track_jobs(bool v)
int symbolic_timeout
options.config.symbolic_timeout, seconds per symbolic request.
double timestep
options.timestep: CTMC fixed transient output step, fluid diffusion step; <= 0 keeps the default.
std::string state_space_gen
SSA options.config.state_space_gen.
SolverOptions & set_obmoverlap(double v)
SolverOptions & set_level(int v)
bool track_jobs
LDES options.track_jobs: return the end-of-run job state; implied by init_jobs.
double confint
options.confint: the confidence level of the half-widths JMT and LDES report, in (0,...
SolverOptions & set_confint(double v)
SolverOptions & set_seed(unsigned long v)
SolverOptions & set_map_env(const std::string &v)
SolverOptions & set_np_priority(const std::string &v)
bool cache
options.cache: reuse the solved tables on later calls to the same solver object.
SolverOptions & set_warmupfrac(double v)
std::string tranfilter
LDES options.tranfilter: mser5 | fixed | none; empty keeps mser5.