LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_gig1_approx_gelenbe.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_GELENBE_H
6#define LINE_API_QSYS_GIG1_APPROX_GELENBE_H
7
8/**
9 * @file
10 * @ingroup api_qsys
11 * Gelenbe diffusion approximation with instantaneous-return boundary.
12 *
13 * Templated port of matlab/src/api/qsys/qsys_gig1_approx_gelenbe.m.
14 *
15 * rhat = exp(-2(1-rho)/(rho ca^2 + cs^2))
16 * W = 1/(mu (1-rhat))
17 *
18 * DIVERGENCE: jar/src/main/java/jline/api/qsys/Qsys_gig1_approx_gelenbe.java
19 * computes rhat = exp(-2(1-rho)/(rho*ca + cs)), treating its arguments as
20 * already-squared coefficients of variation. MATLAB is ground truth and
21 * squares, so this port squares. The two disagree unless ca = cs = 1.
22 *
23 * Reference: Gelenbe, E. (1975). On approximate computer system models.
24 * Journal of the ACM 22(2), 261-269.
25 *
26 * The geometric fit carries an exp, so this requires transcendental
27 * arithmetic and cannot be instantiated at T = Rational.
28 */
29
31#include "line/num/number.h"
32
33namespace line {
34namespace qsys {
35
36/**
37 * @brief Gelenbe diffusion approximation with instantaneous-return boundary.
38 *
39 * @param lambda arrival rate
40 * @param mu service rate
41 * @param ca coefficient of variation of the interarrival time
42 * @param cs coefficient of variation of the service time
43 */
44template <class T>
45QsysResult<T> qsys_gig1_approx_gelenbe(const T& lambda, const T& mu, const T& ca, const T& cs) {
47 "qsys_gig1_approx_gelenbe requires transcendental arithmetic");
48 const T one = num_traits<T>::from_int(1);
49 const T two = num_traits<T>::from_int(2);
50 const T rho = lambda / mu;
51 const T rhat =
52 detail::num_exp(T(-two * (one - rho) / (rho * num_pow_int(ca, 2) + num_pow_int(cs, 2))));
53 const T W = one / (mu * (one - rhat));
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_GELENBE_H
QsysResult< T > qsys_gig1_approx_gelenbe(const T &lambda, const T &mu, const T &ca, const T &cs)
Gelenbe diffusion approximation with instantaneous-return boundary.
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