KktConditions

Helpers & Utilities · AiDotNet.Solvers

Verifies the Karush-Kuhn-Tucker optimality conditions for a constrained problem.

For Beginners

Think of it as a receipt-checker. Any solver can hand you an answer; this tells you whether the answer really satisfies the four properties an optimum must have — nowhere better to move, obeys the rules, prices are sensible, and you are only paying for limits that actually bind.

How It Works

The KKT conditions (Karush, 1939; Kuhn and Tucker, 1951) generalize “set the derivative to zero” to problems with constraints. For a convex problem they are necessary and sufficient, so a point satisfying them is the optimum — no further search can improve it.

This class exists so that a solver’s answer can be audited independently of the solver. That matters more than it sounds: an optimization bug typically produces a plausible-looking number rather than an obvious failure, and the KKT residual is the cheapest way to catch one.

Methods

Method Summary
KktResidual<T> Evaluate(Matrix<T> quadratic, Vector<T> linear, Vector<T> solution, Matrix<T> inequalityMatrix, Vector<T> inequalityBounds, Vector<T> inequalityMultipliers, Matrix<T> equalityMatrix, Vector<T> equalityBounds, Vector<T> equalityMultipliers) Evaluates the KKT residuals for a quadratic objective ½·xᵀQx + cᵀx subject to A_ub·x ≤ b_ub and A_eq·x = b_eq.