LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
aoi_lcfsd_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_LCFSD_MGI1_H
6#define LINE_API_AOI_LCFSD_MGI1_H
7
8/**
9 * @file
10 * @ingroup api_aoi
11 * Mean and peak Age of Information of an M/GI/1 non-preemptive LCFS queue with
12 * discarding (LCFS-D, equivalently M/GI/1/2*).
13 *
14 * Templated port of matlab/src/api/aoi/aoi_lcfsd_mgi1.m, cross-checked against
15 * jar/src/main/java/jline/api/aoi/Aoi_lcfsd_mgi1.java (identical).
16 *
17 * E[H_res] = E[H^2] / (2 E[H]) (residual service time)
18 * E[T_eff] = E[H] + rho E[H_res]
19 * E[A] = 1/lambda + E[H] + rho E[H^2]/(2 E[H]) + rho E[H]/(1+rho)
20 * E[Apeak] = 1/lambda + E[T_eff]
21 *
22 * from Inoue et al. (2019, Section VI).
23 *
24 * As with LCFS-S, the service-time LST is not used: only the first two moments
25 * enter, so the port takes them directly. Rational throughout, hence exact in
26 * the field. MATLAB returns an empty LST handle, reported here as
27 * has_lst = false.
28 */
29
31#include "line/num/number.h"
32#include "line/util/error.h"
33
34namespace line {
35namespace aoi {
36
37/**
38 * @brief Mean and peak Age of Information of an M/GI/1 non-preemptive LCFS
39 * queue with discarding (LCFS-D, equivalently M/GI/1/2*).
40 *
41 * @param lambda arrival rate, > 0
42 * @param E_H mean service time, > 0
43 * @param E_H2 second raw moment of the service time, >= E_H^2
44 * @return [meanAoI, peakAoI], no LST
45 */
46template <class T>
47AoiLstResult<T> aoi_lcfsd_mgi1(const T& lambda, const T& E_H, const T& E_H2) {
48 detail::require_positive(lambda, "aoi_lcfsd_mgi1", "the arrival rate lambda");
49 detail::require_positive(E_H, "aoi_lcfsd_mgi1", "the mean service time E_H");
50 if (E_H2 < E_H * E_H) throw InputError("aoi_lcfsd_mgi1: E_H2 must be at least E_H^2");
51 const T one = num_traits<T>::from_int(1), two = num_traits<T>::from_int(2);
52 const T rho = lambda * E_H;
53 detail::require_stable(rho, "aoi_lcfsd_mgi1");
54
55 const T E_Y = one / lambda;
56 const T E_H_res = E_H2 / (two * E_H);
57 const T E_T_eff = E_H + rho * E_H_res;
58
59 const T meanAoI = E_Y + E_H + rho * E_H2 / (two * E_H) + rho * E_H / (one + rho);
60 const T peakAoI = E_Y + E_T_eff;
61 return {meanAoI, peakAoI, Lst<T>(), false};
62}
63
64} // namespace aoi
65} // namespace line
66
67#endif // LINE_API_AOI_LCFSD_MGI1_H
Shared return types and arithmetic helpers for the templated Age of Information port.
InputError(const std::string &what)
Definition error.h:39
The exception types the port throws.
std::function< T(const T &)> Lst
A Laplace-Stieltjes transform evaluated at real arguments.
Definition aoi_types.h:41
AoiLstResult< T > aoi_lcfsd_mgi1(const T &lambda, const T &E_H, const T &E_H2)
Mean and peak Age of Information of an M/GI/1 non-preemptive LCFS queue with discarding (LCFS-D,...
Number-type abstraction for the templated API port.
[meanAoI, lstAoI, peakAoI], mirroring jline.api.aoi.AoiLstResult.
Definition aoi_types.h:58