LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
qsys_gig1_approx_klb.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_KLB_H
6
#define LINE_API_QSYS_GIG1_APPROX_KLB_H
7
8
/**
9
* @file
10
* @ingroup api_qsys
11
* Kraemer and Langenbach-Belz approximation for the G/I/G/1 queue.
12
*
13
* Templated port of matlab/src/api/qsys/qsys_gig1_approx_klb.m, cross-checked
14
* against jar/src/main/java/jline/api/qsys/Qsys_gig1_approx_klb.java
15
* (identical).
16
*
17
* g = exp(-2(1-rho)(1-ca^2)^2/(3 rho (ca^2+cs^2))) if ca <= 1
18
* g = exp(-(1-rho)(ca^2-1)/(ca^2+4 cs^2)) otherwise
19
* W = 1/mu * ((rho/(1-rho)) (cs^2+ca^2)/2 g + 1)
20
*
21
* The correction factor g is an exponential, so the function requires
22
* transcendental arithmetic and cannot be instantiated at T = Rational, even
23
* though g degenerates to exactly 1 at ca = 1.
24
*/
25
26
#include "
line/api/qsys/qsys_types.h
"
27
#include "
line/num/number.h
"
28
29
namespace
line
{
30
namespace
qsys
{
31
32
/**
33
* @brief Kraemer and Langenbach-Belz approximation for the G/I/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
*/
40
template
<
class
T>
41
QsysResult<T>
qsys_gig1_approx_klb
(
const
T& lambda,
const
T& mu,
const
T& ca,
const
T& cs) {
42
static_assert
(
num_traits<T>::has_transcendental
,
43
"qsys_gig1_approx_klb requires transcendental arithmetic"
);
44
const
T one =
num_traits<T>::from_int
(1);
45
const
T two =
num_traits<T>::from_int
(2);
46
const
T three =
num_traits<T>::from_int
(3);
47
const
T four =
num_traits<T>::from_int
(4);
48
const
T rho = lambda / mu;
49
detail::require_no_pole(T(one - rho),
"qsys_gig1_approx_klb"
);
50
const
T ca2 =
num_pow_int
(ca, 2);
51
const
T cs2 =
num_pow_int
(cs, 2);
52
T g;
53
if
(ca <= one) {
54
g = detail::num_exp(T(-two * (one - rho) *
num_pow_int
(one - ca2, 2) / (three * rho * (ca2 + cs2))));
55
}
else
{
56
g = detail::num_exp(T(-(one - rho) * (ca2 - one) / (ca2 + four * cs2)));
57
}
58
const
T W = one / mu * ((rho / (one - rho)) * ((cs2 + ca2) / two) * g + one);
59
return
{W, detail::rhohat_from_W(W, lambda)};
60
}
61
62
}
// namespace qsys
63
}
// namespace line
64
65
#endif
// LINE_API_QSYS_GIG1_APPROX_KLB_H
line::qsys
Definition
qsys_bmapm1.h:58
line::qsys::qsys_gig1_approx_klb
QsysResult< T > qsys_gig1_approx_klb(const T &lambda, const T &mu, const T &ca, const T &cs)
Kraemer and Langenbach-Belz approximation for the G/I/G/1 queue.
Definition
qsys_gig1_approx_klb.h:41
line
Definition
aoi_dist2ph.h:52
line::num_pow_int
T num_pow_int(const T &base, unsigned e)
Integer power, valid in any field (no transcendental requirement).
Definition
number.h:192
number.h
Number-type abstraction for the templated API port.
qsys_types.h
Shared return type and arithmetic helpers for the templated qsys port.
line::num_traits
Definition
number.h:111
line::qsys::QsysResult
Return value of the qsys family, mirroring MATLAB's [W,rhohat] and the JAR's Ret.qsys.
Definition
qsys_types.h:37
include
line
api
qsys
qsys_gig1_approx_klb.h
Generated by
1.18.0