Expand description
Convex / quadratic optimization (in-house dense interior-point solver).
This crate solves convex quadratic programs (QPs) of the form
minimize ½ xᵀ P x + qᵀ x
subject to A_eq x = b_eq
A_ineq x ≤ b_ineq
l ≤ x ≤ u (per-variable bounds)with a self-contained dense primal-dual interior-point method
(Mehrotra predictor-corrector). The KKT linear systems are inverted with
tpt_math_linalg_dense’s in-house dense solver, so there is no
Apache-2.0-only dependency anywhere in the tree (the old clarabel backend
was removed for that reason — see spec.txt / ADR-0007).
The problem is converted into conic form
minimize qᵀ x + ½ xᵀ P x
subject to A_eq x = b_eq
A x + s = b, s ≥ 0where the equality constraints use the zero cone (no slack) and the
inequality constraints plus per-variable bounds use the nonnegative cone
(one slack s_j ≥ 0 each). Bounds l ≤ x ≤ u are mapped to two
nonnegative slack inequalities each (x - l ≥ 0 and u - x ≥ 0); a
non-finite bound is skipped (treated as “unbounded” on that side).
§Examples
use tpt_math_linalg_dense::{DMatrix, DVector};
use tpt_math_optimize_convex::solve_qp;
// minimize x² + y² subject to x + y = 1
// optimum is (0.5, 0.5)
let p = DMatrix::from_row_slice(2, 2, &[2.0, 0.0, 0.0, 2.0]);
let q = DVector::from_vec(vec![0.0, 0.0]);
let a_eq = DMatrix::from_row_slice(1, 2, &[1.0, 1.0]);
let b_eq = DVector::from_vec(vec![1.0]);
let x = solve_qp(&p, &q, &a_eq, &b_eq, &[]).unwrap();
assert!((x[0] - 0.5).abs() < 1e-6 && (x[1] - 0.5).abs() < 1e-6);Re-exports§
pub use tpt_math_linalg_dense;
Structs§
- QpSolution
- A successful solution to a quadratic program.
- Quadratic
Program - A builder for quadratic programs supporting equality constraints, inequality constraints, and per-variable bounds.
Enums§
- Convex
Error - Errors returned by the QP solvers in this crate.
- QpStatus
- Outcome of a single interior-point solve, used by the status field of
QpSolution.
Functions§
- solve_
qp - Solve a QP with equality constraints and per-variable bounds (the most common convex QP form). See the crate-level docs for the formulation.
- solve_
qp_ internal - Full QP solver: equality constraints, inequality constraints, and per-variable bounds.