LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_gig1_approx_marchal.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_GIG1_APPROX_MARCHAL_H
6#define LINE_API_QSYS_GIG1_APPROX_MARCHAL_H
7
8/**
9 * @file
10 * @ingroup api_qsys
11 * Marchal approximation of the mean response time of a G/I/G/1 queue.
12 *
13 * Templated port of matlab/src/api/qsys/qsys_gig1_approx_marchal.m,
14 * cross-checked against
15 * jar/src/main/java/jline/api/qsys/Qsys_gig1_approx_marchal.java (identical).
16 *
17 * W = rho/(1-rho) * (1+cs^2)/2/mu * (ca + rho^2 cs^2)/(1 + rho^2 cs^2) + 1/mu
18 *
19 * The numerator carries ca and not ca^2. That is what both MATLAB and the JAR
20 * compute, so the port reproduces it verbatim rather than "correcting" it to
21 * the published form. Pure field arithmetic, exact for T = Rational; it still
22 * reduces to M/M/1 at ca = cs = 1 because the correction ratio becomes one.
23 */
24
26#include "line/num/number.h"
27
28namespace line {
29namespace qsys {
30
31/**
32 * @brief Marchal approximation of the mean response time of a G/I/G/1 queue.
33 *
34 * @param lambda arrival rate
35 * @param mu service rate
36 * @param ca coefficient of variation of the interarrival time
37 * @param cs coefficient of variation of the service time
38 */
39template <class T>
40QsysResult<T> qsys_gig1_approx_marchal(const T& lambda, const T& mu, const T& ca, const T& cs) {
41 const T one = num_traits<T>::from_int(1);
42 const T two = num_traits<T>::from_int(2);
43 const T rho = lambda / mu;
44 detail::require_no_pole(T(one - rho), "qsys_gig1_approx_marchal");
45 const T Wmm1 = rho / (one - rho);
46 const T r2cs2 = num_pow_int(rho, 2) * num_pow_int(cs, 2);
47 const T W = Wmm1 * (one + num_pow_int(cs, 2)) / two / mu * (ca + r2cs2) / (one + r2cs2) + one / mu;
48 return {W, detail::rhohat_from_W(W, lambda)};
49}
50
51} // namespace qsys
52} // namespace line
53
54#endif // LINE_API_QSYS_GIG1_APPROX_MARCHAL_H
QsysResult< T > qsys_gig1_approx_marchal(const T &lambda, const T &mu, const T &ca, const T &cs)
Marchal approximation of the mean response time of a G/I/G/1 queue.
T num_pow_int(const T &base, unsigned e)
Integer power, valid in any field (no transcendental requirement).
Definition number.h:192
Number-type abstraction for the templated API port.
Shared return type and arithmetic helpers for the templated qsys port.
Return value of the qsys family, mirroring MATLAB's [W,rhohat] and the JAR's Ret.qsys.
Definition qsys_types.h:37