11 private const double DefaultTolerance = 1.0e-9;
15 double tolerance = DefaultTolerance)
17 ArgumentNullException.ThrowIfNull(model);
19 if (!
double.IsFinite(tolerance) ||
22 throw new ArgumentOutOfRangeException(
30 variable => variable.Id);
33 new List<IntrinsicFeasibilityDiagnostic>();
53 TryProveConstraintInfeasible(
58 if (diagnostic is not
null)
60 diagnostics.Add(diagnostic);
74 IReadOnlyDictionary<int, MathematicalVariable> variables)
76 ArgumentNullException.ThrowIfNull(expression);
77 ArgumentNullException.ThrowIfNull(variables);
79 double minimum = expression.
Constant;
80 double maximum = expression.
Constant;
90 if (!variables.TryGetValue(
94 throw new InvalidOperationException(
95 $
"Expression references unknown variable identifier '{term.VariableId}'.");
98 double lowContribution;
99 double highContribution;
122 minimum += lowContribution;
123 maximum += highContribution;
125 if (
double.IsNaN(minimum) ||
126 double.IsNaN(maximum))
129 double.NegativeInfinity,
130 double.PositiveInfinity);
140 TryProveConstraintInfeasible(
148 switch (constraint.
Sense)
151 if (interval.Minimum >
154 return CreateDiagnostic(
158 "Minimum attainable left-hand side exceeds the <= right-hand side.");
164 if (interval.Maximum <
167 return CreateDiagnostic(
171 "Maximum attainable left-hand side is below the >= right-hand side.");
178 interval.Minimum - tolerance)
180 return CreateDiagnostic(
184 "Equality right-hand side is below the attainable left-hand-side interval.");
188 interval.Maximum + tolerance)
190 return CreateDiagnostic(
194 "Equality right-hand side is above the attainable left-hand-side interval.");
200 throw new NotSupportedException(
201 $
"Constraint sense '{constraint.Sense}' is not supported by intrinsic feasibility analysis.");
205 private static IntrinsicFeasibilityDiagnostic
208 LinearConstraint constraint,
209 LinearExpressionBoundInterval interval,
212 return new IntrinsicFeasibilityDiagnostic(
214 $
"Constraint '{constraint.Name}' is intrinsically infeasible: {reason}",
Proves intrinsic infeasibility from variable-bound interval arithmetic. Absence of a proof is reporte...
LinearExpressionBoundInterval EvaluateInterval(LinearExpression expression, IReadOnlyDictionary< int, MathematicalVariable > variables)
IntrinsicFeasibilityAnalysisResult Analyze(MathematicalModel model, double tolerance=DefaultTolerance)
Represents one linear constraint in a mathematical optimization model.
double RightHandSide
Gets or sets the right-hand-side constant value.
MathematicalConstraintSense Sense
Gets or sets the relational sense of the constraint.
bool IsEnabled
Gets or sets a value indicating whether the constraint is enabled.
LinearExpression LeftHandSide
Gets or sets the left-hand-side linear expression.
int Id
Gets or sets the unique constraint identifier within the mathematical model.
Represents a linear expression composed of variable terms and a constant value.
double Constant
Gets or sets the constant value of the expression.
Represents one coefficient-variable term in a linear expression.
int VariableId
Gets or sets the identifier of the referenced mathematical variable.
double Coefficient
Gets or sets the coefficient multiplying the referenced variable.
Represents a solver-independent mathematical optimization model.
List< MathematicalVariable > Variables
Gets the mathematical variables.
void EnsureValid()
Validates the complete mathematical model.
Represents one decision variable in a mathematical optimization model.
IntrinsicFeasibilityStatus
Conservative pre-solve feasibility status.
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.