LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
example_infer_ubr_open.m
1clear node jobclass solver AvgTable
2
3clearvars -except exampleName;
4model = Network('model');
5
6node{1} = Delay(model, 'Delay');
7node{2} = Queue(model, 'Queue1', SchedStrategy.FCFS);
8node{3} = Source(model,'Source');
9node{4} = Sink(model,'Sink');
10
11jobclass{1} = OpenClass(model, 'Class1', 0);
12
13node{1}.setService(jobclass{1}, HyperExp(0.5,3.0,10.0));
14node{2}.setService(jobclass{1}, Exp(NaN)); % NaN = to be estimated
15node{3}.setArrival(jobclass{1}, Exp(0.1));
16
17M = model.getNumberOfStations();
18K = model.getNumberOfClasses();
19
20P = cell(K,K);
21P{1,1} = [0,1,0,0; 0,0,0,1; 1,0,0,0; 0,0,0,0];
22
23model.link(P);
24
25%% Generate random dataset for utilization and average arrival rate
26n = 1000;
27ts = 1:n; % timestamps at which the system is sampled
28arvrate_samples = 2*ones(n,1)-rand(n,1)*0.15; % sampled arrival rate values
29util_samples = ones(n,1)-rand(n,1)*0.05; % sampled utilization values
30respt_samples = 0.7./(1-util_samples); % sampled response time values
31
32%% Estimate demands
33estoptions = ParamEstimator.defaultOptions;
34estoptions.method = 'ubr';
35se = ParamEstimator(model, estoptions);
36
37lambda1 = SampledMetric(MetricType.ArvR, ts, arvrate_samples, node{2}, jobclass{1});
38respT1 = SampledMetric(MetricType.RespT, ts, respt_samples, node{2}, jobclass{1});
39util = SampledMetric(MetricType.Util, ts, util_samples, node{2});
40
41se.addSamples(lambda1);
42se.addSamples(respT1);
43se.addSamples(util);
44se.interpolate(); % ensures that the metrics are interpolated at the same time instants all
45estVal = se.estimateAt(node{2}) % the change to the NaN value in Exp is applied automatically
46
47%% Solve model
48options = Solver.defaultOptions;
49options.keep=true;
50options.verbose=1;
51options.cutoff = 10;
52options.seed = 23000;
53%options.samples=2e4;
54
55solver = {};
56solver{end+1} = SolverMVA(model);
57
58AvgTable = cell(1,length(solver));
59for s=1:length(solver)
60 fprintf(1,'SOLVER: %s\n',solver{s}.getName());
61 AvgTable{s} = solver{s}.getAvgTable();
62 AvgTable{s}
63end