Skip to content

Commit

Permalink
SCS can directly be requested as a solver
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwittek committed Nov 16, 2016
1 parent 8f9cdb6 commit 37dee14
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Optional dependencies include:
- `SciPy <http://scipy.org/>`_ yields faster execution with the default CPython interpreter.
- `PICOS <http://picos.zib.de/>`_ is necessary for using the Cvxopt solver and for converting the problem to a PICOS instance.
- `MOSEK <http://www.mosek.com/>`_ Python module is necessary to work with the MOSEK solver.
- `CVXPY <http://cvxpy.org/>`_ is required for converting the problem to or by solving it by CVXPY.
- `CVXPY <http://cvxpy.org/>`_ is required for converting the problem to or by solving it by CVXPY or by SCS.
- `Cvxopt <http://cvxopt.org/>`_ is required by both Chompack and PICOS.
- `Chompack <http://chompack.readthedocs.io/en/latest/>`_ improves the sparsity of the chordal graph extension.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/revision_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Revision History
Since 1.11.1:
- New: Pass the optional `momentsubstitutions=` parameter to the `get_relaxation` method to substitute out specific moments.
- Changed: Warning message is displayed if the equality constraints are linearly dependent.
- Changed: CVXPY support improved, solver parameters passed on correctly.
- Changed: CVXPY support improved, solver parameters passed on correctly. SCS can directly be requested as a solver.
- Fixed: Chordal graph extension works with blank objective functions and commuting variables.
- Fixed: Parallel computations produce weird deadlocks less frequently.

Expand Down
13 changes: 11 additions & 2 deletions ncpol2sdpa/sdp_relaxation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def solve(self, solver=None, solverparameters=None):
:param sdpRelaxation: The SDP relaxation to be solved.
:type sdpRelaxation: :class:`ncpol2sdpa.SdpRelaxation`.
:param solver: The solver to be called, either `None`, "sdpa", "mosek",
or "cvxopt". The default is `None`, which triggers
autodetect.
"cvxpy", "scs", or "cvxopt". The default is `None`,
which triggers autodetect.
:type solver: str.
:param solverparameters: Parameters to be passed to the solver. Actual
options depend on the solver:
Expand All @@ -95,6 +95,15 @@ def solve(self, solver=None, solverparameters=None):
Cvxopt:
Refer to the PICOS documentation. All
arguments are passed on.
Cvxpy:
Refer to the Cvxpy documentation. All
arguments are passed on.
SCS:
Refer to the Cvxpy documentation. All
arguments are passed on.
:type solverparameters: dict of str.
"""
if self.F is None:
Expand Down
39 changes: 28 additions & 11 deletions ncpol2sdpa/solver_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def autodetect_solvers(solverparameters):
pass
else:
solvers.append("cvxpy")
solvers.append("scs")
try:
import mosek
except ImportError:
Expand All @@ -45,13 +46,13 @@ def autodetect_solvers(solverparameters):
def solve_sdp(sdp, solver=None, solverparameters=None):
"""Call a solver on the SDP relaxation. Upon successful solution, it
returns the primal and dual objective values along with the solution
matrices. It also sets these values in the `sdp` object, along
with some status information.
matrices.
:param sdp: The SDP relaxation to be solved.
:type sdp: :class:`ncpol2sdpa.sdp`.
:param solver: The solver to be called, either `None`, "sdpa", "mosek", or
"cvxopt". The default is `None`, which triggers autodetect.
:param sdpRelaxation: The SDP relaxation to be solved.
:type sdpRelaxation: :class:`ncpol2sdpa.SdpRelaxation`.
:param solver: The solver to be called, either `None`, "sdpa", "mosek",
"cvxpy", "scs", or "cvxopt". The default is `None`,
which triggers autodetect.
:type solver: str.
:param solverparameters: Parameters to be passed to the solver. Actual
options depend on the solver:
Expand All @@ -62,15 +63,23 @@ def solve_sdp(sdp, solver=None, solverparameters=None):
Specify the executable for SDPA. E.g.,
`"executable":"/usr/local/bin/sdpa"`, or
`"executable":"sdpa_gmp"`
- `"paramsfile"`: Specify the parameter file.
- `"paramsfile"`: Specify the parameter file
Mosek:
Refer to the Mosek documentation. All arguments
are passed on.
Refer to the Mosek documentation. All
arguments are passed on.
Cvxopt:
Refer to the PICOS documentation. All arguments
are passed on.
Refer to the PICOS documentation. All
arguments are passed on.
Cvxpy:
Refer to the Cvxpy documentation. All
arguments are passed on.
SCS:
Refer to the Cvxpy documentation. All
arguments are passed on.
:type solverparameters: dict of str.
:returns: tuple of the primal and dual optimum, and the solutions for the
primal and dual.
Expand Down Expand Up @@ -102,6 +111,14 @@ def solve_sdp(sdp, solver=None, solverparameters=None):
elif solver == "cvxpy":
primal, dual, x_mat, y_mat, status = \
solve_with_cvxpy(sdp, solverparameters)
elif solver == "scs":
if solverparameters is None:
solverparameters_ = {"solver": "SCS"}
else:
solverparameters_ = solverparameters.copy()
solverparameters_["solver"] = "SCS"
primal, dual, x_mat, y_mat, status = \
solve_with_cvxpy(sdp, solverparameters_)
elif solver == "mosek":
primal, dual, x_mat, y_mat, status = \
solve_with_mosek(sdp, solverparameters)
Expand Down

0 comments on commit 37dee14

Please sign in to comment.