LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ActivityThinkTime.m
1classdef ActivityThinkTime < opt.DecisionVariable
2 % ActivityThinkTime Optimize the activity-level think time of an LQN
3 % Activity (continuous). Mirrors native-Python ActivityThinkTime.
4
5 properties
6 activity
7 minValue
8 maxValue
9 end
10
11 methods
12 function obj = ActivityThinkTime(activity, bounds, name)
13 actName = opt.Layered.elemName(activity);
14 if nargin < 3 || isempty(name)
15 name = [actName '_thinktime'];
16 end
17 obj@opt.DecisionVariable(name);
18 obj.activity = actName;
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 act = opt.Layered.resolveActivity(model, obj.activity);
31 if ~isempty(act)
32 act.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 = {};
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
45 end
46
47 function v = currentValue(obj, model)
48 v = [];
49 act = opt.Layered.resolveActivity(model, obj.activity);
50 if ~isempty(act)
51 v = opt.Layered.distMean(act.thinkTime);
52 end
53 end
54 end
55end