1function [AoI, PAoI, aoiTable] = getAvgAoI(self)
2%GETAVGAOI Get average Age of Information metrics
4% [AoI, PAoI, aoiTable] = GETAVGAOI()
6% Returns Age of Information (AoI) and Peak AoI statistics computed by
7% the Fluid solver
using the aoi-fluid MFQ method.
9% This method
requires the model to have a valid AoI topology:
11% - Source -> Queue -> Sink topology
12% - Queue capacity 1 (bufferless) or 2 (single-buffer)
14% - FCFS, LCFS, or LCFSPR scheduling
16% To use
this method, first run the solver with method=
'mfq':
17% solver = SolverFLD(model,
'method',
'mfq');
19% [AoI, PAoI, aoiTable] = solver.getAvgAoI();
22% self: SolverFLD instance
25% AoI (
struct): Age of Information statistics
27% .var: Variance of AoI
28% .std: Standard deviation of AoI
29% PAoI (struct): Peak Age of Information statistics
31% .var: Variance of Peak AoI
32% .std: Standard deviation of Peak AoI
33% aoiTable (table): Summary table with all metrics
36% model = Network(
'AoI_Example');
37% source = Source(model,
'Source');
38% queue = Queue(model,
'Queue', SchedStrategy.FCFS);
39% queue.setCapacity(1); % Bufferless
40% sink = Sink(model,
'Sink');
41%
jobclass = OpenClass(model,
'Updates');
42% source.setArrival(
jobclass, Exp(1));
44% model.link(Network.serialRouting(source, queue, sink));
46% solver = SolverFLD(model,
'method',
'mfq');
47% [AoI, PAoI, aoiTable] = solver.getAvgAoI();
48% fprintf(
'Mean AoI: %.4f, Mean PAoI: %.4f\n', AoI.mean, PAoI.mean);
50% See also: getCdfAoI, solver_mfq_aoi, aoi_is_aoi
52% Copyright (c) 2012-2026, Imperial College London
55% Ensure solver has been run
56if isempty(self.result)
61AoI = struct('mean', NaN, 'var', NaN, 'std', NaN);
62PAoI = struct('mean', NaN, 'var', NaN, 'std', NaN);
65% Check if AoI results are available
66if ~isfield(self.result, 'solverSpecific') || ...
67 ~isfield(self.result.solverSpecific, 'aoiResults') || ...
68 isempty(self.result.solverSpecific.aoiResults)
69 line_warning(mfilename, 'No AoI results available. Ensure model has valid AoI topology and use method=''mfq''.');
73aoiResults = self.result.solverSpecific.aoiResults;
75% Extract AoI statistics
76AoI.mean = aoiResults.AoI_mean;
77AoI.var = aoiResults.AoI_var;
78AoI.std = sqrt(max(0, AoI.var));
80% Extract Peak AoI statistics
81PAoI.mean = aoiResults.PAoI_mean;
82PAoI.var = aoiResults.PAoI_var;
83PAoI.std = sqrt(max(0, PAoI.var));
86Metric = {
'AoI';
'Peak AoI'};
87Mean = [AoI.mean; PAoI.mean];
88Variance = [AoI.var; PAoI.var];
89StdDev = [AoI.std; PAoI.std];
90SystemType = {aoiResults.systemType; aoiResults.systemType};
91Preemption = [aoiResults.preemption; aoiResults.preemption];
93aoiTable = table(Metric, Mean, Variance, StdDev, SystemType, Preemption);