LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getAvgAoI.m
1function [AoI, PAoI, aoiTable] = getAvgAoI(self)
2%GETAVGAOI Get average Age of Information metrics
3%
4% [AoI, PAoI, aoiTable] = GETAVGAOI()
5%
6% Returns Age of Information (AoI) and Peak AoI statistics computed by
7% the Fluid solver using the aoi-fluid MFQ method.
8%
9% This method requires the model to have a valid AoI topology:
10% - Single open class
11% - Source -> Queue -> Sink topology
12% - Queue capacity 1 (bufferless) or 2 (single-buffer)
13% - Single server
14% - FCFS, LCFS, or LCFSPR scheduling
15%
16% To use this method, first run the solver with method='mfq':
17% solver = SolverFLD(model, 'method', 'mfq');
18% solver.getAvg();
19% [AoI, PAoI, aoiTable] = solver.getAvgAoI();
20%
21% Parameters:
22% self: SolverFLD instance
23%
24% Returns:
25% AoI (struct): Age of Information statistics
26% .mean: Mean AoI
27% .var: Variance of AoI
28% .std: Standard deviation of AoI
29% PAoI (struct): Peak Age of Information statistics
30% .mean: Mean Peak AoI
31% .var: Variance of Peak AoI
32% .std: Standard deviation of Peak AoI
33% aoiTable (table): Summary table with all metrics
34%
35% Example:
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));
43% queue.setService(jobclass, Exp(2));
44% model.link(Network.serialRouting(source, queue, sink));
45%
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);
49%
50% See also: getCdfAoI, solver_mfq_aoi, aoi_is_aoi
51
52% Copyright (c) 2012-2026, Imperial College London
53% All rights reserved.
54
55% Ensure solver has been run
56if isempty(self.result)
57 self.getAvg();
58end
59
60% Initialize outputs
61AoI = struct('mean', NaN, 'var', NaN, 'std', NaN);
62PAoI = struct('mean', NaN, 'var', NaN, 'std', NaN);
63aoiTable = table();
64
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''.');
70 return;
71end
72
73aoiResults = self.result.solverSpecific.aoiResults;
74
75% Extract AoI statistics
76AoI.mean = aoiResults.AoI_mean;
77AoI.var = aoiResults.AoI_var;
78AoI.std = sqrt(max(0, AoI.var));
79
80% Extract Peak AoI statistics
81PAoI.mean = aoiResults.PAoI_mean;
82PAoI.var = aoiResults.PAoI_var;
83PAoI.std = sqrt(max(0, PAoI.var));
84
85% Create summary table
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];
92
93aoiTable = table(Metric, Mean, Variance, StdDev, SystemType, Preemption);
94
95end