@@ -285,6 +285,15 @@ def run_simplex(self) -> dict[Any, Any]:
285285 ... [1, 0, 0, 0, 0, 0, -1, 0, 1, 2.0]
286286 ... ]), 2, 2).run_simplex().items()} # doctest: +ELLIPSIS
287287 {'P': 132.0, 'x1': 12.000... 'x2': 5.999...}
288+
289+ >>> original_maxiter = Tableau.maxiter
290+ >>> Tableau.maxiter = 0
291+ >>> Tableau(np.array([[-1, -1, 0, 0, 0], [1, 3, 1, 0, 4],
292+ ... [3, 1, 0, 1, 4.0]]), 2, 0).run_simplex()
293+ Traceback (most recent call last):
294+ ...
295+ ValueError: No convergence within 0 iterations; may be cycling/unbounded.
296+ >>> Tableau.maxiter = original_maxiter
288297 """
289298 # Stop simplex algorithm from cycling.
290299 for _ in range (Tableau .maxiter ):
@@ -302,7 +311,11 @@ def run_simplex(self) -> dict[Any, Any]:
302311 self .tableau = self .change_stage ()
303312 else :
304313 self .tableau = self .pivot (row_idx , col_idx )
305- return {}
314+ msg = (
315+ f"No convergence within { Tableau .maxiter } iterations; "
316+ "may be cycling/unbounded."
317+ )
318+ raise ValueError (msg )
306319
307320 def interpret_tableau (self ) -> dict [str , float ]:
308321 """Given the final tableau, add the corresponding values of the basic
0 commit comments