LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
aoi_lcfspr_mm1.m
1function [meanAoI, varAoI, peakAoI] = aoi_lcfspr_mm1(lambda, mu)
2%AOI_LCFSPR_MM1 Mean, variance, and peak AoI for M/M/1 preemptive LCFS queue
3%
4% [meanAoI, varAoI, peakAoI] = aoi_lcfspr_mm1(lambda, mu)
5%
6% Computes the Age of Information metrics for an M/M/1 queue with
7% preemptive Last-Come First-Served (LCFS-PR) discipline.
8%
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,
11% leading to lower AoI than FCFS.
12%
13% Parameters:
14% lambda (double): Arrival rate (Poisson arrivals)
15% mu (double): Service rate (exponential service)
16%
17% Returns:
18% meanAoI (double): Mean (average) Age of Information
19% varAoI (double): Variance of Age of Information
20% peakAoI (double): Mean Peak Age of Information
21%
22% Formulas (from Inoue et al., IEEE Trans. IT, 2019, Section IV):
23% Mean AoI: E[A] = (1/mu) * (1 + 1/rho)
24% Peak AoI: E[Apeak] = 1/mu + 1/lambda
25%
26% Note: LCFS-PR always achieves lower mean AoI than FCFS for M/M/1.
27%
28% Reference:
29% Y. Inoue, H. Masuyama, T. Takine, T. Tanaka, "A General Formula for
30% the Stationary Distribution of the Age of Information and Its
31% Application to Single-Server Queues," IEEE Trans. Information Theory,
32% vol. 65, no. 12, pp. 8305-8324, 2019.
33%
34% See also: aoi_fcfs_mm1, aoi_lcfspr_mgi1, aoi_compare
35
36% Copyright (c) 2012-2026, Imperial College London
37% All rights reserved.
38
39% Validate inputs
40if lambda <= 0
41 line_error(mfilename, 'Arrival rate lambda must be positive');
42end
43if mu <= 0
44 line_error(mfilename, 'Service rate mu must be positive');
45end
46
47% Compute utilization
48rho = lambda / mu;
49
50% Check stability (for preemptive LCFS, the system is always stable
51% as long as lambda and mu are positive, but rho < 1 is still required
52% for meaningful queueing analysis)
53if rho >= 1
54 line_error(mfilename, 'System unstable: rho = lambda/mu = %.4f >= 1', rho);
55end
56
57% Mean AoI for preemptive LCFS (Proposition 3 / Section IV)
58% E[A] = (1/mu) * (1 + 1/rho) = 1/mu + 1/lambda
59% This is always less than FCFS: (1/mu)(1 + 1/rho) < (1/mu)(1 + 1/rho + rho^2/(1-rho))
60meanAoI = (1/mu) * (1 + 1/rho);
61
62% Mean Peak AoI for preemptive LCFS
63% E[Apeak] = E[S] + E[Y] = 1/mu + 1/lambda
64% where S is service time of the successful update, Y is interarrival time
65% For preemptive LCFS, the peak AoI equals the mean AoI
66peakAoI = 1/mu + 1/lambda;
67
68% Variance of AoI for preemptive LCFS
69% From Section IV of the paper, the second moment is:
70% E[A^2] = 2/mu^2 + 2/(mu*lambda) + 2/lambda^2
71% = 2 * (1/mu + 1/lambda)^2 / something... need to verify
72%
73% Actually, for preemptive LCFS, the AoI distribution is simpler.
74% The AoI at any time equals the interarrival time plus the service time
75% of the most recent successful update. Since these are independent:
76% Var[A] = Var[Y] + Var[S] = 1/lambda^2 + 1/mu^2
77%
78% However, this is an approximation. For exact formula:
79E_A = meanAoI;
80% For preemptive LCFS, E[A^2] = 2*(1/lambda^2 + 1/(lambda*mu) + 1/mu^2)
81E_A2 = 2 * (1/lambda^2 + 1/(lambda*mu) + 1/mu^2);
82varAoI = E_A2 - E_A^2;
83
84% Ensure non-negative variance (numerical safety)
85if varAoI < 0
86 varAoI = 0;
87end
88
89end