LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
qsys_gig1_approx_whitt.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_WHITT_H
6
#define LINE_API_QSYS_GIG1_APPROX_WHITT_H
7
8
/**
9
* @file
10
* @ingroup api_qsys
11
* Whitt's approximation of the G/G/1 mean response time.
12
*
13
* Port of `qsys_gig1_approx_whitt` in
14
* python/line_solver/api/qsys/approximations.py. PYTHON-ONLY, and its own
15
* docstring says so: there is no `qsys_gig1_approx_whitt.m`.
16
*
17
* It is the QNA single-server formula of Whitt, BSTJ 62(9), 1983, eqs.
18
* (44)-(45): the Kingman diffusion form `Lq = rho^2 (ca^2 + cs^2) / (2 (1 - rho))`
19
* multiplied by the correction factor
20
*
21
* g = exp(-2 (1-rho) (1-ca^2)^2 / (3 rho (ca^2 + cs^2))) if ca^2 < 1,
22
* g = 1 if ca^2 >= 1.
23
*
24
* For ca^2 < 1 it is the Kraemer and Langenbach-Belz factor whatever cs^2 is;
25
* for ca^2 >= 1 QNA drops the KLB refinement ("Performance of the QNA", BSTJ
26
* 62(9), 1983, Table I: QNA is KLB when ca^2 < 1 and slightly greater when
27
* ca^2 > 1). The branch depends on ca^2 alone: the former four-arm version keyed
28
* it on cs^2 as well, leaving g = 1 for regular arrivals with bursty service and
29
* using KLB's ca^2 > 1 factor for bursty arrivals with regular service, neither
30
* of which is QNA.
31
*
32
* An unstable queue returns an infinite response time and a unit utilization
33
* rather than dividing by a non-positive `1 - rho`.
34
*
35
* ARITHMETIC: transcendental (phi is an exponential).
36
*/
37
38
#include <cmath>
39
#include <limits>
40
41
#include "
line/api/qsys/qsys_types.h
"
42
#include "
line/num/number.h
"
43
44
namespace
line
{
45
namespace
qsys
{
46
47
/**
48
* @brief Whitt's approximation of the G/G/1 mean response time.
49
*
50
* @param lambda arrival rate
51
* @param mu service rate
52
* @param ca coefficient of variation of the interarrival time
53
* @param cs coefficient of variation of the service time
54
*/
55
template
<
class
T>
56
QsysResult<T>
qsys_gig1_approx_whitt
(
const
T& lambda,
const
T& mu,
const
T& ca,
const
T& cs) {
57
static_assert
(
num_traits<T>::has_transcendental
,
58
"qsys_gig1_approx_whitt needs exp() for the correction factor"
);
59
const
T one =
num_traits<T>::from_int
(1);
60
const
T two =
num_traits<T>::from_int
(2);
61
const
T three =
num_traits<T>::from_int
(3);
62
const
T rho = lambda / mu;
63
if
(!(
num_traits<T>::to_double
(one - rho) > 0.0)) {
64
// Unstable: the queue has no stationary response time, and the
65
// reference reports that rather than dividing.
66
return
{
num_traits<T>::from_double
(std::numeric_limits<double>::infinity()), one};
67
}
68
69
const
T ca2 = ca * ca, cs2 = cs * cs;
70
const
double
ca2d =
num_traits<T>::to_double
(ca2);
71
T phi = one;
72
if
(ca2d < 1.0) {
73
const
T e = T(-two * (one - rho) * (one - ca2) * (one - ca2) / (three * rho * (ca2 + cs2)));
74
phi =
num_traits<T>::from_double
(std::exp(
num_traits<T>::to_double
(e)));
75
}
76
// ca^2 >= 1: g = 1 and this is the Kingman diffusion form.
77
78
const
T Lq = T(phi * rho * rho * (ca2 + cs2) / (two * (one - rho)));
79
const
T L = T(Lq + rho);
80
const
T W = T(L / lambda);
81
return
{W, detail::rhohat_from_W(W, lambda)};
82
}
83
84
}
// namespace qsys
85
}
// namespace line
86
87
#endif
// LINE_API_QSYS_GIG1_APPROX_WHITT_H
line::qsys
Definition
qsys_bmapm1.h:58
line::qsys::qsys_gig1_approx_whitt
QsysResult< T > qsys_gig1_approx_whitt(const T &lambda, const T &mu, const T &ca, const T &cs)
Whitt's approximation of the G/G/1 mean response time.
Definition
qsys_gig1_approx_whitt.h:56
line
Conservation laws of a layered queueing network, enumerated from its structure.
Definition
aoi_dist2ph.h:51
number.h
Number-type abstraction for the templated API port.
qsys_types.h
Shared return type and arithmetic helpers for the templated qsys port.
line::num_traits
Definition
number.h:123
line::qsys::QsysResult
Return value of the qsys family, mirroring MATLAB's [W,rhohat] and the JAR's Ret.qsys.
Definition
qsys_types.h:38
include
line
api
qsys
qsys_gig1_approx_whitt.h
Generated by
1.18.0