Unsupported solvers¶
Unsupported solvers will be made available if they are detected on your system, but their compatibility is not guaranteed as they are not part of continuous integration (for instance because they cannot be executed by CI runners, or are not distributed on PyPI or conda-forge).
HPIPM¶
Solver interface for HPIPM.
HPIPM is a high-performance interior point method for solving convex quadratic programs. It is designed to be efficient for small to medium-size problems arising in model predictive control and embedded optmization. If you are using HPIPM in a scientific work, consider citing the corresponding paper [Frison2020].
Warm-start: this solver interface supports warm starting 🔥
- qpsolvers.solvers.hpipm_.hpipm_solve_problem(problem, initvals=None, mode='balance', verbose=False, **kwargs)¶
Solve a quadratic program using HPIPM.
- Parameters:
problem (
Problem) – Quadratic program to solve.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.mode (
str) – Solver mode, which provides a set of default solver arguments. Pick one of [“speed_abs”, “speed”, “balance”, “robust”]. These modes are documented in section 4.2 IPM implementation choices of the reference paper [Frison2020]. The default one is “balance”.verbose (
bool) – Set to True to print out extra information.
- Return type:
- Returns:
Solution returned by the solver.
Notes
Keyword arguments are forwarded to HPIPM. For instance, we can call
hpipm_solve_qp(P, q, G, h, u, tol_eq=1e-5). HPIPM settings include the following:Name
Description
iter_maxMaximum number of iterations.
tol_eqEquality constraint tolerance.
tol_ineqInequality constraint tolerance.
tol_compComplementarity condition tolerance.
tol_dual_gapDuality gap tolerance.
tol_statStationarity condition tolerance.
- qpsolvers.solvers.hpipm_.hpipm_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, mode='balance', verbose=False, **kwargs)¶
Solve a quadratic program using HPIPM.
The quadratic program is defined as:
\[\begin{split}\begin{split}\begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2} x^T P x + q^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \\ & lb \leq x \leq ub \end{array}\end{split}\end{split}\]It is solved using HPIPM.
- Parameters:
P (
ndarray) – Symmetric cost matrix.q (
ndarray) – Cost vector.G (
Optional[ndarray]) – Linear inequality constraint matrix.h (
Optional[ndarray]) – Linear inequality constraint vector.A (
Optional[ndarray]) – Linear equality constraint matrix.b (
Optional[ndarray]) – Linear equality constraint vector.lb (
Optional[ndarray]) – Lower bound constraint vector.ub (
Optional[ndarray]) – Upper bound constraint vector.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.mode (
str) – Solver mode, which provides a set of default solver arguments. Pick one of [“speed_abs”, “speed”, “balance”, “robust”]. Default is “balance”.verbose (
bool) – Set to True to print out extra information.
- Return type:
Optional[ndarray]- Returns:
Solution to the QP, if found, otherwise
None.
Notes
Keyword arguments are forwarded to HPIPM. For instance, we can call
hpipm_solve_qp(P, q, G, h, u, tol_eq=1e-5). HPIPM settings include the following:Name
Description
iter_maxMaximum number of iterations.
tol_eqEquality constraint tolerance.
tol_ineqInequality constraint tolerance.
tol_compComplementarity condition tolerance.
tol_dual_gapDuality gap tolerance.
tol_statStationarity condition tolerance.
NPPro¶
Solver interface for NPPro.
The NPPro solver implements an enhanced Newton Projection with Proportioning method for strictly convex quadratic programming. Currently, it is designed for dense problems only.
- qpsolvers.solvers.nppro_.nppro_solve_problem(problem, initvals=None, **kwargs)¶
Solve a quadratic program using NPPro.
- Parameters:
problem (
Problem) – Quadratic program to solve.initvals (
Optional[ndarray]) – Warm-start guess vector.
- Return type:
- Returns:
Solution returned by the solver.
Notes
All other keyword arguments are forwarded as options to NPPro. For instance, you can call
nppro_solve_qp(P, q, G, h, MaxIter=15). For a quick overview, the solver accepts the following settings:Name
Effect
MaxIterMaximum number of iterations.
SkipPreprocessingSkip preprocessing phase or not.
SkipPhaseOneSkip feasible starting point finding or not.
InfValValues are assumed to be infinite above this threshold.
HessianUpdatesEnable Hessian updates or not.
- qpsolvers.solvers.nppro_.nppro_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, **kwargs)¶
Solve a quadratic program using NPPro.
The quadratic program is defined as:
\[\begin{split}\begin{split}\begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2} x^T P x + q^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \\ & lb \leq x \leq ub \end{array}\end{split}\end{split}\]It is solved using NPPro.
- Parameters:
P (
ndarray) – Positive definite cost matrix.q (
ndarray) – Cost vector.G (
Optional[ndarray]) – Linear inequality constraint matrix.h (
Optional[ndarray]) – Linear inequality constraint vector.A (
Optional[ndarray]) – Linear equality constraint matrix.b (
Optional[ndarray]) – Linear equality constraint vector.lb (
Optional[ndarray]) – Lower bound constraint vector.ub (
Optional[ndarray]) – Upper bound constraint vector.initvals (
Optional[ndarray]) – Warm-start guess vector.
- Return type:
Optional[ndarray]- Returns:
Solution to the QP, if found, otherwise
None.
Notes
See the Notes section in
nppro_solve_problem().
PDHCG¶
Solver interface for PDHCG.
PDHCG (Primal-Dual Hybrid Conjugate Gradient) is a high-performance, GPU-accelerated solver designed for large-scale convex Quadratic Programming (QP). It is particularly efficient for huge-scale problems by fully leveraging NVIDIA CUDA architectures.
Note
To use this solver, you need an NVIDIA GPU and the pdhcg package
installed via pip install pdhcg. For advanced installation (e.g.,
custom CUDA paths), please refer to the
official PDHCG-II repository.
References
- qpsolvers.solvers.pdhcg_.pdhcg_solve_problem(problem, initvals=None, verbose=False, **kwargs)¶
Solve a quadratic program using PDHCG.
The quadratic program is defined as:
\[\begin{split}\begin{split}\begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2} x^T P x + q^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \\ & lb \leq x \leq ub \end{array}\end{split}\end{split}\]- Parameters:
problem (
Problem) – Quadratic program to solve.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.verbose (
bool) – Set to True to print out extra information.
- Return type:
- Returns:
Solution to the QP, if found, otherwise
None.
Notes
Keyword arguments are forwarded to PDHCG as solver parameters. For instance, you can call
pdhcg_solve_qp(..., TimeLimit=60). Common PDHCG parameters include:Name
Description
TimeLimitMaximum wall-clock time in seconds (default: 3600.0).
IterationLimitMaximum number of iterations.
OptimalityTolRelative tolerance for optimality gap (default: 1e-4).
FeasibilityTolRelative feasibility tolerance for residuals (default: 1e-4).
OutputFlagEnable (True) or disable (False) console logging output.
For advanced parameters, please refer to the PDHCG Documentation.
- qpsolvers.solvers.pdhcg_.pdhcg_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, verbose=False, **kwargs)¶
Solve a quadratic program using PDHCG.
The quadratic program is defined as:
\[\begin{split}\begin{split}\begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2} x^T P x + q^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \\ & lb \leq x \leq ub \end{array}\end{split}\end{split}\]It is solved using PDHCG.
- Parameters:
P (
Union[ndarray,csc_matrix]) – Positive semidefinite cost matrix.q (
ndarray) – Cost vector.G (
Union[ndarray,csc_matrix,None]) – Linear inequality constraint matrix.h (
Optional[ndarray]) – Linear inequality constraint vector.A (
Union[ndarray,csc_matrix,None]) – Linear equality constraint matrix.b (
Optional[ndarray]) – Linear equality constraint vector.lb (
Optional[ndarray]) – Lower bound constraint vector.ub (
Optional[ndarray]) – Upper bound constraint vector.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.verbose (
bool) – Set to True to print out extra information.
- Return type:
Optional[ndarray]- Returns:
Solution to the QP, if found, otherwise
None.
Notes
Keyword arguments are forwarded to PDHCG as solver parameters. For instance, you can call
pdhcg_solve_qp(..., TimeLimit=60). Common PDHCG parameters include:Name
Description
TimeLimitMaximum wall-clock time in seconds (default: 3600.0).
IterationLimitMaximum number of iterations.
OptimalityTolRelative tolerance for optimality gap (default: 1e-4).
FeasibilityTolRelative feasibility tolerance for residuals (default: 1e-4).
OutputFlagEnable (True) or disable (False) console logging output.
For advanced parameters, please refer to the PDHCG Documentation.
qpOASES¶
Solver interface for qpOASES.
qpOASES is an open-source C++ implementation of the online active set strategy, which was inspired by observations from the field of parametric quadratic programming. It has theoretical features that make it suitable to model predictive control. Further numerical modifications have made qpOASES a reliable QP solver, even when tackling semi-definite, ill-posed or degenerated QP problems. If you are using qpOASES in a scientific work, consider citing the corresponding paper [Ferreau2014].
See the installation page for additional instructions on installing this solver.
Warm-start: this solver interface supports warm starting 🔥
- qpsolvers.solvers.qpoases_.qpoases_solve_problem(problem, initvals=None, verbose=False, max_wsr=1000, time_limit=None, predefined_options=None, **kwargs)¶
Solve a quadratic program using qpOASES.
- Parameters:
problem (
Problem) – Quadratic program to solve.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.verbose (
bool) – Set to True to print out extra information.max_wsr (
int) – Maximum number of Working-Set Recalculations given to qpOASES.time_limit (
Optional[float]) – Set a run time limit in seconds.predefined_options (
Optional[str]) – Set solver options to one of the pre-defined choices provided by qpOASES, to pick in["default", "fast", "mpc", "reliable"].
- Return type:
- Returns:
Solution to the QP, if found, otherwise
None.- Raises:
ProblemError : – If the problem is ill-formed in some way, for instance if some matrices are not dense.
ValueError : – If
predefined_optionsis not a valid choice.
Notes
This function relies on an update to qpOASES to allow empty bounds (lb, ub, lbA or ubA) in Python. This is possible in the C++ API but not by the Python API (as of version 3.2.0). If using them, be sure to update the Cython file (qpoases.pyx) in your distribution of qpOASES to convert
Noneto the null pointer. Check out the installation instructions.Keyword arguments are forwarded as options to qpOASES. For instance, we can call
qpoases_solve_qp(P, q, G, h, u, terminationTolerance=1e-14). qpOASES options include the following:Name
Description
boundRelaxationInitial relaxation of bounds to start homotopy and initial value for far bounds.
epsNumNumerator tolerance for ratio tests.
epsDenDenominator tolerance for ratio tests.
numRefinementStepsMaximum number of iterative refinement steps.
terminationToleranceRelative termination tolerance to stop homotopy.
Check out pages 28 to 30 of qpOASES User’s Manual. for all available options.
- qpsolvers.solvers.qpoases_.qpoases_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, verbose=False, max_wsr=1000, time_limit=None, predefined_options=None, **kwargs)¶
Solve a quadratic program using qpOASES.
The quadratic program is defined as:
\[\begin{split}\begin{split}\begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2} x^T P x + q^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \\ & lb \leq x \leq ub \end{array}\end{split}\end{split}\]It is solved using qpOASES.
- Parameters:
P (
ndarray) – Symmetric cost matrix.q (
ndarray) – Cost vector.G (
Optional[ndarray]) – Linear inequality constraint matrix.h (
Optional[ndarray]) – Linear inequality constraint vector.A (
Optional[ndarray]) – Linear equality constraint matrix.b (
Optional[ndarray]) – Linear equality constraint vector.lb (
Optional[ndarray]) – Lower bound constraint vector.ub (
Optional[ndarray]) – Upper bound constraint vector.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.verbose (
bool) – Set to True to print out extra information.max_wsr (
int) – Maximum number of Working-Set Recalculations given to qpOASES.time_limit (
Optional[float]) – Set a run time limit in seconds.predefined_options (
Optional[str]) – Set solver options to one of the pre-defined choices provided by qpOASES, to pick in["default", "fast", "mpc", "reliable"].
- Return type:
Optional[ndarray]- Returns:
Solution to the QP, if found, otherwise
None.- Raises:
ProblemError : – If the problem is ill-formed in some way, for instance if some matrices are not dense.
ValueError : – If
predefined_optionsis not a valid choice.
Notes
This function relies on an update to qpOASES to allow empty bounds (lb, ub, lbA or ubA) in Python. This is possible in the C++ API but not by the Python API (as of version 3.2.0). If using them, be sure to update the Cython file (qpoases.pyx) in your distribution of qpOASES to convert
Noneto the null pointer. Check out the installation instructions.Keyword arguments are forwarded as options to qpOASES. For instance, we can call
qpoases_solve_qp(P, q, G, h, u, terminationTolerance=1e-14). qpOASES options include the following:Name
Description
boundRelaxationInitial relaxation of bounds to start homotopy and initial value for far bounds.
epsNumNumerator tolerance for ratio tests.
epsDenDenominator tolerance for ratio tests.
numRefinementStepsMaximum number of iterative refinement steps.
terminationToleranceRelative termination tolerance to stop homotopy.
Check out pages 28 to 30 of qpOASES User’s Manual. for all available options.
qpSWIFT¶
Solver interface for qpSWIFT.
qpSWIFT is a light-weight sparse Quadratic Programming solver targeted for embedded and robotic applications. It employs Primal-Dual Interior Point method with Mehrotra Predictor corrector step and Nesterov Todd scaling. For solving the linear system of equations, sparse LDL’ factorization is used along with approximate minimum degree heuristic to minimize fill-in of the factorizations. If you use qpSWIFT in your research, consider citing the corresponding paper [Pandala2019].
Warm-start: this solver interface supports warm starting 🔥
- qpsolvers.solvers.qpswift_.qpswift_solve_problem(problem, initvals=None, verbose=False, **kwargs)¶
Solve a quadratic program using qpSWIFT.
Note
This solver does not handle problems without inequality constraints.
- Parameters:
problem (
Problem) – Quadratic program to solve.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.verbose (
bool) – Set to True to print out extra information.
- Return type:
- Returns:
Solution returned by the solver.
- Raises:
ProblemError : – If the problem is ill-formed in some way, for instance if some matrices are not dense or the problem has no inequality constraint.
Note
Rank assumptions: qpSWIFT requires the QP matrices to satisfy the
\[\begin{split}\begin{array}{cc} \mathrm{rank}(A) = p & \mathrm{rank}([P\ A^T\ G^T]) = n \end{array}\end{split}\]where \(p\) is the number of rows of \(A\) and \(n\) is the number of optimization variables. This is the same requirement as
cvxopt_solve_qp(), however qpSWIFT does not perform rank checks as it prioritizes performance. If the solver fails on your problem, try running CVXOPT on it for rank checks.Notes
All other keyword arguments are forwarded as options to the qpSWIFT solver. For instance, you can call
qpswift_solve_qp(P, q, G, h, ABSTOL=1e-5). See the solver documentation for details.For a quick overview, the solver accepts the following settings:
Name
Effect
MAXITERMaximum number of iterations needed.
ABSTOLAbsolute tolerance on the duality gap. See e.g. [Caron2022] for a primer on the duality gap and solver tolerances.
RELTOLRelative tolerance on the residuals \(r_x = P x + G^T z + q\) (dual residual), \(r_y = A x - b\) (primal residual on equality constraints) and \(r_z = h - G x - s\) (primal residual on inequality constraints). See equation (21) in [Pandala2019].
SIGMAMaximum centering allowed.
If a verbose output shows that the maximum number of iterations is reached, check e.g. (1) the rank of your equality constraint matrix and (2) that your inequality constraint matrix does not have zero rows.
As qpSWIFT does not sanity check its inputs, it should be used with a little more care than the other solvers. For instance, make sure you don’t have zero rows in your input matrices, as it can make the solver numerically unstable.
- qpsolvers.solvers.qpswift_.qpswift_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, verbose=False, **kwargs)¶
Solve a quadratic program using qpSWIFT.
The quadratic program is defined as:
\[\begin{split}\begin{split}\begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2} x^T P x + q^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \\ & lb \leq x \leq ub \end{array}\end{split}\end{split}\]It is solved using qpSWIFT.
Note
This solver does not handle problems without inequality constraints yet.
- Parameters:
P (
ndarray) – Symmetric cost matrix. Together with \(A\) and \(G\), it should satisfy \(\mathrm{rank}([P\ A^T\ G^T]) = n\), see the rank assumptions below.q (
ndarray) – Cost vector.G (
Optional[ndarray]) – Linear inequality constraint matrix. Together with \(P\) and \(A\), it should satisfy \(\mathrm{rank}([P\ A^T\ G^T]) = n\), see the rank assumptions below.h (
Optional[ndarray]) – Linear inequality constraint vector.A (
Optional[ndarray]) – Linear equality constraint matrix. It needs to be full row rank, and together with \(P\) and \(G\) satisfy \(\mathrm{rank}([P\ A^T\ G^T]) = n\). See the rank assumptions below.b (
Optional[ndarray]) – Linear equality constraint vector.lb (
Optional[ndarray]) – Lower bound constraint vector.ub (
Optional[ndarray]) – Upper bound constraint vector.initvals (
Optional[ndarray]) – Warm-start guess vector for the primal solution.verbose (
bool) – Set to True to print out extra information.
- Return type:
Optional[ndarray]- Returns:
Solution to the QP, if found, otherwise
None.- Raises:
ProblemError : – If the problem is ill-formed in some way, for instance if some matrices are not dense or the problem has no inequality constraint.
Note
Rank assumptions: qpSWIFT requires the QP matrices to satisfy the
\[\begin{split}\begin{array}{cc} \mathrm{rank}(A) = p & \mathrm{rank}([P\ A^T\ G^T]) = n \end{array}\end{split}\]where \(p\) is the number of rows of \(A\) and \(n\) is the number of optimization variables. This is the same requirement as
cvxopt_solve_qp(), however qpSWIFT does not perform rank checks as it prioritizes performance. If the solver fails on your problem, try running CVXOPT on it for rank checks.Notes
All other keyword arguments are forwarded as options to the qpSWIFT solver. For instance, you can call
qpswift_solve_qp(P, q, G, h, ABSTOL=1e-5). See the solver documentation for details.For a quick overview, the solver accepts the following settings:
Name
Effect
MAXITER
Maximum number of iterations needed.
ABSTOL
Absolute tolerance on the duality gap. See e.g. [Caron2022] for a primer on the duality gap and solver tolerances.
RELTOL
Relative tolerance on the residuals \(r_x = P x + G^T z + q\) (dual residual), \(r_y = A x - b\) (primal residual on equality constraints) and \(r_z = h - G x - s\) (primal residual on inequality constraints). See equation (21) in [Pandala2019].
SIGMA
Maximum centering allowed.
If a verbose output shows that the maximum number of iterations is reached, check e.g. (1) the rank of your equality constraint matrix and (2) that your inequality constraint matrix does not have zero rows.
As qpSWIFT does not sanity check its inputs, it should be used with a little more care than the other solvers. For instance, make sure you don’t have zero rows in your input matrices, as it can make the solver numerically unstable.