@jit(nopython=True, cache=True)
def lemke_howson_tbl(tableaux, bases, init_pivot, max_iter):
 init_player = 0
 for k in bases[0]:
  if (k == init_pivot):
   init_player = 1
   break
 pls = [init_player, (1 - init_player)]
 pivot = init_pivot
 (m, n) = (tableaux[1].shape[0], tableaux[0].shape[0])
 slack_starts = (m, 0)
 argmins = np.empty(max(m, n), dtype=np.int_)
 converged = False
 num_iter = 0
 while True:
  for pl in pls:
   row_min = lex_min_ratio_test(tableaux[pl], pivot, slack_starts[pl], argmins)
   pivoting(tableaux[pl], pivot, row_min)
   (bases[pl][row_min], pivot) = (pivot, bases[pl][row_min])
   num_iter += 1
   if (pivot == init_pivot):
    converged = True
    break
   if (num_iter >= max_iter):
    break
  else:
   continue
  break
 return (converged, num_iter)

@ jit ( nopython = True , cache = True ) def lemke_howson_tbl ( tableaux , bases , init_pivot , max_iter ) : init_player = 0 for k in bases [ 0 ] : if ( k == init_pivot ) : init_player = 1 break pls = [ init_player , ( 1 - init_player ) ] pivot = init_pivot ( m , n ) = ( tableaux [ 1 ] . shape [ 0 ] , tableaux [ 0 ] . shape [ 0 ] ) slack_starts = ( m , 0 ) argmins = np . empty ( max ( m , n ) , dtype = np . int_ ) converged = False num_iter = 0 while True : for pl in pls : row_min = lex_min_ratio_test ( tableaux [ pl ] , pivot , slack_starts [ pl ] , argmins ) pivoting ( tableaux [ pl ] , pivot , row_min ) ( bases [ pl ] [ row_min ] , pivot ) = ( pivot , bases [ pl ] [ row_min ] ) num_iter += 1 if ( pivot == init_pivot ) : converged = True break if ( num_iter >= max_iter ) : break else : continue break return ( converged , num_iter )
main body of the lemke-howson algorithm implementation .