LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
DecisionVariable.m
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
8 % evaluation.
9
10 properties
11 name
12 dimension = 1;
13 end
14
15 methods
16 function obj = DecisionVariable(name)
17 obj.name = name;
18 end
19 function n = getName(obj)
20 n = obj.name;
21 end
22 function d = getDimension(obj)
23 d = obj.dimension;
24 end
25 end
26
27 methods (Abstract)
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)
32 end
33
34 methods (Static)
35 function c = resolveClass(model, jobclass)
36 c = [];
37 target = jobclass.getName();
38 classes = model.getClasses();
39 for i = 1:numel(classes)
40 if strcmp(classes{i}.getName(), target)
41 c = classes{i};
42 return;
43 end
44 end
45 end
46
47 function nd = resolveNode(model, node)
48 nd = [];
49 target = node.getName();
50 nodes = model.getNodes();
51 for i = 1:numel(nodes)
52 if strcmp(nodes{i}.getName(), target)
53 nd = nodes{i};
54 return;
55 end
56 end
57 end
58
59 function conn = connectionMatrix(model)
60 sn = model.getStruct();
61 conn = full(sn.connmatrix);
62 end
63
64 function b = unitBounds(dim)
65 b = [zeros(dim, 1), ones(dim, 1)];
66 end
67
68 function idx = indexOfNode(nodes, nameToFind)
69 idx = -1;
70 for i = 1:numel(nodes)
71 if strcmp(nodes{i}.getName(), nameToFind)
72 idx = i;
73 return;
74 end
75 end
76 end
77 end
78end
Definition fjtag.m:157
Definition Station.m:245