LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
qsys_mapm1.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_API_QSYS_QSYS_MAPM1_H
6
#define LINE_API_QSYS_QSYS_MAPM1_H
7
8
/**
9
* @file
10
* @ingroup api_qsys
11
* The MAP/M/1 FCFS queue, the single-server case of MAP/M/c.
12
*
13
* ALGORITHM, AND HOW IT DIFFERS FROM THE MATLAB REFERENCE.
14
* matlab/src/api/qsys/qsys_mapm1.m is a one-line wrapper for qsys_mapmc with
15
* c = 1, which in turn calls Q-MAM's Q_CT_MAP_M_C, which is not transcribed
16
* here. This port keeps
17
* the same delegation and calls this port's own qsys_mapmc (see qsys_mapmc.h),
18
* which builds the quasi-birth-death process directly: at c = 1 the level
19
* blocks are A0 = D1, A1 = D0 - mu I, A2 = mu I with a single boundary level,
20
* and R comes from cyclic reduction.
21
* Different algorithm, same quantity.
22
*
23
* At c = 1 this is also exactly a MAP/MAP/1 queue with an exponential service
24
* MAP, so qsys_mapmap1(arrival, {[-mu], [mu]}) must return the same numbers by
25
* a completely different route (cyclic reduction on the Kronecker-product QBD
26
* rather than cyclic reduction on the arrival-phase QBD). That
27
* cross-check is one of the assertions in the test file, and holds to 1e-13.
28
*
29
* MEASURED AGREEMENT (MATLAB R2025a, T = double). Metric order is
30
* meanQueueLength / meanWaitingTime / meanSojournTime / utilization.
31
* - M/M/1 collapse, qsys_mapm1(D0 = [-2], D1 = [2], mu = 3): MATLAB
32
* 1.999999994584355 / 0.6666666665442794 / 0.9999999998776128 /
33
* 0.6666666666666666. This port returns the textbook 2 / 0.666666666666667
34
* / 1 / 0.666666666666667 to 1e-15, so the relative differences against
35
* MATLAB are 2.7e-9, 1.7e-10 and 1.2e-10. The residual is the reference's
36
* maxNumComp = 500 level truncation; the port sums the geometric tail in
37
* closed form and matches the exact formulas.
38
* - Correlated MMPP2 arrivals D0 = [-2.5 0.2; 0.1 -0.7], D1 = diag(2.3, 0.6)
39
* (lambda = 7/6), mu = 2: MATLAB 2.795385119831413 / 1.896044396731732 /
40
* 2.396044396731732 / 0.5833333333333333; port 2.79538513100956 /
41
* 1.89604439800819 / 2.39604439800819 / 0.583333333333333. Relative
42
* differences 4.0e-9, 6.7e-10, 5.3e-10.
43
* - Erlang-2 arrivals D0 = [-4 4; 0 -4], D1 = [0 0; 4 0] (lambda = 2),
44
* mu = 3: MATLAB 1.568729300352212 / 0.4510313188166638 /
45
* 0.7843646521499972 / 0.6666666666666666; port 1.56872930440884 /
46
* 0.451031318871088 / 0.784364652204421 / 0.666666666666667. Relative
47
* differences 2.6e-9, 1.2e-10, 6.9e-11.
48
*
49
* The cross-check against qsys_mapmap1 mentioned above was run on both
50
* non-Poisson instances and agrees to 5e-16 on meanQueueLength and
51
* meanWaitingTime, which identifies the 1e-9 residuals above as the
52
* reference's truncation rather than this port's error.
53
*
54
* ARITHMETIC. Gated on num_traits<T>::has_transcendental, inherited from
55
* qsys_mapmc: cyclic reduction drives R to a tolerance and never terminates in
56
* a finite number of field operations. See qbd_r.h.
57
*/
58
59
#include <cstddef>
60
#include <vector>
61
62
#include "
line/api/mam/map_moment.h
"
63
#include "
line/api/qsys/qsys_mapmc.h
"
64
#include "
line/num/number.h
"
65
66
namespace
line
{
67
namespace
qsys
{
68
69
/**
70
* MAP/M/1 by the matrix-geometric solution, i.e. qsys_mapmc at c = 1.
71
*
72
* @param arrival arrival MAP (D0, D1)
73
* @param mu exponential service rate
74
* @param dist_size how many entries of queueLengthDist to materialize
75
*/
76
template
<
class
T>
77
MapMcResult<T>
qsys_mapm1
(
const
mam::Map<T>
& arrival,
const
T& mu, std::size_t dist_size) {
78
static_assert
(
num_traits<T>::has_transcendental
,
79
"qsys_mapm1 requires transcendental arithmetic"
);
80
return
qsys_mapmc
(arrival, mu, 1u, dist_size);
81
}
82
83
/** qsys_mapm1 with 100 materialized levels. */
84
template
<
class
T>
85
MapMcResult<T>
qsys_mapm1
(
const
mam::Map<T>
& arrival,
const
T& mu) {
86
return
qsys_mapm1
(arrival, mu,
static_cast<
std::size_t
>
(100));
87
}
88
89
}
// namespace qsys
90
}
// namespace line
91
92
#endif
// LINE_API_QSYS_QSYS_MAPM1_H
map_moment.h
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
line::qsys
Definition
qsys_bmapm1.h:58
line::qsys::qsys_mapmc
MapMcResult< T > qsys_mapmc(const mam::Map< T > &arrival, const T &mu, unsigned c, std::size_t dist_size)
MAP/M/c by the matrix-geometric solution.
Definition
qsys_mapmc.h:120
line::qsys::qsys_mapm1
MapMcResult< T > qsys_mapm1(const mam::Map< T > &arrival, const T &mu, std::size_t dist_size)
MAP/M/1 by the matrix-geometric solution, i.e.
Definition
qsys_mapm1.h:77
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
qsys_mapmc.h
The MAP/M/c FCFS queue: c identical exponential servers of rate mu fed by a Markovian arrival process...
line::mam::Map
A MAP as the pair of matrices (D0, D1).
Definition
map_moment.h:53
line::num_traits
Definition
number.h:111
line::qsys::MapMcResult
Return value of qsys_mapmc and qsys_mapm1, mirroring the MATLAB struct.
Definition
qsys_mapmc.h:103
include
line
api
qsys
qsys_mapm1.h
Generated by
1.18.0