DAQP: Dual Active-Set QP Solver

0.8.5 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import numpy as np
import daqp

# Define a simple QP: min 0.5*x'*H*x + f'*x  s.t. bl <= A*x <= bu, l <= x <= u
H = np.array([[2.0, 0.0], [0.0, 2.0]]) # Hessian (positive definite)
f = np.array([-2.0, -2.0])           # Linear term

A = np.array([[1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) # Constraint matrix
bl = np.array([0.0, 0.0, 0.0])        # Lower bound for A*x
bu = np.array([10.0, 10.0, 1.0])       # Upper bound for A*x

# No explicit bounds on x (l, u can be omitted or set to -inf, +inf)
x_min = np.full(H.shape[0], -np.inf) # Lower bound for x
x_max = np.full(H.shape[0], np.inf)  # Upper bound for x

# Solve the QP problem
# Note: H, f, A, bl, bu are the minimum required arguments. l and u can be passed if needed.
result = daqp.solve(H, f, A, bl, bu)

if result.exitflag == 1: # exitflag 1 means optimal solution found
    print(f"Optimal solution x: {result.x}")
    print(f"Optimal objective value: {result.fval}")
    print(f"Number of iterations: {result.iter}")
else:
    print(f"Solver failed with exitflag: {result.exitflag}")
    print(f"Result details: {result}")

view raw JSON →