embotech / ecos-python Goto Github PK
View Code? Open in Web Editor NEWPython interface for ECOS
License: GNU General Public License v3.0
Python interface for ECOS
License: GNU General Public License v3.0
Something is deeply wrong with the branch and bound interface. The following code fails, seeming to impose the boolean constraint on y
instead of x
. I will try to look into this but this is a very serious bug. (Possibly in ECOS).
from cvxpy import *
y = Variable()
x = Bool()
prob = Problem(Minimize(x + y), [x >= 0.5, y == 0])
print prob.solve() # should be 1.0
print x.value
print y.value
# Solve using direct call to ECOS.
import ecos
import cvxpy.settings as s
data = prob.get_problem_data(ECOS_BB)
results_dict = ecos.solve(data[s.C], data[s.G], data[s.H],
data[s.DIMS], data[s.A], data[s.B],
verbose=True,
mi_verbose=True,
bool_vars_idx=data[s.BOOL_IDX],
int_vars_idx=data[s.INT_IDX])
print results_dict
Could the Python interface be upgraded to ECOS 2.0.5?
Hello,
New branching strategies were added in ECOS BB 2.0.8 in embotech/ecos#178, however those are not available through the python interface, which means the default "reliability" algorithm is always used.
Would it be possible to add an option for this to the ECOS BB settings in the python interface?
Many thanks
Hello, when I solve a (mixed) integer problem with verbose = False
, ECOS still produces output such as the following:
Iter Lower Bound Upper Bound Gap
================================================
0 38.05 inf inf
1 45.67 55.00 9.33
2 46.85 55.00 8.15
3 51.72 55.00 3.28
4 54.19 55.00 0.81
5 54.67 55.00 0.33
6 54.94 55.00 0.06
7 55.00 55.00 0.00
The branch and bound solver of ECOS supports setting verbosity as of embotech/ecos@cc635e5, so I assume that the issue is rather in the Python interface.
I'd also be happy about a workaround in case the fix takes a while to enter a release.
Hi,
Our team uses cvxpy package for Airflow recipes and we came across some errors happening during the recipe build process pip installation of the latest ecos package:
Collecting ecos>=2 (from cvxpy==1.0.21->-r /python_requirements/requirements_spark3_7.txt (line 3))
Downloading https://files.pythonhosted.org/packages/84/2a/1480b85692f349fd669655e020a1aafdd2b798eab69305d394989f1d2b64/ecos-2.0.11.tar.gz (141kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
Complete output from command /opt/pyenv/versions/3.7.4/bin/python3.7 /opt/pyenv/versions/3.7.4/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpwfkf809e:
Traceback (most recent call last):
File "/opt/pyenv/versions/3.7.4/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/opt/pyenv/versions/3.7.4/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/pyenv/versions/3.7.4/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-souez5we/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-souez5we/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-souez5we/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 485, in run_setup
self).run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-souez5we/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 70, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'README.md'
Fixing the version in our requirements.txt to ecos==2.0.10
seems to be workaround for now.
Hey y'all, I built conda packages for ECOS-Python here. Here is the Conda recipe that I'm using.
I know that you already have some conda support in your code, but I thought this might be helpful for you nonetheless. I have access to build workers for 32-bit & 64-bit windows, linux, and mac (minus 32-bit mac), which is nice, and I've got a webhook to anaconda.org to automatically rebuild when I update the recipe (though that isn't fully tested yet).
I thought you might find this useful. And of course, since I'm with Continuum now, if you need any help with conda and/or anaconda support, let me know.
ECOS does not seem to handle infinite values in inequality bounds, which happen for instance when disabling an inequality while working on a problem (e.g. in box inequalities lb <= x <= ub
). Right now the solver fails at first iteration if we put an infinite float (numpy.inf
) in the inequality vector.
Here is an example:
import numpy as np
import scipy.sparse as spa
import ecos
c = np.array([0.0, 0.0, 1.0])
G = spa.csc_matrix(
np.array(
[
[-1.0, 0.0, 0.0],
[0.0, -1.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, -0.70710678],
[-1.0, 0.0, 0.0],
[0.0, -1.0, 0.0],
[0.0, 0.0, 0.70710678],
]
)
)
h = np.array([1.0, np.inf, np.inf, 1.0, 0.70710678, 0.0, 0.0, 0.70710678])
dims = {"q": [4], "l": 4}
ecos.solve(c, G, h, dims)
It produces the following output:
ECOS 2.0.10 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS
It pcost dcost gap pres dres k/t mu step sigma IR | BT
0 -nan -inf +nan 0e+00 7e-02 1e+00 nan --- --- 0 1 - | - -
Reached NAN dead end, recovering best iterate (368424832) and stopping.
Close to OPTIMAL (within feastol=6.9e-310, reltol=6.9e-310, abstol=6.9e-310).
Runtime: 0.000546 seconds.
This example was produced from a small 2D quadratic program with box inequalities qpsolvers/qpsolvers#160:
import numpy as np
from qpsolvers import solve_qp
# minimize 1/2 x^T P x + q^T x
P = np.eye(2)
q = np.zeros(2)
# subject to lb <= x <= ub
lb = np.array([-1.0, -np.inf])
ub = np.array([np.inf, 1.0])
solve_qp(P, q, lb=lb, ub=ub, solver="ecos")
On aarch64, ‘pip install ecos’ builds the wheels from source code and then installs it. It requires the user to have a development environment installed on his system. Also, it takes some time to build the wheels than downloading and extracting the wheels from pypi.
On aarch64, ‘pip install ecos’ should download the wheels from pypi
@SteveDiamond Please let me know your interest in releasing aarch64 wheels. I can help in this.
Just did pip install ecos
and pip install "ecos >= 2.0.7rc2"
to receive, respectively, ecos==2.0.5 and ecos==2.0.7rc2. On both installations, I ran
>>> import ecos
>>> ecos.__version__
'2.0.4'
I'm probably jumping the gun on trying out the new ecos, but when I ran setup.py I got this error:
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
running install
running bdist_egg
running egg_info
writing requirements to src/ecos.egg-info/requires.txt
writing src/ecos.egg-info/PKG-INFO
writing top-level names to src/ecos.egg-info/top_level.txt
writing dependency_links to src/ecos.egg-info/dependency_links.txt
reading manifest file 'src/ecos.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no directories found matching 'ecos/include'
warning: no directories found matching 'ecos/external/amd/include'
warning: no directories found matching 'ecos/external/ldl/include'
warning: no directories found matching 'ecos/external/SuiteSparse_config'
writing manifest file 'src/ecos.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.5-x86_64/egg
running install_lib
running build_py
running build_ext
building '_ecos' extension
gcc -fno-strict-aliasing -I/Users/stevend2/anaconda/envs/test_ecos_bb/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -I/Users/stevend2/anaconda/envs/test_ecos_bb/lib/python2.7/site-packages/numpy/core/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/Users/stevend2/anaconda/envs/test_ecos_bb/include/python2.7 -c src/ecosmodule.c -o build/temp.macosx-10.5-x86_64-2.7/src/ecosmodule.o
src/ecosmodule.c:5:10: fatal error: 'ecos.h' file not found
#include "ecos.h"
^
1 error generated.
error: command 'gcc' failed with exit status 1
I'm using ECOS (Python) as a subroutine to solve Exponential Cone Programs. I have used it for two different projects and in both, I noticed that up 3% of the instances fail to be solved and the reason is
Combined backtracking failed 0 0 90 0 sigma 1
As a far as I understood from "Ecos" Thesis that problem lies in the line search.
The question is there something which I can do within ECOS to tune the line searching method?
ECOS output for the instance reported is
ECOS 2.0.4 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS
It pcost dcost gap pres dres k/t mu step sigma IR | BT
0 +0.000e+00 -0.000e+00 +1e+03 1e+00 6e-01 1e+00 1e+00 --- --- 0 0 - | - -
1 -9.287e+00 -8.384e+00 +3e+01 1e+00 3e-02 1e+00 3e-02 0.9791 9e-03 1 1 1 | 1 0
2 -7.483e+00 -7.294e+00 +7e+00 3e-01 7e-03 2e-01 7e-03 0.7833 3e-02 1 1 1 | 1 1
3 -4.653e+00 -4.576e+00 +3e+00 2e-01 4e-03 8e-02 3e-03 0.6266 2e-01 1 1 1 | 3 2
4 -2.609e+00 -2.590e+00 +1e+00 7e-02 2e-03 2e-02 1e-03 0.9791 5e-01 1 1 1 | 6 0
5 -2.087e+00 -2.076e+00 +5e-01 2e-02 6e-04 1e-02 5e-04 0.6266 1e-01 1 1 1 | 1 2
6 -1.769e+00 -1.765e+00 +2e-01 8e-03 2e-04 4e-03 2e-04 0.7833 2e-01 1 1 1 | 3 1
7 -1.632e+00 -1.631e+00 +5e-02 2e-03 5e-05 6e-04 5e-05 0.9791 3e-01 1 1 1 | 4 0
8 -1.604e+00 -1.604e+00 +2e-02 9e-04 2e-05 2e-04 2e-05 0.6266 8e-02 1 1 1 | 2 2
9 -1.590e+00 -1.590e+00 +6e-03 3e-04 6e-06 6e-05 6e-06 0.7315 4e-02 1 1 1 | 1 1
10 -1.588e+00 -1.588e+00 +3e-03 1e-04 4e-06 3e-05 3e-06 0.4936 8e-02 1 1 1 | 1 3
11 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.1643 9e-01 2 1 1 | 12 8
12 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0538 1e+00 2 1 0 | 22 13
13 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0090 1e+00 1 1 0 | 32 21
14 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0015 1e+00 1 1 0 | 41 29
15 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0001 1e+00 2 1 0 | 55 43
16 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0000 1e+00 1 1 0 | 64 53
17 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0000 1e+00 2 1 0 | 71 60
18 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0000 1e+00 2 1 0 | 79 67
19 -1.588e+00 -1.588e+00 +3e-03 1e-04 3e-06 3e-05 3e-06 0.0000 1e+00 2 1 1 | 90 80
Combined backtracking failed 0 0 90 0 sigma 1
Combined line search failed, recovering best iterate (11) and stopping.
NUMERICAL PROBLEMS (reached feastol=1.4e-04, reltol=1.9e-03, abstol=3.0e-03).
Runtime: 0.022761 seconds.
P.S. I have other similar instances. If anyone needs to test the instances, I can share the GitHub repository and explain how to use it.
Cheers
The following problem enters an infinite loop.
import ecos
import numpy
from scipy.sparse import csc_matrix
(m, n, p), c, Gx, Gi, Gp, h, dims, Ax, Ai, Ap, b, kwargs = [
[66, 35, 1],
[-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,
-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,
-1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0],
[1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0,
1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0,
1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0,
1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0,
1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, -76.766712,
-76.766712, -85.12862200000001, -78.235004,
-95.66396399999999, -94.662196, -120.258704, -133.785606,
-111.683464, -126.871094, -138.76778399999998, -108.467578,
-126.24320200000001, -113.97456, -90.35547, -103.303138,
-135.686876, -137.63213399999998, -149.460924, -158.617592,
-160.86525199999997, -155.68788800000002, -153.678304,
-142.563728, 1.0, -1.0, -5.130125, -5.168625,
-5.47662512207035, -11.671916748046876, -12.33283349609375,
-13.641833251953125, -13.66108349609375,
-13.391583251953126, -12.1275, -17.007375,
-16.939999755859375, -18.35808349609375,
-15.85558349609375, -18.24579150390625,
-17.863999755859375, -13.298541748046874,
-11.351083251953124, -16.940000244140624,
-17.35066650390625, -17.061916748046876,
-18.43187548828125, -19.03504150390625, -19.80504150390625,
-19.23716650390625, 1.0, -1.0, -1.605, -2.745, -2.85, -3.6,
-1.41, -2.55, -4.035, 1.0, -1.0, -2.384000030517575,
-2.017333312988275, -1.572000030517575, -1.22266665649415,
-2.196000000000025, -3.0573333129882747,
-3.365333312988275, -3.578666687011725, -3.104,
-3.090666687011725, -2.897333312988275, -3.15466662597655,
-2.5146666564941254, -2.5573333740234503, -3.188,
-3.6733332519531, -2.853333251953125, -4.188,
-4.22266662597655, -3.9826666870117253, -4.05066662597655,
-3.662666687011725, -3.551999938964825, -3.35733337402345,
1.0, -1.0, -1.872, -3.1401, -3.0998699999999997, -2.83257,
-3.48291, -3.41037, -3.71412, -4.28958,
-4.5611999999999995, -3.58353, -3.64176, -3.88395,
-3.74004, -3.7368900000000003, -4.3804799999999995,
-4.02282, -5.13495, -4.83237, -4.60386, -4.69665, -4.14072,
-5.6673, -5.5269, -4.7637, 1.0, -1.0, -1.0, 1.0, -1.0,
-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0,
1.0, 1.0, 0.5],
[10, 34, 59, 11, 35, 59, 12, 36, 59, 13, 37, 59, 14, 38, 59,
15, 39, 59, 16, 40, 59, 17, 41, 59, 18, 42, 59, 19, 43, 59,
20, 44, 59, 21, 45, 59, 22, 46, 59, 23, 47, 59, 24, 48, 59,
25, 49, 59, 26, 50, 59, 27, 51, 59, 28, 52, 59, 29, 53, 59,
30, 54, 59, 31, 55, 59, 32, 56, 59, 33, 57, 59, 0, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 60, 1, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 61, 2, 34, 35, 36, 37, 38, 56, 57, 62, 3, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 63, 4, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 64, 5, 60, 65, 6, 61, 65, 7, 62, 65, 8, 63,
65, 9, 64, 65, 58, 59],
[0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45,
48, 51, 54, 57, 60, 63, 66, 69, 72, 98, 124, 133, 159, 185,
188, 191, 194, 197, 200, 202],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.37325,
0.39702499999999996, 0.400775, 0.397, 0.407625, 0.385175,
0.35827499999999995, 0.425725, 0.395775,
0.38952499999999995, 0.360125, 0.3245, 0.23765, 0.301375,
0.342, 0.377025, 0.39572500000000005, 0.40757499999999997,
0.36379999999999996, 0.418225, 0.40385000000000004, 0.397,
0.413275, 1.0052999999999999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 9.677575000000001, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 3.0], {"l": 66, "q": [], "e": 0},
[-2875.126508, -349.3842918701172, -18.795,
-73.44266644287106, -96.75864, 1.0], [0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 6], [0.0],
{"verbose": True, "mi_verbose": True,
"bool_vars_idx": [29, 30, 31, 32, 33], "int_vars_idx": []}]
A = csc_matrix((Ax, Ai, Ap))
G = csc_matrix((Gx, Gi, Gp))
c, h, b = map(numpy.array, [c, h, b])
ecos.solve(c, G, h, dims, A, b, **kwargs)
ecos.solver_version = 2.0.10
The code below reproduces a non-deterministic bug which causes ecos
to crash with the following message, on both Windows (python 3.10) and Gentoo Linux (python 3.8). Despite using the same inputs (by setting numpy's seed), the crash occurs after a varying number of trials. The code uses the correct parameters to trigger a crash 100% of the time (on my machine).
RuntimeError: Internal problem occurred in ECOS while setting up the problem.
Please send a bug report with data to Alexander Domahidi.
Email: [email protected]
The code:
import numpy as np
import time
import math
import scipy
import qpsolvers
np.random.seed(1)
def relu_inv(x): d=np.empty_like(x); d[:]=x[:]; d[x[:]<=0]=np.nan; return d
def relu(x): return (x>0)*x
def invH(x): return math.sqrt(2)*scipy.special.erfcinv(2*x)
solver = "ecos"
def optimize_fixed_points(X, H, threshold=0):
(N, P) = X.shape
assert np.all(H.shape == (N, P))
# Solve quadratic problem for each row
W = np.empty((N, N)); W[:] = np.nan
Q = np.eye(N-1)
found = 0
for ii in range(N):
I = np.concatenate((np.array(range(ii),dtype=int),np.array(range(ii+1,N),dtype=int)))
I = I.reshape(I.shape[0],1)
J = np.nonzero(np.isfinite(H[ii,:])*1)[0]
coJ = np.nonzero(np.isnan(H[ii,:])*1)[0]
assert len(J)+len(coJ) == P
c = np.zeros(I.shape[0])
lb = None
A = X[I,J].T
b = H[ii,J]
G = X[I,coJ].T
z = np.ones(G.shape[0])*threshold
w = qpsolvers.solve_qp(Q, c, G, z, A, b, lb, solver=solver, abstol=1e-8, reltol=1e-6)
if w is not None:
assert np.all(np.isfinite(w))
assert np.linalg.norm(A@w-b)<1e-6
assert np.all(G@w<z+1e-6)
W[ii,ii] = 0
W[ii,I.T] = w
found += 1
return (W, found)
# Problem parameters
N = 128; f = 1/64; K = np.round(f*N); P = 1
print("N=%d K=%d P=%d" % (N,K,P))
for i in range(100):
tictocT = time.time()
# Create patterns
X = relu(np.random.randn(N, P) - invH(f))
H = relu_inv(X)
(W, nfound) = optimize_fixed_points(X, H)
d = X - relu(W@X)
assert np.linalg.norm(d[np.isfinite(d[:])]) < 1e-8, "Fixed-points violation: %1.1e"%np.linalg.norm(d[np.isfinite(d[:])])
assert nfound<N or np.all(np.isfinite(W))
print("Done #%d (found %d/%d, took %1.1fsec)."%(i, nfound, N, time.time()-tictocT))
Here https://pypi.org/project/ecos/ the version is still 2.0.7.post1
Please also update the Homepage on PyPI - it should point here, not to the C project.
We have observed the same problem behaving completely differently in different versions of ecos (test code is proprietary, unfortunately cannot share). The problem has discrete constraints.
for version in '2.0.7.post1' '2.0.8' '2.0.9' '2.0.10' '2.0.11' '2.0.12'; do
rm -f "ecos_${version}.txt"
pip uninstall -y ecos
pip install ecos==${version}
time for i in {1..10}; do pytest tests/ecos_test.py -k 'test_response_ecos' &>> "ecos_${version}.txt"; done
cat ecos_${version}.txt | grep "warnings in"
done
Basically
real 0m18.017s
)real 1m8.491s
)real 0m20.797s
)real 1m26.673s
)After reviewing ecos code, I did not see anything which should explain this difference, except one big thing: ecosbb branching strategy is arbitrary due to the initialization.
Ecosbb settings are defined as
typedef struct settings_bb
{
idxint maxit; /* maximum number of iterations */
idxint verbose; /* verbosity bool for PRINTLEVEL < 3 */
pfloat abs_tol_gap; /* termination criteria |U-L| */
pfloat rel_tol_gap; /* termination criteria for |U-L|/|L| < 3 */
pfloat integer_tol; /* integer rounding tolerance */
enum BRANCHING_STRATEGY branching_strategy;
idxint reliable_eta; /* number of pseudocost values needed for costs to be reliable */
enum NODE_SELECTION_METHOD node_selection_method;
} settings_bb;
In the csolve function
the settings are declared as
/* Default ECOS settings */
settings opts_ecos;
settings_bb opts_ecos_bb;
Later followed by
/* Default ECOS settings */
opts_ecos.feastol = FEASTOL;
opts_ecos.reltol = RELTOL;
opts_ecos.abstol = ABSTOL;
opts_ecos.feastol_inacc = FTOL_INACC;
opts_ecos.abstol_inacc = ATOL_INACC;
opts_ecos.reltol_inacc = RTOL_INACC;
opts_ecos.maxit = MAXIT;
opts_ecos.nitref = NITREF;
opts_ecos.verbose = VERBOSE;
opts_ecos_bb.verbose = 1;
opts_ecos_bb.maxit = MI_MAXITER;
opts_ecos_bb.abs_tol_gap = MI_ABS_EPS;
opts_ecos_bb.rel_tol_gap = MI_REL_EPS;
opts_ecos_bb.integer_tol = MI_INT_TOL;
We can see here than not all fields are provided default values, eg branching_strategy
and node_selection_method
. I am a bit unfamiliar with the compiler used to build the wheels, but given the declaration
/* Default ECOS settings */
settings opts_ecos;
settings_bb opts_ecos_bb;
In a function, the variables have automatic storage duration and thus are initiaized to indeterminate values
Implicit initialization
If an initializer is not provided:
- objects with automatic storage duration are initialized to indeterminate values (which may be trap representations)
- objects with static and thread-local storage duration are empty-initialized
This is not always true as :
Ecos 2.0.8 has the same issue as recently was posted with cvxpy. The underlying numpy build is done with numpy 1.20+. As such it will crash when an environment actually is using a version of numpy<1.20.
I feel a solution comparable to this one below would also be necessary for ECOS. Can this be implemented?
The README briefly mentions how to call the ecos
module but there is no complete example.
In the Julia ECOS interface, you can change the number of iterative refinement steps ECOS takes. Could you add this to the Python interface? I had a request for this option.
This commit fixes an important issue in ECOS BB:
I don't think it's in the ECOS on pip. Could you put out a new version that has this update? This may require bumping the ECOS version number.
I am on Windows 10, using python 3.6
When I ran pip install ecos, I am getting following error.
Collecting ecos
Using cached ecos-2.0.4.tar.gz
Requirement already satisfied: numpy>=1.6 in c:\programdata\anaconda3\lib\site-packages (from ecos)
Requirement already satisfied: scipy>=0.9 in c:\programdata\anaconda3\lib\site-packages (from ecos)
Building wheels for collected packages: ecos
Running setup.py bdist_wheel for ecos ... error
Complete output from command C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Archit\AppData\Local\Temp\pip-build-popsp7ol\ecos\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\Archit\AppData\Local\Temp\tmpzljqek2vpip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
copying src\ecos.py -> build\lib.win-amd64-3.6
running build_ext
building '_ecos' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\src
creating build\temp.win-amd64-3.6\Release\ecos
creating build\temp.win-amd64-3.6\Release\ecos\external
creating build\temp.win-amd64-3.6\Release\ecos\external\ldl
creating build\temp.win-amd64-3.6\Release\ecos\external\ldl\src
creating build\temp.win-amd64-3.6\Release\ecos\src
creating build\temp.win-amd64-3.6\Release\ecos\external\amd
creating build\temp.win-amd64-3.6\Release\ecos\external\amd\src
creating build\temp.win-amd64-3.6\Release\ecos\ecos_bb
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcsrc/ecosmodule.c /Fobuild\temp.win-amd64-3.6\Release\src/ecosmodule.obj
ecosmodule.c
ecos/include\ecos_bb.h(72): warning C4005: 'INFINITY': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): note: see previous definition of 'INFINITY'
ecos/include\ecos_bb.h(74): warning C4005: 'isinf': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(263): note: see previous definition of 'isinf'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/external/ldl/src/ldl.c /Fobuild\temp.win-amd64-3.6\Release\ecos/external/ldl/src/ldl.obj
ldl.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
ecos/external/SuiteSparse_config../../include/glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
ecos/external/SuiteSparse_config../../include/glblopts.h(53): note: see previous definition of 'NAN'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/src/cone.c /Fobuild\temp.win-amd64-3.6\Release\ecos/src/cone.obj
cone.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(53): note: see previous definition of 'NAN'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/src/ctrlc.c /Fobuild\temp.win-amd64-3.6\Release\ecos/src/ctrlc.obj
ctrlc.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(53): note: see previous definition of 'NAN'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/src/ecos.c /Fobuild\temp.win-amd64-3.6\Release\ecos/src/ecos.obj
ecos.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(53): note: see previous definition of 'NAN'
ecos/src/ecos.c(1093): warning C4013: '_set_output_format' undefined; assuming extern returning int
ecos/src/ecos.c(1093): error C2065: '_TWO_DIGIT_EXPONENT': undeclared identifier
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2
Failed building wheel for ecos
Running setup.py clean for ecos
Failed to build ecos
Installing collected packages: ecos
Running setup.py install for ecos ... error
Complete output from command C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Archit\AppData\Local\Temp\pip-build-popsp7ol\ecos\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\Archit\AppData\Local\Temp\pip-hfxv0nbw-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
copying src\ecos.py -> build\lib.win-amd64-3.6
running build_ext
building '_ecos' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\src
creating build\temp.win-amd64-3.6\Release\ecos
creating build\temp.win-amd64-3.6\Release\ecos\external
creating build\temp.win-amd64-3.6\Release\ecos\external\ldl
creating build\temp.win-amd64-3.6\Release\ecos\external\ldl\src
creating build\temp.win-amd64-3.6\Release\ecos\src
creating build\temp.win-amd64-3.6\Release\ecos\external\amd
creating build\temp.win-amd64-3.6\Release\ecos\external\amd\src
creating build\temp.win-amd64-3.6\Release\ecos\ecos_bb
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcsrc/ecosmodule.c /Fobuild\temp.win-amd64-3.6\Release\src/ecosmodule.obj
ecosmodule.c
ecos/include\ecos_bb.h(72): warning C4005: 'INFINITY': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): note: see previous definition of 'INFINITY'
ecos/include\ecos_bb.h(74): warning C4005: 'isinf': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(263): note: see previous definition of 'isinf'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/external/ldl/src/ldl.c /Fobuild\temp.win-amd64-3.6\Release\ecos/external/ldl/src/ldl.obj
ldl.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
ecos/external/SuiteSparse_config../../include/glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
ecos/external/SuiteSparse_config../../include/glblopts.h(53): note: see previous definition of 'NAN'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/src/cone.c /Fobuild\temp.win-amd64-3.6\Release\ecos/src/cone.obj
cone.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(53): note: see previous definition of 'NAN'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/src/ctrlc.c /Fobuild\temp.win-amd64-3.6\Release\ecos/src/ctrlc.obj
ctrlc.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(53): note: see previous definition of 'NAN'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcecos/src/ecos.c /Fobuild\temp.win-amd64-3.6\Release\ecos/src/ecos.obj
ecos.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(78): warning C4005: 'INFINITY': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(58): note: see previous definition of 'INFINITY'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(82): warning C4005: 'NAN': macro redefinition
c:\users\archit\appdata\local\temp\pip-build-popsp7ol\ecos\ecos\include\glblopts.h(53): note: see previous definition of 'NAN'
ecos/src/ecos.c(1093): warning C4013: '_set_output_format' undefined; assuming extern returning int
ecos/src/ecos.c(1093): error C2065: '_TWO_DIGIT_EXPONENT': undeclared identifier
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Archit\AppData\Local\Temp\pip-build-popsp7ol\ecos\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\Archit\AppData\Local\Temp\pip-hfxv0nbw-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Archit\AppData\Local\Temp\pip-build-popsp7ol\ecos\
When we first started using appveyor, they didn't have python or conda support. They now do. We should likewise update our appveyor scripts so they become simpler.
Ideally, the Windows wheels and conda packages are deployed from appveyor.
Packaging link for posterity.
The setup.py script tries importing numpy and thus already causes an installation failure before any missing numpy dependency can be resolved.
The message
ValueError: Number of rows of G does not match dims.l+sum(dims.q)+dims.e
seems to be incorrect with respect to the number of exponetial cones dims.e
as the number of rows of G
is expected to be dims.l + sum(dims.q) + 3*dims.e
.
ERROR: Failed building wheel for ecos
Running setup.py clean for ecos
Failed to build ecos
Installing collected packages: ecos, docopt, colorama, matplotlib, pyqlib
Running setup.py install for ecos ... error
ERROR: Command errored out with exit status 1:
command: /opt/anaconda3/envs/pythonProject/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/0x/6zw4f8td6sg8s9kr2lz9p96r0000gp/T/pip-install-ma18w0hh/ecos_7793a0b822cb4823b5d65b0143803850/setup.py'"'"'; file='"'"'/private/var/folders/0x/6zw4f8td6sg8s9kr2lz9p96r0000gp/T/pip-install-ma18w0hh/ecos_7793a0b822cb4823b5d65b0143803850/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/0x/6zw4f8td6sg8s9kr2lz9p96r0000gp/T/pip-record-j96jtqvp/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/envs/pythonProject/include/python3.8/ecos
cwd: /private/var/folders/0x/6zw4f8td6sg8s9kr2lz9p96r0000gp/T/pip-install-ma18w0hh/ecos_7793a0b822cb4823b5d65b0143803850/
Complete output (65 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/ecos
copying src/ecos/version.py -> build/lib.macosx-10.9-x86_64-3.8/ecos
copying src/ecos/init.py -> build/lib.macosx-10.9-x86_64-3.8/ecos
copying src/ecos/ecos.py -> build/lib.macosx-10.9-x86_64-3.8/ecos
running build_ext
building '_ecos' extension
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/src
creating build/temp.macosx-10.9-x86_64-3.8/ecos
creating build/temp.macosx-10.9-x86_64-3.8/ecos/external
creating build/temp.macosx-10.9-x86_64-3.8/ecos/external/ldl
creating build/temp.macosx-10.9-x86_64-3.8/ecos/external/ldl/src
creating build/temp.macosx-10.9-x86_64-3.8/ecos/src
creating build/temp.macosx-10.9-x86_64-3.8/ecos/external/amd
creating build/temp.macosx-10.9-x86_64-3.8/ecos/external/amd/src
creating build/temp.macosx-10.9-x86_64-3.8/ecos/ecos_bb
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c src/ecosmodule.c -o build/temp.macosx-10.9-x86_64-3.8/src/ecosmodule.o
In file included from src/ecosmodule.c:6:
ecos/include/ecos_bb.h:161:42: warning: this function declaration is not a prototype [-Wstrict-prototypes]
settings_bb* get_default_ECOS_BB_settings();
^
void
ecos/include/ecos_bb.h:164:14: warning: unused function 'get_bool_node_id' [-Wunused-function]
static char* get_bool_node_id(idxint idx, ecos_bb_pwork* prob){
^
ecos/include/ecos_bb.h:168:16: warning: unused function 'get_int_node_id' [-Wunused-function]
static pfloat* get_int_node_id(idxint idx, ecos_bb_pwork* prob){
^
ecos/include/ecos_bb.h:176:15: warning: unused function 'pfloat_round' [-Wunused-function]
static pfloat pfloat_round(pfloat number){
^
ecos/include/ecos_bb.h:180:15: warning: unused function 'pfloat_ceil' [-Wunused-function]
static pfloat pfloat_ceil(pfloat number, pfloat integer_tol){
^
ecos/include/ecos_bb.h:184:15: warning: unused function 'pfloat_floor' [-Wunused-function]
static pfloat pfloat_floor(pfloat number, pfloat integer_tol){
^
ecos/include/ecos_bb.h:188:15: warning: unused function 'float_eqls' [-Wunused-function]
static idxint float_eqls(pfloat a, pfloat b, pfloat integer_tol){
^
7 warnings generated.
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c ecos/external/ldl/src/ldl.c -o build/temp.macosx-10.9-x86_64-3.8/ecos/external/ldl/src/ldl.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c ecos/src/cone.c -o build/temp.macosx-10.9-x86_64-3.8/ecos/src/cone.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c ecos/src/ctrlc.c -o build/temp.macosx-10.9-x86_64-3.8/ecos/src/ctrlc.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c ecos/src/ecos.c -o build/temp.macosx-10.9-x86_64-3.8/ecos/src/ecos.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c ecos/src/equil.c -o build/temp.macosx-10.9-x86_64-3.8/ecos/src/equil.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c ecos/src/expcone.c -o build/temp.macosx-10.9-x86_64-3.8/ecos/src/expcone.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -I/opt/anaconda3/envs/pythonProject/include -arch x86_64 -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/anaconda3/envs/pythonProject/include/python3.8 -I/opt/anaconda3/envs/pythonProject/lib/python3.8/site-packages/numpy/core/include -c ecos/src/kkt.c -o build/temp.macosx-10.9-x86_64-3.8/ecos/src/kkt.o
ecos/src/kkt.c:47:7: error: implicit declaration of function 'LDL_numeric2' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
nd = LDL_numeric2(
^
ecos/src/kkt.c:47:7: note: did you mean 'ldl_numeric'?
/opt/anaconda3/envs/pythonProject/include/ldl.h:48:5: note: 'ldl_numeric' declared here
int ldl_numeric (int n, int Ap [ ], int Ai [ ], double Ax [ ],
^
ecos/src/kkt.c:120:2: error: implicit declaration of function 'LDL_lsolve2' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
LDL_lsolve2(nK, Pb, KKT->L->jc, KKT->L->ir, KKT->L->pr, Px );
^
2 errors generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/anaconda3/envs/pythonProject/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/0x/6zw4f8td6sg8s9kr2lz9p96r0000gp/T/pip-install-ma18w0hh/ecos_7793a0b822cb4823b5d65b0143803850/setup.py'"'"'; file='"'"'/private/var/folders/0x/6zw4f8td6sg8s9kr2lz9p96r0000gp/T/pip-install-ma18w0hh/ecos_7793a0b822cb4823b5d65b0143803850/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/0x/6zw4f8td6sg8s9kr2lz9p96r0000gp/T/pip-record-j96jtqvp/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/envs/pythonProject/include/python3.8/ecos Check the logs for full command output.
(pythonProject)
It's better to reuse the ecos package instead of rebuilding it from scratch.
It seems like you only need to optionally remove sources from setup.py and add include/lib parths.
Thank you,
Yuri
Hello,
I've reported embotech/ecos#194 earlier this year and at the time the issue seemed to be caused by running ECOS 2.0.8
in combination with ecos-python 2.0.7
, as updating the latter also to 2.0.8
had resolved it.
Now, the same issue has resurfaced on the latest Python 3.9
docker image, though I can reproduce it as well locally with Python 3.10
on Arch Linux. Note that just a month ago, the very same pipeline task ran without issues. As you can see from the logs, a month ago pip
was building ecos-python from source, now it is using a wheel. (It is likely that also the third digit in the Python version of the Docker image has changed, which could explain the change from tarball to wheel.) In the case of Arch Linux, however, I can reproduce the issue building both ECOS and ecos-python from source (using this and that recipe respectively).
In summary, it seems that for recent Python versions the interface fails to handle integer QCQPs.
Embotech's web page on ECOS's Python API mentions that G
and A
matrices should be in scipy's CSR format. In fact, the wrapper's preferred format is CSC which is clear from the code (if one supplies the arguments in CSR there is an additional conversion to CSC).
Hi,
Could you help provide prebuilt wheels for python 3.8 and 3.9? We recently updated from 3.7 to 3.9 and noticed that we now have to compile on pip install.
https://pypi.org/project/ecos/#files seems to show prebuilt wheels only up to python 3.7
Ecos version 2.0.8 fails to install on Apple M1 on Mac OS 12.0.1, python 3.9.9 (homebrew installed). It fails to upgrade from ecos 2.0.7.post1.
pip3 install -U ecos
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: ecos in /opt/homebrew/lib/python3.9/site-packages (2.0.7.post1)
Collecting ecos
Downloading ecos-2.0.8.tar.gz (135 kB)
|████████████████████████████████| 135 kB 2.0 MB/s
Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.6 in /opt/homebrew/lib/python3.9/site-packages (from ecos) (1.21.4)
Requirement already satisfied: scipy>=0.9 in /opt/homebrew/lib/python3.9/site-packages (from ecos) (1.7.3)
Building wheels for collected packages: ecos
Building wheel for ecos (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/setup.py'"'"'; __file__='"'"'/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-wheel-cf9ksghb
cwd: /private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/
Complete output (32 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-12-arm64-3.9
creating build/lib.macosx-12-arm64-3.9/ecos
copying src/ecos/version.py -> build/lib.macosx-12-arm64-3.9/ecos
copying src/ecos/__init__.py -> build/lib.macosx-12-arm64-3.9/ecos
copying src/ecos/ecos.py -> build/lib.macosx-12-arm64-3.9/ecos
running build_ext
building '_ecos' extension
creating build/temp.macosx-12-arm64-3.9
creating build/temp.macosx-12-arm64-3.9/ecos
creating build/temp.macosx-12-arm64-3.9/ecos/ecos_bb
creating build/temp.macosx-12-arm64-3.9/ecos/external
creating build/temp.macosx-12-arm64-3.9/ecos/external/amd
creating build/temp.macosx-12-arm64-3.9/ecos/external/amd/src
creating build/temp.macosx-12-arm64-3.9/ecos/external/ldl
creating build/temp.macosx-12-arm64-3.9/ecos/external/ldl/src
creating build/temp.macosx-12-arm64-3.9/ecos/src
creating build/temp.macosx-12-arm64-3.9/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/opt/homebrew/lib/python3.9/site-packages/numpy/core/include -c ecos/ecos_bb/ecos_bb.c -o build/temp.macosx-12-arm64-3.9/ecos/ecos_bb/ecos_bb.o
ecos/ecos_bb/ecos_bb.c:100:77: warning: format specifies type 'unsigned int' but the argument has type 'idxint' (aka 'long') [-Wformat]
PRINTTEXT("Node info %u: %u : %.2f : %.2f : %u : %.2f Partial id:", i, prob->nodes[i].status, prob->nodes[i].L, prob->nodes[i].U, (int)prob->nodes[i].split_idx, prob->nodes[i].split_val);
~~ ^
%ld
ecos/ecos_bb/ecos_bb.c:388:5: error: implicitly declaring library function 'memcpy' with type 'void *(void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
memcpy(problem->tmp_branching_bool_node_id, get_bool_node_id(node_idx, problem), bool_node_size);
^
ecos/ecos_bb/ecos_bb.c:388:5: note: include the header <string.h> or explicitly provide a declaration for 'memcpy'
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for ecos
Running setup.py clean for ecos
Failed to build ecos
Installing collected packages: ecos
Attempting uninstall: ecos
Found existing installation: ecos 2.0.7.post1
Uninstalling ecos-2.0.7.post1:
Successfully uninstalled ecos-2.0.7.post1
Running setup.py install for ecos ... error
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/setup.py'"'"'; __file__='"'"'/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-record-vuid19bg/install-record.txt --single-version-externally-managed --compile --install-headers /opt/homebrew/include/python3.9/ecos
cwd: /private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/
Complete output (34 lines):
running install
/opt/homebrew/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.macosx-12-arm64-3.9
creating build/lib.macosx-12-arm64-3.9/ecos
copying src/ecos/version.py -> build/lib.macosx-12-arm64-3.9/ecos
copying src/ecos/__init__.py -> build/lib.macosx-12-arm64-3.9/ecos
copying src/ecos/ecos.py -> build/lib.macosx-12-arm64-3.9/ecos
running build_ext
building '_ecos' extension
creating build/temp.macosx-12-arm64-3.9
creating build/temp.macosx-12-arm64-3.9/ecos
creating build/temp.macosx-12-arm64-3.9/ecos/ecos_bb
creating build/temp.macosx-12-arm64-3.9/ecos/external
creating build/temp.macosx-12-arm64-3.9/ecos/external/amd
creating build/temp.macosx-12-arm64-3.9/ecos/external/amd/src
creating build/temp.macosx-12-arm64-3.9/ecos/external/ldl
creating build/temp.macosx-12-arm64-3.9/ecos/external/ldl/src
creating build/temp.macosx-12-arm64-3.9/ecos/src
creating build/temp.macosx-12-arm64-3.9/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -DPYTHON -DDLONG -DLDL_LONG -DCTRLC=1 -Iecos/include -Iecos/external/amd/include -Iecos/external/ldl/include -Iecos/external/SuiteSparse_config -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/opt/homebrew/lib/python3.9/site-packages/numpy/core/include -c ecos/ecos_bb/ecos_bb.c -o build/temp.macosx-12-arm64-3.9/ecos/ecos_bb/ecos_bb.o
ecos/ecos_bb/ecos_bb.c:100:77: warning: format specifies type 'unsigned int' but the argument has type 'idxint' (aka 'long') [-Wformat]
PRINTTEXT("Node info %u: %u : %.2f : %.2f : %u : %.2f Partial id:", i, prob->nodes[i].status, prob->nodes[i].L, prob->nodes[i].U, (int)prob->nodes[i].split_idx, prob->nodes[i].split_val);
~~ ^
%ld
ecos/ecos_bb/ecos_bb.c:388:5: error: implicitly declaring library function 'memcpy' with type 'void *(void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
memcpy(problem->tmp_branching_bool_node_id, get_bool_node_id(node_idx, problem), bool_node_size);
^
ecos/ecos_bb/ecos_bb.c:388:5: note: include the header <string.h> or explicitly provide a declaration for 'memcpy'
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
----------------------------------------
Rolling back uninstall of ecos
Moving to /opt/homebrew/lib/python3.9/site-packages/_ecos.cpython-39-darwin.so
from /private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-uninstall-xqao81g_/_ecos.cpython-39-darwin.so
Moving to /opt/homebrew/lib/python3.9/site-packages/ecos-2.0.7.post1.dist-info/
from /opt/homebrew/lib/python3.9/site-packages/~cos-2.0.7.post1.dist-info
Moving to /opt/homebrew/lib/python3.9/site-packages/ecos/
from /opt/homebrew/lib/python3.9/site-packages/~cos
ERROR: Command errored out with exit status 1: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/setup.py'"'"'; __file__='"'"'/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-o7xtfekc/ecos_79d1b425adfe4d40a5153c49dea204d9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-record-vuid19bg/install-record.txt --single-version-externally-managed --compile --install-headers /opt/homebrew/include/python3.9/ecos Check the logs for full command output.
print
function is called wrong.
The ECOS solver failed to converge on a fairly simple problem. As far as I can tell, the problem is well-conditioned and well-scaled, with coefficients, variables and objective function value between -10 and 10. The issue may be reproduced below:
import numpy as np
import cvxpy as cvx
np.random.seed(2)
n = 3000
alpha = np.random.normal(size=n)
sigma = np.ones(n) * 10
w = cvx.Variable(n)
objective = cvx.Maximize(w.T @ alpha - 0.5 * cvx.norm(cvx.multiply(sigma, w), 2))
constraints = [
cvx.norm(w, 1) <= 1,
w <= 1,
w >= -1
]
# this problem fails
problem = cvx.Problem(objective, constraints)
problem.solve(solver=cvx.ECOS, verbose=True)
# however this equivalent problem with rescaled objective works
objective_2 = cvx.Maximize(w.T @ (alpha / 2) - 0.5 * cvx.norm(cvx.multiply(sigma / 2, w), 2))
problem_2 = cvx.Problem(objective_2, constraints)
problem_2.solve(solver=cvx.ECOS, verbose=True)
I understand that the -1 <= w <= 1 constraints are redundant in this case, but these box constraints are part of my more general problem. In other cases that I have tested with some of these binding, I have also occasionally encountered similar failures.
I am using CVXPY 1.1.1 with ECOS solver 2.0.7 and Numpy 1.16.5, on Python 3.7.4.
Shown below is the verbose output from the first and second problems:
ECOS 2.0.7 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS
It pcost dcost gap pres dres k/t mu step sigma IR | BT
0 +0.000e+00 -2.004e+04 +4e+04 3e-01 4e-02 1e+00 4e+00 --- --- 2 1 - | - -
1 +1.164e+01 -2.993e+03 +9e+03 5e-02 5e-03 6e-01 7e-01 0.9188 1e-01 3 2 2 | 0 0
2 -3.805e+00 -3.652e+02 +1e+03 6e-03 6e-04 7e-02 9e-02 0.9166 4e-02 3 3 3 | 0 0
3 -3.262e+00 -1.095e+02 +3e+02 2e-03 2e-04 2e-02 3e-02 0.7148 1e-02 4 4 4 | 0 0
4 -2.538e+00 -8.060e+01 +2e+02 1e-03 1e-04 2e-02 2e-02 0.3963 3e-01 5 5 5 | 0 0
5 -2.378e+00 -3.121e+01 +9e+01 5e-04 5e-05 5e-03 7e-03 0.7804 2e-01 6 6 6 | 0 0
6 -2.865e+00 -3.047e+01 +8e+01 5e-04 4e-05 5e-03 7e-03 0.3156 8e-01 9 9 9 | 0 0
7 -2.437e+00 -2.170e+01 +6e+01 3e-04 3e-05 3e-03 5e-03 0.3446 2e-01 8 8 7 | 0 0
8 -3.181e+00 -2.248e+01 +6e+01 3e-04 3e-05 3e-03 5e-03 0.5370 9e-01 1 1 1 | 0 0
9 -2.114e+00 -1.138e+01 +3e+01 2e-04 1e-05 1e-03 2e-03 0.4852 1e-02 1 1 1 | 0 0
10 -2.159e+00 -7.614e+00 +2e+01 9e-05 6e-06 9e-04 1e-03 0.6587 4e-01 1 1 1 | 0 0
11 -2.189e+00 -6.880e+00 +2e+01 8e-05 5e-06 7e-04 1e-03 0.4153 7e-01 2 2 3 | 0 0
12 -2.199e+00 -6.060e+00 +1e+01 6e-05 5e-06 6e-04 1e-03 0.2944 5e-01 1 1 1 | 0 0
13 -2.175e+00 -3.300e+00 +4e+00 2e-05 1e-06 2e-04 3e-04 0.7723 7e-02 1 1 1 | 0 0
14 -2.126e+00 -2.591e+00 +1e+00 8e-06 5e-07 6e-05 1e-04 0.9053 4e-01 3 3 3 | 0 0
15 -2.167e+00 -2.472e+00 +9e-01 5e-06 3e-07 4e-05 8e-05 0.4346 3e-01 1 1 1 | 0 0
16 -2.268e+00 -2.497e+00 +9e-01 3e-06 2e-07 2e-05 8e-05 0.2453 6e-01 1 1 1 | 0 0
17 -2.343e+00 -2.442e+00 +1e+00 1e-06 8e-08 2e-06 8e-05 0.7877 4e-01 1 1 1 | 0 0
18 -2.321e+00 -2.339e+00 +1e+00 2e-07 1e-08 1e-06 1e-04 0.9263 1e-01 1 1 1 | 0 0
19 -2.345e+00 -2.348e+00 +2e+00 2e-07 1e-09 7e-07 1e-04 0.8785 1e-01 1 1 1 | 0 0
20 -2.384e+00 -2.384e+00 +4e+00 2e-07 1e-10 1e-06 3e-04 0.9890 2e-01 1 1 1 | 0 0
21 -2.464e+00 -2.464e+00 +1e+01 2e-07 1e-11 5e-07 9e-04 0.8400 2e-01 1 1 1 | 0 0
22 -2.371e+00 -2.371e+00 +2e+01 5e-08 4e-12 3e-06 2e-03 0.9890 4e-01 1 1 1 | 0 0
23 -2.482e+00 -2.482e+00 +1e+01 1e-07 9e-13 5e-07 1e-03 0.3478 3e-01 1 1 1 | 0 0
24 -2.314e+00 -2.314e+00 +1e+01 1e-07 8e-13 1e-06 1e-03 0.6785 3e-01 1 1 1 | 0 0
25 -2.366e+00 -2.366e+00 +2e+01 1e-07 6e-13 1e-06 2e-03 0.1050 8e-01 1 1 1 | 0 0
26 -2.480e+00 -2.480e+00 +1e+02 5e-08 2e-13 2e-06 1e-02 0.9890 9e-01 1 1 1 | 0 0
27 -2.375e+00 -2.375e+00 +2e+02 2e-08 8e-14 4e-06 2e-02 0.9890 4e-01 1 1 1 | 0 0
28 -2.426e+00 -2.426e+00 +3e+02 3e-08 8e-14 8e-07 2e-02 0.5278 2e-01 1 1 1 | 0 0
29 -2.357e+00 -2.357e+00 +4e+02 1e-08 3e-14 2e-06 4e-02 0.7551 2e-01 1 1 1 | 0 0
30 -2.472e+00 -2.472e+00 +3e+02 3e-08 5e-14 5e-07 2e-02 0.2992 3e-01 1 1 1 | 0 0
31 -2.305e+00 -2.305e+00 +4e+02 2e-08 2e-14 1e-06 3e-02 0.7517 4e-01 1 1 1 | 0 0
32 -2.447e+00 -2.447e+00 +1e+03 2e-08 3e-14 9e-07 1e-01 0.2539 1e+00 1 1 1 | 0 0
33 -2.366e+00 -2.366e+00 +2e+03 1e-08 1e-14 3e-06 1e-01 0.8188 6e-01 1 1 1 | 0 0
34 -2.481e+00 -2.481e+00 +6e+03 9e-09 2e-14 3e-06 5e-01 0.9584 9e-01 1 1 1 | 0 0
35 -2.358e+00 -2.358e+00 +7e+03 3e-09 7e-15 5e-06 6e-01 0.9890 4e-01 1 1 1 | 0 0
36 -2.475e+00 -2.475e+00 +9e+03 7e-09 1e-14 2e-06 8e-01 0.6557 6e-01 1 1 1 | 0 0
37 -2.261e+00 -2.261e+00 +7e+03 4e-09 8e-15 3e-06 6e-01 0.9890 4e-01 1 1 1 | 0 0
38 -2.327e+00 -2.327e+00 +5e+03 7e-09 3e-15 2e-06 4e-01 0.0305 7e-01 1 1 1 | 0 0
39 -2.276e+00 -2.276e+00 +9e+03 3e-09 2e-15 1e-06 7e-01 0.9890 5e-01 1 1 1 | 0 0
40 -2.374e+00 -2.374e+00 +7e+03 6e-09 5e-15 8e-07 5e-01 0.0791 6e-01 1 1 1 | 0 0
41 -2.215e+00 -2.215e+00 +5e+03 4e-09 4e-15 1e-06 4e-01 0.7626 3e-01 1 1 1 | 0 0
42 -2.251e+00 -2.251e+00 +4e+03 6e-09 2e-15 8e-07 3e-01 0.0070 1e+00 1 1 1 | 0 0
43 -2.409e+00 -2.409e+00 +4e+04 3e-09 5e-15 3e-07 3e+00 0.3366 7e-01 1 1 1 | 0 0
44 -2.387e+00 -2.387e+00 +1e+05 1e-09 3e-15 3e-06 9e+00 0.9890 5e-01 1 1 1 | 0 0
45 -2.485e+00 -2.485e+00 +3e+05 1e-09 3e-15 6e-07 2e+01 0.9171 4e-01 1 1 1 | 0 0
46 -2.388e+00 -2.388e+00 +5e+05 6e-10 1e-15 4e-06 4e+01 0.9890 5e-01 1 1 1 | 0 0
47 -2.500e+00 -2.500e+00 +1e+06 6e-10 2e-15 1e-06 9e+01 0.6802 5e-01 1 1 1 | 0 0
48 -2.309e+00 -2.309e+00 +9e+05 3e-10 6e-16 3e-06 8e+01 0.9051 4e-01 1 1 1 | 0 0
49 -2.415e+00 -2.415e+00 +8e+05 6e-10 6e-16 2e-06 6e+01 0.1300 1e+00 1 1 1 | 0 0
50 -2.254e+00 -2.254e+00 +5e+05 6e-10 5e-16 2e-06 4e+01 0.5786 3e-01 1 1 1 | 0 0
51 -2.349e+00 -2.349e+00 +6e+05 6e-10 3e-16 1e-06 5e+01 0.0489 1e+00 1 1 1 | 0 0
52 -2.220e+00 -2.220e+00 +5e+05 3e-10 3e-16 1e-06 5e+01 0.9435 4e-01 1 1 1 | 0 0
53 -2.269e+00 -2.269e+00 +3e+05 7e-10 1e-16 1e-06 2e+01 0.0119 1e+00 1 1 1 | 0 0
54 -2.186e+00 -2.186e+00 +3e+05 7e-10 4e-16 1e-06 2e+01 0.6015 6e-01 1 1 1 | 0 0
55 -2.195e+00 -2.195e+00 +3e+05 7e-10 3e-16 1e-06 2e+01 0.0005 9e-01 1 1 1 | 0 0
56 -2.253e+00 -2.253e+00 +3e+05 7e-10 9e-17 8e-07 3e+01 0.0099 1e+00 1 1 1 | 0 0
57 -2.405e+00 -2.405e+00 +6e+06 2e-10 6e-16 2e-07 5e+02 0.7214 6e-01 1 1 1 | 0 0
58 -2.464e+00 -2.464e+00 +2e+07 1e-10 4e-16 3e-06 2e+03 0.9890 5e-01 1 1 1 | 0 0
59 -2.396e+00 -2.396e+00 +4e+07 5e-11 2e-16 4e-06 3e+03 0.9890 4e-01 1 1 1 | 0 0
60 -2.450e+00 -2.450e+00 +6e+07 8e-11 2e-16 4e-07 5e+03 0.6402 2e-01 1 1 1 | 0 0
61 -2.350e+00 -2.350e+00 +9e+07 2e-11 5e-17 3e-06 8e+03 0.9890 3e-01 1 1 1 | 0 0
62 -2.463e+00 -2.463e+00 +4e+07 7e-11 1e-16 5e-07 4e+03 0.3473 3e-01 1 1 1 | 0 0
63 -2.217e+00 -2.217e+00 +4e+07 6e-11 1e-16 1e-06 3e+03 0.8556 3e-01 1 1 1 | 0 0
64 -2.234e+00 -2.234e+00 +4e+07 7e-11 9e-17 1e-06 3e+03 0.0020 9e-01 1 1 1 | 0 0
65 -2.384e+00 -2.384e+00 +5e+07 6e-11 4e-17 4e-07 5e+03 0.0746 9e-01 1 1 1 | 0 0
66 -2.183e+00 -2.183e+00 +2e+07 5e-11 8e-17 7e-07 2e+03 0.6559 2e-01 1 1 1 | 0 0
67 -2.191e+00 -2.191e+00 +2e+07 7e-11 7e-17 7e-07 2e+03 0.0036 8e-01 1 1 1 | 0 0
68 -2.219e+00 -2.219e+00 +2e+07 7e-11 5e-17 6e-07 2e+03 0.0019 9e-01 1 1 1 | 0 0
69 -2.180e+00 -2.180e+00 +3e+07 7e-11 6e-17 1e-06 2e+03 0.6182 8e-01 1 1 1 | 0 0
70 -2.181e+00 -2.181e+00 +3e+07 8e-11 6e-17 1e-06 2e+03 0.0001 1e+00 1 1 1 | 0 0
71 -2.199e+00 -2.199e+00 +3e+07 7e-11 5e-17 9e-07 2e+03 0.0011 1e+00 1 1 1 | 0 0
72 -2.276e+00 -2.276e+00 +4e+07 6e-11 1e-17 6e-07 4e+03 0.0206 9e-01 1 1 1 | 0 0
73 -2.410e+00 -2.410e+00 +6e+08 2e-11 6e-17 3e-07 5e+04 0.6718 5e-01 1 1 1 | 0 0
74 -2.473e+00 -2.473e+00 +2e+09 1e-11 4e-17 4e-06 2e+05 0.9890 7e-01 1 1 1 | 0 0
75 -2.378e+00 -2.378e+00 +3e+09 4e-12 2e-17 4e-06 3e+05 0.9890 4e-01 1 1 1 | 0 0
76 -2.437e+00 -2.437e+00 +4e+09 9e-12 2e-17 7e-07 4e+05 0.5470 2e-01 1 1 1 | 0 0
77 -2.347e+00 -2.347e+00 +8e+09 2e-12 5e-18 2e-06 6e+05 0.9890 3e-01 1 1 1 | 0 0
78 -2.459e+00 -2.459e+00 +5e+09 7e-12 1e-17 4e-07 5e+05 0.4477 2e-01 1 1 1 | 0 0
79 -2.312e+00 -2.312e+00 +6e+09 6e-12 3e-18 1e-06 5e+05 0.6890 4e-01 1 1 1 | 0 0
80 -2.443e+00 -2.443e+00 +3e+10 4e-12 7e-18 1e-06 2e+06 0.3337 1e+00 1 1 1 | 0 0
81 -2.339e+00 -2.339e+00 +3e+10 2e-12 2e-18 4e-06 3e+06 0.9886 5e-01 1 1 1 | 0 0
82 -2.446e+00 -2.446e+00 +8e+10 2e-12 5e-18 4e-06 7e+06 0.9368 9e-01 1 1 1 | 0 0
83 -2.421e+00 -2.421e+00 +2e+11 1e-12 3e-18 5e-06 1e+07 0.9890 6e-01 1 1 1 | 0 0
84 -2.405e+00 -2.405e+00 +3e+11 7e-13 2e-18 2e-06 3e+07 0.9890 4e-01 1 1 1 | 0 0
85 -2.361e+00 -2.361e+00 +5e+11 3e-13 1e-18 2e-06 4e+07 0.9890 2e-01 1 1 1 | 0 0
86 -2.454e+00 -2.454e+00 +6e+11 8e-13 2e-18 4e-07 5e+07 0.6078 2e-01 1 1 1 | 0 0
87 -2.309e+00 -2.309e+00 +9e+11 3e-13 6e-19 2e-06 7e+07 0.9890 4e-01 1 1 1 | 0 0
88 -2.426e+00 -2.426e+00 +5e+11 7e-13 7e-19 1e-06 5e+07 0.1460 9e-01 1 1 1 | 0 0
89 -2.294e+00 -2.294e+00 +4e+11 8e-13 3e-19 2e-06 3e+07 0.5459 4e-01 1 1 1 | 0 0
90 -2.287e+00 -2.287e+00 +8e+11 5e-13 2e-19 2e-06 7e+07 0.9890 7e-01 1 1 1 | 0 0
91 -2.358e+00 -2.358e+00 +1e+12 5e-13 5e-19 1e-06 1e+08 0.1590 4e-01 1 1 1 | 0 0
92 -2.401e+00 -2.401e+00 +5e+12 4e-13 7e-19 2e-06 4e+08 0.2571 1e+00 1 1 1 | 0 0
93 -2.444e+00 -2.444e+00 +1e+13 2e-13 5e-19 6e-06 1e+09 0.9890 6e-01 1 1 1 | 0 0
94 -2.258e+00 -2.258e+00 +5e+12 6e-14 2e-19 5e-06 5e+08 0.9825 3e-01 1 1 1 | 0 0
95 -2.315e+00 -2.315e+00 +3e+12 3e-13 1e-19 3e-06 3e+08 0.0642 4e-01 1 1 1 | 0 0
96 -2.192e+00 -2.192e+00 +2e+12 3e-13 3e-19 3e-06 2e+08 0.7883 5e-01 1 1 1 | 0 0
97 -2.197e+00 -2.197e+00 +2e+12 4e-13 2e-19 3e-06 2e+08 0.0019 9e-01 1 1 1 | 0 0
98 -2.334e+00 -2.334e+00 +6e+12 2e-13 2e-19 1e-06 5e+08 0.1242 9e-01 1 1 1 | 0 0
99 -2.416e+00 -2.416e+00 +3e+13 9e-14 3e-19 6e-07 3e+09 0.7886 3e-01 1 1 1 | 0 0
100 -2.445e+00 -2.445e+00 +1e+14 5e-14 2e-19 3e-06 8e+09 0.9890 5e-01 1 1 1 | 0 0
Maximum number of iterations reached, recovering best iterate (16) and stopping.
RAN OUT OF ITERATIONS (reached feastol=3.4e-06, reltol=4.1e-01, abstol=9.2e-01).
Runtime: 0.439599 seconds.
ECOS 2.0.7 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS
It pcost dcost gap pres dres k/t mu step sigma IR | BT
0 +0.000e+00 -1.323e+04 +3e+04 3e-01 5e-02 1e+00 3e+00 --- --- 2 1 - | - -
1 +1.752e+02 -1.338e+03 +5e+03 4e-02 4e-03 5e-01 4e-01 0.9566 1e-01 3 2 2 | 0 0
2 +1.223e+01 -9.891e+01 +4e+02 3e-03 3e-04 4e-02 3e-02 0.9248 2e-03 3 2 2 | 0 0
3 -4.540e-01 -4.515e+00 +2e+01 1e-04 1e-05 9e-04 1e-03 0.9632 8e-04 4 3 3 | 0 0
4 -6.547e-01 -3.226e+00 +1e+01 7e-05 6e-06 5e-04 9e-04 0.4580 3e-01 1 1 1 | 0 0
5 -9.887e-01 -2.287e+00 +5e+00 3e-05 2e-06 2e-04 5e-04 0.9309 5e-01 1 1 1 | 0 0
6 -1.036e+00 -1.868e+00 +3e+00 2e-05 2e-06 1e-04 3e-04 0.5075 3e-01 1 1 1 | 0 0
7 -1.075e+00 -1.301e+00 +9e-01 6e-06 4e-07 3e-05 8e-05 0.8014 8e-02 1 1 1 | 0 0
8 -1.083e+00 -1.100e+00 +7e-02 5e-07 3e-08 3e-06 6e-06 0.9323 5e-03 4 4 5 | 0 0
9 -1.083e+00 -1.085e+00 +5e-03 4e-08 2e-09 2e-07 4e-07 0.9618 4e-02 3 3 2 | 0 0
10 -1.083e+00 -1.083e+00 +4e-04 3e-09 1e-10 1e-08 3e-08 0.9432 1e-02 2 2 2 | 0 0
11 -1.083e+00 -1.083e+00 +4e-05 1e-09 2e-11 1e-09 3e-09 0.9361 4e-02 2 2 2 | 0 0
12 -1.083e+00 -1.083e+00 +9e-06 4e-10 4e-12 3e-10 8e-10 0.8450 1e-01 2 2 2 | 0 0
13 -1.083e+00 -1.083e+00 +2e-06 2e-10 9e-13 7e-11 2e-10 0.9025 2e-01 1 1 1 | 0 0
14 -1.083e+00 -1.083e+00 +2e-07 5e-11 8e-14 7e-12 2e-11 0.9678 6e-02 2 2 2 | 0 0
15 -1.083e+00 -1.083e+00 +4e-09 2e-11 2e-15 1e-13 4e-13 0.9841 6e-03 2 2 2 | 0 0
OPTIMAL (within feastol=1.8e-11, reltol=4.1e-09, abstol=4.5e-09).
Runtime: 0.086484 seconds.
1.0833402080372803
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.