LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ResponseTimeConstraint.m
1classdef ResponseTimeConstraint < opt.Constraint
2 % ResponseTimeConstraint Per-station response time constraint: RT <= maxValue.
3 properties
4 station
5 jobclass = '';
6 maxValue
7 end
8 methods
9 function obj = ResponseTimeConstraint(station, jobclass, maxValue, name)
10 if nargin < 4, name = ''; end
11 obj@opt.Constraint(name);
12 obj.station = opt.Constraint.nameOf(station);
13 if nargin >= 2 && ~isempty(jobclass)
14 obj.jobclass = opt.Constraint.nameOf(jobclass);
15 end
16 obj.maxValue = maxValue;
17 end
18 function n = generateName(obj)
19 if ~isempty(obj.jobclass)
20 n = sprintf('RT_%s_%s_le_%g', obj.station, obj.jobclass, obj.maxValue);
21 else
22 n = sprintf('RT_%s_le_%g', obj.station, obj.maxValue);
23 end
24 end
25 function v = evaluate(obj, result, ~)
26 if ~isempty(obj.jobclass)
27 actual = result.getResponseTime(obj.station, obj.jobclass);
28 else
29 actual = result.getResponseTime(obj.station);
30 end
31 v = opt.Constraint.upperBoundViolation(actual, obj.maxValue);
32 end
33 end
34end