14 MathematicalModel model,
15 MathematicalModelSolveResult solveResult,
16 double tolerance = 1.0e-6)
18 ArgumentNullException.ThrowIfNull(model);
19 ArgumentNullException.ThrowIfNull(solveResult);
21 if (!
double.IsFinite(tolerance) ||
24 throw new ArgumentOutOfRangeException(
31 new List<MathematicalFeasibilityDiagnostic>();
33 if (!solveResult.HasFeasibleSolution)
38 "Solver result does not claim a feasible incumbent; no candidate can be checked."));
41 FeasibilityStatus.NotEvaluated,
46 new Dictionary<int, double>();
50 foreach (MathematicalVariable variable
53 MathematicalVariableValue? value =
54 solveResult.FindVariableValue(
64 $
"Missing value for variable '{variable.Name}' ({variable.Id})."));
82 "LSDM-FEAS-SOL-002" or
86 FeasibilityStatus.Infeasible,
93 FeasibilityStatus.PartiallyEvaluated,
97 foreach (LinearConstraint constraint
100 if (!constraint.IsEnabled)
105 double leftHandSide =
106 constraint.LeftHandSide.Constant;
108 foreach (LinearTerm term
109 in constraint.LeftHandSide.Terms)
113 values[term.VariableId];
117 constraint.Sense
switch
119 MathematicalConstraintSense.LessThanOrEqual =>
121 constraint.RightHandSide +
124 MathematicalConstraintSense.GreaterThanOrEqual =>
126 constraint.RightHandSide -
129 MathematicalConstraintSense.Equal =>
132 constraint.RightHandSide) <=
136 throw new NotSupportedException(
137 $
"Constraint sense '{constraint.Sense}' is not supported by the checker.")
145 $
"Constraint '{constraint.Name}' ({constraint.Id}) is violated: lhs={leftHandSide:G17}, rhs={constraint.RightHandSide:G17}, sense={constraint.Sense}."));
154 ? FeasibilityStatus.Infeasible
155 : FeasibilityStatus.Feasible,