LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
estimator_fmlps.m
1function estVal = estimator_fmlps(self, nodes)
2node = nodes{1};
3% ESTIMATORFMLPS Fluid Maximum Likelihood for Processor Sharing
4% Estimates service demands using the FMLPS fluid likelihood 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 FMLPS 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);
26 eqSn = eqModel.getStruct;
27 W = sum(eqSn.njobs);
28else
29 eqModel = self.model;
30 eqNode = node;
31 W = sum(sn.njobs);
32end
33
34% Extract trace data from SampledMetrics
35rt_all = [];
36class_all = [];
37at_all = [];
38for r = 1:R
39 jc = self.model.classes{r};
40
41 % Arrival timestamps (trace format)
42 arvData = self.getArvR(node, jc);
43 if isempty(arvData)
44 error('Arrival timestamp data for node %s in class %d is missing.', node.name, r);
45 end
46 if ~arvData.isTrace()
47 error('FMLPS estimator requires trace-format arrival data. Use setTrace() on the SampledMetric.');
48 end
49
50 % Response times (trace format)
51 rtData = self.getRespT(node, jc);
52 if isempty(rtData)
53 error('Response time data for node %s in class %d is missing.', node.name, r);
54 end
55 if ~rtData.isTrace()
56 error('FMLPS estimator requires trace-format response time data. Use setTrace() on the SampledMetric.');
57 end
58
59 nSamples = length(rtData.data);
60 rt_all = [rt_all; rtData.data];
61 at_all = [at_all; arvData.data];
62 class_all = [class_all; r * ones(nSamples, 1)];
63end
64
65% Compute queue lengths at arrival from trace data
66n = length(at_all);
67jobid = (1:n)';
68ql = infer_compute_ql_at_arrival(at_all, jobid, rt_all, jobid, class_all, R);
69
70% Sort by arrival time
71[~, sortIdx] = sort(at_all);
72rt_sorted = rt_all(sortIdx);
73class_sorted = class_all(sortIdx);
74ql = ql(sortIdx, :);
75
76% Remove zero response times
77valid = rt_sorted > 0;
78rt_sorted = rt_sorted(valid);
79class_sorted = class_sorted(valid);
80ql = ql(valid, :);
81
82estVal = infer_fmlps(eqModel, eqNode, rt_sorted, class_sorted, ql, W);
83estVal = estVal(:)';
84
85end
Definition mmt.m:124