LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
EvaluationResult.m
1classdef EvaluationResult < handle
2 % EvaluationResult Metrics from evaluating a LINE model via SolverAuto.
3 % Mirrors native-Python line_solver.opt.results.EvaluationResult. Per-
4 % (station, class) metrics use a containers.Map keyed by 'station||class';
5 % utilizations by station; system metrics by chain/class name.
6
7 properties
8 feasible = true;
9 responseTimes % Map 'station||class' -> value
10 throughputs
11 queueLengths
12 utilizations % Map 'station' -> value
13 systemResponseTimes % Map chain/class -> value
14 systemThroughputs
15 solveTime = 0.0;
16 solverUsed = '';
17 sensitivities = []; % opt.SensitivityData or []
18 end
19
20 methods
21 function obj = EvaluationResult()
22 obj.responseTimes = containers.Map('KeyType', 'char', 'ValueType', 'double');
23 obj.throughputs = containers.Map('KeyType', 'char', 'ValueType', 'double');
24 obj.queueLengths = containers.Map('KeyType', 'char', 'ValueType', 'double');
25 obj.utilizations = containers.Map('KeyType', 'char', 'ValueType', 'double');
26 obj.systemResponseTimes = containers.Map('KeyType', 'char', 'ValueType', 'double');
27 obj.systemThroughputs = containers.Map('KeyType', 'char', 'ValueType', 'double');
28 end
29
30 function k = key(~, station, jobclass)
31 k = [station '||' jobclass];
32 end
33
34 function setResponseTime(obj, station, jobclass, v)
35 obj.responseTimes(obj.key(station, jobclass)) = v;
36 end
37 function setThroughput(obj, station, jobclass, v)
38 obj.throughputs(obj.key(station, jobclass)) = v;
39 end
40 function setQueueLength(obj, station, jobclass, v)
41 obj.queueLengths(obj.key(station, jobclass)) = v;
42 end
43
44 function v = getResponseTime(obj, station, jobclass)
45 if nargin >= 3 && ~isempty(jobclass)
46 k = obj.key(station, jobclass);
47 if isKey(obj.responseTimes, k), v = obj.responseTimes(k); else, v = inf; end
48 else
49 v = obj.aggregate(obj.responseTimes, station, true, inf);
50 end
51 end
52 function v = getThroughput(obj, station, jobclass)
53 if nargin >= 3 && ~isempty(jobclass)
54 k = obj.key(station, jobclass);
55 if isKey(obj.throughputs, k), v = obj.throughputs(k); else, v = 0.0; end
56 else
57 v = obj.aggregate(obj.throughputs, station, false, 0.0);
58 end
59 end
60 function v = getQueueLength(obj, station, jobclass)
61 if nargin >= 3 && ~isempty(jobclass)
62 k = obj.key(station, jobclass);
63 if isKey(obj.queueLengths, k), v = obj.queueLengths(k); else, v = 0.0; end
64 else
65 v = obj.aggregate(obj.queueLengths, station, false, 0.0);
66 end
67 end
68 function v = getUtilization(obj, station)
69 if isKey(obj.utilizations, station), v = obj.utilizations(station); else, v = 0.0; end
70 end
71
72 function v = aggregate(~, m, station, doMean, defaultVal)
73 ks = keys(m);
74 total = 0.0; count = 0;
75 prefix = [station '||'];
76 for i = 1:numel(ks)
77 if strncmp(ks{i}, prefix, numel(prefix))
78 total = total + m(ks{i});
79 count = count + 1;
80 end
81 end
82 if count == 0
83 v = defaultVal;
84 elseif doMean
85 v = total / count;
86 else
87 v = total;
88 end
89 end
90
91 function v = getSystemResponseTime(obj, jobclass)
92 if nargin >= 2 && ~isempty(jobclass)
93 if isKey(obj.systemResponseTimes, jobclass), v = obj.systemResponseTimes(jobclass); else, v = inf; end
94 return;
95 end
96 ks = keys(obj.systemResponseTimes);
97 if isempty(ks), v = inf; return; end
98 totalTput = 0.0; weighted = 0.0;
99 for i = 1:numel(ks)
100 rt = obj.systemResponseTimes(ks{i});
101 if isKey(obj.systemThroughputs, ks{i}), tp = obj.systemThroughputs(ks{i}); else, tp = 0.0; end
102 weighted = weighted + rt * tp; totalTput = totalTput + tp;
103 end
104 if totalTput > 0
105 v = weighted / totalTput;
106 else
107 vals = cell2mat(values(obj.systemResponseTimes));
108 v = sum(vals) / numel(vals);
109 end
110 end
111
112 function v = getSystemThroughput(obj, jobclass)
113 if nargin >= 2 && ~isempty(jobclass)
114 if isKey(obj.systemThroughputs, jobclass), v = obj.systemThroughputs(jobclass); else, v = 0.0; end
115 return;
116 end
117 if obj.systemThroughputs.Count == 0, v = 0.0; else, v = sum(cell2mat(values(obj.systemThroughputs))); end
118 end
119 end
120end