{"id":7127,"library":"daqp","title":"DAQP: Dual Active-Set QP Solver","description":"DAQP is a dual active-set solver designed for convex quadratic programs (QPs), including mixed-integer QPs (MIQPs) and hierarchical QPs (HQPs). Written in C and library-free, it provides high-performance interfaces for Python, Julia, and MATLAB. It excels at solving small to medium-scale, dense QP and LP problems, particularly those arising in real-time Model Predictive Control (MPC) applications. The current version is 0.8.5, with frequent releases addressing improvements and bug fixes.","status":"active","version":"0.8.5","language":"en","source_language":"en","source_url":"https://github.com/darnstrom/daqp","tags":["optimization","quadratic programming","QP solver","active-set","control","MPC","mixed-integer QP"],"install":[{"cmd":"pip install daqp","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The primary interface is typically accessed via the top-level 'daqp' module, with functions like 'daqp.solve'.","wrong":"from daqp import solve","symbol":"daqp","correct":"import daqp"},{"note":"The main QP solver function is 'solve' within the 'daqp' module.","symbol":"solve","correct":"daqp.solve(H, f, A, bl, bu)"}],"quickstart":{"code":"import numpy as np\nimport daqp\n\n# Define a simple QP: min 0.5*x'*H*x + f'*x  s.t. bl <= A*x <= bu, l <= x <= u\nH = np.array([[2.0, 0.0], [0.0, 2.0]]) # Hessian (positive definite)\nf = np.array([-2.0, -2.0])           # Linear term\n\nA = np.array([[1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) # Constraint matrix\nbl = np.array([0.0, 0.0, 0.0])        # Lower bound for A*x\nbu = np.array([10.0, 10.0, 1.0])       # Upper bound for A*x\n\n# No explicit bounds on x (l, u can be omitted or set to -inf, +inf)\nx_min = np.full(H.shape[0], -np.inf) # Lower bound for x\nx_max = np.full(H.shape[0], np.inf)  # Upper bound for x\n\n# Solve the QP problem\n# Note: H, f, A, bl, bu are the minimum required arguments. l and u can be passed if needed.\nresult = daqp.solve(H, f, A, bl, bu)\n\nif result.exitflag == 1: # exitflag 1 means optimal solution found\n    print(f\"Optimal solution x: {result.x}\")\n    print(f\"Optimal objective value: {result.fval}\")\n    print(f\"Number of iterations: {result.iter}\")\nelse:\n    print(f\"Solver failed with exitflag: {result.exitflag}\")\n    print(f\"Result details: {result}\")","lang":"python","description":"This example demonstrates how to define and solve a basic quadratic programming problem using the `daqp.solve` function. It minimizes `0.5*x'*H*x + f'*x` subject to `bl <= A*x <= bu` and optional box constraints on `x`. The solution `x` and objective value `fval` are extracted from the result object."},"warnings":[{"fix":"Review your code for any direct C API calls from Python or explicit binary constraint definitions and update to use the new Cython-based API and 'sense' flags for binary constraints if applicable.","message":"The Python interface was re-implemented in Cython in v0.5.0, potentially breaking existing code that relied on the previous Python bindings. Additionally, the detection of binary constraints from the 'sense' parameter was introduced.","severity":"breaking","affected_versions":"<=0.4.x"},{"fix":"Assess the scale and sparsity of your QP problems. For large-scale or sparse problems, evaluate alternative QP solvers designed to exploit sparsity.","message":"DAQP is highly optimized for small to medium-scale, dense quadratic programs. Its performance and suitability for large-scale or sparse problems may be significantly limited. For sparse problems, consider other solvers like OSQP.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that your input Hessian `H` is already symmetric, or that the symmetrization `0.5 * (H + H.T)` is acceptable for your problem formulation. If not, consider explicitly symmetrizing `H` before passing it to DAQP to maintain control over the matrix used by the solver.","message":"Starting from v0.8.3, the Hessian matrix `H` is explicitly symmetrized in-place (as `0.5 * (H + H.T)`) during the solver setup. If your application relies on an asymmetric `H` being passed and processed in a specific non-symmetrized manner, this behavior change might impact results.","severity":"breaking","affected_versions":">=0.8.3"},{"fix":"Upgrade to DAQP v0.8.1 or later to utilize warm-starting capabilities (by providing initial primal/dual iterates) and to enforce a wall-clock time limit for the solver.","message":"Features such as warm-starting with primal/dual iterates and setting a `time_limit` were introduced in v0.8.1. These functionalities are not available in earlier versions of the library.","severity":"deprecated","affected_versions":"<0.8.1"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install daqp` to install the package.","cause":"The DAQP library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'daqp'"},{"fix":"Check the official DAQP documentation or GitHub repository for the correct function names and usage for your installed version. Ensure your `daqp` package is up-to-date (`pip install --upgrade daqp`). The main solver function is `daqp.solve`.","cause":"You are trying to call a function or access an attribute that does not exist or is not exposed in the `daqp` module, or you are using an outdated version where the API differs.","error":"AttributeError: module 'daqp' has no attribute 'solve'"},{"fix":"Ensure all vector inputs (`f`, `bl`, `bu`, `l`, `u`) are 1D NumPy arrays. Use `.flatten()` or `.squeeze()` on 2D arrays, or initialize them directly as 1D arrays, e.g., `np.array([1, 2, 3])` instead of `np.array([[1], [2], [3]])`.","cause":"Commonly occurs when input arrays for `f`, `bl`, `bu`, `l`, or `u` (which should be 1D vectors) are provided as 2D arrays (e.g., `(N, 1)` matrices from NumPy operations).","error":"ValueError: expected array of shape (N,) for f, got (N, M)"}]}