LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
example_infer_mcmc_closed.m
1clear node jobclass solver AvgTable
2%% Example: MCMC estimation 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', 2, 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 = 500;
27ts = 1:n;
28qlen_samples = 1.5 + rand(n,1)*0.5; % aggregate queue-length observations
29
30%% Create SampledMetric objects (aggregate, no class specified)
31ql = SampledMetric(MetricType.QLen, ts, qlen_samples, node{2});
32
33%% Estimate with MCMC
34fprintf(1, '\n=== MCMC Estimator ===\n');
35options = ParamEstimator.defaultOptions;
36options.method = 'mcmc';
37se = ParamEstimator(model, options);
38se.addSamples(ql);
39se.interpolate();
40estVal = se.estimateAt(node{2});
41fprintf(1, 'MCMC demands: Class1=%.4f, Class2=%.4f\n', estVal(1), estVal(2));
42
43%% Solve model
44solver{1} = SolverMVA(model);
45fprintf(1, '\nSOLVER: %s\n', solver{1}.getName());
46AvgTable{1} = solver{1}.getAvgTable();
47AvgTable{1}