Skip to content

Commit

Permalink
BUG: raise RuntimeError when lpsolve does not find an optimal sol…
Browse files Browse the repository at this point in the history
…ution
  • Loading branch information
johnyf committed May 28, 2021
1 parent 368c81a commit 7f59645
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions polytope/polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,12 @@ def bounding_box(polyreg):
if sol['status'] == 0:
x = sol['x']
l[i] = x[i]
else:
raise RuntimeError((
'`polytope.solvers.lpsolve` returned: {v}\n'
'its docstring describes return values'
).format(
v=sol))
# upper corner
for i in xrange(0, n):
c = np.negative(np.array(In[:, i]))
Expand All @@ -1332,6 +1338,12 @@ def bounding_box(polyreg):
if sol['status'] == 0:
x = sol['x']
u[i] = x[i]
else:
raise RuntimeError((
'`polytope.solvers.lpsolve` returned: {v}\n'
'its docstring describes return values'
).format(
v=sol))
polyreg.bbox = l, u
return l, u

Expand Down Expand Up @@ -1879,9 +1891,21 @@ def projection_iterhull(poly1, new_dim, max_iter=1000,
sol = lpsolve(f1, poly1.A, poly1.b)
if sol['status'] == 0:
vert1 = sol['x']
else:
raise RuntimeError((
'`polytope.solvers.lpsolve` returned: {v}\n'
'its docstring describes return values'
).format(
v=sol))
sol = lpsolve(np.negative(f1), poly1.A, poly1.b)
if sol['status'] == 0:
vert2 = sol['x']
else:
raise RuntimeError((
'`polytope.solvers.lpsolve` returned: {v}\n'
'its docstring describes return values'
).format(
v=sol))
vert = np.vstack([vert1, vert2])
return qhull(vert)
else:
Expand Down

0 comments on commit 7f59645

Please sign in to comment.