From 5a5f62d00fd048a2322412459ac8241a7a0c2c19 Mon Sep 17 00:00:00 2001 From: deepshekhardas Date: Mon, 17 Aug 2026 10:34:33 +0530 Subject: [PATCH] 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 --- linear_programming/simplex.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linear_programming/simplex.py b/linear_programming/simplex.py index a8affe1b72d2..9677acf7e233 100644 --- a/linear_programming/simplex.py +++ b/linear_programming/simplex.py @@ -302,7 +302,11 @@ def run_simplex(self) -> dict[Any, Any]: self.tableau = self.change_stage() else: self.tableau = self.pivot(row_idx, col_idx) - return {} + raise ValueError( + "Simplex did not converge within " + f"{Tableau.maxiter} iterations. The problem may be cycling or " + "unbounded." + ) def interpret_tableau(self) -> dict[str, float]: """Given the final tableau, add the corresponding values of the basic