Skip to content

Commit 5a5f62d

Browse files
author
deepshekhardas
committed
fix: raise ValueError when simplex hits max iterations
run_simplex() silently returned {} when maxiter was exhausted, hiding cycling/unbounded problems. Raise an informative ValueError instead. Fixes #14584
1 parent f5988cc commit 5a5f62d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

linear_programming/simplex.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ def run_simplex(self) -> dict[Any, Any]:
302302
self.tableau = self.change_stage()
303303
else:
304304
self.tableau = self.pivot(row_idx, col_idx)
305-
return {}
305+
raise ValueError(
306+
"Simplex did not converge within "
307+
f"{Tableau.maxiter} iterations. The problem may be cycling or "
308+
"unbounded."
309+
)
306310

307311
def interpret_tableau(self) -> dict[str, float]:
308312
"""Given the final tableau, add the corresponding values of the basic

0 commit comments

Comments
 (0)