{"id":5448,"library":"qpsolvers","title":"Quadratic Programming Solvers","description":"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.","status":"active","version":"4.11.0","language":"en","source_language":"en","source_url":"https://github.com/qpsolvers/qpsolvers","tags":["optimization","quadratic programming","solvers","numerical","mathematics"],"install":[{"cmd":"pip install qpsolvers","lang":"bash","label":"Base library only (no solvers)"},{"cmd":"pip install qpsolvers[open_source_solvers]","lang":"bash","label":"Library with common open-source solvers"},{"cmd":"pip install qpsolvers[clarabel,osqp,proxqp]","lang":"bash","label":"Library with specific open-source solvers"}],"dependencies":[{"reason":"Core dependency for numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Needed for sparse matrix formats (CSC) and some internal utilities.","package":"scipy","optional":false},{"reason":"Optional backend QP solver.","package":"clarabel","optional":true},{"reason":"Optional commercial backend QP solver.","package":"copt","optional":true},{"reason":"Optional backend QP solver.","package":"cvxopt","optional":true},{"reason":"Optional backend QP solver.","package":"ecos","optional":true},{"reason":"Optional commercial backend QP solver.","package":"gurobi","optional":true},{"reason":"Optional backend QP solver.","package":"osqp","optional":true},{"reason":"Optional backend QP solver.","package":"piqp","optional":true},{"reason":"Optional backend QP solver.","package":"proxqp","optional":true},{"reason":"Optional backend QP solver.","package":"quadprog","optional":true},{"reason":"Optional backend QP solver.","package":"scs","optional":true}],"imports":[{"symbol":"solve_qp","correct":"from qpsolvers import solve_qp"},{"symbol":"solve_problem","correct":"from qpsolvers import solve_problem"},{"symbol":"available_solvers","correct":"from qpsolvers import available_solvers"}],"quickstart":{"code":"import numpy as np\nfrom qpsolvers import solve_qp, available_solvers\n\n# Define the QP problem in standard form: minimize 0.5 * x.T * P * x + q.T * x \n# subject to G * x <= h, A * x == b, lb <= x <= ub\n\nM = np.array([[1., 2., 0.], [-8., 3., 2.], [0., 1., 1.]])\nP = M.T @ M  # This results in a positive definite matrix\nq = np.array([3., 2., 3.]) @ M\n\nG = np.array([[1., 2., 1.], [2., 0., 1.], [-1., 2., -1.]])\nh = np.array([3., 2., -2.])\n\nA = np.array([1., 1., 1.])\nb = np.array([1.])\n\n# Try to use a common open-source solver, or fallback if not available\nsolver_to_use = \"proxqp\" if \"proxqp\" in available_solvers else available_solvers[0] if available_solvers else None\n\nif solver_to_use:\n    print(f\"Using solver: {solver_to_use}\")\n    x = solve_qp(P, q, G, h, A, b, solver=solver_to_use)\n    print(f\"QP solution: {x = }\")\nelse:\n    print(\"No QP solvers found. Please install one, e.g., pip install qpsolvers[proxqp]\")","lang":"python","description":"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."},"warnings":[{"fix":"Always provide the `solver` keyword argument when calling `solve_qp` or `solve_ls` (e.g., `solve_qp(..., solver=\"osqp\")`).","message":"The `solver` keyword argument became mandatory for `solve_qp` and `solve_ls` functions in v2.0.","severity":"breaking","affected_versions":"< 2.0"},{"fix":"Ensure your Python environment is version 3.10 or newer.","message":"The minimum required Python version was bumped to 3.10.","severity":"breaking","affected_versions":"< 4.9.0"},{"fix":"If using Gurobi through `qpsolvers`, ensure your Gurobi installation is compatible with the latest `qpsolvers` API. Review Gurobi-specific code for potential incompatibilities.","message":"The Gurobi interface was updated to a newer Gurobi API.","severity":"breaking","affected_versions":"4.10.0+"},{"fix":"If using PIQP, update your PIQP installation to v0.6.0 or newer to ensure compatibility with `qpsolvers` v4.8.0 and later.","message":"The PIQP interface was updated to support the new PIQP v0.6.0 API.","severity":"breaking","affected_versions":"4.8.0+"},{"fix":"Install `qpsolvers` with optional solver dependencies using extras, e.g., `pip install qpsolvers[open_source_solvers]` or `pip install qpsolvers[osqp]`.","message":"Starting from v4.3.0, `pip install qpsolvers` no longer installs any default QP solvers alongside the library. Solvers must be installed separately.","severity":"gotcha","affected_versions":"4.3.0+"},{"fix":"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).","message":"The cost matrix `P` in a QP problem should always be symmetric. Many solvers assume this property and may return incorrect results if it's not. Some solvers also require `P` to be positive definite.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"OSQP solver may issue deprecation warnings related to solver status or matrix conversion, particularly with certain versions of OSQP.","severity":"gotcha","affected_versions":"4.8.2+"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}