LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
example_infer_ekf_closed.m
1clear node jobclass solver AvgTable
2%% Example: EKF estimation with autoMethod selection
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', 2, node{1}, 0);
12
13node{1}.setService(jobclass{1}, Exp.fitMean(1.0));
14node{2}.setService(jobclass{1}, Exp(NaN)); % NaN = to be estimated
15
16P = model.initRoutingMatrix;
17P{1} = [0,1; 1,0];
18model.link(P);
19
20%% Generate synthetic dataset
21n = 100;
22ts = 1:n;
23arvr_samples = 1.5*ones(n,1) - rand(n,1)*0.1;
24util_samples = 0.4*arvr_samples;
25respt_samples = 0.4./(1 - util_samples);
26
27%% Create SampledMetric objects
28lambda1 = SampledMetric(MetricType.ArvR, ts, arvr_samples, node{2}, jobclass{1});
29respT1 = SampledMetric(MetricType.RespT, ts, respt_samples, node{2}, jobclass{1});
30util = SampledMetric(MetricType.Util, ts, util_samples, node{2});
31
32%% Estimate with EKF
33fprintf(1, '\n=== EKF Estimator ===\n');
34options = ParamEstimator.defaultOptions;
35options.method = 'ekf';
36se = ParamEstimator(model, options);
37se.addSamples(lambda1);
38se.addSamples(respT1);
39se.addSamples(util);
40se.interpolate();
41estVal_ekf = se.estimateAt(node{2});
42fprintf(1, 'EKF demand: Class1=%.4f (true=0.4000)\n', estVal_ekf(1));
43
44%% Now demonstrate autoMethod
45fprintf(1, '\n=== autoMethod selection ===\n');
46node{2}.setService(jobclass{1}, Exp(NaN));
47model.reset;
48
49options2 = ParamEstimator.defaultOptions;
50options2.method = 'auto';
51se2 = ParamEstimator(model, options2);
52se2.addSamples(lambda1);
53se2.addSamples(respT1);
54se2.addSamples(util);
55se2.interpolate();
56method = se2.autoMethod();
57fprintf(1, 'autoMethod selected: %s\n', method);
58fprintf(1, 'Required metrics for %s: %s\n', method, ParamEstimator.getRequiredMetrics(method));
59estVal_auto = se2.estimateAt(node{2});
60fprintf(1, 'Auto demand: Class1=%.4f (true=0.4000)\n', estVal_auto(1));
61
62%% Solve model
63solver{1} = SolverMVA(model);
64fprintf(1, '\nSOLVER: %s\n', solver{1}.getName());
65AvgTable{1} = solver{1}.getAvgTable();
66AvgTable{1}