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%
11% Parameters:
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[Y] + E[T] + lambda * E[H^2] / (2*(1-rho))
28% = 1/lambda + E[W] + E[H] + lambda * E[H^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_gim1, aoi_lst_exp, aoi_lst_erlang
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 E_H <= 0
46 line_error(mfilename, 'Mean service time E_H must be positive');
47end
48if E_H2 < E_H^2
49 line_error(mfilename, 'Second moment E_H2 must be >= E_H^2');
50end
51
52% Compute utilization
53rho = lambda * E_H;
54
55% Check stability
56if rho >= 1
57 line_error(mfilename, 'System unstable: rho = lambda*E_H = %.4f >= 1', rho);
58end
59
60% Mean interarrival time
61E_Y = 1 / lambda;
62
63% Mean waiting time (Pollaczek-Khinchine formula)
64% E[W] = lambda * E[H^2] / (2 * (1 - rho))
65E_W = lambda * E_H2 / (2 * (1 - rho));
66
67% Mean system time (sojourn time)
68E_T = E_W + E_H;
69
70% Mean AoI (Proposition 1)
71% E[A] = E[Y] + E[T] + lambda * E[H^2] / (2*(1-rho))
72meanAoI = E_Y + E_T + lambda * E_H2 / (2 * (1 - rho));
73
74% Mean Peak AoI
75% E[Apeak] = E[T] + E[Y]
76peakAoI = E_T + E_Y;
77
78% LST of AoI (Theorem 2)
79% A*(s) = (lambda * H*(s)) / (s + lambda - lambda*H*(s)) * W*(s)
80% where W*(s) is the Pollaczek-Khinchine LST:
81% W*(s) = (1-rho) * s / (s - lambda + lambda*H*(s))
82
83lstAoI = @(s) aoi_mgi1_lst_eval(s, lambda, H_lst, rho);
84
85end
86
87function val = aoi_mgi1_lst_eval(s, lambda, H_lst, rho)
88%AOI_MGI1_LST_EVAL Evaluate M/GI/1 FCFS AoI LST at point(s) s
89
90 if isscalar(s)
91 H_s = H_lst(s);
92 % Pollaczek-Khinchine LST for waiting time
93 W_s = (1 - rho) * s / (s - lambda + lambda * H_s);
94 % AoI LST (Theorem 2)
95 val = (lambda * H_s) / (s + lambda - lambda * H_s) * W_s;
96 else
97 % Handle array input
98 val = zeros(size(s));
99 for i = 1:numel(s)
100 H_s = H_lst(s(i));
101 W_s = (1 - rho) * s(i) / (s(i) - lambda + lambda * H_s);
102 val(i) = (lambda * H_s) / (s(i) + lambda - lambda * H_s) * W_s;
103 end
104 end
105end