LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
example_infer_ubo_variants_closed.m
1clear node jobclass solver AvgTable
2%% Example: Compare UBO and MLE estimators on a closed network
3% Copyright (c) 2012-2026, Imperial College London
4% All rights reserved.
5
6%% define model
7model = Network('model');
8
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);
13
14node{1}.setService(jobclass{1}, Exp.fitMean(1.0));
15node{1}.setService(jobclass{2}, Exp.fitMean(1.0));
16
17node{2}.setService(jobclass{1}, Exp(NaN)); % NaN = to be estimated
18node{2}.setService(jobclass{2}, Exp(NaN)); % NaN = to be estimated
19
20P = model.initRoutingMatrix;
21P{1} = [0,1; 1,0];
22P{2} = [0,1; 1,0];
23model.link(P);
24
25%% Generate synthetic dataset
26n = 1000;
27ts = 1:n;
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);
33
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});
40
41%% Estimate with UBO
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);
48se.addSamples(util);
49se.interpolate();
50estVal_ubo = se.estimateAt(node{2});
51fprintf(1, 'UBO demands: Class1=%.4f, Class2=%.4f\n', estVal_ubo(1), estVal_ubo(2));
52
53%% Estimate with MLE
54fprintf(1, '\n=== MLE Estimator ===\n');
55node{2}.setService(jobclass{1}, Exp(NaN));
56node{2}.setService(jobclass{2}, Exp(NaN));
57model.reset;
58
59options.method = 'mle';
60se = ParamEstimator(model, options);
61se.addSamples(lambda1); se.addSamples(lambda2);
62se.addSamples(respT1); se.addSamples(respT2);
63se.addSamples(util);
64se.interpolate();
65estVal_mle = se.estimateAt(node{2});
66fprintf(1, 'MLE demands: Class1=%.4f, Class2=%.4f\n', estVal_mle(1), estVal_mle(2));
67
68%% Compare results
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));
73
74%% Solve model with final estimates
75solver{1} = SolverMVA(model);
76fprintf(1, '\nSOLVER: %s\n', solver{1}.getName());
77AvgTable{1} = solver{1}.getAvgTable();
78AvgTable{1}