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] = 1/lambda + d
17 * E[Apeak] = d + exp(lambda d)/lambda
18 * Var[A] = 1/lambda^2 (the service time is constant)
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 peak age.
24 *
25 * static_assert(num_traits<T>::has_transcendental) -- the exp in the peak age.
26 * The mean and the variance are rational and could be evaluated exactly, but
27 * the triple is returned as a unit, as in MATLAB.
28 */
29
31#include "line/num/number.h"
32
33namespace line {
34namespace aoi {
35
36/**
37 * @brief Mean, variance and peak Age of Information of an M/D/1 preemptive
38 * LCFS queue.
39 *
40 * @param lambda arrival rate, > 0
41 * @param d deterministic service time, > 0
42 * @return [meanAoI, varAoI, peakAoI]
43 */
44template <class T>
45AoiResult<T> aoi_lcfspr_md1(const T& lambda, const T& d) {
47 "aoi_lcfspr_md1 requires transcendental arithmetic");
48 detail::require_positive(lambda, "aoi_lcfspr_md1", "the arrival rate lambda");
49 detail::require_positive(d, "aoi_lcfspr_md1", "the service time d");
50 const T one = num_traits<T>::from_int(1);
51 const T rho = lambda * d;
52 detail::require_stable(rho, "aoi_lcfspr_md1");
53
54 const T meanAoI = one / lambda + d;
55 const T peakAoI = d + detail::num_exp(T(lambda * d)) / lambda;
56 const T varAoI = one / (lambda * lambda);
57 return {meanAoI, varAoI, peakAoI};
58}
59
60} // namespace aoi
61} // namespace line
62
63#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.
Number-type abstraction for the templated API port.
[meanAoI, varAoI, peakAoI], mirroring jline.api.aoi.AoiResult.
Definition aoi_types.h:45