Closed shaesaert closed 6 years ago
Thanks for reporting this error. This error does not arise when scipy
is present and cvxopt.glpk
absent. It arises with cvxopt.glpk
present. Minimal example using e030e125108ff6cd4ffa1ffdb199ffc9864a4b1f:
In [1]: import cvxopt.glpk
In [2]: import polytope as pt
In [3]: p = pt.Polytope.from_box([[0, 1]])
In [4]: p.bounding_box
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-4-03e06b93ceaf> in <module>()
----> 1 p.bounding_box
/path/polytope/polytope/polytope.py in bounding_box(self)
406 """
407 if self.bbox is None:
--> 408 self.bbox = bounding_box(self)
409 return self.bbox
410
/path/path/polytope/polytope/polytope.py in bounding_box(polyreg)
1288 if sol['status'] == 0:
1289 x = sol['x']
-> 1290 l[i] = x[i]
1291 # upper corner
1292 for i in xrange(0, n):
IndexError: too many indices for array
The relevant lines are polytope.polytope
#L1290 and
polytope.polytope
#L1299 (corresponding to lower and upper corners of the bounding box, respectively).
This bug was introduced in 79d85ec95a32819534011756bb0200c824ae2148. It does not exist in 25dbe65eabb89ed6f9a4450a822489558438708f and appears in the merge commit 907934a2a698d7e77c1cd5334bb9c9e5cb18ebf0. The bug is caused by a zero-dimensional array returned by the function lpsolve
.
The error is introduced by the call to numpy.squeeze
on line 2282. Squeezing yields a zero dimensional array when fed with an array of shape (1,)
:
import numpy as np
a = np.array(1)
>>> a.shape
()
>>> a.ndim
()
b = np.array([1])
>>> b.shape
(1,)
c = np.squeeze(b)
>>> c.shape
()
In other words, there is still an asymmetry between the GLPK branch and the SciPy branch of the selection statement within lpsolve
. So the aim of 79d85ec95a32819534011756bb0200c824ae2148 has not been accomplished yet.
See also comments about https://github.com/tulip-control/polytope/commit/bb568be2cad60e51ccd1bdea4351db999889b274.
In one dimensional case studies, the abstraction algorithm of TuLiP triggers a compatibility error. This can be fixed easily: Polytope file:
lines 1285 to 1289 lines 1297 to 1300