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%
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] = d*(1/2 + 1/(2*(1-rho)) + ((1-rho)/rho)*exp(rho)) (exact)
28%
29% Reference:
30% Y. Inoue, H. Masuyama, T. Takine, T. Tanaka, "A General Formula for
31% the Stationary Distribution of the Age of Information and Its
32% Application to Single-Server Queues," IEEE Trans. Information Theory,
33% vol. 65, no. 12, pp. 8305-8324, 2019.
34%
35% See also: aoi_fcfs_mm1, aoi_fcfs_mgi1, aoi_lcfspr_md1
36
37% Copyright (c) 2012-2026, Imperial College London
38% All rights reserved.
39
40% Validate inputs
41if lambda <= 0
42 line_error(mfilename, 'Arrival rate lambda must be positive');
43end
44if d <= 0
45 line_error(mfilename, 'Service time d must be positive');
46end
47
48% Compute utilization
49rho = lambda * d;
50
51% Check stability
52if rho >= 1
53 line_error(mfilename, 'System unstable: rho = lambda*d = %.4f >= 1', rho);
54end
55
56% Service time moments (deterministic)
57E_H = d;
58E_H2 = d^2;
59
60% Mean waiting time (Pollaczek-Khinchine for M/G/1)
61% E[W] = lambda * E[H^2] / (2 * (1 - rho))
62E_W = lambda * E_H2 / (2 * (1 - rho));
63
64% Mean system time (sojourn time)
65E_T = E_W + E_H;
66
67% Mean interarrival time
68E_Y = 1 / lambda;
69
70% Mean AoI for M/D/1 FCFS (exact, Inoue et al. 2019)
71% E[A] = d * (1/2 + 1/(2*(1-rho)) + ((1-rho)/rho) * exp(rho))
72% accounts for the negative correlation between interarrival and waiting
73% times (validated against simulation)
74meanAoI = d * (0.5 + 1 / (2 * (1 - rho)) + ((1 - rho) / rho) * exp(rho));
75
76% Mean Peak AoI
77% E[Apeak] = E[T] + E[Y]
78peakAoI = E_T + E_Y;
79
80% Variance of AoI
81% For M/D/1, the variance depends on the second moment of AoI.
82% Using the general M/G/1 result with deterministic service:
83% Var[A] can be computed from LST derivatives, but for deterministic
84% service, we use:
85% Var[Y] = 1/lambda^2 (exponential interarrival)
86% Var[H] = 0 (deterministic service)
87%
88% A simpler approximation for variance:
89% For now, compute using the relationship with second moments
90% This is an approximation; exact formula requires LST analysis
91E_Y2 = 2 / lambda^2; % Second moment of exponential
92E_T2 = E_H2 + 2*E_H*E_W + E_W^2 + lambda * E_H2 / (1 - rho); % Approx
93
94% Use relationship: E[A^2] approx from paper results
95% For deterministic service, variance is lower than exponential case
96varAoI = E_Y2 - E_Y^2 + 2*E_W*E_H / (1-rho) + E_H2 * rho / (1-rho)^2;
97
98% Ensure non-negative variance (numerical safety)
99if varAoI < 0
100 varAoI = 0;
101end
102
103end
Definition Station.m:245