LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
example_infer_trace_closed.m
1clear node jobclass solver AvgTable
2%% Example: Compare trace-based estimators (MLPS, FMLPS, Gibbs) on a PS station
3% Copyright (c) 2012-2026, Imperial College London
4% All rights reserved.
5
6%% define model
7N = 5; % population
8model = Network('model');
9node{1} = Delay(model, 'Delay');
10node{2} = Queue(model, 'Queue1', SchedStrategy.PS);
11jobclass{1} = ClosedClass(model, 'Class1', N, 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 trace data
21n = 200;
22arrival_times = sort(rand(n,1) * 100);
23response_times = 0.5 + rand(n,1) * 0.3;
24tput_samples = ones(n,1) * (N / (1.0 + 0.5)); % approximate throughput
25
26%% Create trace-format SampledMetric objects
27arvData = SampledMetric(MetricType.ArvR, arrival_times, arrival_times, node{2}, jobclass{1});
28arvData.setTrace();
29rtData = SampledMetric(MetricType.RespT, arrival_times, response_times, node{2}, jobclass{1});
30rtData.setTrace();
31tputData = SampledMetric(MetricType.Tput, arrival_times, tput_samples, node{2}, jobclass{1});
32
33%% Estimate with MLPS
34fprintf(1, '\n=== MLPS Estimator ===\n');
35options = ParamEstimator.defaultOptions;
36options.method = 'mlps';
37se = ParamEstimator(model, options);
38se.addSamples(arvData);
39se.addSamples(rtData);
40se.interpolate();
41try
42 estVal_mlps = se.estimateAt(node{2});
43 fprintf(1, 'MLPS demand: Class1=%.4f\n', estVal_mlps(1));
44catch e
45 fprintf(1, 'MLPS skipped: %s\n', e.message);
46 estVal_mlps = NaN;
47end
48
49%% Estimate with FMLPS
50fprintf(1, '\n=== FMLPS Estimator ===\n');
51node{2}.setService(jobclass{1}, Exp(NaN));
52model.reset;
53
54options.method = 'fmlps';
55se = ParamEstimator(model, options);
56se.addSamples(arvData);
57se.addSamples(rtData);
58se.interpolate();
59try
60 estVal_fmlps = se.estimateAt(node{2});
61 fprintf(1, 'FMLPS demand: Class1=%.4f\n', estVal_fmlps(1));
62catch e
63 fprintf(1, 'FMLPS skipped: %s\n', e.message);
64 estVal_fmlps = NaN;
65end
66
67%% Estimate with Gibbs
68fprintf(1, '\n=== Gibbs Estimator ===\n');
69node{2}.setService(jobclass{1}, Exp(NaN));
70model.reset;
71
72options.method = 'gibbs';
73se = ParamEstimator(model, options);
74se.addSamples(arvData);
75se.addSamples(rtData);
76se.addSamples(tputData);
77se.interpolate();
78try
79 estVal_gibbs = se.estimateAt(node{2});
80 fprintf(1, 'Gibbs demand: Class1=%.4f\n', estVal_gibbs(1));
81catch e
82 fprintf(1, 'Gibbs skipped: %s\n', e.message);
83 estVal_gibbs = NaN;
84end
85
86%% Compare results
87fprintf(1, '\n=== Comparison (true demand ~ 0.5) ===\n');
88fprintf(1, 'MLPS: %.4f\n', estVal_mlps(1));
89fprintf(1, 'FMLPS: %.4f\n', estVal_fmlps(1));
90fprintf(1, 'Gibbs: %.4f\n', estVal_gibbs(1));
91
92%% Solve model with final estimates
93solver{1} = SolverMVA(model);
94fprintf(1, '\nSOLVER: %s\n', solver{1}.getName());
95AvgTable{1} = solver{1}.getAvgTable();
96AvgTable{1}