LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
aoi_fcfs_gim1.m
1function [meanAoI, lstAoI, peakAoI] = aoi_fcfs_gim1(Y_lst, mu, E_Y, E_Y2)
2%AOI_FCFS_GIM1 Mean AoI and LST for GI/M/1 FCFS queue
3%
4% [meanAoI, lstAoI, peakAoI] = aoi_fcfs_gim1(Y_lst, mu, E_Y, E_Y2)
5%
6% Computes the Age of Information metrics for a GI/M/1 queue with
7% First-Come First-Served (FCFS) discipline.
8%
9% GI/M/1: General independent arrivals, exponential service with rate mu.
10%
11% Parameters:
12% Y_lst (function_handle): LST of interarrival time, @(s) -> complex
13% mu (double): Service rate (exponential service)
14% E_Y (double): Mean interarrival time (first moment)
15% E_Y2 (double): Second moment of interarrival 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 3):
23% The key parameter sigma is the unique root in (0,1) of:
24% Y*(mu - mu*sigma) = sigma
25%
26% LST of AoI: A*(s) = (mu*sigma_s) / (s + mu - mu*sigma_s) * D*(s)
27% where sigma_s solves Y*(s + mu - mu*sigma_s) = sigma_s
28% and D*(s) is the LST of system delay.
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_fcfs_dm1
37
38% Copyright (c) 2012-2026, Imperial College London
39% All rights reserved.
40
41% Validate inputs
42if mu <= 0
43 line_error(mfilename, 'Service rate mu must be positive');
44end
45if E_Y <= 0
46 line_error(mfilename, 'Mean interarrival time E_Y must be positive');
47end
48if E_Y2 < E_Y^2
49 line_error(mfilename, 'Second moment E_Y2 must be >= E_Y^2');
50end
51
52% Compute utilization
53lambda = 1 / E_Y;
54rho = lambda / mu;
55
56% Check stability
57if rho >= 1
58 line_error(mfilename, 'System unstable: rho = 1/(E_Y*mu) = %.4f >= 1', rho);
59end
60
61% Find sigma: unique root in (0,1) of Y*(mu - mu*sigma) = sigma
62% This is the probability an arriving customer finds the server busy
63sigma_func = @(sig) Y_lst(mu - mu * sig) - sig;
64
65% Use fzero to find the root
66try
67 sigma = fzero(sigma_func, [0.001, 0.999]);
68catch
69 % Fallback: use fixed-point iteration
70 sigma = 0.5;
71 for iter = 1:100
72 sigma_new = Y_lst(mu - mu * sigma);
73 if abs(sigma_new - sigma) < 1e-10
74 break;
75 end
76 sigma = sigma_new;
77 end
78end
79
80% Mean system delay for GI/M/1
81% E[D] = 1 / (mu * (1 - sigma))
82E_D = 1 / (mu * (1 - sigma));
83
84% Mean AoI (Proposition 2)
85% E[A] = E[Y] + E[D] + sigma / (mu * (1 - sigma) * (1 - sigma_prime))
86% where sigma_prime = d/ds sigma(s)|_{s=0}
87%
88% For the mean, we can use:
89% E[A] = E[Y] + E[D] + sigma * E[Y] / (1 - sigma)
90% This is a simplification; the exact formula involves derivatives.
91
92% Approximate mean AoI using the relationship from the paper
93meanAoI = E_Y + E_D + sigma / (mu * (1 - sigma));
94
95% Mean Peak AoI
96% E[Apeak] = E[Y] + E[D]
97peakAoI = E_Y + E_D;
98
99% LST of AoI (Theorem 3)
100% This requires solving for sigma(s) at each evaluation point
101lstAoI = @(s) aoi_gim1_lst_eval(s, Y_lst, mu, sigma);
102
103end
104
105function val = aoi_gim1_lst_eval(s, Y_lst, mu, sigma0)
106%AOI_GIM1_LST_EVAL Evaluate GI/M/1 FCFS AoI LST at point(s) s
107
108 if isscalar(s)
109 % Find sigma(s): root of Y*(s + mu - mu*sigma) = sigma
110 sig_func = @(sig) Y_lst(s + mu - mu * sig) - sig;
111 try
112 sigma_s = fzero(sig_func, [0.001, 0.999]);
113 catch
114 sigma_s = sigma0; % Fallback
115 end
116
117 % System delay LST: D*(s) = (1-sigma) * mu / (s + mu - mu*sigma_s)
118 D_s = (1 - sigma0) * mu / (s + mu - mu * sigma_s);
119
120 % AoI LST (Theorem 3)
121 val = (mu * sigma_s) / (s + mu - mu * sigma_s) * D_s;
122 else
123 % Handle array input
124 val = zeros(size(s));
125 for i = 1:numel(s)
126 sig_func = @(sig) Y_lst(s(i) + mu - mu * sig) - sig;
127 try
128 sigma_s = fzero(sig_func, [0.001, 0.999]);
129 catch
130 sigma_s = sigma0;
131 end
132 D_s = (1 - sigma0) * mu / (s(i) + mu - mu * sigma_s);
133 val(i) = (mu * sigma_s) / (s(i) + mu - mu * sigma_s) * D_s;
134 end
135 end
136end