LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
aoi_lcfspr_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_LCFSPR_MGI1_H
6
#define LINE_API_AOI_LCFSPR_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
* preemptive LCFS queue.
13
*
14
* Templated port of matlab/src/api/aoi/aoi_lcfspr_mgi1.m, cross-checked
15
* against jar/src/main/java/jline/api/aoi/Aoi_lcfspr_mgi1.java (identical).
16
*
17
* E[A] = 1/lambda + E[H]
18
* q = P(S < Y) = H*(lambda)
19
* E[Apeak] = -H*'(lambda)/H*(lambda) + 1/(lambda H*(lambda))
20
* A*(s) = lambda/(s + lambda) * H*(s)
21
*
22
* from Inoue et al. (2019, Section IV). Under preemption the age at delivery
23
* is the sum of an interarrival time and the successful service time, so the
24
* AoI transform is simply the product of the two transforms.
25
*
26
* static_assert(num_traits<T>::has_transcendental) -- the peak age uses
27
* MATLAB's finite-difference derivative of H* at lambda, with step
28
* 1e-6 max(1,lambda). The mean is rational in lambda and E_H and is exact;
29
* the transform is exact wherever H* 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 an M/GI/1
41
* preemptive LCFS queue.
42
*
43
* @param lambda arrival rate, > 0
44
* @param H_lst LST of the service time
45
* @param E_H mean service time, > 0
46
* @return [meanAoI, peakAoI, A*(s)]
47
*/
48
template
<
class
T>
49
AoiLstResult<T>
aoi_lcfspr_mgi1
(
const
T& lambda,
const
Lst<T>
& H_lst,
const
T& E_H) {
50
static_assert
(
num_traits<T>::has_transcendental
,
51
"aoi_lcfspr_mgi1 requires transcendental arithmetic"
);
52
detail::require_positive(lambda,
"aoi_lcfspr_mgi1"
,
"the arrival rate lambda"
);
53
detail::require_positive(E_H,
"aoi_lcfspr_mgi1"
,
"the mean service time E_H"
);
54
if
(!H_lst)
throw
InputError
(
"aoi_lcfspr_mgi1: the service-time LST must be callable"
);
55
const
T one =
num_traits<T>::from_int
(1);
56
const
T rho = lambda * E_H;
57
detail::require_stable(rho,
"aoi_lcfspr_mgi1"
);
58
59
const
T meanAoI = one / lambda + E_H;
60
const
T dHstar = detail::lst_derivative<T>(H_lst, lambda);
61
const
T Hlam = H_lst(lambda);
62
if
(Hlam ==
num_traits<T>::from_int
(0))
63
throw
NumericError
(
"aoi_lcfspr_mgi1: H*(lambda) = 0, no update ever completes"
);
64
const
T peakAoI = -dHstar / Hlam + one / (lambda * Hlam);
65
66
Lst<T>
lstAoI = [lambda, H_lst](
const
T& s) {
return
T(lambda / (s + lambda) * H_lst(s)); };
67
return
{meanAoI, peakAoI, lstAoI,
true
};
68
}
69
70
}
// namespace aoi
71
}
// namespace line
72
73
#endif
// LINE_API_AOI_LCFSPR_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
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::Lst
std::function< T(const T &)> Lst
A Laplace-Stieltjes transform evaluated at real arguments.
Definition
aoi_types.h:41
line::aoi::aoi_lcfspr_mgi1
AoiLstResult< T > aoi_lcfspr_mgi1(const T &lambda, const Lst< T > &H_lst, const T &E_H)
Mean Age of Information, its transform and the peak age of an M/GI/1 preemptive LCFS queue.
Definition
aoi_lcfspr_mgi1.h:49
line
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:58
line::num_traits
Definition
number.h:111
include
line
api
aoi
aoi_lcfspr_mgi1.h
Generated by
1.18.0