LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
aoi_fcfs_mgi1.m
1function [meanAoI, lstAoI, peakAoI] = aoi_fcfs_mgi1(lambda, H_lst, E_H, E_H2)
2%AOI_FCFS_MGI1 Mean AoI and LST for M/GI/1 FCFS queue
3%
4% [meanAoI, lstAoI, peakAoI] = aoi_fcfs_mgi1(lambda, H_lst, E_H, E_H2)
5%
6% Computes the Age of Information metrics for an M/GI/1 queue with
7% First-Come First-Served (FCFS) discipline.
8%
9% M/GI/1: Poisson arrivals with rate lambda, general independent service.
10%
12% lambda (double): Arrival rate (Poisson arrivals)
13% H_lst (function_handle): LST of service time, @(s) -> complex
14% E_H (double): Mean service time (first moment)
15% E_H2 (double): Second moment of service time
16%
17% Returns:
18% meanAoI (double): Mean (average) Age of Information
19% lstAoI (function_handle): LST of AoI distribution
20% peakAoI (double): Mean Peak Age of Information
21%
22% Formulas (from Inoue et al., IEEE Trans. IT, 2019, Theorem 2):
23% LST of AoI: A*(s) = (lambda * H*(s)) / (s + lambda - lambda*H*(s)) * W*(s)
24% where W*(s) is the LST of waiting time (Pollaczek-Khinchine).
25%
26% Mean AoI (Proposition 1):
27% E[A] = E[H] + E[T] + (1-2*rho)/lambda - d/ds T*(s)|_{s=lambda} (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_gim1, aoi_lst_exp, aoi_lst_erlang
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 E_H <= 0
45 line_error(mfilename, 'Mean service time E_H must be positive');
46end
47if E_H2 < E_H^2
48 line_error(mfilename, 'Second moment E_H2 must be >= E_H^2');
49end
50
51% Compute utilization
52rho = lambda * E_H;
53
54% Check stability
55if rho >= 1
56 line_error(mfilename, 'System unstable: rho = lambda*E_H = %.4f >= 1', rho);
57end
58
59% Mean interarrival time
60E_Y = 1 / lambda;
61
62% Mean waiting time (Pollaczek-Khinchine formula)
63% E[W] = lambda * E[H^2] / (2 * (1 - rho))
64E_W = lambda * E_H2 / (2 * (1 - rho));
65
66% Mean system time (sojourn time)
67E_T = E_W + E_H;
68
69% Mean AoI for M/GI/1 FCFS (exact)
70% E[A] = E[H] + E[T] + (1-2*rho)/lambda - d/ds T*(s)|_{s=lambda}
71% where T*(s) = H*(s)*W*(s) is the system-time LST (Pollaczek-Khinchine).
72% The derivative term captures the interarrival/system-time correlation
73% E[Y*W] = E[Y(T'-Y)^+]; validated against simulation.
74Tstar = @(s) H_lst(s) .* ((1 - rho) .* s ./ (s - lambda + lambda .* H_lst(s)));
75hstep = 1e-6 * max(1, lambda);
76dTstar = (Tstar(lambda + hstep) - Tstar(lambda - hstep)) / (2 * hstep);
77meanAoI = E_H + E_T + (1 - 2 * rho) / lambda - dTstar;
78
79% Mean Peak AoI
80% E[Apeak] = E[T] + E[Y]
81peakAoI = E_T + E_Y;
82
83% LST of AoI (Theorem 2)
84% A*(s) = (lambda * H*(s)) / (s + lambda - lambda*H*(s)) * W*(s)
85% where W*(s) is the Pollaczek-Khinchine LST:
86% W*(s) = (1-rho) * s / (s - lambda + lambda*H*(s))
87
88lstAoI = @(s) aoi_mgi1_lst_eval(s, lambda, H_lst, rho);
89
90end
91
92function val = aoi_mgi1_lst_eval(s, lambda, H_lst, rho)
93%AOI_MGI1_LST_EVAL Evaluate M/GI/1 FCFS AoI LST at point(s) s
94
95 if isscalar(s)
96 H_s = H_lst(s);
97 % Pollaczek-Khinchine LST for waiting time
98 W_s = (1 - rho) * s / (s - lambda + lambda * H_s);
99 % AoI LST (Theorem 2)
100 val = (lambda * H_s) / (s + lambda - lambda * H_s) * W_s;
101 else
102 % Handle array input
103 val = zeros(size(s));
104 for i = 1:numel(s)
105 H_s = H_lst(s(i));
106 W_s = (1 - rho) * s(i) / (s(i) - lambda + lambda * H_s);
107 val(i) = (lambda * H_s) / (s(i) + lambda - lambda * H_s) * W_s;
108 end
109 end
110end
Definition Station.m:245