1function [meanAoI, lstAoI, peakAoI] = aoi_lcfspr_mgi1(lambda, H_lst, E_H, E_H2)
2%AOI_LCFSPR_MGI1 Mean AoI and LST
for M/GI/1 preemptive LCFS queue
4% [meanAoI, lstAoI, peakAoI] = aoi_lcfspr_mgi1(lambda, H_lst, E_H, E_H2)
6% Computes
the Age of Information metrics
for an M/GI/1 queue with
7% preemptive Last-Come First-Served (LCFS-PR) discipline.
9% In LCFS-PR, when a
new update arrives, it preempts
the current update
10% in service (
if any). This ensures
the freshest update
is always served.
13% lambda (
double): Arrival rate (Poisson arrivals)
14% H_lst (function_handle): LST of service time, @(s) -> complex
15% E_H (double): Mean service time (first moment)
16% E_H2 (double): Second moment of service time (for reference)
19% meanAoI (double): Mean (average) Age of Information
20% lstAoI (function_handle): LST of AoI distribution
21% peakAoI (double): Mean Peak Age of Information
23% Formulas (from Inoue et al., IEEE Trans. IT, 2019, Section IV):
24% For preemptive LCFS,
the AoI simplifies significantly:
25% E[A] = E[Y] + E[H] = 1/lambda + E[H]
26% E[Apeak] = -H*(lambda)
'/H*(lambda) + 1/(lambda*H*(lambda))
28% LST of AoI: A*(s) = (lambda/(s+lambda)) * H*(s)
29% This is the convolution of exponential interarrival and service time.
32% Y. Inoue, H. Masuyama, T. Takine, T. Tanaka, "A General Formula for
33% the Stationary Distribution of the Age of Information and Its
34% Application to Single-Server Queues," IEEE Trans. Information Theory,
35% vol. 65, no. 12, pp. 8305-8324, 2019.
37% See also: aoi_fcfs_mgi1, aoi_lcfspr_mm1, aoi_lcfspr_gim1
39% Copyright (c) 2012-2026, Imperial College London
44 line_error(mfilename, 'Arrival rate lambda must be positive
');
47 line_error(mfilename, 'Mean service time E_H must be positive
');
50% Compute utilization (for reference; preemptive LCFS still requires rho < 1)
54 line_error(mfilename, 'System unstable: rho = lambda*E_H = %.4f >= 1', rho);
57% Mean interarrival time
60% Mean AoI
for preemptive LCFS (Proposition 3)
64% Mean Peak AoI (exact)
65% Success probability per arrival q =
P(S < Y) = H*(lambda);
66% E[S|success] = -H*
'(lambda)/H*(lambda);
67% E[Apeak] = E[S|success] + 1/(lambda*H*(lambda)) (validated by DES)
68hstep = 1e-6 * max(1, lambda);
69dHstar = (H_lst(lambda + hstep) - H_lst(lambda - hstep)) / (2 * hstep);
70peakAoI = -dHstar / H_lst(lambda) + 1 / (lambda * H_lst(lambda));
72% LST of AoI for preemptive LCFS
73% A*(s) = (lambda / (s + lambda)) * H*(s)
74% This is the product of exponential interarrival LST and service LST
75lstAoI = @(s) (lambda ./ (s + lambda)) .* H_lst(s);