Supported solvers

Supported solvers will be made available when they are detected on your system. Their compatibility is verified by continuous integration.

The list of solvers detected on your system is available at:

qpsolvers.available_solvers = ['clarabel', 'cvxopt', 'daqp', 'ecos', 'gurobi', 'copt', 'highs', 'hpipm', 'jaxopt_osqp', 'kvxopt', 'mosek', 'nppro', 'osqp', 'pdhcg', 'piqp', 'proxqp', 'qpalm', 'qpax', 'qpoases', 'qpswift', 'qtqp', 'quadprog', 'pyqpmad', 'scs', 'sip']

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

Clarabel

Solver interface for Clarabel.rs.

Clarabel.rs is a Rust implementation of an interior point numerical solver for convex optimization problems using a novel homogeneous embedding. A paper describing the Clarabel solver algorithm and implementation will be forthcoming soon (retrieved: 2023-02-06). Until then, the authors ask that you cite its documentation if you have found Clarabel.rs useful in your work.

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.clarabel_.clarabel_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using Clarabel.rs.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by Clarabel.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Notes

Keyword arguments are forwarded as options to Clarabel.rs. For instance, we can call clarabel_solve_qp(P, q, G, h, u, tol_feas=1e-6). Clarabel options include the following:

Name

Description

max_iter

Maximum number of iterations.

time_limit

Time limit for solve run in seconds (can be fractional).

tol_gap_abs

absolute duality-gap tolerance

tol_gap_rel

relative duality-gap tolerance

tol_feas

feasibility check tolerance (primal and dual)

Check out the API reference for details.

Lower values for absolute or relative tolerances yield more precise solutions at the cost of computation time. See e.g. [Caron2022] for a primer on solver tolerances and residuals.

qpsolvers.solvers.clarabel_.clarabel_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 Clarabel.rs.

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 Clarabel.rs.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Symmetric cost matrix.

  • q (ndarray) – Cost vector.

  • G (Union[ndarray, csc_matrix, None]) – Linear inequality matrix.

  • h (Optional[ndarray]) – Linear inequality 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]) – This argument is not used by Clarabel.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

COPT

Solver interface for COPT.

The COPT Optimizer suite ships several solvers for mathematical programming, including problems that have linear constraints, bound constraints, integrality constraints, cone constraints, or quadratic constraints. It targets modern CPU/GPU architectures and multi-core processors,

See the installation page for additional instructions on installing this solver.

qpsolvers.solvers.copt_.copt_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using COPT.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by COPT.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution returned by the solver.

Notes

Keyword arguments are forwarded to COPT as parameters. For instance, we can call copt_solve_qp(P, q, G, h, u, FeasTol=1e-8, DualTol=1e-8). COPT settings include the following:

Name

Description

FeasTol

Primal feasibility tolerance.

DualTol

Dual feasibility tolerance.

TimeLimit

Run time limit in seconds, 0 to disable.

Check out the Parameter Descriptions documentation for all available COPT parameters.

Lower values for primal or dual tolerances yield more precise solutions at the cost of computation time. See e.g. [Caron2022] for a primer of solver tolerances.

qpsolvers.solvers.copt_.copt_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 COPT.

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 COPT.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Primal quadratic cost matrix.

  • q (ndarray) – Primal quadratic 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]) – This argument is not used by COPT.

  • 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 COPT as parameters. For instance, we can call copt_solve_qp(P, q, G, h, u, FeasTol=1e-8, DualTol=1e-8). COPT settings include the following:

Name

Description

FeasTol

Primal feasibility tolerance.

DualTol

Dual feasibility tolerance.

TimeLimit

Run time limit in seconds, 0 to disable.

Check out the Parameter Descriptions documentation for all available COPT parameters.

Lower values for primal or dual tolerances yield more precise solutions at the cost of computation time. See e.g. [Caron2022] for a primer of solver tolerances.

CVXOPT

Solver interface for CVXOPT.

CVXOPT is a free software package for convex optimization in Python. Its main purpose is to make the development of software for convex optimization applications straightforward by building on Python’s extensive standard library and on the strengths of Python as a high-level programming language. If you are using CVXOPT in a scientific work, consider citing the corresponding report [Vandenberghe2010].

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.cvxopt_.cvxopt_solve_problem(problem, solver=None, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using CVXOPT.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • solver (Optional[str]) – Set to ‘mosek’ to run MOSEK rather than CVXOPT.

  • initvals (Optional[ndarray]) – Warm-start guess vector.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Raises:
  • ProblemError – If the CVXOPT rank assumption is not satisfied.

  • SolverError – If CVXOPT failed with an error.

Note

Rank assumptions: CVXOPT 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. See the “Rank assumptions” paragraph in the report The CVXOPT linear and quadratic cone program solvers for details.

Notes

CVXOPT only considers the lower entries of \(P\), therefore it will use a different cost than the one intended if a non-symmetric matrix is provided.

Keyword arguments are forwarded as options to CVXOPT. For instance, we can call cvxopt_solve_qp(P, q, G, h, u, abstol=1e-4, reltol=1e-4). CVXOPT options include the following:

Name

Description

abstol

Absolute tolerance on the duality gap.

feastol

Tolerance on feasibility conditions, that is, on the primal residual.

maxiters

Maximum number of iterations.

refinement

Number of iterative refinement steps when solving KKT equations

reltol

Relative tolerance on the duality gap.

Check out Algorithm Parameters section of the solver documentation for details and default values of all solver parameters. See also [Caron2022] for a primer on the duality gap, primal and dual residuals.

qpsolvers.solvers.cvxopt_.cvxopt_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, solver=None, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using CVXOPT.

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 CVXOPT.

Parameters:
  • P (Union[ndarray, csc_matrix]) – 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 (Union[ndarray, csc_matrix, None]) – Linear inequality 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 vector.

  • A (Union[ndarray, csc_matrix, None]) – 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.

  • solver (Optional[str]) – Set to ‘mosek’ to run MOSEK rather than CVXOPT.

  • initvals (Optional[ndarray]) – Warm-start guess vector.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

Raises:
  • ProblemError – If the CVXOPT rank assumption is not satisfied.

  • SolverError – If CVXOPT failed with an error.

DAQP

Solver interface for DAQP.

DAQP is a dual active-set algorithm implemented in C [Arnstrom2022]. It has been developed to solve small/medium scale dense problems.

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.daqp_.daqp_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using DAQP.

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:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Notes

Keyword arguments are forwarded to DAQP. For instance, we can call daqp_solve_qp(P, q, G, h, u, primal_tol=1e-6, iter_limit=1000). DAQP settings include the following:

Name

Description

iter_limit

Maximum number of iterations.

primal_tol

Primal feasibility tolerance.

dual_tol

Dual feasibility tolerance.

Check out the DAQP settings documentation for all available settings.

qpsolvers.solvers.daqp_.daqp_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 DAQP.

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 DAQP.

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.

Return type:

Optional[ndarray]

Returns:

Solution to the QP, if found, otherwise None.

Notes

Keyword arguments are forwarded to DAQP. For instance, we can call daqp_solve_qp(P, q, G, h, u, primal_tol=1e-6, iter_limit=1000). DAQP settings include the following:

Name

Description

iter_limit

Maximum number of iterations.

primal_tol

Primal feasibility tolerance.

dual_tol

Dual feasibility tolerance.

time_limit

Time limit for solve run in seconds.

Check out the DAQP settings documentation for all available settings.

ECOS

Solver interface for ECOS.

ECOS is an interior-point solver for convex second-order cone programs (SOCPs). designed specifically for embedded applications. ECOS is written in low footprint, single-threaded, library-free ANSI-C and so runs on most embedded platforms. For small problems, ECOS is faster than most existing SOCP solvers; it is still competitive for medium-sized problems up to tens of thousands of variables. If you are using ECOS in a scientific work, consider citing the corresponding paper [Domahidi2013].

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.ecos_.ecos_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using ECOS.

Parameters:
  • P – Primal quadratic cost matrix.

  • q – Primal quadratic cost vector.

  • G – Linear inequality constraint matrix.

  • h – Linear inequality constraint vector.

  • A – Linear equality constraint matrix.

  • b – Linear equality constraint vector.

  • initvals (Optional[ndarray]) – This argument is not used by ECOS.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Raises:
  • ProblemError : – If inequality constraints contain infinite values that the solver doesn’t handle.

  • ValueError : – If the cost matrix is not positive definite.

Notes

All other keyword arguments are forwarded as options to the ECOS solver. For instance, you can call qpswift_solve_qp(P, q, G, h, abstol=1e-5).

For a quick overview, the solver accepts the following settings:

Name

Effect

feastol

Tolerance on the primal and dual residual.

abstol

Absolute tolerance on the duality gap.

reltol

Relative tolerance on the duality gap.

feastol_inacc

Tolerance on the primal and dual residual if reduced precisions.

abstol_inacc

Absolute tolerance on the duality gap if reduced precision.

reltolL_inacc

Relative tolerance on the duality gap if reduced precision.

max_iters

Maximum numer of iterations.

nitref

Number of iterative refinement steps.

See the ECOS Python wrapper documentation for more details. You can also check out [Caron2022] for a primer on primal-dual residuals or the duality gap.

qpsolvers.solvers.ecos_.ecos_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 ECOS.

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 \end{array}\end{split}\end{split}\]

It is solved using ECOS.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Primal quadratic cost matrix.

  • q (ndarray) – Primal quadratic 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.

  • initvals (Optional[ndarray]) – This argument is not used by ECOS.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Optional[ndarray]

Returns:

Solution to the QP, if found, otherwise None.

Notes

All other keyword arguments are forwarded as options to the ECOS solver. For instance, you can call ecos_solve_qp(P, q, G, h, abstol=1e-5).

For a quick overview, the solver accepts the following settings:

Name

Effect

feastol

Tolerance on the primal and dual residual.

abstol

Absolute tolerance on the duality gap.

reltol

Relative tolerance on the duality gap.

feastol_inacc

Tolerance on the primal and dual residual if reduced precisions.

abstol_inacc

Absolute tolerance on the duality gap if reduced precision.

reltolL_inacc

Relative tolerance on the duality gap if reduced precision.

max_iters

Maximum numer of iterations.

nitref

Number of iterative refinement steps.

See the ECOS Python wrapper documentation for more details. You can also check out [Caron2022] for a primer on primal-dual residuals or the duality gap.

Gurobi

Solver interface for Gurobi.

The Gurobi Optimizer suite ships several solvers for mathematical programming, including problems that have linear constraints, bound constraints, integrality constraints, cone constraints, or quadratic constraints. It targets modern CPU architectures and multi-core processors,

See the installation page for additional instructions on installing this solver.

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.gurobi_.gurobi_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using Gurobi.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by Gurobi.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution returned by the solver.

Notes

Keyword arguments are forwarded to Gurobi as parameters. For instance, we can call gurobi_solve_qp(P, q, G, h, u, FeasibilityTol=1e-8, OptimalityTol=1e-8). Gurobi settings include the following:

Name

Description

FeasibilityTol

Primal feasibility tolerance.

OptimalityTol

Dual feasibility tolerance.

PSDTol

Positive semi-definite tolerance.

TimeLimit

Run time limit in seconds, 0 to disable.

Check out the Parameter Descriptions documentation for all available Gurobi parameters.

Lower values for primal or dual tolerances yield more precise solutions at the cost of computation time. See e.g. [Caron2022] for a primer of solver tolerances.

qpsolvers.solvers.gurobi_.gurobi_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 Gurobi.

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 Gurobi.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Primal quadratic cost matrix.

  • q (ndarray) – Primal quadratic 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]) – This argument is not used by Gurobi.

  • 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 Gurobi as parameters. For instance, we can call gurobi_solve_qp(P, q, G, h, u, FeasibilityTol=1e-8, OptimalityTol=1e-8). Gurobi settings include the following:

Name

Description

FeasibilityTol

Primal feasibility tolerance.

OptimalityTol

Dual feasibility tolerance.

PSDTol

Positive semi-definite tolerance.

TimeLimit

Run time limit in seconds, 0 to disable.

Check out the Parameter Descriptions documentation for all available Gurobi parameters.

Lower values for primal or dual tolerances yield more precise solutions at the cost of computation time. See e.g. [Caron2022] for a primer of solver tolerances.

HiGHS

Solver interface for HiGHS.

HiGHS is an open source, serial and parallel solver for large scale sparse linear programming (LP), mixed-integer programming (MIP), and quadratic programming (QP). It is written mostly in C++11 and available under the MIT licence. HiGHS’s QP solver implements a Nullspace Active Set method. It works best on moderately-sized dense problems. If you are using HiGHS in a scientific work, consider citing the corresponding paper [Huangfu2018].

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.highs_.highs_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using HiGHS.

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:

Solution

Returns:

Solution returned by the solver.

Notes

Keyword arguments are forwarded to HiGHS as options. For instance, we can call highs_solve_qp(P, q, G, h, u, primal_feasibility_tolerance=1e-8, dual_feasibility_tolerance=1e-8). HiGHS settings include the following:

Name

Description

dual_feasibility_tolerance

Dual feasibility tolerance.

primal_feasibility_tolerance

Primal feasibility tolerance.

time_limit

Run time limit in seconds.

Check out the HiGHS documentation for more information on the solver.

qpsolvers.solvers.highs_.highs_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 HiGHS.

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 HiGHS.

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 HiGHS as options. For instance, we can call highs_solve_qp(P, q, G, h, u, primal_feasibility_tolerance=1e-8, dual_feasibility_tolerance=1e-8). HiGHS settings include the following:

Name

Description

dual_feasibility_tolerance

Dual feasibility tolerance.

primal_feasibility_tolerance

Primal feasibility tolerance.

time_limit

Run time limit in seconds.

Check out the HiGHS documentation for more information on the solver.

jaxopt.OSQP

Solver interface for jaxopt’s implementation of the OSQP algorithm.

JAXopt is a library of hardware-accelerated, batchable and differentiable optimizers implemented with JAX. JAX itself is a library for array-oriented numerical computation that provides automatic differentiation and just-in-time compilation.

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.jaxopt_osqp_.jaxopt_osqp_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program with the OSQP algorithm implemented in jaxopt.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by jaxopt.OSQP.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP returned by the solver.

Notes

All other keyword arguments are forwarded as keyword arguments to jaxopt.OSQP. For instance, you can call jaxopt_osqp_solve_qp(P, q, G, h, sigma=1e-5, momentum=0.9).

Note that JAX by default uses 32-bit floating point numbers, which can lead to numerical instability. If you encounter numerical issues, consider using 64-bit floating point numbers by setting its jax_enable_x64 configuration.

qpsolvers.solvers.jaxopt_osqp_.jaxopt_osqp_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, verbose=False, **kwargs)

Solve a QP with the OSQP algorithm implemented in jaxopt.

The quadratic program is defined as:

\[\begin{split}\begin{split}\begin{array}{ll} \underset{\mbox{minimize}}{x} & \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 jaxopt.OSQP.

Parameters:
  • P (ndarray) – Positive semidefinite 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.

  • verbose (bool) – Set to True to print out extra information.

  • initvals (Optional[ndarray]) – This argument is not used by jaxopt.OSQP.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

KVXOPT

Solver interface for KVXOPT.

KVXOPT is a fork from CVXOPT including more SuiteSparse functions and KLU sparse matrix solver. As CVXOPT, it is a free, open-source interior-point solver.

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.kvxopt_.kvxopt_solve_problem(problem, solver=None, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using KVXOPT.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • solver (Optional[str]) – Set to ‘mosek’ to run MOSEK rather than KVXOPT.

  • initvals (Optional[ndarray]) – Warm-start guess vector for the primal solution.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Raises:
  • ProblemError – If the KVXOPT rank assumption is not satisfied.

  • SolverError – If KVXOPT failed with an error.

Note

Rank assumptions: KVXOPT 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. See the “Rank assumptions” paragraph in the report The CVXOPT linear and quadratic cone program solvers for details.

Notes

KVXOPT only considers the lower entries of \(P\), therefore it will use a different cost than the one intended if a non-symmetric matrix is provided.

Keyword arguments are forwarded as options to KVXOPT. For instance, we can call kvxopt_solve_qp(P, q, G, h, u, abstol=1e-4, reltol=1e-4). KVXOPT options include the following:

Name

Description

abstol

Absolute tolerance on the duality gap.

feastol

Tolerance on feasibility conditions, that is, on the primal residual.

maxiters

Maximum number of iterations.

refinement

Number of iterative refinement steps when solving KKT equations

reltol

Relative tolerance on the duality gap.

Check out Algorithm Parameters section of the solver documentation for details and default values of all solver parameters. See also [Caron2022] for a primer on the duality gap, primal and dual residuals.

qpsolvers.solvers.kvxopt_.kvxopt_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, solver=None, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using KVXOPT.

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 KVXOPT.

Parameters:
  • P (Union[ndarray, csc_matrix]) – 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 (Union[ndarray, csc_matrix, None]) – Linear inequality 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 vector.

  • A (Union[ndarray, csc_matrix, None]) – 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.

  • solver (Optional[str]) – Set to ‘mosek’ to run MOSEK rather than KVXOPT.

  • 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:

Primal solution to the QP, if found, otherwise None.

Raises:
  • ProblemError – If the KVXOPT rank assumption is not satisfied.

  • SolverError – If KVXOPT failed with an error.

MOSEK

Solver interface for MOSEK.

MOSEK is a solver for linear, mixed-integer linear, quadratic, mixed-integer quadratic, quadratically constraint, conic and convex nonlinear mathematical optimization problems. Its interior-point method is geared towards large scale sparse problems, in particular for linear or conic quadratic programs.

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.mosek_.mosek_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using MOSEK.

Parameters:
  • P – Symmetric cost matrix.

  • q – Cost vector.

  • G – Linear inequality constraint matrix.

  • h – Linear inequality constraint vector.

  • A – Linear equality constraint matrix.

  • b – Linear equality constraint vector.

  • lb – Lower bound constraint vector.

  • ub – 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:

Solution

Returns:

Solution to the QP, if found, otherwise None.

qpsolvers.solvers.mosek_.mosek_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 MOSEK.

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 the MOSEK interface from CVXOPT.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Symmetric 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.

OSQP

Solver interface for OSQP.

The OSQP solver implements an operator-splitting method, more precisely an alternating direction method of multipliers (ADMM). It is designed for both dense and sparse problems, and convexity is the only assumption it makes on problem data (for instance, it does not make any rank assumption, contrary to solvers such as CVXOPT or qpSWIFT). If you are using OSQP in a scientific work, consider citing the corresponding paper [Stellato2020].

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.osqp_.osqp_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using OSQP.

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:

Solution

Returns:

Solution returned by the solver.

Raises:

ValueError – If the problem is clearly non-convex. See this recommendation. Note that OSQP may find the problem unfeasible if the problem is slightly non-convex (in this context, the meaning of “clearly” and “slightly” depends on how close the negative eigenvalues of \(P\) are to zero).

Note

OSQP requires a symmetric P and won’t check for errors otherwise. Check out this point if you get nan values in your solutions.

Notes

Keyword arguments are forwarded to either the setup or the solve function of OSQP. For instance, we can call osqp_solve_qp(P, q, G, h, u, eps_abs=1e-8, eps_rel=0.0). OSQP settings include the following:

Name

Description

max_iter

Maximum number of iterations.

time_limit

Run time limit in seconds, 0 to disable.

eps_abs

Absolute feasibility tolerance. See Convergence.

eps_rel

Relative feasibility tolerance. See Convergence.

eps_prim_inf

Primal infeasibility tolerance.

eps_dual_inf

Dual infeasibility tolerance.

polish

Perform polishing. See Polishing.

raise_error

If True, raise an exception if the solver does not find a solution. See Solve.

Check out the OSQP settings documentation for all available settings.

Lower values for absolute or relative tolerances yield more precise solutions at the cost of computation time. See e.g. [Caron2022] for an overview of solver tolerances.

qpsolvers.solvers.osqp_.osqp_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 OSQP.

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 OSQP.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Symmetric 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.

Raises:

ValueError

If the problem is clearly non-convex. See this recommendation. Note that OSQP may find the problem unfeasible if the problem is slightly non-convex (in this context, the meaning of “clearly” and “slightly” depends on how close the negative eigenvalues of \(P\) are to zero).

Note

OSQP requires a symmetric P and won’t check for errors otherwise. Check out this point if you get nan values in your solutions.

Notes

Keyword arguments are forwarded to OSQP. For instance, we can call osqp_solve_qp(P, q, G, h, u, eps_abs=1e-8, eps_rel=0.0). OSQP settings include the following:

Name

Description

max_iter

Maximum number of iterations.

time_limit

Run time limit in seconds, 0 to disable.

eps_abs

Absolute feasibility tolerance. See Convergence.

eps_rel

Relative feasibility tolerance. See Convergence.

eps_prim_inf

Primal infeasibility tolerance.

eps_dual_inf

Dual infeasibility tolerance.

polish

Perform polishing. See Polishing.

Check out the OSQP settings documentation for all available settings.

Lower values for absolute or relative tolerances yield more precise solutions at the cost of computation time. See e.g. [Caron2022] for an overview of solver tolerances.

PIQP

Solver interface for PIQP.

PIQP is a proximal interior-point quadratic programming solver for dense and sparse problems. Its algorithm combines an infeasible interior-point method with the proximal method of multipliers, and is designed to handle ill-conditioned convex problems without the need for linear independence of constraints. If you are using PIQP in a scientific work, consider citing the corresponding paper [Schwan2023].

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.piqp_.piqp_solve_problem(problem, initvals=None, verbose=False, backend=None, **kwargs)

Solve a quadratic program using PIQP.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by PIQP.

  • backend (Optional[str]) – PIQP backend to use in [None, "dense", "sparse"]. If None (default), the backend is selected based on the type of P.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP returned by the solver.

Notes

All other keyword arguments are forwarded as options to PIQP. For instance, you can call piqp_solve_qp(P, q, G, h, eps_abs=1e-6). For a quick overview, the solver accepts the following settings:

Name

Effect

rho_init

Initial value for the primal proximal penalty parameter rho.

delta_init

Initial value for the augmented lagrangian penalty parameter delta.

eps_abs

Absolute tolerance.

eps_rel

Relative tolerance.

check_duality_gap

Check terminal criterion on duality gap.

eps_duality_gap_abs

Absolute tolerance on duality gap.

eps_duality_gap_rel

Threshold value for infeasibility detection.

infeasibility_threshold

Relative tolerance on duality gap.

reg_lower_limit

Lower limit for regularization.

reg_finetune_lower_limit

Fine tune lower limit regularization.

reg_finetune_primal_update_threshold

Threshold of number of no primal updates to transition to fine tune mode.

reg_finetune_dual_update_threshold

Threshold of number of no dual updates to transition to fine tune mode.

max_iter

Maximum number of iterations.

max_factor_retires

Maximum number of factorization retires before failure.

preconditioner_scale_cost

Scale cost in Ruiz preconditioner.

preconditioner_reuse_on_update

Reuse the preconditioner from previous setup/update.

preconditioner_iter

Maximum of preconditioner iterations.

tau

Maximum interior point step length.

kkt_solver

KKT solver backend.

iterative_refinement_always_enabled

Always run iterative refinement and not only on factorization failure.

iterative_refinement_eps_abs

Iterative refinement absolute tolerance.

iterative_refinement_eps_rel

Iterative refinement relative tolerance.

iterative_refinement_max_iter

Maximum number of iterations for iterative refinement.

iterative_refinement_min_improvement_rate

Minimum improvement rate for iterative refinement.

iterative_refinement_static_regularization_eps

Static regularization for KKT system for iterative refinement.

iterative_refinement_static_regularization_rel

Static regularization w.r.t. the maximum abs diagonal term of KKT system.

verbose

Verbose printing.

compute_timings

Measure timing information internally.

This list is not exhaustive. Check out the solver documentation for details.

qpsolvers.solvers.piqp_.piqp_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, verbose=False, backend=None, **kwargs)

Solve a quadratic program using PIQP.

The quadratic program is defined as:

\[\begin{split}\begin{split}\begin{array}{ll} \underset{\mbox{minimize}}{x} & \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 PIQP.

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.

  • backend (Optional[str]) – PIQP backend to use in [None, "dense", "sparse"]. If None (default), the backend is selected based on the type of P.

  • verbose (bool) – Set to True to print out extra information.

  • initvals (Optional[ndarray]) – This argument is not used by PIQP.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

ProxQP

Solver interface for ProxQP.

ProxQP is a primal-dual augmented Lagrangian method with proximal heuristics. It converges to the solution of feasible problems, or to the solution to the closest feasible one if the input problem is unfeasible. ProxQP is part of the ProxSuite collection of open-source solvers. If you use ProxQP in a scientific work, consider citing the corresponding paper [Bambade2022].

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.proxqp_.proxqp_solve_problem(problem, initvals=None, verbose=False, backend=None, **kwargs)

Solve a quadratic program using ProxQP.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – Warm-start guess vector for the primal solution.

  • backend (Optional[str]) – ProxQP backend to use in [None, "dense", "sparse"]. If None (default), the backend is selected based on the type of P.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP returned by the solver.

Raises:

ParamError – If a warm-start value is given both in initvals and the x keyword argument.

Notes

All other keyword arguments are forwarded as options to ProxQP. For instance, you can call proxqp_solve_qp(P, q, G, h, eps_abs=1e-6). For a quick overview, the solver accepts the following settings:

Name

Effect

x

Warm start value for the primal variable.

y

Warm start value for the dual Lagrange multiplier for equality constraints.

z

Warm start value for the dual Lagrange multiplier for inequality constraints.

eps_abs

Asbolute stopping criterion of the solver (default: 1e-3, note that this is a laxer default than other solvers). See e.g. [Caron2022] for an overview of solver tolerances.

eps_rel

Relative stopping criterion of the solver. See e.g. [Caron2022] for an overview of solver tolerances.

check_duality_gap

If set to true (false by default), ProxQP will include the duality gap in absolute and relative stopping criteria.

mu_eq

Proximal step size wrt equality constraints multiplier.

mu_in

Proximal step size wrt inequality constraints multiplier.

rho

Proximal step size wrt primal variable.

compute_preconditioner

If True (default), the preconditioner will be derived.

compute_timings

If True (default), timings will be computed by the solver (setup time, solving time, and run time = setup time + solving time).

max_iter

Maximal number of authorized outer iterations.

initial_guess

Sets the initial guess option for initilizing x, y and z.

This list is not exhaustive. Check out the solver documentation for details.

qpsolvers.solvers.proxqp_.proxqp_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, verbose=False, backend=None, **kwargs)

Solve a quadratic program using ProxQP.

The quadratic program is defined as:

\[\begin{split}\begin{split}\begin{array}{ll} \underset{\mbox{minimize}}{x} & \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 ProxQP.

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.

  • backend (Optional[str]) – ProxQP backend to use in [None, "dense", "sparse"]. If None (default), the backend is selected based on the type of P.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

pyqpmad

Solver interface for pyqpmad.

pyqpmad is a Python wrapper for qpmad, a C++ implementation of Goldfarb-Idnani’s dual active-set method [Goldfarb1983]. It works best on well-conditioned dense problems with a positive-definite Hessian.

qpmad <https://github.com/asherikov/qpmad>

Warm-start: this solver interface supports warm starting 🌡️

qpsolvers.solvers.pyqpmad_.pyqpmad_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using pyqpmad.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – Initial guess for the primal solution. pyqpmad uses this as a warm-start if provided.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Raises:

ProblemError : – If the problem has sparse matrices (pyqpmad is a dense solver).

Notes

Keyword arguments are forwarded as attributes of a pyqpmad.SolverParameters object. Supported settings include:

Name

Description

tolerance

Solver feasibility/optimality tolerance.

max_iter

Maximum number of iterations.

Check out the qpmad documentation for all available settings.

qpsolvers.solvers.pyqpmad_.pyqpmad_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 pyqpmad.

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 pyqpmad, a Python wrapper for the qpmad C++ solver.

Parameters:
  • P (ndarray) – Symmetric 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]) – Initial guess for the primal solution (warm start).

  • verbose (bool) – Set to True to print out extra information.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

QPALM

Solver interface for QPALM.

QPALM is a proximal augmented-Lagrangian solver for (possibly nonconvex) quadratic programs, implemented in the C programming language. If you use QPALM in a scientific work, consider citing the corresponding paper [Hermans2022].

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.qpalm_.qpalm_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using QPALM.

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:

Solution

Returns:

Solution to the QP returned by the solver.

Raises:

ParamError – If a warm-start value is given both in initvals and the x keyword argument.

Note

QPALM internally only uses the upper-triangular part of the cost matrix \(P\).

Notes

Keyword arguments are forwarded as “settings” to QPALM. For instance, we can call qpalm_solve_qp(P, q, G, h, u, eps_abs=1e-4, eps_rel=1e-4).

Name

Effect

max_iter

Maximum number of iterations.

eps_abs

Asbolute stopping criterion of the solver. See e.g. [Caron2022] for an overview of solver tolerances.

eps_rel

Relative stopping criterion of the solver. See e.g. [Caron2022] for an overview of solver tolerances.

rho

Tolerance scaling factor.

theta

Penalty update criterion parameter.

delta

Penalty update factor.

sigma_max

Penalty factor cap.

proximal

Boolean, use proximal method of multipliers or not.

This list is not exhaustive. Check out the solver documentation for details.

qpsolvers.solvers.qpalm_.qpalm_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 QPALM.

The quadratic program is defined as:

\[\begin{split}\begin{split}\begin{array}{ll} \underset{\mbox{minimize}}{x} & \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 QPALM.

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:

Primal solution to the QP, if found, otherwise None.

qpax ===

Solver interface for qpax.

qpax is an open-source QP solver that can be combined with JAX’s jit and vmap functionality, as well as differentiated with reverse-mode differentiation. It is based on a primal-dual interior point algorithm. If you are using qpax in a scientific work, consider citing the corresponding paper [Tracy2024].

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.qpax_.qpax_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using qpax.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by qpax.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP returned by the solver.

Notes

All other keyword arguments are forwarded as options to qpax. For instance, you can call qpax_solve_qp(P, q, G, h, solver_tol=1e-5). For a quick overview, the solver accepts the following settings:

Name

Effect

solver_tol

Tolerance for the solver.

Note that jax by default uses 32-bit floating point numbers, which can lead to numerical instability. If you encounter numerical issues, consider using 64-bit floating point numbers by setting `python import jax jax.config.update("jax_enable_x64", True) `

qpsolvers.solvers.qpax_.qpax_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 qpax.

The quadratic program is defined as:

\[\begin{split}\begin{split}\begin{array}{ll} \underset{\mbox{minimize}}{x} & \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 qpax. Paper:.

Parameters:
  • P (ndarray) – Positive semidefinite 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.

  • verbose (bool) – Set to True to print out extra information.

  • initvals (Optional[ndarray]) – This argument is not used by qpax.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

QTQP

Solver interface for QTQP.

QTQP is a primal-dual interior point method for solving convex quadratic programs (QPs), implemented in pure Python. It is developed by Google DeepMind.

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.qtqp_.qtqp_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using QTQP.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by QTQP.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Notes

Keyword arguments are forwarded as options to QTQP. For instance, we can call qtqp_solve_qp(P, q, G, h, atol=1e-8, max_iter=200). QTQP options include the following:

Name

Description

atol

Absolute tolerance for optimality convergence (default: 1e-7).

rtol

Relative tolerance for optimality convergence (default: 1e-8).

atol_infeas

Absolute tolerance for infeasibility detection (default: 1e-8).

rtol_infeas

Relative tolerance for infeasibility detection (default: 1e-9).

max_iter

Maximum number of iterations (default: 100).

step_size_scale

Scale factor in (0,1) for line search step size (default: 0.99).

min_static_regularization

Diagonal regularization on KKT for robustness (default: 1e-7).

max_iterative_refinement_steps

Maximum steps for iterative refinement (default: 50).

linear_solver_atol

Absolute tolerance for iterative refinement (default: 1e-12).

linear_solver_rtol

Relative tolerance for iterative refinement (default: 1e-12).

linear_solver

KKT solver backend (default: qtqp.LinearSolver.SCIPY).

equilibrate

Scale/equilibrate data for numerical stability (default: True).

Check out the QTQP repository for details.

Lower values for absolute or relative tolerances yield more precise solutions at the cost of computation time.

qpsolvers.solvers.qtqp_.qtqp_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 QTQP.

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 QTQP.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Symmetric cost matrix.

  • q (ndarray) – Cost vector.

  • G (Union[ndarray, csc_matrix, None]) – Linear inequality matrix.

  • h (Optional[ndarray]) – Linear inequality 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]) – This argument is not used by QTQP.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

Notes

Keyword arguments are forwarded to the solver. For example, we can call qtqp_solve_qp(P, q, G, h, atol=1e-8, max_iter=200).

QTQP is a primal-dual interior point method that solves convex quadratic programs. It requires the cost matrix P to be positive semidefinite.

quadprog

Solver interface for quadprog.

quadprog is a C implementation of the Goldfarb-Idnani dual algorithm [Goldfarb1983]. It works best on well-conditioned dense problems.

Warm-start: this solver interface does not support warm starting ❄️

qpsolvers.solvers.quadprog_.quadprog_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using quadprog.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – This argument is not used by quadprog.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Solution

Returns:

Solution to the QP, if found, otherwise None.

Raises:

ProblemError : – If the cost matrix of the quadratic program if not positive definite, or if the problem is ill-formed in some way, for instance if some matrices are not dense.

Note

The quadprog solver only considers the lower entries of \(P\), therefore it will use a different cost than the one intended if a non-symmetric matrix is provided.

Notes

All other keyword arguments are forwarded to the quadprog solver. For instance, you can call quadprog_solve_qp(P, q, G, h, factorized=True). See the solver documentation for details.

qpsolvers.solvers.quadprog_.quadprog_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 quadprog.

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 quadprog.

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]) – This argument is not used by quadprog.

  • verbose (bool) – Set to True to print out extra information.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

SCS

Solver interface for SCS.

SCS (Splitting Conic Solver) is a numerical optimization package for solving large-scale convex quadratic cone problems, which is a general class of problems that includes quadratic programming. If you use SCS in a scientific work, consider citing the corresponding paper [ODonoghue2021].

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.scs_.scs_solve_problem(problem, initvals=None, verbose=False, **kwargs)

Solve a quadratic program using SCS.

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:

Solution

Returns:

Solution returned by the solver.

Raises:

ValueError – If the quadratic program is not unbounded below.

Notes

Keyword arguments are forwarded as is to SCS. For instance, we can call scs_solve_qp(P, q, G, h, eps_abs=1e-6, eps_rel=1e-4). SCS settings include the following:

Name

Description

max_iters

Maximum number of iterations to run.

time_limit_secs

Time limit for solve run in seconds (can be fractional). 0 is interpreted as no limit.

eps_abs

Absolute feasibility tolerance. See Termination criteria.

eps_rel

Relative feasibility tolerance. See Termination criteria.

eps_infeas

Infeasibility tolerance (primal and dual), see Certificate of infeasibility.

normalize

Whether to perform heuristic data rescaling. See Data equilibration.

Check out the SCS settings documentation for all available settings.

qpsolvers.solvers.scs_.scs_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 SCS.

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 SCS.

Parameters:
  • P (Union[ndarray, csc_matrix]) – Primal quadratic cost matrix.

  • q (ndarray) – Primal quadratic 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.

Raises:

ValueError – If the quadratic program is not unbounded below.

Notes

Keyword arguments are forwarded as is to SCS. For instance, we can call scs_solve_qp(P, q, G, h, eps_abs=1e-6, eps_rel=1e-4). SCS settings include the following:

Name

Description

max_iters

Maximum number of iterations to run.

time_limit_secs

Time limit for solve run in seconds (can be fractional). 0 is interpreted as no limit.

eps_abs

Absolute feasibility tolerance. See Termination criteria.

eps_rel

Relative feasibility tolerance. See Termination criteria.

eps_infeas

Infeasibility tolerance (primal and dual), see Certificate of infeasibility.

normalize

Whether to perform heuristic data rescaling. See Data equilibration.

Check out the SCS settings documentation for all available settings.

SIP

Solver interface for SIP.

SIP is a general NLP solver based. It is based on the barrier augmented Lagrangian method, which combines the interior point and augmented Lagrangian methods. If you are using SIP in a scientific work, consider citing the corresponding GitHub repository (or paper, if one has been released).

Warm-start: this solver interface supports warm starting 🔥

qpsolvers.solvers.sip_.sip_solve_problem(problem, initvals=None, verbose=False, allow_non_psd_P=False, **kwargs)

Solve a quadratic program using SIP.

Parameters:
  • problem (Problem) – Quadratic program to solve.

  • initvals (Optional[ndarray]) – Warm-start guess for the primal solution.

  • verbose (bool) – Set to True to print SIP logs.

  • allow_non_psd_P (bool) – This argument is not used by SIP.

Return type:

Solution

Returns:

Solution to the QP returned by SIP.

Notes

Additional keyword arguments configure sip_qp_python.Settings. Structured setting groups are passed as dictionaries. For example:

solve_problem(
    problem,
    solver="sip",
    max_iterations=500,
    termination={"max_absolute_duality_gap": 1e-8},
    scaling={"max_iterations": 20},
)

The following settings are supported:

Name

Effect

mode

Select regularized, primal-proximal, or primal-dual-proximal IPM.

max_iterations

Maximum number of SIP iterations.

num_iterative_refinement_steps

Number of Newton-KKT iterative-refinement steps.

assert_checks_pass

Handle internal consistency-check failures with assertions.

barrier

Dictionary containing initial_mu, mu_update_factor, mu_min, and mu_update_kappa.

penalty

Dictionary containing penalty initialization, warm-start, update, and maximum-value settings.

termination

Dictionary containing absolute and relative QP residual and duality-gap tolerances.

regularization

Dictionary containing the initial, first-positive, and maximum regularization values, factorization-attempt limit, and increase and decrease factors.

line_search

Dictionary containing fraction-to-boundary, Armijo, backtracking, filter, line-search failure, and line-search limit settings.

logging

Dictionary controlling solver, line-search, search-direction, and derivative-check logs.

scaling

Dictionary containing max_iterations, min_norm, max_norm, and convergence_tolerance for QP equilibration.

eps_abs

Set the absolute QP residual and duality-gap tolerances.

eps_rel

Set the relative QP primal, dual, and duality-gap tolerances.

time_limit

Maximum solve time in seconds.

Variable bounds are passed to SIP natively rather than expanded into general inequalities. Exact fixed bounds are represented as equalities because SIP requires strict lower and upper bound intervals.

qpsolvers.solvers.sip_.sip_solve_qp(P, q, G=None, h=None, A=None, b=None, lb=None, ub=None, initvals=None, allow_non_psd_P=False, verbose=False, **kwargs)

Solve a quadratic program using SIP.

The quadratic program is defined as:

\[\begin{split}\begin{split}\begin{array}{ll} \underset{\mbox{minimize}}{x} & \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 SIP.

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 for the primal solution.

  • allow_non_psd_P (bool) – This argument is not used by SIP.

  • verbose (bool) – Set to True to print SIP logs.

Return type:

Optional[ndarray]

Returns:

Primal solution to the QP, if found, otherwise None.

Notes

Additional keyword arguments are forwarded to sip_solve_problem().