3% Single-
class FES Aggregation Example
5% This tests FES aggregation with a single job
class, where it should be exact.
7fprintf(
'=== Single-Class FES Aggregation Example ===\n\n');
9%% Create original 4-station tandem network with 1
class
10fprintf(
'Creating original 4-station network...\n');
12N1 = 5; % number of jobs
14model = Network(
'OriginalModel');
17node{1} = Delay(model,
'ThinkTime');
18node{2} = Queue(model,
'Queue1', SchedStrategy.PS);
19node{3} = Queue(model,
'Queue2', SchedStrategy.PS);
20node{4} = Queue(model,
'Queue3', SchedStrategy.PS);
23jobclass{1} = ClosedClass(model,
'Class1', N1, node{1}, 0);
26node{1}.setService(
jobclass{1}, Exp.fitMean(5.0));
27node{2}.setService(
jobclass{1}, Exp.fitMean(1.5));
28node{3}.setService(
jobclass{1}, Exp.fitMean(1.0));
29node{4}.setService(
jobclass{1}, Exp.fitMean(0.8));
31% Set up tandem routing
32P = model.initRoutingMatrix();
39%% Solve original model with MVA
40fprintf(
'\n--- Solving Original Model ---\n');
41solverOriginal = SolverMVA(model);
42AvgTableOriginal = solverOriginal.getAvgTable;
43fprintf(
'Original model results:\n');
44disp(AvgTableOriginal);
46%% Aggregate stations 2 and 3 into a Flow-Equivalent Server
47fprintf(
'\n--- Creating FES Model ---\n');
48fprintf(
'Aggregating Queue1 and Queue2 into a single FES...\n');
50stationSubset = {node{2}, node{3}};
51options.verbose =
true;
52options.solver =
'mva';
55 [fesModel, fesStation, deaggInfo] = ModelAdapter.aggregateFES(model, stationSubset, options);
57 fprintf(
'\nFES model created successfully!\n');
58 fprintf(
'FES station name: %s\n', fesStation.getName());
59 fprintf(
'Number of stations in FES model: %d\n', fesModel.getNumberOfStations());
62 fprintf(
'\n--- Solving FES Model ---\n');
63 solverFES = SolverMVA(fesModel);
64 AvgTableFES = solverFES.getAvgTable;
65 fprintf(
'FES model results:\n');
68 %% Compare throughputs
69 fprintf(
'\n--- Throughput Comparison ---\n');
71 % Find throughput at ThinkTime station
73 for row = 1:height(AvgTableOriginal)
74 if strcmp(
string(AvgTableOriginal.Station(row)),
'ThinkTime')
75 tputOrig = AvgTableOriginal.Tput(row);
81 for row = 1:height(AvgTableFES)
82 if strcmp(
string(AvgTableFES.Station(row)), 'ThinkTime')
83 tputFES = AvgTableFES.Tput(row);
88 relError = abs(tputOrig - tputFES) / max(tputOrig, 1e-10) * 100;
89 fprintf('Throughput: Original=%.4f, FES=%.4f, RelError=%.2f%%\n', ...
90 tputOrig, tputFES, relError);
93 fprintf('\nSUCCESS: FES aggregation
is nearly exact (< 1%% error)\n');
95 fprintf('\nWARNING: FES aggregation has significant error\n');
99 fprintf('Error during FES aggregation: %s\n', ME.message);
100 fprintf('Stack trace:\n');
101 for i = 1:length(ME.stack)
102 fprintf(' %s (line %d)\n', ME.stack(i).name, ME.stack(i).line);
106fprintf('\n=== Example Complete ===\n');