Package: ecos
Python Wrapper for Embedded Conic Solver (ECOS)Visitwww.embotech.com/ECOSfor detailed information on ECOS.ECOS is a numerical software for solving convex second-order cone
programs (SOCPs) of typemin  c'*x
s.t. A*x = b
     G*x <=_K hwhere the last inequality is generalized, i.e.h - G*xbelongs to the
coneK. ECOS supports the positive orthantR_+and second-order
conesQ_ndefined asQ_n = { (t,x) | t >= || x ||_2 }In the definition above, t is a scalar andxis inR_{n-1}. The coneKis therefore a direct product of the positive orthant and
second-order cones:K = R_+ x Q_n1 x ... x Q_nNInstallationThe latest version of ECOS is available viapip:pip install ecosThis will download the relevant wheel for your machine.Building from sourceIf you are attempting to build the Python extension from source, then
usemake installThis will use the latest tag on git to version your local installation
of ECOS.You will needNumpyandScipy. For installation instructions, see
their respective pages.You may needsudoprivileges for a global installation.Windows usersWindows 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
theMinicondadistribution to minimize this pain.If during the installation process, you see the error messageUnable to find vcvarsall.bat, you will need to installMicrosoft Visual Studio Express 2008,
sincePython 2.7is 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 againstVisual Studio
2010.Calling ECOS from PythonAfter installing the ECOS interface, you must import the module withimport ecosThis module provides a single functionecoswith one of the following calling sequences:solution = ecos.solve(c,G,h,dims)
solution = ecos.solve(c,G,h,dims,A,b,**kwargs)The argumentsc,h, andbare Numpy arrays (i.e., matrices with a single
column).  The argumentsGandAare Scipysparsematrices in CSR format;
if they are not of the proper format, ECOS will attempt to convert them.  The
argumentdimsis a dictionary with two fields,dims['l']anddims['q'].
These are the same fields as in the Matlab case. If the fields are omitted or
empty, they default to 0.
The argumentkwargscan include the keywordsfeastol,abstol,reltol,feastol_inacc,abstol_innac, andreltol_inaccfor tolerance values,max_itersfor the maximum number of iterations,the Booleansverboseandmi_verbose,bool_vars_idx, a list ofints which index the boolean variables,int_vars_idx, a list ofints which index the integer variables,mi_max_itersfor maximum number of branch and bound iterations (mixed integer problems only),mi_abs_epsfor the absolute tolerance between upper and lower bounds (mixed integer problems only), andmi_rel_epsfor the relative tolerance, (U-L)/L, between upper and lower bounds (mixed integer problems only).The argumentsA,b, andkwargsare optional.The returned object is a dictionary containing the fieldssolution['x'],solution['y'],solution['s'],solution['z'], andsolution['info'].
The first four are Numpy arrays containing the relevant solution. The last field contains a dictionary with the same fields as theinfostruct in the MATLAB interface.Using ECOS with CVXPYCVXPYis 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 smallexamplefrom the CVXPY tutorial:importcvxpyascp# 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 VersioningThe 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
solverThese 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 version-syncing ECOS and ECOS-Python can be tricky, the 2.0.7
version did not incorporate some minor changes to ECOS. In an
ill-advised move, the release was deleted in hopes it could be
re-uploaded, despite plenty warnings stating otherwise.Instead, a post release has been made that contains identical content to
the 2.0.7 release. Generally,pipshould pick up the post release for
2.0.7 and any dependencies such aspip install "ecos>=2.0.5"should still
work as expected.DeploymentWhen creating new versions of the Python wrapper, please usebumpversionto bump the version number and also remember to tag the
commit so that CI is able to properly pick it up. SeeReleasefor more information.Python2 SupportStarting with version 2.0.8, ecos-python will no longer support
Python2.7. You may be able to download anolder
versionbut moving forward we will no longer publish Python2 wheels for use.LicenseECOS is distributed under theGNU General Public License
v3.0. Other licenses may be
available upon request fromembotech.CreditsThe solver is essentially based on Lieven Vandenberghe'sCVXOPTConeLPsolver, 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 shortpaper. More details are given in Alexander Domahidi'sPhD Thesisin 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={3071-3076}
}