qpsolvers is a Python library that provides a unified API to various quadratic programming (QP) solvers. It simplifies the process of solving convex QPs by abstracting away solver-specific APIs and matrix format requirements. Currently at version 4.11.0, the library maintains an active development pace with frequent minor releases to integrate new solvers and provide updates for existing ones.
pip install qpsolversVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to define a quadratic programming problem using NumPy arrays and solve it with an available backend solver. It automatically selects 'proxqp' if available, otherwise it tries the first available solver, or prompts the user to install one if no solvers are found. The problem is formulated in the standard quadratic program form.
Always provide the `solver` keyword argument when calling `solve_qp` or `solve_ls` (e.g., `solve_qp(..., solver="osqp")`).
Ensure your Python environment is version 3.10 or newer.
If using Gurobi through `qpsolvers`, ensure your Gurobi installation is compatible with the latest `qpsolvers` API. Review Gurobi-specific code for potential incompatibilities.
If using PIQP, update your PIQP installation to v0.6.0 or newer to ensure compatibility with `qpsolvers` v4.8.0 and later.
Install `qpsolvers` with optional solver dependencies using extras, e.g., `pip install qpsolvers[open_source_solvers]` or `pip install qpsolvers[osqp]`.
Explicitly symmetrize your cost matrix `P` (e.g., `P = 0.5 * (P + P.T)`). Check the documentation for your chosen solver regarding its requirements for `P` (positive (semi-)definite).
These warnings were partially addressed in `qpsolvers` v4.8.2. Ensure you are on the latest `qpsolvers` version and consider updating your OSQP installation to a version known to be compatible to mitigate these warnings.
Install a backend solver, for example OSQP, using `pip install osqp` or `pip install cvxopt` for CVXOPT.
Ensure all input matrices and vectors (P, q, G, h, A, b, lb, ub) are correctly shaped NumPy arrays or SciPy sparse matrices according to QP formulation, e.g., P as n x n, q as n-vector.
Import the function directly using `from qpsolvers import solve_qp` or import the package and call the function as `qpsolvers.solve_qp(...)`.
Consult the official documentation for the specific backend solver you are using (e.g., OSQP settings, CVXOPT options) to find the correct option names and accepted values.