LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
aoi_lcfss_mgi1.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_MGI1_H
6
#define LINE_API_AOI_LCFSS_MGI1_H
7
8
/**
9
* @file
10
* @ingroup api_aoi
11
* Mean Age of Information, its transform and the peak age of an M/GI/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_mgi1.m, cross-checked against
16
* jar/src/main/java/jline/api/aoi/Aoi_lcfss_mgi1.java (identical).
17
*
18
* Exact, Inoue et al. (2019, Section 3.3, NP-LCFS (D)), H* the service LST:
19
*
20
* E[A] = lambda E[H^2]/2 + ((1-rho)^2/(rho H*(lambda)) + 2) E[H] (eq. 70)
21
* E[Apeak] = E[H] + E[W] + 1/(lambda (2 - rho - H*(lambda)))
22
* E[W] = ((1 - H*(lambda))/lambda + H*'(lambda))/(2 - rho - H*(lambda))
23
* A*(s) = eq. (66)
24
*
25
* static_assert(num_traits<T>::has_transcendental) -- MATLAB's
26
* finite-difference derivative of H* at lambda.
27
*/
28
29
#include "
line/api/aoi/aoi_types.h
"
30
#include "
line/num/number.h
"
31
#include "
line/util/error.h
"
32
33
namespace
line
{
34
namespace
aoi
{
35
36
/**
37
* @brief Mean Age of Information, its transform and the peak age of an M/GI/1
38
* non-preemptive LCFS queue with set-aside (LCFS-S).
39
*
40
* @param lambda arrival rate, > 0
41
* @param H_lst LST of the service time
42
* @param E_H mean service time, > 0
43
* @param E_H2 second raw moment of the service time, >= E_H^2
44
* @return [meanAoI, peakAoI, A*(s)]
45
*/
46
template
<
class
T>
47
AoiLstResult<T>
aoi_lcfss_mgi1
(
const
T& lambda,
const
Lst<T>
& H_lst,
const
T& E_H,
const
T& E_H2) {
48
static_assert
(
num_traits<T>::has_transcendental
,
49
"aoi_lcfss_mgi1 requires transcendental arithmetic"
);
50
detail::require_positive(lambda,
"aoi_lcfss_mgi1"
,
"the arrival rate lambda"
);
51
detail::require_positive(E_H,
"aoi_lcfss_mgi1"
,
"the mean service time E_H"
);
52
if
(!H_lst)
throw
InputError
(
"aoi_lcfss_mgi1: the service-time LST must be callable"
);
53
if
(E_H2 < E_H * E_H)
throw
InputError
(
"aoi_lcfss_mgi1: E_H2 must be at least E_H^2"
);
54
const
T one =
num_traits<T>::from_int
(1), two =
num_traits<T>::from_int
(2);
55
const
T rho = lambda * E_H;
56
detail::require_stable(rho,
"aoi_lcfss_mgi1"
);
57
58
const
T hL = H_lst(lambda);
59
const
T mdH = T(-detail::lst_derivative<T>(H_lst, lambda));
60
61
const
T meanAoI = lambda * E_H2 / two + ((one - rho) * (one - rho) / (rho * hL) + two) * E_H;
62
// informative arrivals: lambda_dagger = lambda (2 - rho - H*(lambda)); E[W] from eq. (98)
63
const
T den = two - rho - hL;
64
const
T E_W = ((one - hL) / lambda - mdH) / den;
65
const
T peakAoI = E_H + E_W + one / (lambda * den);
66
67
Lst<T>
lstAoI = [lambda, H_lst, E_H, rho, one](
const
T& s) {
68
if
(
num_traits<T>::to_double
(s < T(0) ? T(-s) : s) < 1e-12)
69
return
one;
// removable singularity of the residual-service LST
70
const
T Hs = H_lst(s);
71
const
T HsL = H_lst(T(s + lambda));
72
const
T hres_s = (one - Hs) / (s * E_H);
73
return
T(lambda / (s + lambda) * Hs *
74
(rho * hres_s + (one - rho) * (s + lambda) * (one - Hs + HsL) / (s + lambda * HsL)));
75
};
76
return
{meanAoI, peakAoI, lstAoI,
true
};
77
}
78
79
}
// namespace aoi
80
}
// namespace line
81
82
#endif
// LINE_API_AOI_LCFSS_MGI1_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_lcfss_mgi1
AoiLstResult< T > aoi_lcfss_mgi1(const T &lambda, const Lst< T > &H_lst, const T &E_H, const T &E_H2)
Mean Age of Information, its transform and the peak age of an M/GI/1 non-preemptive LCFS queue with s...
Definition
aoi_lcfss_mgi1.h:47
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_mgi1.h
Generated by
1.18.0