1classdef TaskThinkTime < opt.DecisionVariable
2 % TaskThinkTime Optimize the think time of an LQN Task (continuous).
3 % Mirrors native-Python TaskThinkTime.
12 function obj = TaskThinkTime(task, bounds, name)
13 taskName = opt.Layered.elemName(task);
14 if nargin < 3 || isempty(name)
15 name = [taskName
'_thinktime'];
17 obj@opt.DecisionVariable(name);
19 obj.minValue = bounds(1);
20 obj.maxValue = bounds(2);
23 function b = getBounds(obj), b = opt.DecisionVariable.unitBounds(1); end
25 function v = decode(obj, x)
26 v = obj.minValue + x(1) * (obj.maxValue - obj.minValue);
29 function apply(obj, model, value)
30 task = opt.Layered.resolveTask(model, obj.task);
32 task.setThinkTime(
double(value));
36 function t = getVariableType(obj), t =
'think_time'; end
38 function layers = getLayer(obj, model)
40 proc = opt.Layered.taskProcessorName(model, obj.task);
41 if ~isempty(proc), layers{end+1} = proc; end
44 function v = currentValue(obj, model)
46 task = opt.Layered.resolveTask(model, obj.task);
48 v = opt.Layered.distMean(task.thinkTime);