LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_mapmc.h File Reference

The MAP/M/c FCFS queue: c identical exponential servers of rate mu fed by a Markovian arrival process. More...

#include <cstddef>
#include <vector>
#include "line/api/mam/map_moment.h"
#include "line/api/mam/qbd_r.h"
#include "line/num/number.h"
#include "line/util/error.h"
#include "line/util/linalg.h"
#include "line/util/lu.h"
#include "line/util/matrix.h"
Include dependency graph for qsys_mapmc.h:

Go to the source code of this file.

Classes

struct  line::qsys::MapMcResult< T >
 Return value of qsys_mapmc and qsys_mapm1, mirroring the MATLAB struct. More...

Namespaces

namespace  line
namespace  line::qsys

Functions

template<class T>
MapMcResult< T > line::qsys::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.
template<class T>
MapMcResult< T > line::qsys::qsys_mapmc (const mam::Map< T > &arrival, const T &mu, unsigned c)
 qsys_mapmc with 100 materialized levels, the reference's maxNumComp scale.

Detailed Description

The MAP/M/c FCFS queue: c identical exponential servers of rate mu fed by a Markovian arrival process.

ALGORITHM, AND HOW IT DIFFERS FROM THE MATLAB REFERENCE. matlab/src/api/qsys/qsys_mapmc.m obtains these quantities by calling Q-MAM's Q_CT_MAP_M_C, which is not transcribed here. This port computes the SAME quantities from the port's own quasi-birth-death machinery, by building the QBD directly: the level is the number in system and the phase is the arrival phase, so for levels n >= c the process is level independent with

A0 = D1  (an arrival),  A1 = D0 - c mu I  (local),  A2 = c mu I  (a
completion),

while levels 0..c-1 form the boundary, where level k has downward rate k mu instead of c mu. R is the minimal non-negative solution of R^2 A2 + R A1 + A0 = 0, reached by cyclic reduction (qbd_fundmat called with B = A2, L = A1, F = A0), and pi_{c+k} = pi_c R^k. The boundary vectors pi_0..pi_c come from the level balance equations with the last one replaced by the normalization

sum_{n<c} pi_n e + pi_c (I - R)^-1 e = 1,

after which the number in system is

L = sum_{n<c} n pi_n e + pi_c ( c (I-R)^-1 + R (I-R)^-2 ) e

and the queued jobs are Lq = pi_c R (I-R)^-2 e. This is the same construction as qsys_phmc.h with the PH arrival replaced by a general MAP: a PH arrival is the special case D0 = T, D1 = (-T e) alpha. Utilization is lambda/(c mu), the reference's per-server convention.

meanWaitingTime is Lq/lambda by Little's law rather than the mean of the waiting-time PH representation that the reference extracts from Q-MAM; the two are the same quantity and the measurements below confirm they agree.

MEASURED AGREEMENT (MATLAB R2025a, T = double). Metric order is meanQueueLength / meanWaitingTime / meanSojournTime / utilization. Every relative difference below is limited by the REFERENCE, whose maxNumComp = 500 level truncation shows at the 1e-9 level; this port sums the geometric tail in closed form.

  • M/M/c collapse, qsys_mapmc(D0 = [-1.2], D1 = [1.2], mu = 1, c = 2): MATLAB 1.874999996296936 / 0.5624999998489539 / 1.562499999848954 / 0.6. The port returns the exact Erlang-C values 1.875 / 0.5625 / 1.5625 / 0.6 to 1e-15, so the differences against MATLAB are 2.0e-9, 2.7e-10 and 9.7e-11; the port matches the textbook formulas and MATLAB does not.
  • Correlated MMPP2 arrivals D0 = [-2.5 0.2; 0.1 -0.7], D1 = diag(2.3, 0.6) (lambda = 7/6), mu = 1, c = 2: MATLAB 3.121850390835039 / 1.675871772757968 / 2.675871772757968 / 0.5833333333333333; port 3.12185040294165 / 1.67587177394999 / 2.67587177394999 / 0.583333333333333. Relative differences 3.9e-9, 7.1e-10, 4.5e-10.
  • Erlang-2 arrivals D0 = [-4 4; 0 -4], D1 = [0 0; 4 0] (lambda = 2), mu = 1.5, c = 2: MATLAB 2.022056024561071 / 0.3443613471500779 / 1.011028013816745 / 0.6666666666666666; port 2.02205602772974 / 0.344361347198204 / 1.01102801386487 / 0.666666666666667. Relative differences 1.6e-9, 1.4e-10, 4.8e-11.
  • Three servers, correlated arrivals, mu = 0.5, c = 3 (rho = 7/9): MATLAB 9.441571472754669 / 6.092775552492106 / 8.092775552492107 / 0.7777777777777777; port 9.44157149906991 / 6.09277557063135 / 8.09277557063135 / 0.777777777777778. Relative differences 2.8e-9, 3.0e-9, 2.2e-9.

That the port and not the reference is the accurate one was checked without MATLAB: at c = 1 the same instance is also a MAP/MAP/1 queue with an exponential service MAP, and qsys_mapmap1 – a completely different route, cyclic reduction on the Kronecker-product QBD followed by the closed-form factorial moment – reproduces this function to 5e-16 on both the correlated and the Erlang-2 arrival instances. The test file carries that cross-check.

ARITHMETIC. Gated on num_traits<T>::has_transcendental: cyclic reduction drives R to a tolerance and never terminates in a finite number of field operations, exactly as in qbd_r.h and qsys_phmc.h. The boundary solve, the geometric-tail sums and the moment formulas that consume R are finite exact matrix algebra and add no error of their own.

Definition in file qsys_mapmc.h.