Crate osqp [−] [src]
The OSQP (Operator Splitting Quadratic Program) solver is a numerical optimization package for solving convex quadratic programs in the form \[\begin{split}\begin{array}{ll} \mbox{minimize} & \frac{1}{2} x^T P x + q^T x \\ \mbox{subject to} & l \leq A x \leq u \end{array}\end{split}\] where \(x\) is the optimization variable and \(P \in \mathbf{S}^{n}_{+}\) a positive semidefinite matrix.
Further information about the solver is available at osqp.readthedocs.io.
Example
Consider the following QP
use osqp::{Settings, Problem}; // Define problem data let P = &[[4.0, 1.0], [1.0, 2.0]]; let q = &[1.0, 1.0]; let A = &[[1.0, 1.0], [1.0, 0.0], [0.0, 1.0]]; let l = &[1.0, 0.0, 0.0]; let u = &[1.0, 0.7, 0.7]; // Change the default alpha and disable verbose output let settings = Settings::default() .alpha(1.0) .verbose(false); // Create an OSQP problem let mut prob = Problem::new(P, q, A, l, u, &settings); // Solve problem let result = prob.solve(); // Print the solution println!("{:?}", result.x().expect("failed to solve problem"));
Structs
CscMatrix |
A matrix in Compressed Sparse Column format. |
DualInfeasibilityCertificate |
A proof of dual infeasibility. |
PrimalInfeasibilityCertificate |
A proof of primal infeasibility. |
Problem |
An instance of the OSQP solver. |
Settings |
The settings used when initialising a solver. |
Solution |
A solution to a problem. |
Enums
LinsysSolver |
The linear system solver for OSQP to use. |
Status |
The result of solving a problem. |