LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
aoi_lcfspr_md1.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_MD1_H
6#define LINE_API_AOI_LCFSPR_MD1_H
7
8/**
9 * @file
10 * @ingroup api_aoi
11 * Mean, variance and peak Age of Information of an M/D/1 preemptive LCFS queue.
12 *
13 * Templated port of matlab/src/api/aoi/aoi_lcfspr_md1.m, cross-checked against
14 * jar/src/main/java/jline/api/aoi/Aoi_lcfspr_md1.java (identical).
15 *
16 * E[A] = exp(lambda d)/lambda
17 * E[Apeak] = d + exp(lambda d)/lambda
18 * Var[A] = (exp(2 lambda d) - 2 lambda d exp(lambda d))/lambda^2
19 *
20 * from Inoue et al. (2019, Section IV). Under preemption an update is
21 * delivered only if no arrival occurs during its service, which happens with
22 * probability exp(-lambda d); the reciprocal of that probability is the
23 * exp(lambda d) in the mean and peak age. The moments follow from the M/GI/1
24 * preemptive transform A*(s) = f(s)/(s + f(s)), f(s) = lambda H*(s+lambda).
25 *
26 * static_assert(num_traits<T>::has_transcendental) -- the exp in all three.
27 */
28
30#include "line/num/number.h"
31
32namespace line {
33namespace aoi {
34
35/**
36 * @brief Mean, variance and peak Age of Information of an M/D/1 preemptive
37 * LCFS queue.
38 *
39 * @param lambda arrival rate, > 0
40 * @param d deterministic service time, > 0
41 * @return [meanAoI, varAoI, peakAoI]
42 */
43template <class T>
44AoiResult<T> aoi_lcfspr_md1(const T& lambda, const T& d) {
46 "aoi_lcfspr_md1 requires transcendental arithmetic");
47 detail::require_positive(lambda, "aoi_lcfspr_md1", "the arrival rate lambda");
48 detail::require_positive(d, "aoi_lcfspr_md1", "the service time d");
49 const T one = num_traits<T>::from_int(1);
50 const T rho = lambda * d;
51 detail::require_stable(rho, "aoi_lcfspr_md1");
52
53 const T two = num_traits<T>::from_int(2);
54 const T e = detail::num_exp(T(lambda * d));
55 const T meanAoI = e / lambda;
56 const T peakAoI = d + e / lambda;
57 const T varAoI = (e * e - two * lambda * d * e) / (lambda * lambda);
58 return {meanAoI, varAoI, peakAoI};
59}
60
61} // namespace aoi
62} // namespace line
63
64#endif // LINE_API_AOI_LCFSPR_MD1_H
Shared return types and arithmetic helpers for the templated Age of Information port.
AoiResult< T > aoi_lcfspr_md1(const T &lambda, const T &d)
Mean, variance and peak Age of Information of an M/D/1 preemptive LCFS queue.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
Number-type abstraction for the templated API port.
[meanAoI, varAoI, peakAoI], mirroring jline.api.aoi.AoiResult.
Definition aoi_types.h:45