Skip to content

Commit

Permalink
Fixed student identified bugs.
Browse files Browse the repository at this point in the history
Two bugs came up during testing. The first was that the origin was not
hoverable. This came from the fact that the shaded region layer was above
the BFS points. The BFS points are now the top layer. The other was that
the provided index options for the manual selection pivot rule were off by
one which is now fixed.
  • Loading branch information
henryrobbins committed Sep 10, 2020
1 parent 2b46027 commit ba929de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion gilp/simplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ def simplex_iteration(lp: LP,
else:
user_input = None
if pivot_rule == 'manual_select':
user_input = int(input('Pick one of ' + str(entering.keys())))
user_options = [i + 1 for i in entering.keys()]
user_input = int(input('Pick one of ' + str(user_options))) - 1
k = {'bland': min(entering.keys()),
'min_index': min(entering.keys()),
'dantzig': max(entering, key=entering.get),
Expand Down
13 changes: 8 additions & 5 deletions gilp/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,28 @@ def plot_lp(lp: LP) -> plt.Figure:
d['Obj'] = float(unique_val[i])
lbs.append(label(d))

# Plot basic feasible solutions with their label
# Get basic feasible solutions and set axis limits
pts = [np.array([x]).transpose()[0:n] for x in unique_bfs]
set_axis_limits(fig, pts)
fig.add_trace(scatter(pts,'bfs',lbs))

# Plot feasible region
if n == 2:
fig.add_trace(polygon(pts,'region'))
if n == 3:
for i in range(n+m):
pts = [bfs[j][0:n,:] for j in range(len(bfs)) if i not in bases[j]]
if len(pts) > 0:
fig.add_trace(polygon(pts,'region'))
face_pts = [bfs[j][0:n,:] for j in range(len(bfs)) if i not in bases[j]]
if len(face_pts) > 0:
fig.add_trace(polygon(face_pts,'region'))

# Plot constraints
for i in range(m):
lb = '('+str(i+n+1)+') '+equation_string(A[i],b[i][0])
fig.add_trace(equation(fig,A[i],b[i][0],'constraint',lb))

# Plot basic feasible solutions with their label
# (Plot last so they are on the top layer for hovering)
fig.add_trace(scatter(pts,'bfs',lbs))

return fig


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="gilp",
version="0.0.1-rc-9",
version="0.0.1-rc-10",
author="Henry Robbins",
author_email="hwr26@cornell.edu",
description="A Python package for visualizing the geometry of linear programs.",
Expand Down

0 comments on commit ba929de

Please sign in to comment.