LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
solver_mam_basic_mmap.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_SOLVER_MAM_BASIC_MMAP_H
6#define LINE_SOLVERS_MAM_SOLVER_MAM_BASIC_MMAP_H
7
8/**
9 * @file
10 * @ingroup line_solvers
11 * Port of `solver_mam_basic_mmap.m`, `solver_mam_basic_mmap_inner.m` and
12 * `solver_mam_basic_mmap_closed.m`: the MMAP fork-join decomposition, reached as
13 * the `dec.source.mmap` method and as branch 2b of the dispatch (every open
14 * fork-join model that is not in the homogeneous class `solver_mam_fj` serves).
15 *
16 * THE METHOD. It is a PARAMETRIC DECOMPOSITION, not a per-station isolation:
17 * unlike `dec.source`, which hands every station a rescaled copy of the chain's
18 * source process, this one carries a per-node DEPARTURE process table and
19 * recomputes the arrival stream at every node from the traffic equations each
20 * sweep (`solver_mam_traffic_mmap`, the fork-join aware traffic step). The
21 * departure process of an FCFS or PS station is the ETAQA truncation of its own
22 * QBD (`qbd_depproc_etaqa`, `qbd_depproc_etaqa_ps`), so the correlation a queue
23 * introduces travels downstream instead of being discarded. The fixed point is
24 * driven on the station queue lengths by `da_fpi` with a RELATIVE increment
25 * norm, and the reference starts testing convergence only from the third sweep
26 * (`config.da_miniter = 3`).
27 *
28 * WHAT MAKES IT THE FORK-JOIN ANALYZER. Two things, and neither is in
29 * `dec.source`:
30 * - the traffic step SYNCHRONIZES the flows arriving at a join along one sync
31 * group with `mmap_max` rather than superposing them, so the join's output
32 * process is the slowest branch's, blocking included;
33 * - the join's own metrics are derived AFTER the fixed point from the branch
34 * response times, as the expected maximum of independent exponentials with
35 * rates 1/R_b minus their mean. That difference is the synchronization delay,
36 * and `QN = (sum of branch throughputs) * delay` is Little's law on it.
37 *
38 * THE CLOSED WRAPPER has no source to fix the arrival rates, so it wraps the
39 * inner analyzer in a per-class BISECTION on a surrogate arrival rate, driven
40 * against the population, exactly as `solver_mna_closed` does. Three details of
41 * the reference are reproduced rather than tidied: the bracket's upper bound is
42 * the SLOWEST rate over the finite-server stations (the fallback to the
43 * infinite-server ones, and then to 1, is the reference's own); the loop breaks
44 * when every bracket has collapsed below the precision floor, undoing its own
45 * iteration count as it does so; and a diverged inner call is caught, treated as
46 * an overload, and the last successful metrics are restored if the FINAL trial
47 * is the one that diverged.
48 *
49 * SELF-LOOPING CLASSES. `sn.isslc` guards the surrogate-rate zeroing, the queue
50 * clamp and the final throughput pin in the reference's closed wrapper, and the
51 * PS denominator and the FCFS saturation test in the inner analyzer. The C++
52 * `JobClassType` is OPEN or CLOSED only, so no model this port can build enters
53 * them, and they are not transcribed -- the same decision `solver_mna.h` and
54 * `solver_mam_ag.h` record.
55 *
56 * THE REFERENCE'S OWN QUIRKS, REPRODUCED. `XN` is initialised to zeros and never
57 * assigned by either the inner analyzer or the closed wrapper, so the per-class
58 * throughput column is zero however the model is solved; the station
59 * throughputs in `TN` are the real ones. The inner analyzer's `try/catch` around
60 * the ETAQA departure process, and the closed wrapper's around the whole inner
61 * call, are the reference's control flow and not defensive additions: the first
62 * falls back to the scaled service process, the second to a bisection step
63 * downwards.
64 *
65 * ARITHMETIC. Double (or real) only, for the reasons `solver_mam_basic.h` lists:
66 * the fixed point stops on a tolerance, MMAP[K]/PH[K]/1 runs the ADDA doubling
67 * iteration, and both ETAQA departure processes static_assert on transcendental
68 * arithmetic.
69 */
70
71#include <algorithm>
72#include <cmath>
73#include <limits>
74#include <map>
75#include <string>
76#include <utility>
77#include <vector>
78
79#include "line/api/da/da_fpi.h"
94#include "line/solvers/mam/solver_mam_bmap.h" // mam_detect_mmck
96#include "line/util/error.h"
98#include "line/util/matrix.h"
99
100namespace line {
101namespace mam {
102
103/**
104 * The `options.config` fields the MMAP decomposition reads on top of
105 * `MamOptions`.
106 *
107 * Neither is a SolverMAM option: `etaqa_trunc` is defaulted by
108 * `solver_mam_analyzer.m` before the dispatch and `fj_sync_q_len` by
109 * `solver_mam_traffic_mmap.m` itself, so a caller cannot reach either through
110 * the solver's option surface. Kept out of `MamOptions` for that reason, as
111 * `MnaConfig` is.
112 */
114 /** `config.etaqa_trunc`, the ETAQA level truncation of the departure process. */
115 std::size_t etaqa_trunc = 8;
116 /** `config.fj_sync_q_len`, the synchronization queue at a join. */
117 std::size_t fj_sync_q_len = 2;
118};
119
120namespace basic_mmap_detail {
121
124
125/**
126 * The `PH`, `pie` and `D0` tables both MMAP analyzers build before the loop.
127 *
128 * `PH[i][r]` is the service process of class r at station i AFTER the
129 * reference's per-discipline rescaling (divided by the server count at FCFS,
130 * HOL and PS, left alone at INF and at a Source, whose entry is the ARRIVAL
131 * process the reference never overwrites), `svc[i][r]` is the same law as the
132 * (sigma, S) pair `MMAPPH1FCFS` consumes, and `known[i][r]` says whether the
133 * station serves the class at all.
134 *
135 * The NaN guard below is applied at EVERY station, where the reference applies
136 * it only inside its four rescaling branches. The difference is invisible: an
137 * entry it touches is one whose class the station never serves, whose
138 * throughput is therefore zero, so the reference's NaN and this port's mean of
139 * 1e8 both leave the product at zero -- the first through the terminal NaN
140 * sweep, the second directly.
141 *
142 * THE REFERENCE'S NaN GUARD IS INCONSISTENT, AND IS REPRODUCED AS WRITTEN. When
143 * `D0` comes back NaN -- the class is not served here -- it sets
144 * `D0 = -GlobalConstants.Immediate` (an IMMEDIATE service, rate 1e8) but
145 * `PH = map_exponential(GlobalConstants.Immediate)`, and `map_exponential` takes
146 * a MEAN, so that is a service of mean 1e8, the exact opposite. The two are read
147 * in different places -- `D0`/`pie` by the queue solver, `PH` only through
148 * `map_mean` in the utilization and surrogate-delay lines -- and every metric
149 * that reads `PH` multiplies it by a throughput that is identically zero on such
150 * a class, so the contradiction never reaches a reported number. Written the
151 * reference's way rather than tidied, because tidying it would change what
152 * MMAPPH1FCFS is handed.
153 */
154template <class T>
155struct MmapPhTable {
156 std::vector<std::vector<Map<T>>> PH;
157 std::vector<std::vector<PhService<T>>> svc;
158 std::vector<std::vector<bool>> known;
159};
160
161template <class T>
162MmapPhTable<T> mmap_ph_table(const qn::NetworkStruct<T>& L) {
163 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1);
164 const std::size_t M = L.nstations, K = L.nclasses;
165 const T imm = num_traits<T>::from_double(GlobalConstants::Immediate);
166 MmapPhTable<T> t;
167 t.PH.assign(M, std::vector<Map<T>>(K));
168 t.svc.assign(M, std::vector<PhService<T>>(K));
169 t.known.assign(M, std::vector<bool>(K, false));
170 for (std::size_t i = 0; i < M; ++i) {
171 const SchedStrategy sc = L.stations[i].sched;
172 // EVERY STATION IS FILLED, not only the ones with a branch. The
173 // reference's `PH = sn.proc` starts as the whole table and its station
174 // loop only OVERWRITES the entries it rescales, so a Source keeps its
175 // own ARRIVAL process there -- and both analyzers read it: `dec.mmap`'s
176 // trailing surrogate-delay block runs at every station, and the MMAP
177 // variant seeds DEP from PH at every station node.
178 // FCFS, HOL and PS are the disciplines the reference divides by the
179 // server count; INF is not (an infinite server has no queue to speed
180 // up), and neither is a Source.
181 const bool divide = (sc == SchedStrategy::FCFS || sc == SchedStrategy::HOL ||
182 sc == SchedStrategy::PS);
183 const double ns = L.stations[i].nservers;
184 for (std::size_t r = 0; r < K; ++r) {
185 if (!L.has_service_law(i, r) || !(L.rates(i, r) > zero)) {
186 t.PH[i][r] = map_exponential_mean(imm); // mean 1e8; see the struct note
187 t.svc[i][r].sigma.assign(1, one);
188 t.svc[i][r].S = Matrix<T>(1, 1, T(-imm));
189 continue;
190 }
191 Map<T> ph = lang::dist_to_map(L.service[i][r]);
192 if (divide && std::isfinite(ns) && ns > 0.0)
193 ph = map_scale(ph, T(map_mean(ph) / num_traits<T>::from_double(ns)));
194 t.PH[i][r] = ph;
195 t.svc[i][r].sigma = map_pie(ph);
196 t.svc[i][r].S = ph.D0;
197 t.known[i][r] = true;
198 }
199 }
200 return t;
201}
202
203/**
204 * The expected maximum of independent exponentials, by inclusion-exclusion.
205 *
206 * The reference writes it as
207 * sum_{p=0}^{n-1} (-1)^p sum(1 ./ sum(nchoosek(lambda, p+1), 2))
208 * i.e. the alternating sum over subsets of every size, which is the classical
209 * E[max] = sum_{S nonempty} (-1)^(|S|+1) / sum_{i in S} lambda_i. Enumerated
210 * here over bitmasks, which is the same set of subsets in the same signs; the
211 * cost is 2^n either way, and the reference's own nchoosek is what bounds n in
212 * practice. A join with more than 20 synchronized branches is refused by name
213 * rather than run into a 10^6-term sum.
214 */
215template <class T>
216T exp_max_mean(const std::vector<T>& rate) {
217 const std::size_t n = rate.size();
218 if (n > 20)
219 throw UnsupportedError(ErrorKind{"Fork"},
220 "solver_mam_basic_mmap: the join synchronizes " + std::to_string(n) +
221 " branches, and the reference's expected-maximum formula is an alternating sum over "
222 "all 2^n subsets of them; that is not evaluable at this width");
223 const T zero = num_traits<T>::from_int(0);
224 T acc = zero;
225 for (std::size_t mask = 1; mask < (std::size_t(1) << n); ++mask) {
226 T s = zero;
227 std::size_t bits = 0;
228 for (std::size_t i = 0; i < n; ++i)
229 if (mask & (std::size_t(1) << i)) {
230 s += rate[i];
231 ++bits;
232 }
233 if (!(s > zero)) continue;
234 const T term = T(num_traits<T>::from_int(1) / s);
235 if (bits % 2 == 1) acc += term;
236 else acc -= term;
237 }
238 return acc;
239}
240
241/** `mmap_compress(ARV{ind}, config)` under the arithmetic gate the tree uses. */
242template <class T>
243Mmap<T> compress_arrival(const Mmap<T>& m) {
244 if constexpr (num_traits<T>::has_transcendental) {
246 } else {
247 (void)m;
248 throw UnsupportedError(ErrorKind{"Arithmetic"},
249 "solver_mam_basic_mmap: the arrival superposition passed config.space_max and must be "
250 "compressed, which fits an APH(2) and needs transcendental arithmetic");
251 }
252}
253
254} // namespace basic_mmap_detail
255
256/**
257 * Port of `solver_mam_basic_mmap_inner.m`.
258 *
259 * @param L the refreshed struct
260 * @param opt the SolverMAM options; `tol` is the fixed point's iter_tol
261 * @param cfg the two `options.config` fields the analyzer defaults itself
262 * @param lambda per-CLASS surrogate arrival rate, the reference's `lambda`
263 * @param totiter out: the sweeps the fixed point took
264 */
265template <class T>
267 const MamOptions& opt, const MmapDecConfig& cfg,
268 const std::vector<T>& lambda,
269 std::size_t* totiter) {
270 if constexpr (!num_traits<T>::has_transcendental) {
271 (void)L; (void)opt; (void)cfg; (void)lambda; (void)totiter;
272 throw UnsupportedError(ErrorKind{"Arithmetic"},
273 "solver_mam_basic_mmap_inner: the departure-process fixed point stops on a tolerance, "
274 "MMAP[K]/PH[K]/1 runs the ADDA doubling iteration and the ETAQA departure process "
275 "needs transcendental arithmetic; rerun with --arith double or --arith real");
276 } else {
277 using namespace basic_mmap_detail;
278 using basic_detail::station_visits;
279 using basic_detail::truncate_renorm;
280 using basic_detail::zero_nans;
281 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1);
282 const std::size_t I = L.nof_nodes(), M = L.nstations, K = L.nclasses;
283 const T ftol = num_traits<T>::from_double(GlobalConstants::FineTol);
284
285 if (lambda.size() != K)
286 throw InputError("solver_mam_basic_mmap_inner: lambda is not indexed over the classes");
287
288 const Matrix<T> V = station_visits(L);
289 Matrix<T> S(M, K, zero);
290 for (std::size_t i = 0; i < M; ++i)
291 for (std::size_t r = 0; r < K; ++r)
292 if (!L.disabled[i][r] && L.rates(i, r) > zero) S(i, r) = T(one / L.rates(i, r));
293
294 const MmapPhTable<T> ph = mmap_ph_table(L);
297 tcfg.fj_sync_q_len = cfg.fj_sync_q_len;
298
299 Matrix<T> QN(M, K, zero), UN(M, K, zero), RN(M, K, zero), TN(M, K, zero);
300 // The Source's throughput is its declared rate and is set once, before the
301 // loop, exactly as the reference's pre-loop station switch does.
302 for (std::size_t i = 0; i < M; ++i)
303 if (L.stations[i].sched == SchedStrategy::EXT)
304 for (std::size_t r = 0; r < K; ++r)
305 TN(i, r) = L.disabled[i][r] ? zero : L.rates(i, r);
306
307 DepTable<T> DEP(I, std::vector<Map<T>>(K));
308 std::vector<bool> car_warned(M, false); // one carried-phase warning per station
309
310 auto sweep = [&](const std::vector<T>&,
311 std::size_t itnum) -> std::pair<std::vector<T>, std::vector<T>> {
312 // ---- the departure table, NODE-indexed --------------------------
313 if (itnum == 1) {
314 for (std::size_t ind = 0; ind < I; ++ind) {
315 const qn::NodeType ty = L.nodes[ind].nodetype;
316 const bool isfj = (ty == qn::NodeType::Fork || ty == qn::NodeType::Join);
317 if (L.nodes[ind].station != 0 && !isfj) {
318 const std::size_t ist = L.nodes[ind].station - 1;
319 for (std::size_t r = 0; r < K; ++r) {
320 if (V(ist, r) > zero && lambda[r] > zero)
321 DEP[ind][r] =
322 map_scale(ph.PH[ist][r], T(one / T(lambda[r] * V(ist, r))));
323 else
324 DEP[ind][r] = ph.PH[ist][r];
325 }
326 } else {
327 for (std::size_t r = 0; r < K; ++r)
328 DEP[ind][r] = map_exponential_mean(
329 lambda[r] > zero
330 ? T(one / lambda[r])
331 : T(one / num_traits<T>::from_double(GlobalConstants::Immediate)));
332 }
333 }
334 }
335
336 std::vector<Mmap<T>> ARV = solver_mam_traffic_mmap(L, DEP, tcfg, fj);
337
338 std::vector<T> xref(M * K, zero);
339 for (std::size_t i = 0; i < M; ++i)
340 for (std::size_t r = 0; r < K; ++r) xref[i * K + r] = QN(i, r);
341
342 // ---- one isolated-station solve per station ----------------------
343 for (std::size_t i = 0; i < M; ++i) {
344 const std::size_t ind = L.node_of_station(i + 1) - 1;
345 const qn::NodeType ty = L.nodes[ind].nodetype;
346 const SchedStrategy sc = L.stations[i].sched;
347 const double ns = L.stations[i].nservers;
348
349 if (ty == qn::NodeType::Join) {
350 // Zeroed here and rebuilt from the branch response times after
351 // the fixed point; the throughput is the surrogate rate.
352 for (std::size_t r = 0; r < K; ++r) {
353 TN(i, r) = lambda[r];
354 UN(i, r) = zero;
355 QN(i, r) = zero;
356 RN(i, r) = zero;
357 }
358 continue;
359 }
360 if (ty != qn::NodeType::Queue) {
361 if (sc == SchedStrategy::INF) {
362 if (ARV[ind].order() > 0) {
363 const std::vector<T> lam = mmap_lambda(ARV[ind]);
364 for (std::size_t r = 0; r < K; ++r) TN(i, r) = lam[r];
365 }
366 for (std::size_t r = 0; r < K; ++r)
367 if (TN(i, r) > zero) {
368 UN(i, r) = T(S(i, r) * TN(i, r));
369 QN(i, r) = T(TN(i, r) * S(i, r));
370 RN(i, r) = S(i, r);
371 }
372 }
373 // EXT: the throughput was pinned before the loop.
374 continue;
375 }
376 if (ARV[ind].order() == 0) continue;
377 if (ARV[ind].order() > tcfg.space_max) ARV[ind] = compress_arrival(ARV[ind]);
378
379 bool finiteCapUsed = false, exactStation = false;
380 std::vector<PhService<T>> sl;
381 for (std::size_t r = 0; r < K; ++r) sl.push_back(ph.svc[i][r]);
382
383 if (sc == SchedStrategy::FCFS || sc == SchedStrategy::HOL) {
384 if (std::isfinite(L.stations[i].cap)) {
385 const std::size_t capK =
386 static_cast<std::size_t>(std::llround(L.stations[i].cap));
387 T meanQ = zero, lossProb = zero;
388 const MmckDetection<T> det = mam_detect_mmck(L, i + 1, ARV[ind]);
389 if (det.isMmck) {
390 const std::vector<T> lam = mmap_lambda(ARV[ind]);
391 T lamTot = zero;
392 for (const T& v : lam)
393 if (!std::isnan(num_traits<T>::to_double(v))) lamTot += v;
395 lamTot, det.muRate, static_cast<unsigned>(std::llround(ns)),
396 static_cast<unsigned>(capK));
397 meanQ = ex.meanQueueLength;
398 lossProb = ex.lossProbability;
399 } else {
400 const basic_detail::TruncRenorm<T> tr = truncate_renorm(ARV[ind], sl, capK);
401 meanQ = tr.meanQ;
402 lossProb = tr.lossProb;
403 }
404 const std::vector<T> lam = mmap_lambda(ARV[ind]);
405 std::vector<T> eff(K, zero), Sact(K, zero);
406 T sumTN = zero;
407 for (std::size_t r = 0; r < K; ++r) {
408 const T inflow =
409 std::isnan(num_traits<T>::to_double(lam[r])) ? zero : lam[r];
410 eff[r] = T(inflow * T(one - lossProb));
411 // The PH was divided by the server count, so the actual
412 // per-class service mean multiplies it back.
413 Sact[r] = T(map_mean(ph.PH[i][r]) * num_traits<T>::from_double(ns));
414 sumTN += eff[r];
415 }
416 T Wq = zero;
417 if (sumTN > zero) {
418 T sw = zero;
419 for (std::size_t r = 0; r < K; ++r) {
420 const T c = T(eff[r] * Sact[r]);
421 if (!std::isnan(num_traits<T>::to_double(c))) sw += c;
422 }
423 const T w = T(T(meanQ / sumTN) - T(sw / sumTN));
424 Wq = (w > zero) ? w : zero;
425 }
426 for (std::size_t r = 0; r < K; ++r) {
427 TN(i, r) = eff[r];
428 UN(i, r) = T(TN(i, r) * map_mean(ph.PH[i][r]));
429 if (TN(i, r) > zero) {
430 RN(i, r) = T(Wq + Sact[r]);
431 QN(i, r) = T(TN(i, r) * RN(i, r));
432 } else {
433 RN(i, r) = zero;
434 QN(i, r) = zero;
435 }
436 }
437 finiteCapUsed = true;
438 } else {
439 const std::vector<T> lam = mmap_lambda(ARV[ind]);
440 T rho = zero;
441 for (std::size_t r = 0; r < K; ++r) {
442 const T u = T(lam[r] * map_mean(ph.PH[i][r]));
443 if (!std::isnan(num_traits<T>::to_double(u))) rho += u;
444 }
445 if (rho < T(one - ftol)) {
446 // A correlated single-class service is answered by the
447 // exact MAP/MAP/1 QBD, which carries the service phase
448 // across departures; MMAPPH1FCFS would discard it.
449 const bool corr =
450 (K == 1) && (ns == 1.0) && ph.known[i][0] &&
451 std::fabs(num_traits<T>::to_double(
452 map_acf(ph.PH[i][0], std::vector<unsigned>{1})[0])) >
453 GlobalConstants::CoarseTol;
454 // Correlated MAP services elsewhere: the exact MAP/MAP/c at one
455 // class, else each class's phase carried, warned at c > 1.
456 std::vector<bool> corrSvc(K, false);
457 if (!corr)
458 corrSvc = basic_detail::corr_service_classes(L, i, ph.PH[i], ph.known[i]);
459 const bool anyCorr =
460 std::find(corrSvc.begin(), corrSvc.end(), true) != corrSvc.end();
461 if (K == 1 && anyCorr && std::isfinite(ns) && ns > 1.0) {
462 try {
463 Map<T> arv;
464 arv.D0 = ARV[ind].D0;
465 arv.D1 = ARV[ind].Dc[0];
466 const Map<T> svcTrue = map_scale(
467 ph.PH[i][0],
468 T(map_mean(ph.PH[i][0]) * num_traits<T>::from_double(ns)));
469 QN(i, 0) = qsys::qsys_mapmapc(arv, svcTrue,
470 static_cast<unsigned>(std::llround(ns)),
471 static_cast<std::size_t>(500),
472 static_cast<std::size_t>(0))
473 .meanQueueLength;
474 exactStation = true;
475 } catch (const std::exception&) {
476 exactStation = false; // chain too large: carried surrogate below
477 }
478 }
479 if (anyCorr && !exactStation && !car_warned[i]) {
480 car_warned[i] = true;
481 basic_detail::warn_carried(L, i, corrSvc);
482 }
483 if (exactStation) {
484 // solved above
485 } else if (anyCorr) {
486 std::vector<Map<T>> svcK(ph.PH[i].begin(), ph.PH[i].begin() + K);
487 const qsys::MmapMap1Result<T> cr =
488 qsys::qsys_mmapmap1(ARV[ind], svcK, corrSvc);
489 for (std::size_t r = 0; r < K; ++r) QN(i, r) = cr.meanQueueLength[r];
490 } else if (corr) {
491 Map<T> arv;
492 arv.D0 = ARV[ind].D0;
493 arv.D1 = ARV[ind].Dc[0];
494 QN(i, 0) = qbd_mapmap1(arv, ph.PH[i][0]).QN;
495 } else {
496 const std::vector<T> m = mmapph1fcfs_ncmean(ARV[ind], sl);
497 for (std::size_t r = 0; r < K; ++r)
498 QN(i, r) = m[ARV[ind].classes() == 1 ? 0 : r];
499 }
500 } else {
501 // Bounded rather than left to diverge: an overloaded
502 // station holds its class's own population, or 1/FineTol
503 // when the class is open.
504 for (std::size_t r = 0; r < K; ++r)
505 QN(i, r) = std::isfinite(L.classes[r].population)
506 ? num_traits<T>::from_double(L.classes[r].population)
507 : T(one / ftol);
508 }
509 for (std::size_t r = 0; r < K; ++r) TN(i, r) = lam[r];
510 }
511 } else if (sc == SchedStrategy::PS) {
512 const std::vector<T> lam = mmap_lambda(ARV[ind]);
513 for (std::size_t r = 0; r < K; ++r) {
514 TN(i, r) = lam[r];
515 // S, NOT the server-count-scaled PH mean: the reference
516 // writes 1./sn.rates here and overwrites UN with the PH mean
517 // in the surrogate-delay block below, so this value only ever
518 // reaches the sharing denominator.
519 UN(i, r) = T(TN(i, r) * S(i, r));
520 }
521 T usum = zero;
522 for (std::size_t r = 0; r < K; ++r) usum += UN(i, r);
523 const T uden = (usum < T(one - ftol)) ? usum : T(one - ftol);
524 for (std::size_t r = 0; r < K; ++r) QN(i, r) = T(UN(i, r) / T(one - uden));
525 }
526
527 if (!finiteCapUsed) {
528 for (std::size_t r = 0; r < K; ++r) {
529 UN(i, r) = T(TN(i, r) * map_mean(ph.PH[i][r]));
530 // The jobs at the surrogate delay server the c-fold service
531 // speedup removed; an exact MAP/MAP/c station has no surrogate.
532 if (std::isfinite(ns) && !exactStation)
533 QN(i, r) = T(QN(i, r) + TN(i, r) *
534 T(map_mean(ph.PH[i][r]) *
536 num_traits<T>::from_double((ns - 1.0) / ns));
537 RN(i, r) = T(QN(i, r) / TN(i, r));
538 }
539 }
540 }
541
542 // ---- the departure processes for the next sweep -------------------
543 for (std::size_t i = 0; i < M; ++i) {
544 const std::size_t ind = L.node_of_station(i + 1) - 1;
545 const qn::NodeType ty = L.nodes[ind].nodetype;
546 const SchedStrategy sc = L.stations[i].sched;
547 if (ty == qn::NodeType::Join) {
548 for (std::size_t r = 0; r < K; ++r)
549 if (TN(i, r) > zero) DEP[ind][r] = map_exponential_mean(T(one / TN(i, r)));
550 continue;
551 }
552 if (ty != qn::NodeType::Queue || ARV[ind].order() == 0) continue;
553 const bool fcfs = (sc == SchedStrategy::FCFS || sc == SchedStrategy::HOL);
554 if (!fcfs && sc != SchedStrategy::PS) continue;
555
556 T rho = zero;
557 for (std::size_t r = 0; r < K; ++r) rho += UN(i, r);
558 for (std::size_t r = 0; r < K; ++r) {
559 const bool scalable = (V(i, r) > zero && lambda[r] > zero);
560 // The PS branch of the reference does nothing at all when the
561 // class does not flow through the station; the FCFS branch still
562 // recomputes the departure process and only skips the rescaling.
563 if (!fcfs && !scalable) continue;
564 const Mmap<T> A = mmap_hide_but(ARV[ind], r);
565 const Map<T>& Srv = ph.PH[i][r];
566 const std::size_t etaqa_sz =
567 (cfg.etaqa_trunc + 1) * A.order() * Srv.D0.rows();
568 Map<T> dep = Srv;
569 if (etaqa_sz <= tcfg.space_max && rho < T(one - ftol)) {
570 // The reference's own try/catch: an ETAQA truncation that
571 // fails to build falls back to the scaled service process.
572 try {
573 const Map<T> Am{A.D0, A.D1};
574 dep = map_normalize(fcfs ? qbd_depproc_etaqa(Am, Srv, cfg.etaqa_trunc)
575 : qbd_depproc_etaqa_ps(Am, Srv, cfg.etaqa_trunc));
576 } catch (const Error&) {
577 dep = Srv;
578 }
579 }
580 if (scalable) dep = map_scale(dep, T(one / T(lambda[r] * V(i, r))));
581 DEP[ind][r] = dep;
582 }
583 }
584
585 std::vector<T> xnew(M * K, zero);
586 for (std::size_t i = 0; i < M; ++i)
587 for (std::size_t r = 0; r < K; ++r) xnew[i * K + r] = QN(i, r);
588 return std::make_pair(xnew, xref);
589 };
590
592 fo.iter_max = static_cast<std::size_t>(opt.iter_max);
593 fo.iter_tol = opt.tol;
594 // `config.da_miniter = 3`: the legacy loop tested convergence only from the
595 // third sweep, and `config.da_norm` is the relative difference offset by
596 // FineTol so a zero reference entry does not divide by zero.
597 fo.miniter = 3;
598 fo.relative_norm = true;
599 fo.relative_eps = GlobalConstants::FineTol;
600 const da::FpiResult<T> fr = da::da_fpi<T>(sweep, std::vector<T>(M * K, zero), fo);
601 if (totiter) *totiter = fr.iterations;
602
603 // ---- the join, from the branch response times -------------------------
604 for (std::size_t j = 0; j < I; ++j) {
605 if (L.nodes[j].nodetype != qn::NodeType::Join) continue;
606 if (L.nodes[j].station == 0) continue;
607 const std::size_t jst = L.nodes[j].station - 1;
608 std::map<std::size_t, std::vector<std::size_t>> groups; // ordered, as unique() is
609 for (std::size_t b = 0; b < I; ++b) {
610 const std::size_t gid = fj.node_sync[j][b];
611 if (gid > 0) groups[gid].push_back(b);
612 }
613 for (std::size_t r = 0; r < K; ++r) {
614 if (!(TN(jst, r) > zero)) continue;
615 T syncDelay = zero, joinArrivalRate = zero;
616 for (const std::pair<const std::size_t, std::vector<std::size_t>>& g : groups) {
617 std::vector<T> branchRt, branchTput;
618 for (std::size_t b : g.second) {
619 if (L.nodes[b].station == 0) continue;
620 const std::size_t bst = L.nodes[b].station - 1;
621 if (!(RN(bst, r) > zero)) continue;
622 branchRt.push_back(RN(bst, r));
623 branchTput.push_back(TN(bst, r));
624 }
625 if (branchRt.size() < 2) continue;
626 std::vector<T> rate(branchRt.size(), zero);
627 T meanRt = zero;
628 for (std::size_t b = 0; b < branchRt.size(); ++b) {
629 rate[b] = T(one / branchRt[b]);
630 meanRt += branchRt[b];
631 }
632 meanRt /= num_traits<T>::from_int(static_cast<long>(branchRt.size()));
633 const T excess = T(exp_max_mean(rate) - meanRt);
634 if (excess > zero) syncDelay += excess;
635 for (const T& t : branchTput) joinArrivalRate += t;
636 }
637 RN(jst, r) = syncDelay;
638 QN(jst, r) = T(joinArrivalRate * syncDelay);
639 UN(jst, r) = zero;
640 }
641 }
642
644 out.Q = QN;
645 out.U = UN;
646 out.R = RN;
647 out.Tp = TN;
648 out.C.assign(K, zero);
649 for (std::size_t r = 0; r < K; ++r)
650 for (std::size_t i = 0; i < M; ++i) out.C[r] += RN(i, r);
651 // X is left at zero: the reference never assigns it. See the file header.
652 out.X.assign(K, zero);
653 zero_nans(out.Q);
654 zero_nans(out.U);
655 zero_nans(out.R);
656 zero_nans(out.Tp);
657 for (std::size_t r = 0; r < K; ++r)
658 if (std::isnan(num_traits<T>::to_double(out.C[r]))) out.C[r] = zero;
659 out.method = "dec.source.mmap";
660 out.iter = static_cast<int>(fr.iterations);
661 out.lG = 0.0;
662 return out;
663 } // if constexpr has_transcendental
664}
665
666/**
667 * Port of `solver_mam_basic_mmap_closed.m`: the per-class bisection on the
668 * surrogate arrival rate that makes the inner analyzer's queue lengths match the
669 * closed population.
670 */
671template <class T>
673 const MamOptions& opt, const MmapDecConfig& cfg,
674 std::size_t* totiter) {
675 if constexpr (!num_traits<T>::has_transcendental) {
676 (void)L; (void)opt; (void)cfg; (void)totiter;
677 throw UnsupportedError(ErrorKind{"Arithmetic"},
678 "solver_mam_basic_mmap_closed: the throughput bisection wraps the inner MMAP "
679 "decomposition, which needs transcendental arithmetic; rerun with --arith double or "
680 "--arith real");
681 } else {
682 using namespace basic_mmap_detail;
683 using basic_detail::zero_nans;
684 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1);
685 const std::size_t M = L.nstations, K = L.nclasses, C = L.nchains;
686
687 // REFERENCE INDEXING, CHECKED RATHER THAN ASSUMED, exactly as
688 // `solver_mna_closed` checks the same line: the terminal renormalization
689 // scales chain c's queue lengths to `sn.njobs(c)`, and `sn.njobs` is
690 // CLASS-indexed. That is only correct when each chain holds exactly one
691 // class; otherwise a chain would be scaled to another class's population,
692 // which is a wrong number with no symptom.
693 if (C != K)
694 throw UnsupportedError(ErrorKind{"MultiClass"},
695 "solver_mam_basic_mmap_closed: the reference renormalizes chain c's queue lengths with "
696 "the class-indexed sn.njobs(c), which is only correct when each chain holds exactly "
697 "one class; this model has " +
698 std::to_string(C) + " chains over " + std::to_string(K) + " classes");
699
700 // ---- the bisection bracket -------------------------------------------
701 // The upper bound is the SLOWEST rate the class meets at a finite-server
702 // station; with none, the reference falls back to the FASTEST rate over the
703 // infinite-server ones, and to 1 when the class is served nowhere.
704 std::vector<T> lambda_lb(K, zero), lambda_ub(K, zero);
705 for (std::size_t r = 0; r < K; ++r) {
706 bool any = false;
707 double best = 0.0;
708 for (std::size_t i = 0; i < M; ++i) {
709 if (!std::isfinite(L.stations[i].nservers)) continue;
710 if (L.disabled[i][r] || !(L.rates(i, r) > zero)) continue;
711 const double v = num_traits<T>::to_double(L.rates(i, r));
712 if (!any || v < best) { best = v; any = true; }
713 }
714 if (!any) {
715 for (std::size_t i = 0; i < M; ++i) {
716 if (std::isfinite(L.stations[i].nservers)) continue;
717 if (L.disabled[i][r] || !(L.rates(i, r) > zero)) continue;
718 const double v = num_traits<T>::to_double(L.rates(i, r));
719 if (!any || v > best) { best = v; any = true; }
720 }
721 }
722 lambda_ub[r] = any ? num_traits<T>::from_double(best) : one;
723 }
724 std::vector<T> lambda = lambda_ub;
725
726 std::vector<T> QNc(K, zero);
727 for (std::size_t r = 0; r < K; ++r)
728 // An open class contributes 0: only the closed populations gate the loop.
729 QNc[r] = std::isfinite(L.classes[r].population)
730 ? num_traits<T>::from_double(L.classes[r].population)
731 : zero;
732 std::vector<T> QN_chain(K, zero);
733
734 MamOptions inner = opt;
735 inner.iter_max = std::max(20, (opt.iter_max + 9) / 10);
736 // The reference caps the MMAP phase truncation at 16 here: the inner call is
737 // made once per bisection step, and the compression above that width is
738 // O(dim^3) for no accuracy the bisection can use.
739 if (inner.space_max > 16) inner.space_max = 16;
740
741 mva::MvaSolution<T> sol, last;
742 bool have_good = false, algorithm_ok = false;
743 const double bisect_tol = std::max(opt.tol, 1e-3);
744 int it_out = 0;
745
746 for (;;) {
747 double gap = 0.0;
748 for (std::size_t r = 0; r < K; ++r)
749 gap = std::max(gap, std::fabs(num_traits<T>::to_double(T(QN_chain[r] - QNc[r]))));
750 if (!(gap > bisect_tol) || it_out >= opt.iter_max) break;
751 // Wall-clock budget (options.timeout): the last completed pass is the
752 // interim solution, as the reference's `if it>0 && lineTimeoutExceeded`.
753 if (it_out > 0 && util::timeout_exceeded()) break;
754 ++it_out;
755 if (it_out > 1) {
756 bool bracket_collapsed = true;
757 for (std::size_t r = 0; r < K; ++r) {
758 if (!std::isfinite(L.classes[r].population) || !(QNc[r] > zero)) continue;
759 if (QN_chain[r] < QNc[r]) lambda_lb[r] = lambda[r];
760 else lambda_ub[r] = lambda[r];
761 lambda[r] = T(T(lambda_lb[r] + lambda_ub[r]) / num_traits<T>::from_int(2));
762 // Bisection can still refine class r only while its bracket is
763 // wider than the precision floor below which lambda cannot move
764 // any reported metric.
765 const double width =
766 num_traits<T>::to_double(T(lambda_ub[r] - lambda_lb[r]));
767 if (width > GlobalConstants::FineTol *
768 std::max(1.0, std::fabs(num_traits<T>::to_double(lambda_ub[r]))))
769 bracket_collapsed = false;
770 }
771 if (bracket_collapsed) {
772 --it_out;
773 break;
774 }
775 }
776
777 try {
778 std::size_t inner_iter = 0;
779 sol = solver_mam_basic_mmap_inner(L, inner, cfg, lambda, &inner_iter);
780 algorithm_ok = true;
781 } catch (const Error&) {
782 // The reference's own catch: the inner algorithm diverged (typically
783 // MMAPPH1FCFS under saturation). Every chain is treated as
784 // overloaded, so the next bisection step drops lambda.
785 algorithm_ok = false;
786 }
787
788 if (algorithm_ok) {
789 for (std::size_t r = 0; r < K; ++r) {
790 QN_chain[r] = zero;
791 for (std::size_t i = 0; i < M; ++i) QN_chain[r] += sol.Q(i, r);
792 if (!std::isfinite(num_traits<T>::to_double(QN_chain[r])))
793 QN_chain[r] = T(one / num_traits<T>::from_double(GlobalConstants::FineTol));
794 }
795 last = sol;
796 have_good = true;
797 } else {
798 for (std::size_t r = 0; r < K; ++r)
799 QN_chain[r] = T(one / num_traits<T>::from_double(GlobalConstants::FineTol));
800 }
801 }
802
803 // If the LAST trial diverged, fall back to the most recent successful one.
804 if (!algorithm_ok && have_good) sol = last;
805 if (sol.Q.rows() != M) {
806 // The loop never ran a trial: the initial gap was already inside the
807 // tolerance, which for a model of zero population is the honest answer.
808 sol.Q = Matrix<T>(M, K, zero);
809 sol.U = Matrix<T>(M, K, zero);
810 sol.R = Matrix<T>(M, K, zero);
811 sol.Tp = Matrix<T>(M, K, zero);
812 sol.C.assign(K, zero);
813 sol.X.assign(K, zero);
814 }
815
816 // ---- population redistribution within each chain ----------------------
817 for (std::size_t c = 0; c < C; ++c) {
818 if (!std::isfinite(L.classes[c].population)) continue;
819 T sumQ = zero;
820 for (std::size_t k : L.inchain[c])
821 for (std::size_t i = 0; i < M; ++i) sumQ += sol.Q(i, k - 1);
822 if (!(sumQ > zero)) continue;
823 const T Nc = num_traits<T>::from_double(L.classes[c].population);
824 for (std::size_t k : L.inchain[c])
825 for (std::size_t i = 0; i < M; ++i) sol.Q(i, k - 1) = T(Nc * sol.Q(i, k - 1) / sumQ);
826 }
827
828 // An infinite server's utilization IS its queue length.
829 for (std::size_t i = 0; i < M; ++i)
830 if (L.stations[i].sched == SchedStrategy::INF)
831 for (std::size_t r = 0; r < K; ++r) sol.U(i, r) = sol.Q(i, r);
832
833 sol.C.assign(K, zero);
834 for (std::size_t r = 0; r < K; ++r)
835 for (std::size_t i = 0; i < M; ++i) sol.C[r] += sol.R(i, r);
836 zero_nans(sol.Q);
837 zero_nans(sol.U);
838 zero_nans(sol.R);
839 zero_nans(sol.Tp);
840 for (std::size_t r = 0; r < K; ++r)
841 if (std::isnan(num_traits<T>::to_double(sol.C[r]))) sol.C[r] = zero;
842 sol.iter = it_out;
843 if (totiter) *totiter = static_cast<std::size_t>(it_out);
844 return sol;
845 } // if constexpr has_transcendental
846}
847
848/**
849 * Port of `solver_mam_basic_mmap.m`, the top-level dispatcher of the MMAP
850 * fork-join decomposition: an open model goes straight to the inner algorithm
851 * with the arrival rates its sources declare, a closed one through the
852 * bisection wrapper.
853 */
854template <class T>
856 const T zero = num_traits<T>::from_int(0);
857 MmapDecConfig cfg;
858 if (!L.is_open_model()) {
859 std::size_t iter = 0;
860 return solver_mam_basic_mmap_closed(L, opt, cfg, &iter);
861 }
862 // The chain's arrival rate is the total rate its classes are released at by
863 // the reference station of its first class; every class of the chain carries
864 // that same total, as the reference assigns it.
865 std::vector<T> lambda(L.nclasses, zero);
866 for (std::size_t c = 0; c < L.nchains; ++c) {
867 if (L.inchain[c].empty()) continue;
868 const std::size_t rs = L.classes[L.inchain[c][0] - 1].refstat - 1;
869 T tot = zero;
870 for (std::size_t k : L.inchain[c]) {
871 if (L.disabled[rs][k - 1]) continue;
872 const double v = num_traits<T>::to_double(L.rates(rs, k - 1));
873 if (!std::isfinite(v)) continue;
874 tot += L.rates(rs, k - 1);
875 }
876 for (std::size_t k : L.inchain[c]) lambda[k - 1] = tot;
877 }
878 std::size_t iter = 0;
879 return solver_mam_basic_mmap_inner(L, opt, cfg, lambda, &iter);
880}
881
882} // namespace mam
883} // namespace line
884
885#endif // LINE_SOLVERS_MAM_SOLVER_MAM_BASIC_MMAP_H
Base error for the multiprecision C++ port.
Definition error.h:73
InputError(const std::string &what)
Definition error.h:105
UnsupportedError(const std::string &what)
Definition error.h:119
A network plus its refreshed NetworkStruct.
std::size_t nof_nodes() const
std::vector< std::vector< Distrib< T > > > service
service[i][r], 0-based station and class; a disabled entry marks a pair never visited.
bool has_service_law(std::size_t i, std::size_t r) const
Does (station i, class r) have a service law an analyzer may convert?
std::vector< std::vector< bool > > disabled
std::vector< JobClass > classes
std::vector< Station< T > > stations
stations[k-1] is the k-th station
Matrix< T > rates
(nstations x nclasses) service rates and SCVs, with a PARALLEL disabled flag instead of MATLAB's NaN ...
std::vector< std::vector< std::size_t > > inchain
1-based class indices per chain
std::size_t node_of_station(std::size_t st) const
1-based node index of station st, 0 when the map has no entry.
std::vector< NodeDef > nodes
every node, in creation order
bool is_open_model() const
sn_is_open_model: EVERY class is open, which is not has_open_classes.
Damped fixed-point iteration, the shared driver of the decomposition algorithms.
What refreshProcessRepresentations and refreshLST compute FROM a distribution: the (D0,...
The exception types the port throws.
options.timeout: one wall-clock budget per top-level solve, on a per-THREAD deadline stack.
The option and result types SolverMAM shares with its analyzers.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
MAP constructors and structural transformations.
Dense matrix and non-owning view.
Compression of a marked MAP into a smaller representation, and the two M3A primitives it is built fro...
Marked MAP (MMAP) algebra: per-class rates, class probabilities, superposition, normalization and sca...
The MMAP[K]/PH[K]/1 FCFS queue: per-class mean number in system and per-class queue-length distributi...
FpiResult< T > da_fpi(const std::function< std::pair< std::vector< T >, std::vector< T > >(const std::vector< T > &, std::size_t)> &iterfun, const std::vector< T > &x0, const FpiOptions &options=FpiOptions())
Damped fixed-point iteration, the shared driver of the decomposition algorithms.
Definition da_fpi.h:102
mam::Map< T > dist_to_map(const Distrib< T > &d)
The (D0,D1) pair that reaches sn.proc.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
Definition lang_types.h:194
NodeType
Node kinds, with the values of MATLAB NodeType.
Definition lang_types.h:345
FjSyncMap sn_build_fj_sync_map(const qn::NetworkStruct< T > &sn)
sn_build_fj_sync_map.
std::vector< T > map_acf(const Map< T > &m, const std::vector< unsigned > &lags)
Autocorrelation coefficients of the inter-arrival times at the given lags,.
Definition map_moment.h:168
std::vector< T > mmapph1fcfs_ncmean(const Mmap< T > &arrival, const std::vector< PhService< T > > &svc)
Per-class mean number of customers in the system, BUTools' 'ncMoms', 1.
MmckDetection< T > mam_detect_mmck(const qn::NetworkStruct< T > &L, std::size_t ist, const Mmap< T > &arv)
Port of mam_detect_mmck.m: is the exact M/M/c/K closed form legitimate at this station?
@ MixtureOrder1
'default', 'mixture', 'mixture.order1'
std::vector< std::vector< Map< T > > > DepTable
DEP{i,r}, the departure process of class r from i in (D0,D1) form.
mva::MvaSolution< T > solver_mam_basic_mmap_inner(const qn::NetworkStruct< T > &L, const MamOptions &opt, const MmapDecConfig &cfg, const std::vector< T > &lambda, std::size_t *totiter)
Port of solver_mam_basic_mmap_inner.m.
TrafficConfig traffic_config(const MamOptions &opt)
The traffic step's view of SolverOptions('MAM').
std::vector< T > mmap_lambda(const Mmap< T > &m)
Alias kept for parity with the MATLAB name.
Mmap< T > mmap_hide_but(const Mmap< T > &in, std::size_t keep)
mmap_hide(m, setdiff(1:K, keep)): keep ONE mark, hide every other.
mva::MvaSolution< T > solver_mam_basic_mmap(const qn::NetworkStruct< T > &L, const MamOptions &opt)
Port of solver_mam_basic_mmap.m, the top-level dispatcher of the MMAP fork-join decomposition: an ope...
Map< T > qbd_depproc_etaqa(const Map< T > &arrival, const Map< T > &service, std::size_t n)
MAP descriptor of the departure process of a MAP/MAP/1-FCFS queue, ETAQA-truncated at level n (qbd_de...
QbdMapMap1Result< T > qbd_mapmap1(const Map< T > &arrival, const Map< T > &service_in, const T &util, std::size_t max_levels)
MAP/MAP/1 queue (qbd_mapmap1.m).
std::vector< Mmap< T > > solver_mam_traffic_mmap(const qn::NetworkStruct< T > &sn, const DepTable< T > &DEP, const TrafficConfig &config, const FjSyncMap &fjSyncMap)
Port of solver_mam_traffic_mmap.m, the fork-join aware traffic step.
T map_mean(const Map< T > &m)
Mean inter-arrival time, 1/lambda.
Definition map_moment.h:101
Map< T > qbd_depproc_etaqa_ps(const Map< T > &arrival, const Map< T > &service, std::size_t n)
MAP descriptor of the departure process of a MAP/MAP/1-PS queue, ETAQA-truncated at level n (qbd_depp...
Mmap< T > mmap_compress(const Mmap< T > &in, MmapCompressMethod method)
Compress an MMAP (mmap_compress.m).
Map< T > map_exponential_mean(const T &mean)
Poisson process with the given mean inter-arrival time (map_exponential.m).
Map< T > map_scale(const Map< T > &in, const T &new_mean)
Rescale time so that the mean inter-arrival time becomes new_mean.
mva::MvaSolution< T > solver_mam_basic_mmap_closed(const qn::NetworkStruct< T > &L, const MamOptions &opt, const MmapDecConfig &cfg, std::size_t *totiter)
Port of solver_mam_basic_mmap_closed.m: the per-class bisection on the surrogate arrival rate that ma...
std::vector< T > map_pie(const Map< T > &m)
Phase distribution seen by an arriving job, pie = pi D1 / (pi D1 e).
Definition map_moment.h:89
Map< T > map_normalize(const Map< T > &in)
Clamp negative off-diagonal entries of D0 and negative entries of D1 to zero, then rebuild the diagon...
MapPhcResult< T > qsys_mapmapc(const mam::Map< T > &arrival, const mam::Map< T > &service, unsigned c, std::size_t dist_size=500, std::size_t num_w_moms=3)
MAP/MAP/c FCFS with the service phase carried in start order, exactly.
MmckResult< T > qsys_mmck(const T &lambda, const T &mu, unsigned c, unsigned K)
Exact analysis of the M/M/c/K queue (truncated Erlang form).
Definition qsys_mmck.h:70
MmapMap1Result< T > qsys_mmapmap1(const mam::Mmap< T > &arrival, const std::vector< mam::Map< T > > &svc, std::vector< bool > carry=std::vector< bool >())
MMAP[K]/MAP[K]/1 FCFS with per-class carried service phases, exactly.
bool timeout_exceeded()
The checkpoint: true when the innermost budget has run out, marking it tripped.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51
A queueing network and its refreshed NetworkStruct.
Departure process of a MAP/MAP/1 queue: the ETAQA-truncated MAP descriptor under FCFS and under PS,...
The MAP/MAP/1 queue solved as a quasi-birth-death process.
The MAP/MAP/c FCFS queue whose service MAP is CARRIED in service-start order.
The MMAP[K]/MAP[K]/1 FCFS queue in which each class's service phase is CARRIED.
Exact analysis of the M/M/c/K queue (truncated Erlang form).
Port of solver_mam_basic.m, the dec.source analyzer and the default algorithm of SolverMAM.
The batch-arrival and batch-service queues of the MAM solver, and the two finite-capacity helpers sol...
Port of solver_mam_traffic.m and solver_mam_traffic_mmap.m: the traffic step of the dec....
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
Definition error.h:37
Options mirroring the fields MATLAB reads off the options struct.
Definition da_fpi.h:50
std::size_t iter_max
Definition da_fpi.h:51
std::size_t miniter
iterations before the stopping test applies
Definition da_fpi.h:54
double relative_eps
Definition da_fpi.h:72
bool relative_norm
config.da_norm, the increment norm.
Definition da_fpi.h:71
std::size_t iterations
Definition da_fpi.h:88
The MATLAB GlobalConstants, as reported by lineStart at its defaults.
Definition lang_types.h:822
sn_build_fj_sync_map: which incoming flows at a Join must be synchronized.
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 space_max
options.config.space_max: the order budget of the per-station arrival superposition,...
Definition mam_types.h:40
A MAP as the pair of matrices (D0, D1).
Definition map_moment.h:53
Matrix< T > D1
Definition map_moment.h:55
Matrix< T > D0
Definition map_moment.h:54
The options.config fields the MMAP decomposition reads on top of MamOptions.
std::size_t etaqa_trunc
config.etaqa_trunc, the ETAQA level truncation of the departure process.
std::size_t fj_sync_q_len
config.fj_sync_q_len, the synchronization queue at a join.
An MMAP: the underlying MAP plus the per-class arrival matrices.
Definition mmap_lambda.h:45
Matrix< T > D0
Definition mmap_lambda.h:46
Matrix< T > D1
Definition mmap_lambda.h:47
std::size_t order() const
Definition mmap_lambda.h:50
What mam_detect_mmck returns; muRate is meaningful only when isMmck.
The fields of options.config the traffic step reads.
std::size_t fj_sync_q_len
config.fj_sync_q_len, the join's synchronization queue; MATLAB's default.
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
Definition mva_types.h:97
std::vector< T > X
Definition mva_types.h:99
double lG
log of the normalizing constant, the reference's lG.
Definition mva_types.h:119
std::vector< T > C
Definition mva_types.h:99
Return value of qsys_mmapmap1, mirroring the MATLAB struct.
std::vector< T > meanQueueLength
E[N_k].
T meanQueueLength
L, mean number in system.
Definition qsys_mmck.h:45