LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
aoi_lcfspr_mm1.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_MM1_H
6#define LINE_API_AOI_LCFSPR_MM1_H
7
8/**
9 * @file
10 * @ingroup api_aoi
11 * Mean, variance and peak Age of Information of an M/M/1 preemptive LCFS queue.
12 *
13 * Templated port of matlab/src/api/aoi/aoi_lcfspr_mm1.m, cross-checked against
14 * jar/src/main/java/jline/api/aoi/Aoi_lcfspr_mm1.java (identical).
15 *
16 * E[A] = (1/mu)(1 + 1/rho) = 1/mu + 1/lambda
17 * E[Apeak] = 1/(lambda+mu) + 1/lambda + 1/mu
18 * E[A^2] = 2 (1/lambda^2 + 1/(lambda mu) + 1/mu^2)
19 *
20 * from Inoue et al. (2019, Section IV). Rational throughout, hence exact in
21 * the field. The identity worth checking is E[A]_LCFSPR < E[A]_FCFS at every
22 * rho in (0,1): both sides are exact rationals, so the comparison is a
23 * theorem rather than a numerical observation.
24 */
25
27#include "line/num/number.h"
28
29namespace line {
30namespace aoi {
31
32/**
33 * @brief Mean, variance and peak Age of Information of an M/M/1 preemptive
34 * LCFS queue.
35 *
36 * @param lambda arrival rate, > 0
37 * @param mu service rate, > 0
38 * @return [meanAoI, varAoI, peakAoI]
39 */
40template <class T>
41AoiResult<T> aoi_lcfspr_mm1(const T& lambda, const T& mu) {
42 detail::require_positive(lambda, "aoi_lcfspr_mm1", "the arrival rate lambda");
43 detail::require_positive(mu, "aoi_lcfspr_mm1", "the service rate mu");
44 const T one = num_traits<T>::from_int(1), two = num_traits<T>::from_int(2);
45 const T rho = lambda / mu;
46 detail::require_stable(rho, "aoi_lcfspr_mm1");
47
48 const T meanAoI = (one / mu) * (one + one / rho);
49 const T peakAoI = one / (lambda + mu) + one / lambda + one / mu;
50 const T E_A2 = two * (one / (lambda * lambda) + one / (lambda * mu) + one / (mu * mu));
51 T varAoI = E_A2 - meanAoI * meanAoI;
52 if (varAoI < num_traits<T>::from_int(0)) varAoI = num_traits<T>::from_int(0);
53 return {meanAoI, varAoI, peakAoI};
54}
55
56} // namespace aoi
57} // namespace line
58
59#endif // LINE_API_AOI_LCFSPR_MM1_H
Shared return types and arithmetic helpers for the templated Age of Information port.
AoiResult< T > aoi_lcfspr_mm1(const T &lambda, const T &mu)
Mean, variance and peak Age of Information of an M/M/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