parameters: (res)
docstring: A sample callback function demonstrating the linprog callback interface.
      This callback produces detailed output to sys.stdout before each iteration
      and after the final iteration of the simplex algorithm.
  
      Parameters
      ----------
      res : A `scipy.optimize.OptimizeResult` consisting of the following fields:
  
          x : 1D array
              The independent variable vector which optimizes the linear
              programming problem.
          fun : float
              Value of the objective function.
          success : bool
              True if the algorithm succeeded in finding an optimal solution.
          slack : 1D array
              The values of the slack variables. Each slack variable corresponds
              to an inequality constraint. If the slack is zero, then the
              corresponding constraint is active.
          con : 1D array
              The (nominally zero) residuals of the equality constraints, that is,
              ``b - A_eq @ x``
          phase : int
              The phase of the optimization being executed. In phase 1 a basic
              feasible solution is sought and the T has an additional row
              representing an alternate objective function.
          status : int
              An integer representing the exit status of the optimization::
  
                   0 : Optimization terminated successfully
                   1 : Iteration limit reached
                   2 : Problem appears to be infeasible
                   3 : Problem appears to be unbounded
                   4 : Serious numerical difficulties encountered
  
          nit : int
              The number of iterations performed.
          message : str
              A string descriptor of the exit status of the optimization.
docstring_summary: A sample callback function demonstrating the linprog callback interface.
      This callback produces detailed output to sys.stdout before each iteration
      and after the final iteration of the simplex algorithm.
docstring_tokens: A sample callback function demonstrating the linprog callback interface . This callback produces detailed output to sys . stdout before each iteration and after the final iteration of the simplex algorithm .
function: def linprog_verbose_callback(res):
      """
      A sample callback function demonstrating the linprog callback interface.
      This callback produces detailed output to sys.stdout before each iteration
      and after the final iteration of the simplex algorithm.
  
      Parameters
      ----------
      res : A `scipy.optimize.OptimizeResult` consisting of the following fields:
  
          x : 1D array
              The independent variable vector which optimizes the linear
              programming problem.
          fun : float
              Value of the objective function.
          success : bool
              True if the algorithm succeeded in finding an optimal solution.
          slack : 1D array
              The values of the slack variables. Each slack variable corresponds
              to an inequality constraint. If the slack is zero, then the
              corresponding constraint is active.
          con : 1D array
              The (nominally zero) residuals of the equality constraints, that is,
              ``b - A_eq @ x``
          phase : int
              The phase of the optimization being executed. In phase 1 a basic
              feasible solution is sought and the T has an additional row
              representing an alternate objective function.
          status : int
              An integer representing the exit status of the optimization::
  
                   0 : Optimization terminated successfully
                   1 : Iteration limit reached
                   2 : Problem appears to be infeasible
                   3 : Problem appears to be unbounded
                   4 : Serious numerical difficulties encountered
  
          nit : int
              The number of iterations performed.
          message : str
              A string descriptor of the exit status of the optimization.
      """
      x = res['x']
      fun = res['fun']
      success = res['success']
      phase = res['phase']
      status = res['status']
      nit = res['nit']
      message = res['message']
      complete = res['complete']
  
      saved_printoptions = np.get_printoptions()
      np.set_printoptions(linewidth=500,
                          formatter={'float': lambda x: "{0: 12.4f}".format(x)})
      if status:
          print('--------- Simplex Early Exit -------\n'.format(nit))
          print('The simplex method exited early with status {0:d}'.format(status))
          print(message)
      elif complete:
          print('--------- Simplex Complete --------\n')
          print('Iterations required: {}'.format(nit))
      else:
          print('--------- Iteration {0:d}  ---------\n'.format(nit))
  
      if nit > 0:
          if phase == 1:
              print('Current Pseudo-Objective Value:')
          else:
              print('Current Objective Value:')
          print('f = ', fun)
          print()
          print('Current Solution Vector:')
          print('x = ', x)
          print()
  
      np.set_printoptions(**saved_printoptions)
function_tokens: def linprog_verbose_callback ( res ) : x = res [ 'x' ] fun = res [ 'fun' ] success = res [ 'success' ] phase = res [ 'phase' ] status = res [ 'status' ] nit = res [ 'nit' ] message = res [ 'message' ] complete = res [ 'complete' ] saved_printoptions = np . get_printoptions ( ) np . set_printoptions ( linewidth = 500 , formatter = { 'float' : lambda x : "{0: 12.4f}" . format ( x ) } ) if status : print ( '--------- Simplex Early Exit -------\n' . format ( nit ) ) print ( 'The simplex method exited early with status {0:d}' . format ( status ) ) print ( message ) elif complete : print ( '--------- Simplex Complete --------\n' ) print ( 'Iterations required: {}' . format ( nit ) ) else : print ( '--------- Iteration {0:d}  ---------\n' . format ( nit ) ) if nit > 0 : if phase == 1 : print ( 'Current Pseudo-Objective Value:' ) else : print ( 'Current Objective Value:' ) print ( 'f = ' , fun ) print ( ) print ( 'Current Solution Vector:' ) print ( 'x = ' , x ) print ( ) np . set_printoptions ( * * saved_printoptions )