1classdef DecisionVariable < handle
2 % DecisionVariable Abstract base
for line-opt decision variables. Mirrors
3 % native-Python line_solver.opt.variables.DecisionVariable: each variable
4 % encodes a tunable model parameter as continuous values in [0,1]
5 % (getBounds), decodes them to the native domain (decode), and applies the
6 % decoded value to a per-evaluation model copy (apply). Objects are
7 % re-resolved by name in the target model because models are copied per
16 function obj = DecisionVariable(name)
19 function n = getName(obj)
22 function d = getDimension(obj)
26 function layers = getLayer(~, ~)
27 % LQN layer name(s)
this variable perturbs, or {}
for flat models.
28 % Consumed by layer freezing (
explicit frozenLayers and adaptive
29 %
auto-freeze): a variable whose layer set intersects the frozen
30 % set
is held fixed. LQN variable subclasses override this.
34 function v = currentValue(~, ~)
35 % The variable
's current (decoded) value in the given model, or []
36 % when not introspectable. Used by layer freezing to hold a
37 % variable at the model's existing parameter value. LQN variable
38 % subclasses
override this.
44 b = getBounds(obj) % dimension x 2
45 v = decode(obj, x) % x
is 1 x dimension in [0,1]
46 apply(obj, model, value)
47 t = getVariableType(obj)
51 function c = resolveClass(model,
jobclass)
54 classes = model.getClasses();
55 for i = 1:numel(classes)
56 if strcmp(classes{i}.getName(), target)
63 function nd = resolveNode(model, node)
65 target = node.getName();
66 nodes = model.getNodes();
67 for i = 1:numel(
nodes)
68 if strcmp(
nodes{i}.getName(), target)
75 function conn = connectionMatrix(model)
76 sn = model.getStruct();
77 conn = full(sn.connmatrix);
80 function b = unitBounds(dim)
81 b = [zeros(dim, 1), ones(dim, 1)];
84 function idx = indexOfNode(
nodes, nameToFind)
86 for i = 1:numel(
nodes)
87 if strcmp(
nodes{i}.getName(), nameToFind)