LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
aoi_lcfspr_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_LCFSPR_GIM1_H
6
#define LINE_API_AOI_LCFSPR_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
* preemptive LCFS queue.
13
*
14
* Templated port of matlab/src/api/aoi/aoi_lcfspr_gim1.m, cross-checked
15
* against jar/src/main/java/jline/api/aoi/Aoi_lcfspr_gim1.java (identical).
16
*
17
* E[A] = lambda E[Y^2]/2 + 1/mu
18
* q = P(S < Y) = 1 - Y*(mu)
19
* E[S|succ] = (1/mu + Y*'(mu) - Y*(mu)/mu) / q
20
* E[Apeak] = E[S|succ] + 1/(lambda q)
21
* A*(s) = mu/(s + mu) * lambda (1 - Y*(s))/s
22
*
23
* With memoryless service the age is the backward recurrence time of the
24
* arrivals plus an independent Exp(mu); the old E[Y] + 1/mu and Y*(s) mu/(s+mu)
25
* hold only for Poisson arrivals (general age formula of Inoue et al. 2019).
26
*
27
* static_assert(num_traits<T>::has_transcendental) -- MATLAB's
28
* finite-difference derivative of Y* at mu. The mean is rational in E_Y, E_Y2
29
* and mu and is exact; the transform is exact wherever Y* is.
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
* preemptive LCFS queue.
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_lcfspr_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_lcfspr_gim1 requires transcendental arithmetic"
);
53
detail::require_positive(mu,
"aoi_lcfspr_gim1"
,
"the service rate mu"
);
54
detail::require_positive(E_Y,
"aoi_lcfspr_gim1"
,
"the mean interarrival time E_Y"
);
55
if
(!Y_lst)
throw
InputError
(
"aoi_lcfspr_gim1: the interarrival LST must be callable"
);
56
if
(E_Y2 < E_Y * E_Y)
throw
InputError
(
"aoi_lcfspr_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_lcfspr_gim1"
);
61
62
const
T meanAoI = lambda * E_Y2 / two + one / mu;
63
const
T dYstar = detail::lst_derivative<T>(Y_lst, mu);
64
const
T q = one - Y_lst(mu);
65
if
(q ==
num_traits<T>::from_int
(0))
66
throw
NumericError
(
"aoi_lcfspr_gim1: Y*(mu) = 1, no update ever completes"
);
67
const
T ES_succ = (one / mu + dYstar - Y_lst(mu) / mu) / q;
68
const
T peakAoI = ES_succ + one / (lambda * q);
69
70
Lst<T>
lstAoI = [Y_lst, mu, lambda, one](
const
T& s) {
71
if
(
num_traits<T>::to_double
(s < T(0) ? T(-s) : s) < 1e-12)
72
return
one;
// removable singularity: lambda (1 - Y*(s))/s -> 1
73
return
T((mu / (s + mu)) * lambda * (one - Y_lst(s)) / s);
74
};
75
return
{meanAoI, peakAoI, lstAoI,
true
};
76
}
77
78
}
// namespace aoi
79
}
// namespace line
80
81
#endif
// LINE_API_AOI_LCFSPR_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
line::NumericError::NumericError
NumericError(const std::string &what)
Definition
error.h:45
error.h
The exception types the port throws.
line::aoi
Definition
aoi_dist2ph.h:53
line::aoi::aoi_lcfspr_gim1
AoiLstResult< T > aoi_lcfspr_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 preemptive LCFS queue.
Definition
aoi_lcfspr_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_lcfspr_gim1.h
Generated by
1.18.0