2%% Example: Compare trace-based estimators (MLPS, FMLPS, Gibbs) on a PS station
3% Copyright (c) 2012-2026, Imperial College London
8model = Network(
'model');
9node{1} = Delay(model,
'Delay');
10node{2} = Queue(model,
'Queue1', SchedStrategy.PS);
11jobclass{1} = ClosedClass(model,
'Class1', N, node{1}, 0);
13node{1}.setService(
jobclass{1}, Exp.fitMean(1.0));
14node{2}.setService(
jobclass{1}, Exp(NaN)); % NaN = to be estimated
16P = model.initRoutingMatrix;
20%% Generate synthetic trace data
22arrival_times = sort(rand(n,1) * 100);
23response_times = 0.5 + rand(n,1) * 0.3;
24tput_samples = ones(n,1) * (N / (1.0 + 0.5)); % approximate throughput
26%% Create trace-format SampledMetric objects
27arvData = SampledMetric(MetricType.ArvR, arrival_times, arrival_times, node{2},
jobclass{1});
29rtData = SampledMetric(MetricType.RespT, arrival_times, response_times, node{2},
jobclass{1});
31tputData = SampledMetric(MetricType.Tput, arrival_times, tput_samples, node{2},
jobclass{1});
34fprintf(1,
'\n=== MLPS Estimator ===\n');
35options = ParamEstimator.defaultOptions;
36options.method =
'mlps';
37se = ParamEstimator(model, options);
38se.addSamples(arvData);
42 estVal_mlps = se.estimateAt(node{2});
43 fprintf(1,
'MLPS demand: Class1=%.4f\n', estVal_mlps(1));
45 fprintf(1,
'MLPS skipped: %s\n', e.message);
50fprintf(1,
'\n=== FMLPS Estimator ===\n');
51node{2}.setService(
jobclass{1}, Exp(NaN));
54options.method =
'fmlps';
55se = ParamEstimator(model, options);
56se.addSamples(arvData);
60 estVal_fmlps = se.estimateAt(node{2});
61 fprintf(1,
'FMLPS demand: Class1=%.4f\n', estVal_fmlps(1));
63 fprintf(1,
'FMLPS skipped: %s\n', e.message);
68fprintf(1,
'\n=== Gibbs Estimator ===\n');
69node{2}.setService(
jobclass{1}, Exp(NaN));
72options.method =
'gibbs';
73se = ParamEstimator(model, options);
74se.addSamples(arvData);
76se.addSamples(tputData);
79 estVal_gibbs = se.estimateAt(node{2});
80 fprintf(1,
'Gibbs demand: Class1=%.4f\n', estVal_gibbs(1));
82 fprintf(1,
'Gibbs skipped: %s\n', e.message);
87fprintf(1,
'\n=== Comparison (true demand ~ 0.5) ===\n');
88fprintf(1,
'MLPS: %.4f\n', estVal_mlps(1));
89fprintf(1,
'FMLPS: %.4f\n', estVal_fmlps(1));
90fprintf(1,
'Gibbs: %.4f\n', estVal_gibbs(1));
92%% Solve model with
final estimates
93solver{1} = SolverMVA(model);
94fprintf(1,
'\nSOLVER: %s\n', solver{1}.getName());
95AvgTable{1} = solver{1}.getAvgTable();