1classdef MaximizePerformance < opt.Objective
2 % MaximizePerformance Maximize weighted throughput + 1/RespT + 1/QLen,
3 % subject to an optional budget constraint. Returns negated performance
4 % (DE minimizes). Mirrors native-Python MaximizePerformance.
7 throughputWeight = 1.0;
8 responseTimeWeight = 1.0;
9 queueLengthWeight = 0.0;
10 stations = []; % cell of station names, or [] = all
14 function obj = MaximizePerformance(throughputWeight, responseTimeWeight, ...
15 queueLengthWeight, stations, budget, budgetTerms)
16 if nargin >= 1 && ~isempty(throughputWeight), obj.throughputWeight = throughputWeight; end
17 if nargin >= 2 && ~isempty(responseTimeWeight), obj.responseTimeWeight = responseTimeWeight; end
18 if nargin >= 3 && ~isempty(queueLengthWeight), obj.queueLengthWeight = queueLengthWeight; end
19 if nargin >= 4 && ~isempty(stations)
20 names = cell(1, numel(stations));
21 for i = 1:numel(stations)
22 names{i} = opt.Constraint.nameOf(stations{i});
26 if nargin >= 5 && ~isempty(budget)
27 if nargin < 6, budgetTerms = []; end
28 obj.constraints = {opt.BudgetConstraint(budget, budgetTerms)};
32 function tf = isMinimization(~), tf =
true; end
34 function v = evaluate(obj, result, ~)
36 if isempty(obj.stations)
37 % unique station names from throughput keys 'station||class'
38 ks = keys(result.throughputs);
41 parts = strsplit(ks{i},
'||');
42 sts{end+1} = parts{1}; %#ok<AGROW>
50 if obj.throughputWeight > 0
51 performance = performance + obj.throughputWeight * result.getThroughput(station);
53 if obj.responseTimeWeight > 0
54 rt = result.getResponseTime(station);
55 if rt > 0 && isfinite(rt)
56 performance = performance + obj.responseTimeWeight * (1.0 / rt);
59 if obj.queueLengthWeight > 0
60 qlen = result.getQueueLength(station);
62 performance = performance + obj.queueLengthWeight * (1.0 / qlen);