1classdef Constraint < handle
2 % Constraint Abstract base
for line-opt constraints. Each computes a
3 % non-negative violation (0
if satisfied). Mirrors native-Python
4 % line_solver.opt.objectives.Constraint.
11 function obj = Constraint(name)
12 if nargin >= 1 && ~isempty(name)
16 function n = getName(obj)
18 n = obj.generateName();
23 function tf = isSatisfied(obj, result, variableValues, tol)
24 if nargin < 4, tol = 1e-6; end
25 tf = obj.evaluate(result, variableValues) <= tol;
31 v = evaluate(obj, result, variableValues)
35 function v = upperBoundViolation(actual, bound)
39 v = max(0.0, actual - bound);
42 function v = lowerBoundViolation(actual, bound)
46 v = max(0.0, bound - actual);
49 function nm = nameOf(x)
50 if ischar(x) || isstring(x)