Python interface for SCS 2.0.0 and higher.
To install using pip (recommended) use:
pip install scsIf you run into an error like this:
RuntimeError: Found /usr/lib/libcblas.dylib, but that file is a symbolic link to
the MacOS Accelerate framework, which is not supported by NumPy
you can try:
brew install openblas
OPENBLAS="$(brew --prefix openblas)" pip install scsTo install SCS from source:
git clone --recursive https://github.com/bodono/scs-python.git
cd scs-python
python setup.py installYou may need sudo privileges for a global installation. Running SCS requires
numpy and scipy to be installed. You can install the gpu interface using
python setup.py install --scs --gpuTo test that SCS installed correctly and you have pytest installed, run
pytestAfter installing the SCS interface, you import SCS using
import scsThis module provides a single function solve with the following call signature:
sol = scs.solve(data,
cone,
use_indirect=False,
gpu=False,
verbose=True,
normalize=True,
max_iters=5000,
scale=1,
eps=1e-5,
cg_rate=2,
alpha=1.5,
rho_x=1e-3,
acceleration_lookback=10,
write_data_filename=None)The argument data is a python dictionary with three elements A, b, and c
where b and c are 1d NUMPY arrays and A is a SCIPY sparse matrix in
CSC format; if they are not of the proper format, SCS will attempt to convert
them.
The argument cone is a dictionary with fields f, l, q, s, ep, ed,
and p (all of which are optional) corresponding to the supported cone types.
The returned object is a dictionary containing the keys 'x', 'y', 's', and
'info'. The first three are NUMPY arrays containing the respective solution
vector. The 'info' value is a dictionary with solver information.
Warm-starting SCS with a guess of the primal-dual solution can reduce the total
solve time. This is useful, for example, when solving several similar problems
sequentially. To do this simply add fields to the data dictionary passed to
scs.solve with additional fields x, y, and s (or any subset thereof)
where x and s correspond to NUMPY arrays containing the primal solution
guesses and y corresponds to a NUMPY array containing the dual solution guess.