LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
OptimizationResult.m
1classdef OptimizationResult < handle
2 % OptimizationResult Result from a single optimization run. Mirrors
3 % native-Python line_solver.opt.results.OptimizationResult.
4
5 properties
6 objectiveValue = inf;
7 variableValues % Map name -> value (scalar or vector)
8 constraintViolations % Map name -> violation
9 feasible = false;
10 iterations = 0;
11 solveTime = 0.0;
12 modelEvaluations = 0;
13 convergenceHistory = [];
14 terminatedBy = '';
15 end
16
17 methods
18 function obj = OptimizationResult()
19 obj.variableValues = containers.Map('KeyType', 'char', 'ValueType', 'any');
20 obj.constraintViolations = containers.Map('KeyType', 'char', 'ValueType', 'double');
21 end
22
23 function tf = isFeasible(obj)
24 tf = obj.feasible;
25 end
26 function v = getObjectiveValue(obj)
27 v = obj.objectiveValue;
28 end
29 function v = getVariableValue(obj, name)
30 if isKey(obj.variableValues, name), v = obj.variableValues(name); else, v = []; end
31 end
32 function v = getConstraintViolation(obj, name)
33 if isKey(obj.constraintViolations, name), v = obj.constraintViolations(name); else, v = 0.0; end
34 end
35 function v = getTotalViolation(obj)
36 if obj.constraintViolations.Count == 0, v = 0.0;
37 else, v = sum(cell2mat(values(obj.constraintViolations))); end
38 end
39 end
40end