LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
TaskThinkTime.m
1classdef TaskThinkTime < opt.DecisionVariable
2 % TaskThinkTime Optimize the think time of an LQN Task (continuous).
3 % Mirrors native-Python TaskThinkTime.
4
5 properties
6 task
7 minValue
8 maxValue
9 end
10
11 methods
12 function obj = TaskThinkTime(task, bounds, name)
13 taskName = opt.Layered.elemName(task);
14 if nargin < 3 || isempty(name)
15 name = [taskName '_thinktime'];
16 end
17 obj@opt.DecisionVariable(name);
18 obj.task = taskName;
19 obj.minValue = bounds(1);
20 obj.maxValue = bounds(2);
21 end
22
23 function b = getBounds(obj), b = opt.DecisionVariable.unitBounds(1); end
24
25 function v = decode(obj, x)
26 v = obj.minValue + x(1) * (obj.maxValue - obj.minValue);
27 end
28
29 function apply(obj, model, value)
30 task = opt.Layered.resolveTask(model, obj.task);
31 if ~isempty(task)
32 task.setThinkTime(double(value));
33 end
34 end
35
36 function t = getVariableType(obj), t = 'think_time'; end
37
38 function layers = getLayer(obj, model)
39 layers = {obj.task};
40 proc = opt.Layered.taskProcessorName(model, obj.task);
41 if ~isempty(proc), layers{end+1} = proc; end
42 end
43
44 function v = currentValue(obj, model)
45 v = [];
46 task = opt.Layered.resolveTask(model, obj.task);
47 if ~isempty(task)
48 v = opt.Layered.distMean(task.thinkTime);
49 end
50 end
51 end
52end