@@ -163,14 +163,9 @@ def linprog_simplex(c, A_ub=np.empty((0, 0)), b_ub=np.empty((0,)),
163163
164164 # Phase 1
165165 success , status , num_iter_1 = \
166- solve_tableau (tableau , basis , max_iter , skip_aux = False ,
167- piv_options = piv_options )
166+ solve_phase_1 (tableau , basis , max_iter , piv_options = piv_options )
168167 num_iter += num_iter_1
169- if not success : # max_iter exceeded
170- return SimplexResult (x , lambd , fun , success , status , num_iter )
171- if tableau [- 1 , - 1 ] > piv_options .fea_tol : # Infeasible
172- success = False
173- status = 2
168+ if not success :
174169 return SimplexResult (x , lambd , fun , success , status , num_iter )
175170
176171 # Modify the criterion row for Phase 2
@@ -442,6 +437,32 @@ def solve_tableau(tableau, basis, max_iter=10**6, skip_aux=True,
442437 return success , status , num_iter
443438
444439
440+ @jit (nopython = True , cache = True )
441+ def solve_phase_1 (tableau , basis , max_iter = 10 ** 6 , piv_options = PivOptions ()):
442+ """
443+ Perform the simplex algorithm for Phase 1 on a given tableau in
444+ canonical form, by calling `solve_tableau` with `skip_aux=False`.
445+
446+ Parameters
447+ ----------
448+ See `solve_tableau`.
449+
450+ Returns
451+ -------
452+ See `solve_tableau`.
453+
454+ """
455+ success , status , num_iter_1 = \
456+ solve_tableau (tableau , basis , max_iter , skip_aux = False ,
457+ piv_options = piv_options )
458+
459+ if success and tableau [- 1 , - 1 ] > piv_options .fea_tol : # Infeasible
460+ success = False
461+ status = 2
462+
463+ return success , status , num_iter_1
464+
465+
445466@jit (nopython = True , cache = True )
446467def _pivot_col (tableau , skip_aux , piv_options ):
447468 """
0 commit comments