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.phfit`: true selects the two-moment concentrated-ME fit
59 * (the reference default), false the Bernstein density fit. MAM consumes a
60 * matrix exponential happily, so the default stands here.
61 */
62 bool phfit_cme = true;
63 /**
64 * `options.config.num_cdf_pts`: how many points the response-time CDF is
65 * evaluated at. The GLOBAL default is 200, not the 100 that
66 * `solver_mam_passage_time.m`'s own fallback names -- the fallback is dead,
67 * because SolverOptions always sets the field. Measured: MATLAB returns 200
68 * rows for a model whose `options.config` was never touched.
69 */
70 std::size_t num_cdf_pts = 200;
71 /**
72 * `options.cutoff`: the level truncation `getProb` / `getProbMarg` use for
73 * an OPEN model, where the queue length is unbounded. 0 selects the
74 * reference's default of 100.
75 */
76 std::size_t cutoff = 0;
77 /**
78 * `options.config.bgstates_max`: the cap on the number of states of the
79 * bgchain background chain, which enumerates the closed-class population
80 * vector and so grows as nchoosek(N+Mc-1,Mc-1) per background class. 0
81 * selects the default of 20000. Exceeding it is a named error, not a silent
82 * degradation.
83 */
84 std::size_t bgstates_max = 0;
85 /**
86 * `options.config.bgaggr`: the number G of AGGREGATE background classes the
87 * bgchain method carries, so the chain has 1 + G classes. G = 1 is the
88 * classic tagged/aggregate pair and the default; G >= R-1 aggregates nothing
89 * and carries every closed chain exactly. 0 selects the default of 1.
90 */
91 std::size_t bgaggr = 0;
92 /**
93 * `options.config.qbdphases_max`: the cap on the phase count of one bgchain
94 * station QBD, the product (arrival order) x (environment states) x (service
95 * phases). 0 selects the default of 500.
96 */
97 std::size_t qbdphases_max = 0;
98 /**
99 * `options.config.fj_accuracy`: the FJ_codes truncation C of the
100 * queue-length DIFFERENCE between the two fork-join branches. Larger is
101 * more accurate and costs (C + 1) m^2 ma in every matrix dimension; the
102 * reference default is 100.
103 */
104 std::size_t fj_accuracy = 100;
105 /**
106 * `options.config.fj_tmode`: which route `computeT.m` takes to the T
107 * matrix, 'NARE' (Riccati, the reference default) or 'Sylves' (the
108 * fixed-point iteration of Section 5.1).
109 */
110 std::string fj_tmode = "NARE";
111 /**
112 * `options.config.timescale`: "auto", "discrete" or "continuous". "auto"
113 * lets the distributions decide whether the model is slotted; the other two
114 * force the reading and raise when the model does not admit it.
115 */
116 std::string timescale = "auto";
117 /** `options.config.slotlength`: the slot in model time units. */
118 double slotlength = 1.0;
119 /**
120 * `options.timespan`: the transient horizon. SolverOptions('MAM') defaults
121 * it to [Inf, Inf], i.e. steady state only, and `runAnalyzer` treats a
122 * finite upper bound as the request for a transient solve.
123 */
124 double timespan_start = 0.0;
125 double timespan_end = std::numeric_limits<double>::infinity();
126
127 /**
128 * `preserve_det` with the reference's method-dependent default applied,
129 * and the ONLY spelling any analyzer should read.
130 *
131 * 'bgchain' builds a phase-type MIXTURE of the open service laws and has
132 * no deterministic-service branch at all, so a Det that survives to it
133 * arrives with no (D0,D1) pair to mix. It therefore needs the Det FITTED
134 * to PH, which is what `solver_mam_analyzer.m:47` says by defaulting
135 * `preserveDet` to `~strcmpi(options.method,'bgchain')`. Every other
136 * method wants the Det preserved so the exact MAP/D/c branch can claim it.
137 *
138 * The method name is compared exactly, not case-insensitively as the
139 * reference's `strcmpi` does, because `check_method` has already refused
140 * anything that is not one of `list_valid_methods`' lowercase names by the
141 * time an analyzer reads this.
142 */
144 return preserve_det.value_or(method != "bgchain");
145 }
146};
147
148/** What the MAM dispatch returns: the metrics plus the algorithm that ran. */
149template <class T>
152 /** The concrete algorithm, as the reference's `actualmethod`. */
153 std::string actualmethod;
154};
155
156} // namespace mam
157} // namespace line
158
159#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
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:70
double timespan_start
options.timespan: the transient horizon.
Definition mam_types.h:124
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:84
std::string timescale
options.config.timescale: "auto", "discrete" or "continuous".
Definition mam_types.h:116
std::size_t bgaggr
options.config.bgaggr: the number G of AGGREGATE background classes the bgchain method carries,...
Definition mam_types.h:91
bool phfit_cme
options.config.phfit: true selects the two-moment concentrated-ME fit (the reference default),...
Definition mam_types.h:62
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:104
std::size_t qbdphases_max
options.config.qbdphases_max: the cap on the phase count of one bgchain station QBD,...
Definition mam_types.h:97
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:76
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:110
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:143
double slotlength
options.config.slotlength: the slot in model time units.
Definition mam_types.h:118
What the MAM dispatch returns: the metrics plus the algorithm that ran.
Definition mam_types.h:150
std::string actualmethod
The concrete algorithm, as the reference's actualmethod.
Definition mam_types.h:153
mva::MvaSolution< T > sol
Definition mam_types.h:151
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
Definition mva_types.h:96