LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_gig1_ubnd_kingman.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_UBND_KINGMAN_H
6#define LINE_API_QSYS_GIG1_UBND_KINGMAN_H
7
8/**
9 * @file
10 * @ingroup api_qsys
11 * Kingman upper bound on the mean waiting time of a G/G/1 queue.
12 *
13 * Templated port of matlab/src/api/qsys/qsys_gig1_ubnd_kingman.m,
14 * cross-checked against
15 * jar/src/main/java/jline/api/qsys/Qsys_gig1_ubnd_kingman.java (identical).
16 *
17 * Wq <= lambda (sa^2 + ss^2)/(2(1-rho)), sa^2 = ca^2/lambda^2, ss^2 = cs^2/mu^2
18 * W = Wq + 1/mu
19 *
20 * Reference: Kingman, J.F.C. (1962). Some inequalities for the queue GI/G/1.
21 * Biometrika 49(3/4), 315-324.
22 *
23 * Pure field arithmetic, exact for T = Rational.
24 */
25
27#include "line/num/number.h"
28
29namespace line {
30namespace qsys {
31
32/**
33 * @brief Kingman upper bound on the mean waiting time of a G/G/1 queue.
34 *
35 * @param lambda arrival rate
36 * @param mu service rate
37 * @param ca coefficient of variation of the interarrival time
38 * @param cs coefficient of variation of the service time
39 */
40template <class T>
41QsysResult<T> qsys_gig1_ubnd_kingman(const T& lambda, const T& mu, const T& ca, const T& cs) {
42 const T one = num_traits<T>::from_int(1);
43 const T two = num_traits<T>::from_int(2);
44 const T rho = lambda / mu;
45 detail::require_no_pole(T(one - rho), "qsys_gig1_ubnd_kingman");
46 const T Wq = lambda *
47 (num_pow_int(ca, 2) / num_pow_int(lambda, 2) + num_pow_int(cs, 2) / num_pow_int(mu, 2)) /
48 (two * (one - rho));
49 const T W = Wq + one / mu;
50 return {W, detail::rhohat_from_W(W, lambda)};
51}
52
53} // namespace qsys
54} // namespace line
55
56#endif // LINE_API_QSYS_GIG1_UBND_KINGMAN_H
QsysResult< T > qsys_gig1_ubnd_kingman(const T &lambda, const T &mu, const T &ca, const T &cs)
Kingman upper bound on the mean waiting time of a G/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