Supported solvers

CVXOPT

Solver interface for CVXOPT.

lpsolvers.cvxopt_.cvxopt_matrix(M)

Convert matrix M to CVXOPT format.

Parameters:

M (ndarray) – Matrix to convert.

Return type:

matrix

Returns:

Same matrix in CVXOPT format.

lpsolvers.cvxopt_.cvxopt_solve_lp(c, G, h, A=None, b=None, solver='glpk', **kwargs)

Solve a linear program using CVXOPT.

The linear program is defined by:

\[\begin{split}\begin{split}\begin{array}{ll} \mbox{minimize} & c^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \end{array}\end{split}\end{split}\]

It is solved using the LP solver from CVXOPT.

Parameters:
  • c (ndarray) – Linear cost vector.

  • G (ndarray) – Linear inequality constraint matrix.

  • h (ndarray) – Linear inequality constraint vector.

  • A (Optional[ndarray]) – Linear equality constraint matrix.

  • b (Optional[ndarray]) – Linear equality constraint vector.

  • solver (Optional[str]) – Solver to use, default is GLPK if available

Return type:

ndarray

Returns:

Optimal (primal) solution of the linear program, if it exists.

Raises:

ValueError – If the LP is not feasible.

CVXPY

Solver interface for CVXPY.

lpsolvers.cvxpy_.cvxpy_solve_lp(c, G, h, A=None, b=None, solver=None, verbose=False, **kwargs)

Solve a linear program using CVXPY.

The linear program is defined by:

\[\begin{split}\begin{split}\begin{array}{ll} \mbox{minimize} & c^T x \\ \mbox{subject to} & G x \leq h \\ & A x = b \end{array}\end{split}\end{split}\]

It is solved using a solver wrapped by CVXPY. The underlying solver is selected via the corresponding keyword argument.

Parameters:
  • c (ndarray) – Linear cost vector.

  • G (ndarray) – Linear inequality constraint matrix.

  • h (ndarray) – Linear inequality constraint vector.

  • A (Optional[ndarray]) – Linear equality constraint matrix.

  • b (Optional[ndarray]) – Linear equality constraint vector.

  • solver (Optional[str]) – Solver name in cvxpy.installed_solvers().

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

Returns:

x – Optimal (primal) solution of the linear program, if it exists.

Return type:

array, shape=(n,)

Raises:

ValueError – If the LP is not feasible.

cdd

Solver interface for cdd.

lpsolvers.cdd_.cdd_solve_lp(c, G, h, A=None, b=None)

Solve a linear program using the LP solver from cdd.

The linear program is defined by:

\[\begin{split}\\begin{split}\\begin{array}{ll} \\mbox{minimize} & c^T x \\\\ \\mbox{subject to} & G x \\leq h \\\\ & A x = b \\end{array}\\end{split}\end{split}\]

It is solved using cdd.

Parameters:
  • c (ndarray) – Linear cost vector.

  • G (ndarray) – Linear inequality constraint matrix.

  • h (ndarray) – Linear inequality constraint vector.

  • A (Optional[ndarray]) – Linear equality constraint matrix.

  • b (Optional[ndarray]) – Linear equality constraint vector.

  • solver – Solver to use, default is GLPK if available

Return type:

ndarray

Returns:

Optimal (primal) solution of the linear program, if it exists.

Raises:

ValueError – If the linear program is not feasible.

PDLP

Solver interface for PDLP.

PDLP is a first-order method for convex quadratic programming aiming for high-accuracy solutions and scaling to large problems. If you use PDLP in your academic works, consider citing the corresponding paper [Applegate2021].

lpsolvers.pdlp_.pdlp_solve_lp(c, G, h, A=None, b=None, verbose=False, eps_optimal_absolute=None, eps_optimal_relative=None, time_sec_limits=None, **kwargs)

Solve a quadratic program using PDLP.

Parameters:
  • c (ndarray) – Linear cost vector.

  • G (ndarray) – Linear inequality constraint matrix.

  • h (ndarray) – Linear inequality constraint vector.

  • A (Optional[ndarray]) – Linear equality constraint matrix.

  • b (Optional[ndarray]) – Linear equality constraint vector.

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

  • verbose – Set to True to print out extra information.

  • eps_optimal_absolute (Optional[float]) – Absolute tolerance on the primal-dual residuals and duality gap. See e.g. [tolerances] for an overview of solver tolerances.

  • eps_optimal_relative (Optional[float]) – Relative tolerance on the primal-dual residuals and duality gap. See e.g. [tolerances] for an overview of solver tolerances.

  • time_sec_limits (Optional[float]) – Maximum computation time the solver is allowed, in seconds.

Return type:

ndarray

Returns:

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

Notes

All other keyword arguments are forwarded as parameters to PDLP. For instance, you can call pdlp_solve_qp(P, q, G, h, num_threads=3, verbosity_level=2). For a quick overview, the solver accepts the following settings:

Name

Effect

num_threads

Number of threads to use (positive).

verbosity_level

Verbosity level from 0 (no logging) to 4 (extensive logging).

initial_primal_weight

Initial value of the primal weight (ratio of primal over dual step sizes).

l_inf_ruiz_iterations

Number of L-infinity Ruiz rescaling iterations applied to the constraint matrix.

l2_norm_rescaling

If set to True, applies L2-norm rescaling after Ruiz rescaling.

This list is not exhaustive. Check out the solver’s Protocol Bufffers file for more. See also the Mathematical background for PDLP.

ProxQP

Solver interface for ProxQP.

ProxQP is the QP solver from ProxSuite, a collection of open-source solvers rooted in revisited primal-dual proximal algorithms. If you use ProxQP in some academic work, consider citing the corresponding paper [Bambade2022].

lpsolvers.proxqp_.proxqp_solve_lp(c, G, h, A=None, b=None, verbose=False, backend=None, **kwargs)

Solve a quadratic program using ProxQP.

Parameters:
  • c (ndarray) – Linear cost vector.

  • G (ndarray) – Linear inequality constraint matrix.

  • h (ndarray) – Linear inequality constraint vector.

  • A (Optional[ndarray]) – Linear equality constraint matrix.

  • b (Optional[ndarray]) – Linear equality constraint vector.

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

ndarray

Returns:

Solution to the QP returned by the solver.

Notes

All other keyword arguments are forwarded as solver settings to ProxQP. For instance, you can call proxqp_solve_qp(P, q, G, h, eps_abs=1e-6). Check out the solver documentation for details.