LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
estimator_mlps.m
1function estVal = estimator_mlps(self, nodes)
2node = nodes{1};
3% ESTIMATORMLPS Maximum Likelihood for Processor Sharing
4% Estimates service demands using the MLPS likelihood-based method.
5% Supports closed, open, and mixed queueing networks.
6% For open/mixed models, builds a closed equivalent using Z_r = N_r / lambda_r.
7%
8% Requires trace-format SampledMetric objects with per-request arrival
9% timestamps and response times. PS stations only.
10%
11% Copyright (c) 2012-2026, Imperial College London
12% All rights reserved.
13% This code is released under the 3-Clause BSD License.
14
15sn = self.model.getStruct;
16R = sn.nclasses;
17
18if node.schedStrategy ~= SchedStrategy.PS
19 error('The MLPS method is available only for processor sharing stations.');
20end
21
22% Build closed equivalent model if any class is open
23hasOpen = any(sn.njobs == Inf);
24if hasOpen
25 [eqModel, eqNode] = self.buildClosedEquivalentForPS(node);
26else
27 eqModel = self.model;
28 eqNode = node;
29end
30
31% Extract trace data from SampledMetrics
32rt_all = [];
33class_all = [];
34at_all = [];
35for r = 1:R
36 jc = self.model.classes{r};
37
38 % Arrival timestamps (trace format)
39 arvData = self.getArvR(node, jc);
40 if isempty(arvData)
41 error('Arrival timestamp data for node %s in class %d is missing.', node.name, r);
42 end
43 if ~arvData.isTrace()
44 error('MLPS estimator requires trace-format arrival data. Use setTrace() on the SampledMetric.');
45 end
46
47 % Response times (trace format)
48 rtData = self.getRespT(node, jc);
49 if isempty(rtData)
50 error('Response time data for node %s in class %d is missing.', node.name, r);
51 end
52 if ~rtData.isTrace()
53 error('MLPS estimator requires trace-format response time data. Use setTrace() on the SampledMetric.');
54 end
55
56 nSamples = length(rtData.data);
57 rt_all = [rt_all; rtData.data];
58 at_all = [at_all; arvData.data];
59 class_all = [class_all; r * ones(nSamples, 1)];
60end
61
62% Compute queue lengths at arrival from trace data
63n = length(at_all);
64jobid = (1:n)';
65ql = infer_compute_ql_at_arrival(at_all, jobid, rt_all, jobid, class_all, R);
66
67% Sort by arrival time
68[~, sortIdx] = sort(at_all);
69rt_sorted = rt_all(sortIdx);
70class_sorted = class_all(sortIdx);
71ql = ql(sortIdx, :);
72
73% Remove zero response times
74valid = rt_sorted > 0;
75rt_sorted = rt_sorted(valid);
76class_sorted = class_sorted(valid);
77ql = ql(valid, :);
78
79estVal = infer_mlps(eqModel, eqNode, rt_sorted, class_sorted, ql);
80estVal = estVal(:)';
81
82end
Definition mmt.m:124