Skip to main content

Convex QP Solver: numerical engineering for constrained optimization

A Python implementation of convex quadratic programming with primal-dual interior-point and Mehrotra predictor-corrector methods, backed by numerical validation and reference-solver comparison.

Context

Many real decision problems can be expressed as constrained optimization models. This project focuses on implementing a solver for convex quadratic programming, where both the mathematical formulation and numerical behavior matter.

Problem

Convex quadratic programming formulation
\min_x \; \frac{1}{2}x^T P x + q^T x \quad \text{s.t.} \quad Ax=b,\; Gx\le h

The solver is designed to expose diagnostics for stationarity, primal feasibility, complementarity, and duality gap rather than treating the final solution vector as the only output.

Constraints & requirements

  • Preserve the mathematical conditions of convex QP
  • Solve the KKT system through dense or sparse paths
  • Use fraction-to-boundary safeguards
  • Validate behavior on a numerical problem corpus
  • Compare results with reference solvers OSQP and Clarabel
  • Cover the solver with unit, property-based, and API tests

Approach

The solver core uses primal-dual interior-point methods and a Mehrotra predictor-corrector path. KKT systems can use dense NumPy or sparse SciPy SuperLU, with validation and numerical diagnostics kept separate from the solve path.

text
QP Model -> Validation -> IPM / Mehrotra
                       -> KKT System
                       -> Residual Diagnostics

Key decisions & trade-offs

DecisionReason
Primal-dual interior-pointProvides a general solve path for constrained convex QP.
Mehrotra predictor-correctorImproves centering with predictor and correction steps.
Dense + sparse KKT pathsAllows the implementation to fit different problem structures.
Reference-solver comparisonNumerical validation should not rely only on internal tests.
Diagnostics as outputSolver quality should be inspectable beyond the final x vector.

Outcome

The result is a research-oriented convex QP solver with numerical diagnostics and validation against reference-solver behavior. The project README reports 84 passing tests, 93% solver-source coverage, and agreement with OSQP and Clarabel. It demonstrates the path from mathematical formulation and problem structure through algorithm design, numerical implementation, and independent validation.

Technical depth

  • Primal-dual interior-point and Mehrotra predictor-corrector
  • KKT residuals for stationarity, primal feasibility, complementarity, and duality gap
  • Dense NumPy and sparse SciPy SuperLU paths
  • Property-based tests and a numerical validation corpus
  • CLI and REST API with OpenAPI/Swagger

Evidence

The code, mathematical formulation, tests, and validation work are inspectable on GitHub.

GitHub — Convex Quadratic Programming Solver

The repository contains the solver, validation, benchmarks, mathematical documentation, tests, and API.

Open source

Working on an optimization or decision problem?

For problems involving mathematical models, constraints, numerical solving, or custom algorithms, we can discuss scope and an appropriate path forward.