LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
example_infer_ekf_open.m
1clear node jobclass solver AvgTable
2%% Example: EKF estimation on an open 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.FCFS);
11node{3} = Source(model, 'Source');
12node{4} = Sink(model, 'Sink');
13
14jobclass{1} = OpenClass(model, 'Class1', 0);
15
16node{1}.setService(jobclass{1}, Exp.fitMean(1.0));
17node{2}.setService(jobclass{1}, Exp(NaN)); % NaN = to be estimated (true demand = 0.4)
18node{3}.setArrival(jobclass{1}, Exp(1.0)); % arrival rate = 1.0
19
20P = model.initRoutingMatrix;
21P{1,1} = [0,1,0,0; 0,0,0,1; 1,0,0,0; 0,0,0,0];
22model.link(P);
23
24%% Generate synthetic dataset consistent with model
25% True demand D=0.4, arrival rate lambda=1.0
26% True utilization U = lambda*D = 0.4
27% True response time R = D/(1-U) = 0.4/0.6 = 0.667
28n = 100;
29ts = 1:n;
30arvr_samples = 1.0*ones(n,1) + randn(n,1)*0.05;
31util_samples = 0.4*ones(n,1) + randn(n,1)*0.02;
32util_samples = max(0.01, min(0.95, util_samples));
33respt_samples = 0.4./(1 - util_samples);
34
35%% Create SampledMetric objects
36lambda1 = SampledMetric(MetricType.ArvR, ts, arvr_samples, node{2}, jobclass{1});
37respT1 = SampledMetric(MetricType.RespT, ts, respt_samples, node{2}, jobclass{1});
38util = SampledMetric(MetricType.Util, ts, util_samples, node{2});
39
40%% Estimate with EKF
41fprintf(1, '\n=== EKF Estimator (Open Network) ===\n');
42options = ParamEstimator.defaultOptions;
43options.method = 'ekf';
44se = ParamEstimator(model, options);
45se.addSamples(lambda1);
46se.addSamples(respT1);
47se.addSamples(util);
48se.interpolate();
49estVal = se.estimateAt(node{2});
50fprintf(1, 'EKF demand: Class1=%.4f (true=0.4000)\n', estVal(1));
51
52%% Solve model
53solver{1} = SolverMVA(model);
54fprintf(1, '\nSOLVER: %s\n', solver{1}.getName());
55AvgTable{1} = solver{1}.getAvgTable();
56AvgTable{1}