LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
aoi_fcfs_dm1.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_FCFS_DM1_H
6
#define LINE_API_AOI_FCFS_DM1_H
7
8
/**
9
* @file
10
* @ingroup api_aoi
11
* Mean, variance and peak Age of Information of a D/M/1 FCFS queue.
12
*
13
* Templated port of matlab/src/api/aoi/aoi_fcfs_dm1.m, cross-checked against
14
* jar/src/main/java/jline/api/aoi/Aoi_fcfs_dm1.java (identical; both solve for
15
* sigma by a bracketed root search, MATLAB with fzero on [0.001, 0.999] and
16
* the JAR with bisection, which this port follows).
17
*
18
* sigma solves sigma = exp(-mu tau (1 - sigma)) in (0,1)
19
* E[D] = 1/(mu (1 - sigma))
20
* E[A] = tau/2 + E[D]
21
* E[Apeak] = tau + E[D]
22
* Var[A] = (E[D^2] - E[D]^2) + (sigma/(mu(1-sigma)))^2, E[D^2] = 2 E[D]^2
23
*
24
* from Inoue et al. (2019). With deterministic interarrivals the correlation
25
* term in the mean vanishes, which is why E[A] is simply E[Y^2]/(2E[Y]) + E[D].
26
*
27
* static_assert(num_traits<T>::has_transcendental) -- sigma is the root of a
28
* transcendental equation, so nothing downstream of it is in the field.
29
*
30
* The variance, as in the MATLAB source, is not the exact second moment of the
31
* AoI: it adds the system-delay variance to a squared sigma term rather than
32
* differentiating the AoI transform.
33
*/
34
35
#include "
line/api/aoi/aoi_types.h
"
36
#include "
line/num/number.h
"
37
38
namespace
line
{
39
namespace
aoi
{
40
41
/**
42
* @brief Mean, variance and peak Age of Information of a D/M/1 FCFS queue.
43
*
44
* @param tau deterministic interarrival time, > 0
45
* @param mu service rate, > 0
46
* @return [meanAoI, varAoI, peakAoI]
47
*/
48
template
<
class
T>
49
AoiResult<T>
aoi_fcfs_dm1
(
const
T& tau,
const
T& mu) {
50
static_assert
(
num_traits<T>::has_transcendental
,
51
"aoi_fcfs_dm1 requires transcendental arithmetic"
);
52
detail::require_positive(tau,
"aoi_fcfs_dm1"
,
"the interarrival time tau"
);
53
detail::require_positive(mu,
"aoi_fcfs_dm1"
,
"the service rate mu"
);
54
const
T one =
num_traits<T>::from_int
(1), two =
num_traits<T>::from_int
(2);
55
const
T lambda = one / tau;
56
const
T rho = lambda / mu;
57
detail::require_stable(rho,
"aoi_fcfs_dm1"
);
58
59
const
T sigma = detail::bisect<T>(
60
[&](
const
T& s) {
return
T(detail::num_exp(T(-mu * tau * (one - s))) - s); },
61
num_traits<T>::from_double
(0.001),
num_traits<T>::from_double
(0.999),
"aoi_fcfs_dm1"
);
62
63
const
T E_D = one / (mu * (one - sigma));
64
const
T meanAoI = tau / two + E_D;
65
const
T peakAoI = tau + E_D;
66
67
const
T E_D2 = two * E_D * E_D;
68
const
T Var_D = E_D2 - E_D * E_D;
69
const
T extra = sigma / (mu * (one - sigma));
70
T varAoI = Var_D + extra * extra;
71
if
(varAoI <
num_traits<T>::from_int
(0)) varAoI =
num_traits<T>::from_int
(0);
72
return
{meanAoI, varAoI, peakAoI};
73
}
74
75
}
// namespace aoi
76
}
// namespace line
77
78
#endif
// LINE_API_AOI_FCFS_DM1_H
aoi_types.h
Shared return types and arithmetic helpers for the templated Age of Information port.
line::aoi
Definition
aoi_dist2ph.h:53
line::aoi::aoi_fcfs_dm1
AoiResult< T > aoi_fcfs_dm1(const T &tau, const T &mu)
Mean, variance and peak Age of Information of a D/M/1 FCFS queue.
Definition
aoi_fcfs_dm1.h:49
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::aoi::AoiResult
[meanAoI, varAoI, peakAoI], mirroring jline.api.aoi.AoiResult.
Definition
aoi_types.h:45
line::num_traits
Definition
number.h:111
include
line
api
aoi
aoi_fcfs_dm1.h
Generated by
1.18.0