LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
aoi_lcfsd_gim1.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_GIM1_H
6#define LINE_API_AOI_LCFSD_GIM1_H
7
8/**
9 * @file
10 * @ingroup api_aoi
11 * Mean and peak Age of Information of a GI/M/1 non-preemptive LCFS queue with
12 * discarding (LCFS-D, equivalently GI/M/1/2*).
13 *
14 * Templated port of matlab/src/api/aoi/aoi_lcfsd_gim1.m, cross-checked against
15 * jar/src/main/java/jline/api/aoi/Aoi_lcfsd_gim1.java (identical).
16 *
17 * sigma solves Y*(mu - mu sigma) = sigma in (0,1)
18 * E[S] = 1/mu, E[T_eff] = E[S](1 + sigma)
19 * E[A] = E[Y] + E[S](1 + sigma) + sigma E[S]/(1 + sigma)
20 * E[Apeak] = E[Y] + E[T_eff]
21 *
22 * from Inoue et al. (2019, Section VI) adapted to GI/M/1: an arriving update
23 * finds the server busy with probability sigma, and by memorylessness the
24 * remaining service is again exponential with rate mu.
25 *
26 * static_assert(num_traits<T>::has_transcendental) -- sigma is a bracketed
27 * root of a transcendental equation. Everything downstream of sigma is
28 * rational.
29 *
30 * MATLAB falls back to sigma = rho when fzero fails to bracket; this port
31 * instead reports the failure, since a silent substitution of the utilization
32 * for the busy probability changes the answer without saying so. MATLAB
33 * returns an empty LST handle, reported here as has_lst = false.
34 */
35
37#include "line/num/number.h"
38#include "line/util/error.h"
39
40namespace line {
41namespace aoi {
42
43/**
44 * @brief Mean and peak Age of Information of a GI/M/1 non-preemptive LCFS
45 * queue with discarding (LCFS-D, equivalently GI/M/1/2*).
46 *
47 * @param Y_lst LST of the interarrival time
48 * @param mu service rate, > 0
49 * @param E_Y mean interarrival time, > 0
50 * @return [meanAoI, peakAoI], no LST
51 */
52template <class T>
53AoiLstResult<T> aoi_lcfsd_gim1(const Lst<T>& Y_lst, const T& mu, const T& E_Y) {
55 "aoi_lcfsd_gim1 requires transcendental arithmetic");
56 detail::require_positive(mu, "aoi_lcfsd_gim1", "the service rate mu");
57 detail::require_positive(E_Y, "aoi_lcfsd_gim1", "the mean interarrival time E_Y");
58 if (!Y_lst) throw InputError("aoi_lcfsd_gim1: the interarrival LST must be callable");
59 const T one = num_traits<T>::from_int(1);
60 const T lambda = one / E_Y;
61 const T rho = lambda / mu;
62 detail::require_stable(rho, "aoi_lcfsd_gim1");
63
64 const T E_S = one / mu;
65 const T sigma = detail::gim1_sigma<T>(Y_lst, mu, "aoi_lcfsd_gim1");
66 const T E_T_eff = E_S + sigma * E_S;
67 const T meanAoI = E_Y + E_S * (one + sigma) + sigma * E_S / (one + sigma);
68 const T peakAoI = E_Y + E_T_eff;
69 return {meanAoI, peakAoI, Lst<T>(), false};
70}
71
72} // namespace aoi
73} // namespace line
74
75#endif // LINE_API_AOI_LCFSD_GIM1_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.
AoiLstResult< T > aoi_lcfsd_gim1(const Lst< T > &Y_lst, const T &mu, const T &E_Y)
Mean and peak Age of Information of a GI/M/1 non-preemptive LCFS queue with discarding (LCFS-D,...
std::function< T(const T &)> Lst
A Laplace-Stieltjes transform evaluated at real arguments.
Definition aoi_types.h:41
Number-type abstraction for the templated API port.
[meanAoI, lstAoI, peakAoI], mirroring jline.api.aoi.AoiLstResult.
Definition aoi_types.h:58