tpt-math-optimize
Umbrella crate for the tpt-math optimisation layer: it re-exports
tpt-math-optimize-general (in-house closure-driven smooth, unconstrained
minimisers) and tpt-math-optimize-convex (a convex QP interface over an
in-house dense primal-dual interior-point solver) behind Cargo features.
Depend on this crate when you want both smooth unconstrained minimisation and
constrained convex programming from a single dependency line.
Part of tpt-math
Part of the tpt-math workspace —
the numeric substrate for tpt-science, tpt-engineering, and tpt-formal.
This crate sits at the top of the optimisation layer and contains no algorithms
of its own; it is purely a re-export facade over the two leaf crates below it:
| Feature | Re-exported as | Source crate |
|---|---|---|
tpt-math-optimize-general |
general |
tpt-math-optimize-general — in-house closure-driven smooth, unconstrained minimisers |
tpt-math-optimize-convex |
convex |
tpt-math-optimize-convex — convex QPs via an in-house dense interior-point solver |
Both leaf crates take their parameter vectors as tpt-math-linalg-dense
DVector<f64> / DMatrix<f64> (faer-backed, MIT-only), so values move
between the two solver families (and the rest of the workspace) without
conversion. The old clarabel (Apache-2.0-only) and nalgebra backends were
removed to satisfy the workspace license policy (ADR-0007); tpt-math-linalg
wraps faer (via tpt-math-linalg-dense) rather than nalgebra.
Features
tpt-math-optimize-general(default) — pulls intpt-math-optimize-generaland exposes it as thegeneralmodule:minimize_gradient_descent,minimize_conjugate_gradient,minimize_newton, their*_withvariants takingOptionsand returning aSolution, plus the unchangedtpt_math_linalg/tpt_math_linalg_densere-exports.tpt-math-optimize-convex(default) — pulls intpt-math-optimize-convexand exposes it as theconvexmodule:solve_qp, theQuadraticProgrambuilder,QpSolution,ConvexError, plus the unchangedtpt_math_linalg_densere-export.- Default: both features are on. Disable default features to take only the half you need — that also drops the corresponding leaf crate from the dependency graph.
This crate requires std; both leaf crates depend on tpt-math-linalg-dense's
default (allocator-backed, faer) storage, which is std-only, so there is no
no_std configuration of this umbrella.
Quick start
[]
= "0.1"
Unconstrained minimisation through the general module:
use DVector;
use minimize_gradient_descent;
// f(x, y) = (x - 3)^2 + (y - 2)^2, minimised at (3, 2).
let cost = ;
let grad = ;
let best = minimize_gradient_descent.unwrap;
assert!;
assert!;
A constrained convex QP through the convex module:
use ;
use solve_qp;
// minimize x^2 + y^2 subject to x + y = 1 -> (0.5, 0.5)
let p = from_row_slice;
let q = zeros;
let a_eq = from_row_slice;
let b_eq = from_vec;
let x = solve_qp.unwrap;
assert!;
assert!;
Taking only one half:
[]
= { = "0.1", = false, = ["tpt-math-optimize-convex"] }
Notes
- The feature names deliberately match the crate names, so
--features tpt-math-optimize-convexenables exactly thetpt-math-optimize-convexdependency and nothing else. - Nothing is hidden: both
generalandconvexre-exporttpt_math_linalg/tpt_math_linalg_dense, so you can build on the same parameter types without adding a second, possibly version-skewed, dependency on them. generalflattens its errors to aStringmessage;convexreturns a typedConvexError. The two leaf crates are independent and do not share an error type.tpt-math-linalg-dense(and therefore both leaf crates) isMIT-only (faer). The oldargmin/clarabel/nalgebradependencies (mixed or Apache-2.0-only licensing) were removed to satisfy the workspace's no-exceptions license policy (ADR-0007).
License
Licensed under either of MIT or Apache-2.0 at your option.