Skip to content

Commit 70c7868

Browse files
author
MiniMax Agent
committed
fix(simplex): raise ValueError instead of returning empty dict when max iterations reached
Fixes #14584 The run_simplex() method now raises a descriptive ValueError when the maximum iteration limit (Tableau.maxiter) is reached, instead of silently returning an empty dict. This allows callers to distinguish between a converging solution and a cycling/unbounded problem.
1 parent 791deb4 commit 70c7868

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

linear_programming/simplex.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,13 @@ 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+
306+
max_iterations = Tableau.maxiter
307+
raise ValueError(
308+
"Simplex did not converge within "
309+
+ str(max_iterations)
310+
+ " iterations. The problem may be cycling or unbounded."
311+
)
306312

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

0 commit comments

Comments
 (0)