LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_gigk_rqt_gamma.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_GIGK_RQT_GAMMA_H
6#define LINE_API_QSYS_QSYS_GIGK_RQT_GAMMA_H
7
8/**
9 * @file
10 * @ingroup api_qsys
11 * Service variability parameter of the Robust Queueing Theory (RQT) framework.
12 *
13 * Templated port of matlab/src/api/qsys/qsys_gigk_rqt_gamma.m, cross-checked
14 * against jar/src/main/java/jline/api/qsys/Qsys_gigk_rqt_gamma.java.
15 *
16 * The adaptation of Section 7.1 turns the first two moments into an uncertainty
17 * set:
18 *
19 * Gamma_s = (2 (theta0 + theta1 sigma_s^2/k + theta2 Gamma_a^2 rho^2 k))^((a-1)/a)
20 * - Gamma_a k^((a-1)/a),
21 *
22 * with (theta0,theta1,theta2) regressed so that the worst-case system time of
23 * Theorem 3 approximates the MEAN system time of the corresponding stochastic
24 * queue. The arrival side needs no adaptation: Gamma_a = sigma_a for an external
25 * renewal stream. Since the last term cancels Gamma_a at alpha = 2, the
26 * adaptation acts on the sum Gamma_a + Gamma_s/k^(1/alpha) that Theorem 3 reads.
27 *
28 * THE FACTOR 2 IS NOT IN THE PRINTED FORMULA and is restored here. Section 7.1
29 * states that the functional form is motivated by Kingman's bound, which the
30 * alpha=2 bound of Theorem 3 reproduces when (Gamma_a+Gamma_s)^2 =
31 * 2(sigma_a^2+sigma_s^2); the published thetas are all near unity, i.e.
32 * corrections to that bound rather than a substitute for its factor 2. Dropping
33 * the factor puts M/M/1 about 40% BELOW its exact mean system time at rho = 0.9,
34 * contradicting the errors of at most 9.5% that Tables 2-3 report; restoring it
35 * gives +4.7%.
36 *
37 * CAUTION: the form is not dimensionally homogeneous, since theta0 is an
38 * additive constant on a scale of variances, so it is only valid in the time
39 * unit the regression was run in. It is evaluated here in units of the mean
40 * service time, 1/mu = 1, and converted back.
41 *
42 * ARITHMETIC. A real exponent makes this transcendental.
43 *
44 * Reference: C. Bandi, D. Bertsimas, N. Youssef (2015). Robust Queueing Theory.
45 * Operations Research 63(3), 676-700, Section 7.1 and Table 1.
46 */
47
48#include <cstddef>
49#include <string>
50
52#include "line/num/number.h"
53#include "line/util/error.h"
54
55namespace line {
56namespace qsys {
57
58/**
59 * @brief Service variability parameter of the Robust Queueing Theory (RQT)
60 * framework.
61 *
62 * @param rho traffic intensity lambda/(k mu)
63 * @param mu service rate of each server, which sets the time unit
64 * @param Gamma_a variability parameter of the arrival uncertainty set
65 * @param sigma_s standard deviation of the service time
66 * @param k number of servers
67 * @param alpha_a effective arrival tail coefficient in (1,2]
68 * @param regime adaptation regime of Table 1: "independent" (service
69 * distribution unknown), "normal" or "pareto"
70 */
71template <class T>
72T qsys_gigk_rqt_gamma(const T& rho, const T& mu, const T& Gamma_a, const T& sigma_s, std::size_t k,
73 const T& alpha_a, const std::string& regime = "independent") {
75 "qsys_gigk_rqt_gamma requires transcendental arithmetic");
76 double t0 = 0.0, t1 = 0.0, t2 = 0.0;
77 if (regime == "pareto") {
78 t0 = -0.05; t1 = 1.09; t2 = 1.11;
79 } else if (regime == "normal") {
80 t0 = -0.02; t1 = 1.03; t2 = 1.04;
81 } else if (regime == "independent" || regime == "default" || regime.empty()) {
82 t0 = -0.06; t1 = 1.07; t2 = 1.07;
83 } else {
84 throw InputError("qsys_gigk_rqt_gamma: unknown RQT adaptation regime: " + regime);
85 }
86 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1);
87 const T two = num_traits<T>::from_int(2);
88 const T kk = num_traits<T>::from_int(static_cast<int>(k));
89
90 // evaluate in units of the mean service time, then convert back
91 const T ga = Gamma_a * mu;
92 const T ss = sigma_s * mu;
93 const T e = (alpha_a - one) / alpha_a;
94 T b = two * (num_traits<T>::from_double(t0) + num_traits<T>::from_double(t1) * ss * ss / kk +
95 num_traits<T>::from_double(t2) * ga * ga * rho * rho * kk);
96 if (b < zero) b = zero;
97 const T gs = detail::num_pow(b, e) - ga * detail::num_pow(kk, e);
98 return gs / mu;
99}
100
101} // namespace qsys
102} // namespace line
103
104#endif // LINE_API_QSYS_QSYS_GIGK_RQT_GAMMA_H
InputError(const std::string &what)
Definition error.h:39
The exception types the port throws.
T qsys_gigk_rqt_gamma(const T &rho, const T &mu, const T &Gamma_a, const T &sigma_s, std::size_t k, const T &alpha_a, const std::string &regime="independent")
Service variability parameter of the Robust Queueing Theory (RQT) framework.
Number-type abstraction for the templated API port.
Shared return type and arithmetic helpers for the templated qsys port.