LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
aoi_fcfs_md1.m
1function [meanAoI, varAoI, peakAoI] = aoi_fcfs_md1(lambda, d)
2%AOI_FCFS_MD1 Mean, variance, and peak AoI for M/D/1 FCFS queue
3%
4% [meanAoI, varAoI, peakAoI] = aoi_fcfs_md1(lambda, d)
5%
6% Computes the Age of Information metrics for an M/D/1 queue with
7% First-Come First-Served (FCFS) discipline.
8%
9% M/D/1: Poisson arrivals with rate lambda, deterministic service time d.
10%
11% Parameters:
12% lambda (double): Arrival rate (Poisson arrivals)
13% d (double): Deterministic service time
14%
15% Returns:
16% meanAoI (double): Mean (average) Age of Information
17% varAoI (double): Variance of Age of Information
18% peakAoI (double): Mean Peak Age of Information
19%
20% Formulas (from Inoue et al., IEEE Trans. IT, 2019):
21% Uses M/GI/1 FCFS results with deterministic service.
22% For M/D/1:
23% E[H] = d, E[H^2] = d^2 (deterministic)
24% rho = lambda * d
25% E[W] = lambda * d^2 / (2*(1-rho)) (Pollaczek-Khinchine)
26% E[T] = E[W] + d
27% E[A] = E[Y] + E[T] + lambda*E[H^2]/(2*(1-rho))
28% = 1/lambda + E[W] + d + lambda*d^2/(2*(1-rho))
29%
30% Reference:
31% Y. Inoue, H. Masuyama, T. Takine, T. Tanaka, "A General Formula for
32% the Stationary Distribution of the Age of Information and Its
33% Application to Single-Server Queues," IEEE Trans. Information Theory,
34% vol. 65, no. 12, pp. 8305-8324, 2019.
35%
36% See also: aoi_fcfs_mm1, aoi_fcfs_mgi1, aoi_lcfspr_md1
37
38% Copyright (c) 2012-2026, Imperial College London
39% All rights reserved.
40
41% Validate inputs
42if lambda <= 0
43 line_error(mfilename, 'Arrival rate lambda must be positive');
44end
45if d <= 0
46 line_error(mfilename, 'Service time d must be positive');
47end
48
49% Compute utilization
50rho = lambda * d;
51
52% Check stability
53if rho >= 1
54 line_error(mfilename, 'System unstable: rho = lambda*d = %.4f >= 1', rho);
55end
56
57% Service time moments (deterministic)
58E_H = d;
59E_H2 = d^2;
60
61% Mean waiting time (Pollaczek-Khinchine for M/G/1)
62% E[W] = lambda * E[H^2] / (2 * (1 - rho))
63E_W = lambda * E_H2 / (2 * (1 - rho));
64
65% Mean system time (sojourn time)
66E_T = E_W + E_H;
67
68% Mean interarrival time
69E_Y = 1 / lambda;
70
71% Mean AoI for M/G/1 FCFS (Proposition 1)
72% E[A] = E[Y] + E[T] + lambda * E[H^2] / (2*(1-rho))
73% = 1/lambda + E[W] + d + lambda*d^2/(2*(1-rho))
74% = 1/lambda + d + lambda*d^2/(1-rho) [since E[W] uses same term]
75meanAoI = E_Y + E_T + lambda * E_H2 / (2 * (1 - rho));
76
77% Mean Peak AoI
78% E[Apeak] = E[T] + E[Y]
79peakAoI = E_T + E_Y;
80
81% Variance of AoI
82% For M/D/1, the variance depends on the second moment of AoI.
83% Using the general M/G/1 result with deterministic service:
84% Var[A] can be computed from LST derivatives, but for deterministic
85% service, we use:
86% Var[Y] = 1/lambda^2 (exponential interarrival)
87% Var[H] = 0 (deterministic service)
88%
89% A simpler approximation for variance:
90% For now, compute using the relationship with second moments
91% This is an approximation; exact formula requires LST analysis
92E_Y2 = 2 / lambda^2; % Second moment of exponential
93E_T2 = E_H2 + 2*E_H*E_W + E_W^2 + lambda * E_H2 / (1 - rho); % Approx
94
95% Use relationship: E[A^2] approx from paper results
96% For deterministic service, variance is lower than exponential case
97varAoI = E_Y2 - E_Y^2 + 2*E_W*E_H / (1-rho) + E_H2 * rho / (1-rho)^2;
98
99% Ensure non-negative variance (numerical safety)
100if varAoI < 0
101 varAoI = 0;
102end
103
104end