The Karush-Kuhn-Tucker (KKT) conditions are necessary optimality conditions for constrained nonlinear programs. For a minimization problem with inequality constraintsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/FabianeloV/Metodo-simplex/llms.txt
Use this file to discover all available pages before exploring further.
gᵢ(x) ≤ 0 and equality constraints hⱼ(x) = 0, any local optimum x* must satisfy:
- Stationarity:
∇f(x*) + Σ λᵢ ∇gᵢ(x*) + Σ μⱼ ∇hⱼ(x*) = 0 - Dual feasibility:
λᵢ ≥ 0for all inequality constraints - Primal feasibility:
gᵢ(x*) ≤ 0andhⱼ(x*) = 0 - Complementary slackness:
λᵢ · gᵢ(x*) = 0
S of inequality constraints treated as active (gᵢ(x) = 0, i ∈ S), it assembles a square KKT system and solves it with multivariate Newton’s method. Candidates that violate dual feasibility (λᵢ < 0) or primal feasibility (an inactive constraint is violated) are discarded. The best valid candidate becomes the reported optimum.
For maximization, the engine internally minimizes −f subject to the same constraints; the multipliers returned are directly the correct KKT multipliers for the original maximization problem.
Endpoint
Request
The objective function as a SymPy-compatible symbolic string. Use
** for exponents and * for multiplication.Examples: "x**2 + y**2", "x**2 + 2*y**2 - x*y"List of variable names in the expression. Must contain 2 or 3 names.Example:
["x", "y"]Optimization direction:
"min" or "max".List of constraints. Must contain 1 to 5 entries.
Response
"optimal" if at least one case satisfies all KKT conditions; "infeasible" if no valid case was found across all enumerated active-set combinations.Echo of the variable names from the request.
The objective expression as parsed and simplified by SymPy.
Echo of the
goal field from the request ("min" or "max").Human-readable representation of each constraint as processed by the engine, e.g.,
["x + y ≤ 4", "x ≥ 0"].Coordinates of the global KKT optimum found, ordered to match
variables. null when status is "infeasible".Objective function value at
optimal_point.The
case_id of the winning case. Use this to look up the full case detail (active constraints and multipliers) in the cases array.Full record of every active-set combination tried. Includes both valid and discarded cases — useful for understanding why certain constraint combinations were rejected.
Total number of active-set combinations tried. For
m inequality constraints, this equals 2^m (all subsets). For example, 3 inequality constraints → 8 cases explored.Human-readable summary of the result, including the optimal point, objective value, and winning case ID.
Multiplier Conventions
lambdas (λ) are the inequality constraint multipliers. For a valid KKT point, all λᵢ must be non-negative (dual feasibility). Keys reflect the original 1-based position of each constraint in the constraints array — for example, if constraints at indices 0 and 2 are active, the keys are "λ1" and "λ3".mus (μ) are the equality constraint multipliers. They have no sign restriction and are indexed over the equality constraints in the order they appear in the request.Example
Minimizef(x, y) = x² + 2y² − x·y subject to x + y ≤ 4 and x ≥ 0:
Algorithm Notes
cases_explored counts every active-set combination attempted, including cases that failed to converge. Inspecting the cases array lets you trace exactly which combinations were tried, why each was accepted or rejected, and what multiplier values were found.