LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
aoi_lcfss_gim1.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_AOI_LCFSS_GIM1_H
6
#define LINE_API_AOI_LCFSS_GIM1_H
7
8
/**
9
* @file
10
* @ingroup api_aoi
11
* Mean Age of Information, its transform and the peak age of a GI/M/1
12
* non-preemptive LCFS queue with set-aside (LCFS-S), i.e. LCFS without
13
* discarding: older waiting updates are still served, after fresher ones.
14
*
15
* Templated port of matlab/src/api/aoi/aoi_lcfss_gim1.m, cross-checked against
16
* jar/src/main/java/jline/api/aoi/Aoi_lcfss_gim1.java (identical).
17
*
18
* Exact, Inoue et al. (2019, Section 3.3, NP-LCFS (D)), G* the interarrival
19
* LST, rho = 1/(E_Y mu) and gamma the root of G*(mu - mu x) = x:
20
*
21
* E[A] = 1/mu + E[G^2]/(2E[G]) + rho (-G*'(mu - mu gamma)) (eq. 71)
22
* E[Apeak] = P0 (E[G] + (1+G*(mu))/mu)
23
* + Pw (1/mu + (E[G] + G*'(mu) + (gamma - G*(mu))/(gamma mu))/(1 - G*(mu)))
24
* P0 = (1-gamma)/(1 - gamma G*(mu)), Pw = 1 - P0 (eqs. 100-103)
25
* A*(s) = eq. (67)
26
*
27
* static_assert(num_traits<T>::has_transcendental) -- gamma is a bracketed
28
* root of a transcendental equation and G*' is a finite difference. A
29
* bracketing failure is an error, never a gamma = rho fallback.
30
*/
31
32
#include "
line/api/aoi/aoi_types.h
"
33
#include "
line/num/number.h
"
34
#include "
line/util/error.h
"
35
36
namespace
line
{
37
namespace
aoi
{
38
39
/**
40
* @brief Mean Age of Information, its transform and the peak age of a GI/M/1
41
* non-preemptive LCFS queue with set-aside (LCFS-S).
42
*
43
* @param Y_lst LST of the interarrival time
44
* @param mu service rate, > 0
45
* @param E_Y mean interarrival time, > 0
46
* @param E_Y2 second moment of the interarrival time, >= E_Y^2
47
* @return [meanAoI, peakAoI, A*(s)]
48
*/
49
template
<
class
T>
50
AoiLstResult<T>
aoi_lcfss_gim1
(
const
Lst<T>
& Y_lst,
const
T& mu,
const
T& E_Y,
const
T& E_Y2) {
51
static_assert
(
num_traits<T>::has_transcendental
,
52
"aoi_lcfss_gim1 requires transcendental arithmetic"
);
53
detail::require_positive(mu,
"aoi_lcfss_gim1"
,
"the service rate mu"
);
54
detail::require_positive(E_Y,
"aoi_lcfss_gim1"
,
"the mean interarrival time E_Y"
);
55
if
(!Y_lst)
throw
InputError
(
"aoi_lcfss_gim1: the interarrival LST must be callable"
);
56
if
(E_Y2 < E_Y * E_Y)
throw
InputError
(
"aoi_lcfss_gim1: E_Y2 must be at least E_Y^2"
);
57
const
T one =
num_traits<T>::from_int
(1), two =
num_traits<T>::from_int
(2);
58
const
T lambda = one / E_Y;
59
const
T rho = lambda / mu;
60
detail::require_stable(rho,
"aoi_lcfss_gim1"
);
61
62
const
T gam = detail::gim1_sigma<T>(Y_lst, mu,
"aoi_lcfss_gim1"
);
63
const
T gM = Y_lst(mu);
64
const
T mdY = T(-detail::lst_derivative<T>(Y_lst, mu));
65
const
T mdYg = T(-detail::lst_derivative<T>(Y_lst, T(mu - mu * gam)));
66
67
const
T meanAoI = one / mu + E_Y2 / (two * E_Y) + rho * mdYg;
68
69
const
T P0 = (one - gam) / (one - gam * gM);
70
const
T Pw = gam * (one - gM) / (one - gam * gM);
71
const
T E0 = E_Y + (one + gM) / mu;
72
const
T Ew = one / mu + (E_Y - mdY + (gam - gM) / (gam * mu)) / (one - gM);
73
const
T peakAoI = P0 * E0 + Pw * Ew;
74
75
Lst<T>
lstAoI = [Y_lst, mu, E_Y, rho, gam, one](
const
T& s) {
76
if
(
num_traits<T>::to_double
(s < T(0) ? T(-s) : s) < 1e-12)
77
return
one;
// removable singularity of the residual-interarrival LST
78
const
T gres = (one - Y_lst(s)) / (s * E_Y);
79
return
T((gres + rho * (Y_lst(T(s + mu - mu * gam)) - gam) * mu / (s + mu)) * mu / (s + mu));
80
};
81
return
{meanAoI, peakAoI, lstAoI,
true
};
82
}
83
84
}
// namespace aoi
85
}
// namespace line
86
87
#endif
// LINE_API_AOI_LCFSS_GIM1_H
aoi_types.h
Shared return types and arithmetic helpers for the templated Age of Information port.
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
line::aoi
Definition
aoi_dist2ph.h:53
line::aoi::aoi_lcfss_gim1
AoiLstResult< T > aoi_lcfss_gim1(const Lst< T > &Y_lst, const T &mu, const T &E_Y, const T &E_Y2)
Mean Age of Information, its transform and the peak age of a GI/M/1 non-preemptive LCFS queue with se...
Definition
aoi_lcfss_gim1.h:50
line::aoi::Lst
std::function< T(const T &)> Lst
A Laplace-Stieltjes transform evaluated at real arguments.
Definition
aoi_types.h:41
line
Conservation laws of a layered queueing network, enumerated from its structure.
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::aoi::AoiLstResult
[meanAoI, lstAoI, peakAoI], mirroring jline.api.aoi.AoiLstResult.
Definition
aoi_types.h:59
line::num_traits
Definition
number.h:137
include
line
api
aoi
aoi_lcfss_gim1.h
Generated by
1.18.0