LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
qsys_gigk_approx.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_GIGK_APPROX_H
6
#define LINE_API_QSYS_GIGK_APPROX_H
7
8
/**
9
* @file
10
* @ingroup api_qsys
11
* Default G/I/G/k approximation of the mean response time.
12
*
13
* Templated port of matlab/src/api/qsys/qsys_gigk_approx.m, cross-checked
14
* against jar/src/main/java/jline/api/qsys/Qsys_gigk_approx.java (identical;
15
* the JAR is careful to write (k+1)/2.0 so the exponent stays a real, as in
16
* MATLAB).
17
*
18
* rho = lambda/(mu k)
19
* alpha = (rho^k+rho)/2 if rho > 0.7
20
* alpha = rho^((k+1)/2) otherwise
21
* W = (alpha/mu)(1/(1-rho))(ca^2+cs^2)/(2k) + 1/mu
22
*
23
* The low-load branch raises rho to a half-integer power whenever k is even,
24
* which is a genuine transcendental, so the function requires
25
* num_traits<T>::has_transcendental and cannot be instantiated at exact
26
* arithmetic. Gating is at function level rather than per branch, since the
27
* branch is chosen at run time.
28
*/
29
30
#include "
line/api/qsys/qsys_types.h
"
31
#include "
line/num/number.h
"
32
#include "
line/util/error.h
"
33
34
namespace
line
{
35
namespace
qsys
{
36
37
/**
38
* @brief Default G/I/G/k approximation of the mean response time.
39
*
40
* @param lambda arrival rate
41
* @param mu service rate of a single server
42
* @param ca coefficient of variation of the interarrival time
43
* @param cs coefficient of variation of the service time
44
* @param k number of servers, k >= 1
45
*/
46
template
<
class
T>
47
QsysResult<T>
qsys_gigk_approx
(
const
T& lambda,
const
T& mu,
const
T& ca,
const
T& cs,
unsigned
k) {
48
static_assert
(
num_traits<T>::has_transcendental
,
49
"qsys_gigk_approx requires transcendental arithmetic"
);
50
if
(k == 0)
throw
InputError
(
"qsys_gigk_approx: k must be at least 1"
);
51
const
T one =
num_traits<T>::from_int
(1);
52
const
T two =
num_traits<T>::from_int
(2);
53
const
T kT =
num_traits<T>::from_int
(
static_cast<
long
>
(k));
54
const
T rho = lambda / (mu * kT);
55
detail::require_no_pole(T(one - rho),
"qsys_gigk_approx"
);
56
T alpha;
57
if
(rho >
num_traits<T>::from_rational
(7, 10)) {
58
alpha = (
num_pow_int
(rho, k) + rho) / two;
59
}
else
{
60
alpha = detail::num_pow(rho,
num_traits<T>::from_rational
(
static_cast<
long
>
(k) + 1, 2));
61
}
62
const
T W = (alpha / mu) * (one / (one - rho)) * (
num_pow_int
(ca, 2) +
num_pow_int
(cs, 2)) /
63
(two * kT) +
64
one / mu;
65
return
{W, detail::rhohat_from_W(W, lambda)};
66
}
67
68
}
// namespace qsys
69
}
// namespace line
70
71
#endif
// LINE_API_QSYS_GIGK_APPROX_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
line::qsys
Definition
qsys_bmapm1.h:58
line::qsys::qsys_gigk_approx
QsysResult< T > qsys_gigk_approx(const T &lambda, const T &mu, const T &ca, const T &cs, unsigned k)
Default G/I/G/k approximation of the mean response time.
Definition
qsys_gigk_approx.h:47
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_gigk_approx.h
Generated by
1.18.0