1classdef ActivityThinkTime < opt.DecisionVariable
2 % ActivityThinkTime Optimize the activity-level think time of an LQN
3 % Activity (continuous). Mirrors native-Python ActivityThinkTime.
12 function obj = ActivityThinkTime(activity, bounds, name)
13 actName = opt.Layered.elemName(activity);
14 if nargin < 3 || isempty(name)
15 name = [actName
'_thinktime'];
17 obj@opt.DecisionVariable(name);
18 obj.activity = actName;
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 act = opt.Layered.resolveActivity(model, obj.activity);
32 act.setThinkTime(
double(value));
36 function t = getVariableType(obj), t =
'think_time'; end
38 function layers = getLayer(obj, model)
40 task = opt.Layered.taskOfActivity(model, obj.activity);
41 if ~isempty(task), layers{end+1} = task.getName(); end
42 proc = opt.Layered.activityProcessorName(model, obj.activity);
43 if ~isempty(proc), layers{end+1} = proc; end
44 if isempty(layers), layers = {}; end
47 function v = currentValue(obj, model)
49 act = opt.Layered.resolveActivity(model, obj.activity);
51 v = opt.Layered.distMean(act.thinkTime);