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)
28 b = getBounds(obj) % dimension x 2
29 v = decode(obj, x) % x
is 1 x dimension in [0,1]
30 apply(obj, model, value)
31 t = getVariableType(obj)
35 function c = resolveClass(model,
jobclass)
38 classes = model.getClasses();
39 for i = 1:numel(classes)
40 if strcmp(classes{i}.getName(), target)
47 function nd = resolveNode(model, node)
49 target = node.getName();
50 nodes = model.getNodes();
51 for i = 1:numel(
nodes)
52 if strcmp(
nodes{i}.getName(), target)
59 function conn = connectionMatrix(model)
60 sn = model.getStruct();
61 conn = full(sn.connmatrix);
64 function b = unitBounds(dim)
65 b = [zeros(dim, 1), ones(dim, 1)];
68 function idx = indexOfNode(
nodes, nameToFind)
70 for i = 1:numel(
nodes)
71 if strcmp(
nodes{i}.getName(), nameToFind)