LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_gig1_approx_kobayashi.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_KOBAYASHI_H
6#define LINE_API_QSYS_GIG1_APPROX_KOBAYASHI_H
7
8/**
9 * @file
10 * @ingroup api_qsys
11 * Kobayashi diffusion approximation for the G/I/G/1 queue.
12 *
13 * Templated port of matlab/src/api/qsys/qsys_gig1_approx_kobayashi.m,
14 * cross-checked against
15 * jar/src/main/java/jline/api/qsys/Qsys_gig1_approx_kobayashi.java
16 * (identical).
17 *
18 * rhohat = exp(-2(1-rho)/(rho(ca^2 + cs^2/rho)))
19 * W = rhohat/(1-rhohat)/lambda
20 *
21 * The geometric fit carries an exp, so this requires transcendental
22 * arithmetic and cannot be instantiated at T = Rational.
23 */
24
26#include "line/num/number.h"
27
28namespace line {
29namespace qsys {
30
31/**
32 * @brief Kobayashi diffusion approximation for the 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_kobayashi(const T& lambda, const T& mu, const T& ca, const T& cs) {
42 "qsys_gig1_approx_kobayashi requires transcendental arithmetic");
43 const T one = num_traits<T>::from_int(1);
44 const T two = num_traits<T>::from_int(2);
45 const T rho = lambda / mu;
46 const T rhohat =
47 detail::num_exp(T(-two * (one - rho) / (rho * (num_pow_int(ca, 2) + num_pow_int(cs, 2) / rho))));
48 const T W = rhohat / (one - rhohat) / lambda;
49 return {W, rhohat};
50}
51
52} // namespace qsys
53} // namespace line
54
55#endif // LINE_API_QSYS_GIG1_APPROX_KOBAYASHI_H
QsysResult< T > qsys_gig1_approx_kobayashi(const T &lambda, const T &mu, const T &ca, const T &cs)
Kobayashi diffusion 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