This is the Python package for ECOS: Embedded Cone Solver. See Github page for more information.
Project description
Python Wrapper for Embedded Conic Solver (ECOS)
Visit www.embotech.com/ECOS for detailed information on ECOS.
ECOS is a numerical software for solving convex secondorder cone programs (SOCPs) of type
min c'*x
s.t. A*x = b
G*x <=_K h
where the last inequality is generalized, i.e. h  G*x
belongs to the
cone K
. ECOS supports the positive orthant R_+
and secondorder
cones Q_n
defined as
Q_n = { (t,x)  t >=  x _2 }
In the definition above, t is a scalar and x
is in R_{n1}
. The cone
K
is therefore a direct product of the positive orthant and
secondorder cones:
K = R_+ x Q_n1 x ... x Q_nN
Installation
The latest version of ECOS is available via pip
:
pip install ecos
This will download the relevant wheel for your machine.
Building from source
If you are attempting to build the Python extension from source, then use
make install
This will use the latest tag on git to version your local installation of ECOS.
You will need Numpy and Scipy. For installation instructions, see their respective pages.
You may need sudo
privileges for a global installation.
Windows users
Windows users may experience some extreme pain when installing ECOS from source for Python 2.7. We suggest switching to Linux or Mac OSX.
If you must use (or insist on using) Windows, we suggest using the Miniconda distribution to minimize this pain.
If during the installation process, you see the error message
Unable to find vcvarsall.bat
, you will need to install
Microsoft Visual Studio Express 2008,
since Python 2.7 is built against the 2008 compiler.
If using a newer version of Python, you can use a newer version of Visual Studio. For instance, Python 3.3 is built against Visual Studio 2010.
Calling ECOS from Python
After installing the ECOS interface, you must import the module with
import ecos
This module provides a single function ecos
with one of the following calling sequences:
solution = ecos.solve(c,G,h,dims)
solution = ecos.solve(c,G,h,dims,A,b,**kwargs)
The arguments c
, h
, and b
are Numpy arrays (i.e., matrices with a single
column). The arguments G
and A
are Scipy sparse matrices in CSR format;
if they are not of the proper format, ECOS will attempt to convert them. The
argument dims
is a dictionary with two fields, dims['l']
and dims['q']
.
These are the same fields as in the Matlab case. If the fields are omitted or
empty, they default to 0.
The argument kwargs
can include the keywords
feastol
,abstol
,reltol
,feastol_inacc
,abstol_innac
, andreltol_inacc
for tolerance values,max_iters
for the maximum number of iterations, the Booleans
verbose
andmi_verbose
, bool_vars_idx
, a list ofint
s which index the boolean variables,int_vars_idx
, a list ofint
s which index the integer variables,mi_max_iters
for maximum number of branch and bound iterations (mixed integer problems only),mi_abs_eps
for the absolute tolerance between upper and lower bounds (mixed integer problems only), andmi_rel_eps
for the relative tolerance, (UL)/L, between upper and lower bounds (mixed integer problems only).
The arguments A
, b
, and kwargs
are optional.
The returned object is a dictionary containing the fields solution['x']
, solution['y']
, solution['s']
, solution['z']
, and solution['info']
.
The first four are Numpy arrays containing the relevant solution. The last field contains a dictionary with the same fields as the info
struct in the MATLAB interface.
Using ECOS with CVXPY
CVXPY is a powerful Python modeling framework for convex optimization, similar to the MATLAB counterpart CVX. ECOS is one of the default solvers in CVXPY, so there is nothing special you have to do in order to use ECOS with CVXPY, besides specifying it as a solver. Here is a small example from the CVXPY tutorial:
import cvxpy as cp
# Solving a problem with different solvers.
x = cp.Variable(2)
obj = cp.Minimize(cp.norm(x, 2) + cp.norm(x, 1))
constraints = [x >= 2]
prob = cp.Problem(obj, constraints)
# Solve with ECOS.
prob.solve(solver=cp.ECOS)
print("optimal value with ECOS:", prob.value)
ECOS Versioning
The Python module contains two version numbers:
ecos.__version__
: This is the version of the Python wrapper for ECOSecos.__solver_version__
: This is the version of the underlying ECOS solver
These two version numbers should typically agree, but they might not when a bug in the Python module has been fixed and nothing in the underlying C solver has changed. The major version numbers should agree, however.
What happened to 2.0.7?
Because versionsyncing ECOS and ECOSPython can be tricky, the 2.0.7 version did not incorporate some minor changes to ECOS. In an illadvised move, the release was deleted in hopes it could be reuploaded, despite plenty warnings stating otherwise.
Instead, a post release has been made that contains identical content to
the 2.0.7 release. Generally, pip
should pick up the post release for
2.0.7 and any dependencies such as pip install "ecos>=2.0.5"
should still
work as expected.
Deployment
When creating new versions of the Python wrapper, please use
bumpversion
to bump the version number and also remember to tag the
commit so that CI is able to properly pick it up. See
Release for more information.
Python2 Support
Starting with version 2.0.8, ecospython will no longer support Python2.7. You may be able to download an older version but moving forward we will no longer publish Python2 wheels for use.
License
ECOS is distributed under the GNU General Public License v3.0. Other licenses may be available upon request from embotech.
Credits
The solver is essentially based on Lieven Vandenberghe's CVXOPT ConeLP solver, although it differs in the particular way the linear systems are treated.
The following people have been, and are, involved in the development and maintenance of ECOS:
 Alexander Domahidi (principal developer)
 Eric Chu (Python interface, unit tests)
 Stephen Boyd (methods and maths)
 Michael Grant (CVX interface)
 Johan Löfberg (YALMIP interface)
 João Felipe Santos, Iain Dunning (Julia interface)
 Han Wang (ECOS branch and bound)
The main technical idea behind ECOS is described in a short paper. More details are given in Alexander Domahidi's PhD Thesis in Chapter 9.
If you find ECOS useful, you can cite it using the following BibTex entry:
@INPROCEEDINGS{bib:Domahidi2013ecos,
author={Domahidi, A. and Chu, E. and Boyd, S.},
booktitle={European Control Conference (ECC)},
title={{ECOS}: {A}n {SOCP} solver for embedded systems},
year={2013},
pages={30713076}
}
Project details
Release history Release notifications  RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for ecos2.0.12cp311cp311win_amd64.whl
Algorithm  Hash digest  

SHA256  da8fbbca3feb83a9e27075d29b3765417d0c80af8ea83cbdc4a558cae7b564af 

MD5  1863d5731ecd5c5dd2cb9306f207c764 

BLAKE2b256  ab4b09ed42ee4800b1fe142ca18ced3824f46a6709752d4da7625681086b42e6 
Hashes for ecos2.0.12cp311cp311manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm  Hash digest  

SHA256  4979dc2d1cb6667e371a45a61887068505c1305437eef104ed6ef16f4b6aa0e3 

MD5  2f9663ddf791388d6cb817c5b3599b11 

BLAKE2b256  c7b112fac27a2afc40c3a02db4d0a454faa4b08c086025e77ade822e694fdf45 
Hashes for ecos2.0.12cp311cp311macosx_10_9_x86_64.whl
Algorithm  Hash digest  

SHA256  eba07599084724eedc20b2862d5580eebebb09609f4740baadc78401cb99827c 

MD5  af3bc49f8dd4259edbca0291c7b484cb 

BLAKE2b256  b3dc22fb7a26e12f7b610c1b2ae4640995c536562e8cb02068ff873d5d6200ad 
Hashes for ecos2.0.12cp310cp310win_amd64.whl
Algorithm  Hash digest  

SHA256  5184a9d8521ad1af90ffcd9902a6fa75c7bc473f37d30d86f97beda1033dfca2 

MD5  0b72b1861edce3a42cd4de594ab44c6d 

BLAKE2b256  5bcd04605d89661879ff9e8c3771da3674f6b522cff693bd369ef44551ea0fe5 
Hashes for ecos2.0.12cp310cp310manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm  Hash digest  

SHA256  608bc822ee8e070927ab3519169b13a1a0fe88f3d562212d6b5dbb1039776360 

MD5  c4efdc704cb8331de8b64413b815a9ed 

BLAKE2b256  6920b1f8aa05dea40825181d62be127fc8077193a769b10ee2b1ecd986ef634e 
Hashes for ecos2.0.12cp310cp310macosx_10_9_x86_64.whl
Algorithm  Hash digest  

SHA256  835298a299c88c207b3402fba60ad9b5688b59bbbf2ac34a46de5b37165d773a 

MD5  56b9b501ef4f8303a764e56dc1a9f997 

BLAKE2b256  0782408273c86d2aa99a26d4a1518a4fd2efe799bf01bdabf1fdcf3883b2c46b 
Hashes for ecos2.0.12cp39cp39win_amd64.whl
Algorithm  Hash digest  

SHA256  7af08941552fce108bd80145cdb6be7fa74477a20bacdac170800442cc7027d4 

MD5  d285384722d1b0c1b06bdb0e4f37bd20 

BLAKE2b256  e29ea9c8786fb278ba4a2a5388e14a4143ac294a3c7b8a0a4249dacf12b47f82 
Hashes for ecos2.0.12cp39cp39manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm  Hash digest  

SHA256  6def54336a15b5a49bc3bfcaa36035e8557cae8a4853b17ca84f5a29c93bcaea 

MD5  bd7390d466ee919150bc0d9ca880255f 

BLAKE2b256  0ed7d79bddbfe09da07dee320fe2edbaa5224720b2a679c53db47a461a6f1d98 
Hashes for ecos2.0.12cp39cp39macosx_10_9_x86_64.whl
Algorithm  Hash digest  

SHA256  3e42bd4c19af6e04f76ccc85d941b1f1adc7faeee4d06d482395a6beb7bec895 

MD5  771f1ec5fda80e9e1ec25e20ed444b2f 

BLAKE2b256  8b547e63a1dc9d45ebe7743c1647af63a97b3306679deb2d9bea29d5d1575ebb 
Hashes for ecos2.0.12cp38cp38win_amd64.whl
Algorithm  Hash digest  

SHA256  528b02f53835bd1baeb2e23f8153b8d6cc2b3704e1768be6a1a972f542241670 

MD5  6b7b21b3b78e02812692906763387bed 

BLAKE2b256  bc40458fbe1e9ddefa6958f862974e28a1cd9405e6d3555583944834b199cebc 
Hashes for ecos2.0.12cp38cp38manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm  Hash digest  

SHA256  858a4dd3177bdc8cc6e362031732f5177b62138a1e4ef91c0dc3c6bd7d2d1248 

MD5  bfe710696b737e123a02f154e3e15eb3 

BLAKE2b256  aa1bf72a5fd12afda79f1d885b45b9c2737070576d4a9cf48112cbb288bf5230 
Hashes for ecos2.0.12cp38cp38macosx_10_9_x86_64.whl
Algorithm  Hash digest  

SHA256  4e86671397d1d2cd7cccff8a9c45be0541b0c60af8b92a0ff3581c9ed869db67 

MD5  0d1307f0d9936f1ef990605b02a8b564 

BLAKE2b256  1836eda93730201877db06bfc321f410877ff49f92654edc6d7650802124dba9 
Hashes for ecos2.0.12cp37cp37mwin_amd64.whl
Algorithm  Hash digest  

SHA256  29d00164eaea66ed54697a3b361c575284a8bca54f2623381a0635806c7303a7 

MD5  d3eea15ed5d041e54181c7733d047d4c 

BLAKE2b256  236a922704896b631bc6c67f40a9507af7c8ad1d5f0613052a16da48651e60e0 
Hashes for ecos2.0.12cp37cp37mmanylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm  Hash digest  

SHA256  617be25d74222849622b0f82b94a11abcf1fae78ccaf69977b328321ee6ffa0b 

MD5  883e9f2d248f0c1974dbc2cf0603074c 

BLAKE2b256  d7e74cb8b9597c7e649bedc4ba8247d9f4305c453f6176b12dacaff0f0d97831 
Hashes for ecos2.0.12cp37cp37mmacosx_10_9_x86_64.whl
Algorithm  Hash digest  

SHA256  f70e4547966f530fd7715756f7a65d5b9b90b312b9d37f243ef9356c05e7d74c 

MD5  2af1acc994e053045c83c5c7b0ceecb0 

BLAKE2b256  9acbba4abbedfb4bfb4f41c8fa0da1df0c78cc8014f6efc72516bcc8028b9b58 