2%% Example: Compare UBO and MLE estimators on a closed network
3% Copyright (c) 2012-2026, Imperial College London
7model = Network(
'model');
9node{1} = Delay(model,
'Delay');
10node{2} = Queue(model,
'Queue1', SchedStrategy.PS);
11jobclass{1} = ClosedClass(model,
'Class1', 1, node{1}, 0);
12jobclass{2} = ClosedClass(model,
'Class2', 3, node{1}, 0);
14node{1}.setService(
jobclass{1}, Exp.fitMean(1.0));
15node{1}.setService(
jobclass{2}, Exp.fitMean(1.0));
17node{2}.setService(
jobclass{1}, Exp(NaN)); % NaN = to be estimated
18node{2}.setService(
jobclass{2}, Exp(NaN)); % NaN = to be estimated
20P = model.initRoutingMatrix;
25%% Generate synthetic dataset
28arvr1_samples = 2*ones(n,1) - rand(n,1)*0.15;
29arvr2_samples = ones(n,1) - rand(n,1)*0.15;
30util_samples = 0.1*arvr1_samples + 0.3*arvr2_samples;
31respt1_samples = 0.1./(1 - util_samples);
32respt2_samples = 0.3./(1 - util_samples);
34%% Create SampledMetric objects
35lambda1 = SampledMetric(MetricType.ArvR, ts, arvr1_samples, node{2},
jobclass{1});
36lambda2 = SampledMetric(MetricType.ArvR, ts, arvr2_samples, node{2},
jobclass{2});
37respT1 = SampledMetric(MetricType.RespT, ts, respt1_samples, node{2},
jobclass{1});
38respT2 = SampledMetric(MetricType.RespT, ts, respt2_samples, node{2},
jobclass{2});
39util = SampledMetric(MetricType.Util, ts, util_samples, node{2});
42fprintf(1,
'\n=== UBO Estimator ===\n');
43options = ParamEstimator.defaultOptions;
44options.method =
'ubo';
45se = ParamEstimator(model, options);
46se.addSamples(lambda1); se.addSamples(lambda2);
47se.addSamples(respT1); se.addSamples(respT2);
50estVal_ubo = se.estimateAt(node{2});
51fprintf(1,
'UBO demands: Class1=%.4f, Class2=%.4f\n', estVal_ubo(1), estVal_ubo(2));
54fprintf(1,
'\n=== MLE Estimator ===\n');
55node{2}.setService(
jobclass{1}, Exp(NaN));
56node{2}.setService(
jobclass{2}, Exp(NaN));
59options.method =
'mle';
60se = ParamEstimator(model, options);
61se.addSamples(lambda1); se.addSamples(lambda2);
62se.addSamples(respT1); se.addSamples(respT2);
65estVal_mle = se.estimateAt(node{2});
66fprintf(1,
'MLE demands: Class1=%.4f, Class2=%.4f\n', estVal_mle(1), estVal_mle(2));
69fprintf(1,
'\n=== Comparison ===\n');
70fprintf(1,
'True demands: Class1=0.1000, Class2=0.3000\n');
71fprintf(1,
'UBO: Class1=%.4f, Class2=%.4f\n', estVal_ubo(1), estVal_ubo(2));
72fprintf(1,
'MLE: Class1=%.4f, Class2=%.4f\n', estVal_mle(1), estVal_mle(2));
74%% Solve model with
final estimates
75solver{1} = SolverMVA(model);
76fprintf(1,
'\nSOLVER: %s\n', solver{1}.getName());
77AvgTable{1} = solver{1}.getAvgTable();