LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
qsys_gig1_approx_myskja2.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_QSYS_GIG1_APPROX_MYSKJA2_H
6
#define LINE_API_QSYS_QSYS_GIG1_APPROX_MYSKJA2_H
7
8
/**
9
* @file
10
* @ingroup api_qsys
11
* Myskja's enhanced third-moment approximation of the mean response time of a
12
* G/I/G/1 queue.
13
*
14
* Templated port of matlab/src/api/qsys/qsys_gig1_approx_myskja2.m.
15
*
16
* ra = (1+ca^2)/2, rs = (1+cs^2)/2, rho = lambda/mu
17
* theta = [ rho(qa-ra) - (qa-ra^2) ] / [ 2 rho (ra-1) ]
18
* d = (1+1/ra)(1-rs)(1-(q0/qa)^3)(1-rho^3)
19
* D = (rs-theta)^2 + (2 rs - 1 + d)(ra-1), clamped at 0
20
* W = (rho/(1-rho))/lambda [ rs + (1/rho)( sqrt(D) - (rs-theta) ) ]
21
*
22
* At ca = 1 the interpolation parameter theta is a 0/0 form, so the exact
23
* M/G/1 answer is returned instead; that is also the anchor the method
24
* interpolates from.
25
*
26
* ARITHMETIC. sqrt(D) and the cube of q0/qa make this transcendental (the cube
27
* alone would not, but the square root does), so the function is gated.
28
*
29
* MATLAB-vs-JAR. jline.api.qsys.Qsys_gig1_approx_myskja2 sets
30
* ra = (1+ca)/2, rs = (1+cs)/2 and branches on |ca-1| < 1e-8, i.e. it reads
31
* ca/cs as squared coefficients of variation, and in the M/G/1 branch it calls
32
* qsys_mg1 with sqrt(cs) rather than cs. MATLAB reads them as coefficients of
33
* variation throughout. The two disagree on every non-Markovian input; this
34
* port follows MATLAB.
35
*/
36
37
#include "
line/api/qsys/qsys_mg1.h
"
38
#include "
line/api/qsys/qsys_types.h
"
39
#include "
line/num/number.h
"
40
41
namespace
line
{
42
namespace
qsys
{
43
44
/**
45
* @brief Myskja's enhanced third-moment approximation of the mean response
46
* time of a G/I/G/1 queue.
47
*
48
* @param lambda arrival rate
49
* @param mu service rate
50
* @param ca coefficient of variation of the interarrival time
51
* @param cs coefficient of variation of the service time
52
* @param q0 smallest third relative moment for the given mean and SCV
53
* @param qa third relative moment E[A^3]/(6 E[A]^3) of the interarrival time
54
*/
55
template
<
class
T>
56
QsysResult<T>
qsys_gig1_approx_myskja2
(
const
T& lambda,
const
T& mu,
const
T& ca,
const
T& cs,
57
const
T& q0,
const
T& qa) {
58
static_assert
(
num_traits<T>::has_transcendental
,
59
"qsys_gig1_approx_myskja2 requires transcendental arithmetic"
);
60
const
T zero =
num_traits<T>::from_int
(0), one =
num_traits<T>::from_int
(1);
61
const
T two =
num_traits<T>::from_int
(2);
62
if
(
num_abs
(T(ca * ca - one)) < T(
num_traits<T>::from_double
(1e-8)))
63
return
qsys_mg1
(lambda, mu, cs);
// M/G/1 case: exact
64
65
const
T ra = (one + ca * ca) / two;
66
const
T rs = (one + cs * cs) / two;
67
const
T rho = lambda / mu;
68
detail::require_no_pole(T(one - rho),
"qsys_gig1_approx_myskja2"
);
69
const
T theta = (rho * (qa - ra) - (qa - ra * ra)) / (two * rho * (ra - one));
70
const
T d = (one + one / ra) * (one - rs) * (one -
num_pow_int
(T(q0 / qa), 3)) *
71
(one -
num_pow_int
(rho, 3));
72
T D =
num_pow_int
(T(rs - theta), 2) + (two * rs - one + d) * (ra - one);
73
if
(D < zero) D = zero;
// guard small negative values due to round-off
74
const
T W = (rho / (one - rho)) / lambda *
75
(rs + (one / rho) * (detail::num_sqrt(D) - (rs - theta)));
76
return
{W, detail::rhohat_from_W(W, lambda)};
77
}
78
79
}
// namespace qsys
80
}
// namespace line
81
82
#endif
// LINE_API_QSYS_QSYS_GIG1_APPROX_MYSKJA2_H
line::qsys
Definition
qsys_bmapm1.h:58
line::qsys::qsys_gig1_approx_myskja2
QsysResult< T > qsys_gig1_approx_myskja2(const T &lambda, const T &mu, const T &ca, const T &cs, const T &q0, const T &qa)
Myskja's enhanced third-moment approximation of the mean response time of a G/I/G/1 queue.
Definition
qsys_gig1_approx_myskja2.h:56
line::qsys::qsys_mg1
QsysResult< T > qsys_mg1(const T &lambda, const T &mu, const T &cs)
Exact mean response time of the M/G/1 queue (Pollaczek-Khinchine).
Definition
qsys_mg1.h:39
line
Definition
aoi_dist2ph.h:52
line::num_abs
T num_abs(const T &v)
Definition
number.h:172
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_mg1.h
Exact mean response time of the M/G/1 queue (Pollaczek-Khinchine).
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_myskja2.h
Generated by
1.18.0