Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fix handling of unbounded/infeasible problems and add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
novoselt committed Oct 22, 2015
1 parent dc70260 commit 63fa385
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/sage/numerical/interactive_simplex_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -2904,13 +2904,28 @@ def run_dual_simplex_method(self):
\end{equation*}
sage: D.is_optimal()
True
This method detects infeasible problems::
sage: A = ([1, 0],)
sage: b = (-1,)
sage: c = (0, -1)
sage: P = InteractiveLPProblemStandardForm(A, b, c)
sage: D = P.initial_dictionary()
sage: D.run_dual_simplex_method()
\begin{equation*}
...
\end{equation*}
The problem is infeasible.
"""
output = []
while not self.is_optimal():
if self.leaving() is None:
self.leave(min(self.possible_leaving()))
if self.entering() is None:
self.enter(min(self.possible_entering()))
possible = self.possible_entering()
if possible:
self.enter(min(possible))
output.append(self._html_())
if self.entering() is None:
output.append("The problem is infeasible.")
Expand Down Expand Up @@ -2968,13 +2983,28 @@ def run_simplex_method(self):
\end{equation*}
sage: D.is_optimal()
True
This method detects unbounded problems::
sage: A = ([1, 0],)
sage: b = (1,)
sage: c = (0, 1)
sage: P = InteractiveLPProblemStandardForm(A, b, c)
sage: D = P.initial_dictionary()
sage: D.run_simplex_method()
\begin{equation*}
...
\end{equation*}
The problem is unbounded in $x_{2}$ direction.
"""
output = []
while not self.is_optimal():
if self.entering() is None:
self.enter(min(self.possible_entering()))
if self.leaving() is None:
self.leave(min(self.possible_leaving()))
possible = self.possible_leaving()
if possible:
self.leave(min(possible))
output.append(self._html_())
if self.leaving() is None:
output.append("The problem is unbounded in ${}$ direction."
Expand Down

0 comments on commit 63fa385

Please sign in to comment.