1classdef Objective < handle
2 % Objective Abstract base
for line-opt objectives. Mirrors native-Python
3 % line_solver.opt.objectives.Objective: defines
the scalar to minimize,
4 % with attached constraints folded in as penalties by evaluateWithPenalty.
7 constraints = {}; % cell array of opt.Constraint
11 function c = getConstraints(obj)
14 function v = evaluateWithPenalty(obj, result, variableValues, penaltyWeight)
15 if nargin < 4, penaltyWeight = 1e6; end
16 v = obj.evaluate(result, variableValues);
17 for i = 1:numel(obj.constraints)
18 v = v + obj.constraints{i}.evaluate(result, variableValues) * penaltyWeight;
24 v = evaluate(obj, result, variableValues)
25 tf = isMinimization(obj)
29 function d = numericValue(value)
32 elseif isnumeric(value)
38 function tf = isScalarNumeric(value)
39 tf = isnumeric(value) && isscalar(value);