LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_gig1_approx_kimura.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_KIMURA_H
6#define LINE_API_QSYS_GIG1_APPROX_KIMURA_H
7
8/**
9 * @file
10 * @ingroup api_qsys
11 * Kimura diffusion-interpolation approximation for the G/I/G/1 queue.
12 *
13 * Templated port of matlab/src/api/qsys/qsys_gig1_approx_kimura.m.
14 *
15 * Wq = rho (ca^2+cs^2) / (mu (1-rho) (1+ca^2)), W = Wq + 1/mu
16 *
17 * exact for M/M/1 and M/G/1.
18 *
19 * DIVERGENCE: jar/src/main/java/jline/api/qsys/Qsys_gig1_approx_kimura.java
20 * computes Wq = rho*(ca+cs)/mu/(1-rho)/(1+ca), i.e. it treats its arguments as
21 * already-squared coefficients of variation and never squares them. MATLAB is
22 * ground truth and squares, so this port squares. The two implementations
23 * disagree numerically whenever ca != 1 or cs != 1.
24 *
25 * Reference: Kimura, T. (1986). A two-moment approximation for the mean
26 * waiting time in the GI/G/s queue. Management Science 32(6), 751-763.
27 *
28 * Pure field arithmetic, exact for T = Rational.
29 */
30
32#include "line/num/number.h"
33
34namespace line {
35namespace qsys {
36
37/**
38 * @brief Kimura diffusion-interpolation approximation for the G/I/G/1 queue.
39 *
40 * @param lambda arrival rate
41 * @param mu service rate
42 * @param ca coefficient of variation of the interarrival time
43 * @param cs coefficient of variation of the service time
44 */
45template <class T>
46QsysResult<T> qsys_gig1_approx_kimura(const T& lambda, const T& mu, const T& ca, const T& cs) {
47 const T one = num_traits<T>::from_int(1);
48 const T rho = lambda / mu;
49 detail::require_no_pole(T(one - rho), "qsys_gig1_approx_kimura");
50 const T ca2 = num_pow_int(ca, 2);
51 const T cs2 = num_pow_int(cs, 2);
52 const T Wq = rho * (ca2 + cs2) / mu / (one - rho) / (one + ca2);
53 const T W = Wq + one / mu;
54 return {W, detail::rhohat_from_W(W, lambda)};
55}
56
57} // namespace qsys
58} // namespace line
59
60#endif // LINE_API_QSYS_GIG1_APPROX_KIMURA_H
QsysResult< T > qsys_gig1_approx_kimura(const T &lambda, const T &mu, const T &ca, const T &cs)
Kimura diffusion-interpolation approximation for the 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