LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
mam_types.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_MAM_MAM_TYPES_H
6#define LINE_SOLVERS_MAM_MAM_TYPES_H
7
8/**
9 * @file
10 * @ingroup line_solvers
11 * The option and result types SolverMAM shares with its analyzers.
12 *
13 * The solution type IS `mva::MvaSolution<T>`: the MAM analyzers return the same
14 * [Q,U,R,T,C,X] tuple, and `@@NetworkSolver/getAvg` applies the same
15 * solver-independent metric filter afterwards, so reusing it is what keeps the
16 * two runners from drifting apart.
17 */
18
19#include <cstddef>
20#include <limits>
21#include <optional>
22#include <string>
23
25
26namespace line {
27namespace mam {
28
29/** The options SolverMAM reads. Defaults are SolverOptions('MAM'). */
30struct MamOptions {
31 std::string method = "default";
32 double tol = 1e-4;
33 /** SolverOptions('MAM') lowers this from the global 1000 to 100. */
34 int iter_max = 100;
35 /**
36 * `options.config.space_max`: the order budget of the per-station arrival
37 * superposition, handed to mmap_super_safe. `dec.poisson` is exactly this
38 * set to 1, which collapses every stream to marked Poisson.
39 */
40 std::size_t space_max = 128;
41 /**
42 * `options.config.preserveDet`: keep a Det service as Det so the exact
43 * MAP/D/c solver can claim it, instead of Erlang-approximating it.
44 *
45 * EMPTY MEANS NOT GIVEN, which is the whole point of the optional. The
46 * reference defaults the field only when the caller left it unset
47 * (`solver_mam_analyzer.m:43-47`), and the default it picks is
48 * METHOD-DEPENDENT, so a plain `= true` here is not the same thing: it
49 * cannot say "on unless bgchain" and cannot let an explicit request win.
50 */
51 std::optional<bool> preserve_det;
52 /**
53 * `options.config.nonmkvorder`: the phase budget `sn_nonmarkov_toph` spends
54 * replacing a non-Markovian service law. The reference default is 20.
55 */
56 std::size_t nonmkv_order = 20;
57 /**
58 * `options.config.nonmkv`: 'bernstein' (default) runs `sn_nonmarkov_toph`,
59 * 'none' skips it; any other name is refused (`api::nonmkv_enabled`).
60 */
61 std::string nonmkv = "bernstein";
62 /**
63 * `options.config.phfit`: true selects the two-moment concentrated-ME fit
64 * (the reference default), false the Bernstein density fit. MAM consumes a
65 * matrix exponential happily, so the default stands here.
66 */
67 bool phfit_cme = true;
68 /**
69 * `options.config.num_cdf_pts`: how many points the response-time CDF is
70 * evaluated at. The GLOBAL default is 200, not the 100 that
71 * `solver_mam_passage_time.m`'s own fallback names -- the fallback is dead,
72 * because SolverOptions always sets the field. Measured: MATLAB returns 200
73 * rows for a model whose `options.config` was never touched.
74 */
75 std::size_t num_cdf_pts = 200;
76 /**
77 * `options.cutoff`: the level truncation `getProb` / `getProbMarg` use for
78 * an OPEN model, where the queue length is unbounded. 0 selects the
79 * reference's default of 100.
80 */
81 std::size_t cutoff = 0;
82 /**
83 * `options.config.bgstates_max`: the cap on the number of states of the
84 * bgchain background chain, which enumerates the closed-class population
85 * vector and so grows as nchoosek(N+Mc-1,Mc-1) per background class. 0
86 * selects the default of 20000. Exceeding it is a named error, not a silent
87 * degradation.
88 */
89 std::size_t bgstates_max = 0;
90 /**
91 * `options.config.bgaggr`: the number G of AGGREGATE background classes the
92 * bgchain method carries, so the chain has 1 + G classes. G = 1 is the
93 * classic tagged/aggregate pair and the default; G >= R-1 aggregates nothing
94 * and carries every closed chain exactly. 0 selects the default of 1.
95 */
96 std::size_t bgaggr = 0;
97 /**
98 * `options.config.qbdphases_max`: the cap on the phase count of one bgchain
99 * station QBD, the product (arrival order) x (environment states) x (service
100 * phases). 0 selects the default of 500.
101 */
102 std::size_t qbdphases_max = 0;
103 /**
104 * `options.config.fj_accuracy`: the FJ_codes truncation C of the
105 * queue-length DIFFERENCE between the two fork-join branches. Larger is
106 * more accurate and costs (C + 1) m^2 ma in every matrix dimension; the
107 * reference default is 100.
108 */
109 std::size_t fj_accuracy = 100;
110 /**
111 * `options.config.fj_tmode`: which route `computeT.m` takes to the T
112 * matrix, 'NARE' (Riccati, the reference default) or 'Sylvester' (the
113 * fixed-point iteration of Section 5.1).
114 */
115 std::string fj_tmode = "NARE";
116 /**
117 * `options.config.sync_phases`: the synchronous phase expansion of the
118 * 'sync.faster' / 'sync.slower' methods. 0 (the default) solves the
119 * synchronous approximation without expansion; N >= 1 splits a
120 * deterministic service into N phases and tightens both bounds.
121 */
122 std::size_t sync_phases = 0;
123 /**
124 * `options.config.mapmsg_quantization`: the number of regimes the MAP/M/s+G
125 * reneging analyzer quantizes the patience CDF into (solver_mam_reneging.h).
126 * The reference default is 81; fewer than 2 leaves no grid and is refused.
127 */
128 std::size_t mapmsg_quantization = 81;
129 /**
130 * `options.config.timescale`: "auto", "discrete" or "continuous". "auto"
131 * lets the distributions decide whether the model is slotted; the other two
132 * force the reading and raise when the model does not admit it.
133 */
134 std::string timescale = "auto";
135 /** `options.config.slotlength`: the slot in model time units. */
136 double slotlength = 1.0;
137 /**
138 * `options.timespan`: the transient horizon. SolverOptions('MAM') defaults
139 * it to [Inf, Inf], i.e. steady state only, and `runAnalyzer` treats a
140 * finite upper bound as the request for a transient solve.
141 */
142 double timespan_start = 0.0;
143 double timespan_end = std::numeric_limits<double>::infinity();
144
145 /**
146 * `preserve_det` with the reference's method-dependent default applied,
147 * and the ONLY spelling any analyzer should read.
148 *
149 * 'bgchain' builds a phase-type MIXTURE of the open service laws and has
150 * no deterministic-service branch at all, so a Det that survives to it
151 * arrives with no (D0,D1) pair to mix. It therefore needs the Det FITTED
152 * to PH, which is what `solver_mam_analyzer.m:47` says by defaulting
153 * `preserveDet` to `~strcmpi(options.method,'bgchain')`. Every other
154 * method wants the Det preserved so the exact MAP/D/c branch can claim it.
155 *
156 * The method name is compared exactly, not case-insensitively as the
157 * reference's `strcmpi` does, because `check_method` has already refused
158 * anything that is not one of `list_valid_methods`' lowercase names by the
159 * time an analyzer reads this.
160 */
162 return preserve_det.value_or(method != "bgchain");
163 }
164};
165
166/** What the MAM dispatch returns: the metrics plus the algorithm that ran. */
167template <class T>
170 /** The concrete algorithm, as the reference's `actualmethod`. */
171 std::string actualmethod;
172};
173
174} // namespace mam
175} // namespace line
176
177#endif // LINE_SOLVERS_MAM_MAM_TYPES_H
The option and result types every MVA analyzer shares.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
The options SolverMAM reads.
Definition mam_types.h:30
std::size_t mapmsg_quantization
options.config.mapmsg_quantization: the number of regimes the MAP/M/s+G reneging analyzer quantizes t...
Definition mam_types.h:128
int iter_max
SolverOptions('MAM') lowers this from the global 1000 to 100.
Definition mam_types.h:34
std::size_t num_cdf_pts
options.config.num_cdf_pts: how many points the response-time CDF is evaluated at.
Definition mam_types.h:75
double timespan_start
options.timespan: the transient horizon.
Definition mam_types.h:142
std::size_t bgstates_max
options.config.bgstates_max: the cap on the number of states of the bgchain background chain,...
Definition mam_types.h:89
std::string timescale
options.config.timescale: "auto", "discrete" or "continuous".
Definition mam_types.h:134
std::size_t bgaggr
options.config.bgaggr: the number G of AGGREGATE background classes the bgchain method carries,...
Definition mam_types.h:96
bool phfit_cme
options.config.phfit: true selects the two-moment concentrated-ME fit (the reference default),...
Definition mam_types.h:67
std::string nonmkv
options.config.nonmkv: 'bernstein' (default) runs sn_nonmarkov_toph, 'none' skips it; any other name ...
Definition mam_types.h:61
std::size_t fj_accuracy
options.config.fj_accuracy: the FJ_codes truncation C of the queue-length DIFFERENCE between the two ...
Definition mam_types.h:109
std::size_t qbdphases_max
options.config.qbdphases_max: the cap on the phase count of one bgchain station QBD,...
Definition mam_types.h:102
std::string method
Definition mam_types.h:31
std::size_t cutoff
options.cutoff: the level truncation getProb / getProbMarg use for an OPEN model, where the queue len...
Definition mam_types.h:81
std::size_t nonmkv_order
options.config.nonmkvorder: the phase budget sn_nonmarkov_toph spends replacing a non-Markovian servi...
Definition mam_types.h:56
std::optional< bool > preserve_det
options.config.preserveDet: keep a Det service as Det so the exact MAP/D/c solver can claim it,...
Definition mam_types.h:51
std::size_t space_max
options.config.space_max: the order budget of the per-station arrival superposition,...
Definition mam_types.h:40
std::string fj_tmode
options.config.fj_tmode: which route computeT.m takes to the T matrix, 'NARE' (Riccati,...
Definition mam_types.h:115
bool preserve_det_resolved() const
preserve_det with the reference's method-dependent default applied, and the ONLY spelling any analyze...
Definition mam_types.h:161
std::size_t sync_phases
options.config.sync_phases: the synchronous phase expansion of the 'sync.faster' / 'sync....
Definition mam_types.h:122
double slotlength
options.config.slotlength: the slot in model time units.
Definition mam_types.h:136
What the MAM dispatch returns: the metrics plus the algorithm that ran.
Definition mam_types.h:168
std::string actualmethod
The concrete algorithm, as the reference's actualmethod.
Definition mam_types.h:171
mva::MvaSolution< T > sol
Definition mam_types.h:169
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
Definition mva_types.h:97