Python interface for SCS 2.0.0 and higher.
To install using pip (recommended) use:
pip install scs
To install SCS from source:
git clone --recursive https://github.com/bodono/scs-python.git
cd scs-python
python setup.py install
You 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 --gpu
To test that SCS installed correctly and you have pytest
installed, run
pytest
After installing the SCS interface, you import SCS using
import scs
This 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.