KKT Conditions Calculator

Test candidate solutions for quadratic programs with constraints. Inspect feasibility, stationarity, and slackness clearly. Use responsive inputs, exports, tables, and visual diagnostic plots.

Enter Problem Data

This calculator checks KKT conditions for a two-variable quadratic objective with up to three linear inequalities and one linear equality.

Objective Function

Use f(x,y) = c0 + cx·x + cy·y + 0.5(qxx·x² + 2qxy·xy + qyy·y²)

Inequality Constraints

Each inequality uses g(x,y) = a·x + b·y - rhs ≤ 0 with multiplier λ ≥ 0.

Optional Equality Constraint

Use h(x,y) = p·x + q·y - rhs = 0 with multiplier μ.

Example Data Table

This sample matches the default loaded values and gives a numerically valid KKT point.

Item Sample Value Meaning
Objective f(x,y) = x² + y² Set qxx = 2, qyy = 2, others zero.
Candidate Point (1.5, 1.5) Point to test against all KKT conditions.
g1 -x - y + 3 ≤ 0, λ1 = 3 Represents x + y ≥ 3 after rearrangement.
g2 -x ≤ 0, λ2 = 0 Nonnegativity for x.
g3 -y ≤ 0, λ3 = 0 Nonnegativity for y.
Expected Outcome KKT satisfied Primal, dual, slackness, and stationarity all pass.

Formula Used

Objective Function

f(x,y) = c0 + cx·x + cy·y + 0.5(qxx·x² + 2qxy·xy + qyy·y²)

Constraint Forms

gᵢ(x,y) = aᵢx + bᵢy - rhsᵢ ≤ 0, h(x,y) = px + qy - rhs = 0

Lagrangian

For minimization: L(x,y,λ,μ) = f(x,y) + Σ λᵢgᵢ(x,y) + μh(x,y)
For maximization, the calculator applies KKT to the transformed minimization of -f(x,y).

KKT Checks

Primal feasibility: gᵢ(x,y) ≤ 0 and h(x,y) = 0
Dual feasibility: λᵢ ≥ 0
Complementary slackness: λᵢ · gᵢ(x,y) = 0
Stationarity: ∇f + Σ λᵢ∇gᵢ + μ∇h = 0

Gradient and Convexity

The calculator computes ∇f using the quadratic coefficients. It also checks the transformed Hessian for positive semidefiniteness. For linear constraints, satisfied KKT conditions plus convexity indicate a global optimum for the transformed problem.

How to Use This Calculator

Enter the candidate point x and y first. Then choose whether the problem is a minimization or maximization task.

Define the quadratic objective coefficients. The calculator uses a standard two-variable quadratic form, so you only need six coefficients.

Enable the constraints you want to test. For each enabled inequality, enter a, b, rhs, and the corresponding multiplier λ.

Enable the equality only when needed. Enter its coefficients and multiplier μ if your problem contains one.

Press the evaluate button. The report shows primal feasibility, dual feasibility, complementary slackness, stationarity, active constraints, exports, and a visual graph.

Frequently Asked Questions

1) What does this calculator actually test?

It checks the four main KKT conditions at a candidate point: primal feasibility, dual feasibility, complementary slackness, and stationarity. It also adds a simple LICQ and convexity review for extra interpretation.

2) Does this solve the optimization problem automatically?

No. It evaluates a supplied candidate point and the supplied multipliers. You can use it to verify suspected solutions, test manual work, or inspect numerical conditions around a point.

3) Why does the calculator use a quadratic objective?

A quadratic objective keeps the tool practical and reliable inside one file. It still covers many common mathematical, engineering, and economics problems while allowing exact gradients and clear plotting.

4) How are maximization problems handled?

The calculator transforms a maximization into a minimization of the negative objective when applying the stationarity and convexity checks. This keeps the KKT evaluation consistent and numerically simple.

5) What tolerance should I use?

A small value like 0.0001 works well for most classroom and practical examples. Increase it slightly if your numbers are large or rounded, and decrease it for stricter checks.

6) What does an active constraint mean?

An inequality is active when its value is numerically near zero at the candidate point. Active constraints usually influence stationarity through their multipliers and help define the local boundary geometry.

7) Does passing KKT always prove global optimality?

Not always. KKT conditions are necessary under suitable regularity assumptions, but global optimality needs more structure. For this tool, convexity of the transformed quadratic objective and linear constraints greatly strengthens the conclusion.

8) What can I export from the result?

You can export a CSV summary of the computed values and download a PDF snapshot of the report section, including the table content and the Plotly visualization.

Related Calculators

knapsack problem solverprofit maximization calculatorslack variable calculatorbranch and bound solverconstrained optimization solverdual simplex solvergenetic algorithm solvertransportation problem solverconstraint satisfaction solverpower flow optimization

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.