LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
aoi_lcfsd_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_LCFSD_GIM1_H
6
#define LINE_API_AOI_LCFSD_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 discarding (LCFS-D).
13
*
14
* Templated port of matlab/src/api/aoi/aoi_lcfsd_gim1.m, cross-checked against
15
* jar/src/main/java/jline/api/aoi/Aoi_lcfsd_gim1.java (identical).
16
*
17
* Exact, Inoue et al. (2019, Section 3.3, NP-LCFS (C)), G* the interarrival
18
* LST and rho = 1/(E_Y mu):
19
*
20
* E[A] = 1/mu + E[G^2]/(2E[G])
21
* + rho (-G*'(mu) + mu G*(mu) G*''(mu)/(1 + mu G*'(mu))) (eq. 69)
22
* E[Apeak] = P0 (E[G] + (1+G*(mu))/mu) + Pw (E[G]/(1-G*(mu)) + 1/mu)
23
* P0 = q/(q + G*(mu)), Pw = 1 - P0, q = 1 + mu G*'(mu)/(1-G*(mu)) (eq. 91)
24
* A*(s) = eq. (65)
25
*
26
* Discarding keeps at most one update waiting, so rho >= 1 is accepted.
27
*
28
* static_assert(num_traits<T>::has_transcendental) -- finite-difference first
29
* and second derivatives of G* at mu, with the steps MATLAB uses.
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 discarding (LCFS-D).
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_lcfsd_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_lcfsd_gim1 requires transcendental arithmetic"
);
53
detail::require_positive(mu,
"aoi_lcfsd_gim1"
,
"the service rate mu"
);
54
detail::require_positive(E_Y,
"aoi_lcfsd_gim1"
,
"the mean interarrival time E_Y"
);
55
if
(!Y_lst)
throw
InputError
(
"aoi_lcfsd_gim1: the interarrival LST must be callable"
);
56
if
(E_Y2 < E_Y * E_Y)
throw
InputError
(
"aoi_lcfsd_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
61
const
T gM = Y_lst(mu);
62
const
T mdY = T(-detail::lst_derivative<T>(Y_lst, mu));
63
const
T d2Y = detail::lst_second_derivative<T>(Y_lst, mu);
64
65
const
T meanAoI =
66
one / mu + E_Y2 / (two * E_Y) + rho * (mdY + mu * gM * d2Y / (one - mu * mdY));
67
68
// two-state chain "no wait"/"wait" of the informative updates (eq. 91)
69
const
T q = one - mu * mdY / (one - gM);
70
const
T P0 = q / (q + gM);
71
const
T Pw = gM / (q + gM);
72
const
T peakAoI = P0 * (E_Y + (one + gM) / mu) + Pw * (E_Y / (one - gM) + one / mu);
73
74
Lst<T>
lstAoI = [Y_lst, mu, E_Y, rho, gM, mdY, one](
const
T& s) {
75
if
(
num_traits<T>::to_double
(s < T(0) ? T(-s) : s) < 1e-12)
76
return
one;
// removable singularity of the residual-interarrival LST
77
const
T ys = s + mu;
78
const
T mdYs = T(-detail::lst_derivative<T>(Y_lst, ys));
79
const
T gres = (one - Y_lst(s)) / (s * E_Y);
80
return
T((gres + rho * mu / ys * (Y_lst(ys) - gM * (one - mu * mdYs) / (one - mu * mdY))) *
81
mu / ys);
82
};
83
return
{meanAoI, peakAoI, lstAoI,
true
};
84
}
85
86
}
// namespace aoi
87
}
// namespace line
88
89
#endif
// LINE_API_AOI_LCFSD_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::Lst
std::function< T(const T &)> Lst
A Laplace-Stieltjes transform evaluated at real arguments.
Definition
aoi_types.h:41
line::aoi::aoi_lcfsd_gim1
AoiLstResult< T > aoi_lcfsd_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 di...
Definition
aoi_lcfsd_gim1.h:50
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_lcfsd_gim1.h
Generated by
1.18.0