docstr: A class for handling minimization of scalar function of one or more
  variables.
  
  Parameters
  ----------
  fun : callable
      Objective function.
  
  x0 : ndarray
      Initial guess.
  
  args : tuple, optional
      Extra arguments passed to the objective function and its
      derivatives (Jacobian, Hessian).
  
  method : str, optional
      Type of solver.  Should be one of
  
          - 'Nelder-Mead'
          - 'Powell'
          - 'CG'
          - 'BFGS'
          - 'Newton-CG'
          - 'Anneal'
          - 'L-BFGS-B'
          - 'TNC'
          - 'COBYLA'
          - 'SLSQP'
          - 'dogleg'
          - 'trust-ncg'
  
  jac : bool or callable, optional
      Jacobian of objective function. Only for CG, BFGS, Newton-CG,
      dogleg, trust-ncg.
      If `jac` is a Boolean and is True, `fun` is assumed to return the
      value of Jacobian along with the objective function. If False, the
      Jacobian will be estimated numerically.
      `jac` can also be a callable returning the Jacobian of the
      objective. In this case, it must accept the same arguments
      as `fun`.
  
  hess, hessp : callable, optional
      Hessian of objective function or Hessian of objective function
      times an arbitrary vector p.  Only for Newton-CG,
      dogleg, trust-ncg.
      Only one of `hessp` or `hess` needs to be given.  If `hess` is
      provided, then `hessp` will be ignored.  If neither `hess` nor
      `hessp` is provided, then the hessian product will be approximated
      using finite differences on `jac`. `hessp` must compute the Hessian
      times an arbitrary vector.
  
  bounds : sequence, optional
      Bounds for variables (only for L-BFGS-B, TNC and SLSQP).
      ``(min, max)`` pairs for each element in ``x``, defining
      the bounds on that parameter. Use None for one of ``min`` or
      ``max`` when there is no bound in that direction.
  
  constraints : dict or sequence of dict, optional
      Constraints definition (only for COBYLA and SLSQP).
      Each constraint is defined in a dictionary with fields:
          type : str
              Constraint type: 'eq' for equality, 'ineq' for inequality.
          fun : callable
              The function defining the constraint.
          jac : callable, optional
              The Jacobian of `fun` (only for SLSQP).
          args : sequence, optional
              Extra arguments to be passed to the function and Jacobian.
      Equality constraint means that the constraint function result is to
      be zero whereas inequality means that it is to be non-negative.
      Note that COBYLA only supports inequality constraints.
  
  tol : float, optional
      Tolerance for termination. For detailed control, use
      solver-specific options.
  
  callback : callable, optional
      Called after each iteration, as ``callback(xk)``, where ``xk`` is
      the current parameter vector. Only available using Scipy >= 0.12.
  
  options : dict, optional
      A dictionary of solver options. All methods accept the following
      generic options:
          maxiter : int
              Maximum number of iterations to perform.
          disp : bool
              Set to True to print convergence messages.
      For method-specific options, see
      `show_options('minimize', method)`.
  
  evolution : bool, optional
      save history of x for each iteration. Only available using Scipy
      >= 0.12.
  
  See Also
  --------
  scipy.optimize.minimize
docstr_tok: ["A","class","for","handling","minimization","of","scalar","function","of","one","or","more","variables",".","Parameters","--","--","--","--","--","fun",":","callable","Objective","function",".","x0",":","ndarray","Initial","guess",".","args",":","tuple",",","optional","Extra","arguments","passed","to","the","objective","function","and","its","derivatives","(","Jacobian",",","Hessian",")",".","method",":","str",",","optional","Type","of","solver",".","Should","be","one","of","-","'Nelder-Mead'","-","'Powell'","-","'CG'","-","'BFGS'","-","'Newton-CG'","-","'Anneal'","-","'","L-BFGS-B'","-","'TNC'","-","'COBYLA'","-","'SLSQP'","-","'dogleg'","-","'trust-ncg'","jac",":","bool","or","callable",",","optional","Jacobian","of","objective","function",".","Only","for","CG",",","BFGS",",","Newton-CG",",","dogleg",",","trust-ncg",".","If","`","jac","`","is","a","Boolean","and","is","True",",","`","fun","`","is","assumed","to","return","the","value","of","Jacobian","along","with","the","objective","function",".","If","False",",","the","Jacobian","will","be","estimated","numerically",".","`","jac","`","can","also","be","a","callable","returning","the","Jacobian","of","the","objective",".","In","this","case",",","it","must","accept","the","same","arguments","as","`","fun","`",".","hess",",","hessp",":","callable",",","optional","Hessian","of","objective","function","or","Hessian","of","objective","function","times","an","arbitrary","vector","p.","Only","for","Newton-CG",",","dogleg",",","trust-ncg",".","Only","one","of","`","hessp","`","or","`","hess","`","needs","to","be","given",".","If","`","hess","`","is","provided",",","then","`","hessp","`","will","be","ignored",".","If","neither","`","hess","`","nor","`","hessp","`","is","provided",",","then","the","hessian","product","will","be","approximated","using","finite","differences","on","`","jac","`",".","`","hessp","`","must","compute","the","Hessian","times","an","arbitrary","vector",".","bounds",":","sequence",",","optional","Bounds","for","variables","(","only","for","L-BFGS-B",",","TNC","and","SLSQP",")",".","``","(","min",",","max",")","``","pairs","for","each","element","in","``","x","``",",","defining","the","bounds","on","that","parameter",".","Use","None","for","one","of","``","min","``","or","``","max","``","when","there","is","no","bound","in","that","direction",".","constraints",":","dict","or","sequence","of","dict",",","optional","Constraints","definition","(","only","for","COBYLA","and","SLSQP",")",".","Each","constraint","is","defined","in","a","dictionary","with","fields",":","type",":","str","Constraint","type",":","'eq","'","for","equality",",","'ineq","'","for","inequality",".","fun",":","callable","The","function","defining","the","constraint",".","jac",":","callable",",","optional","The","Jacobian","of","`","fun","`","(","only","for","SLSQP",")",".","args",":","sequence",",","optional","Extra","arguments","to","be","passed","to","the","function","and","Jacobian",".","Equality","constraint","means","that","the","constraint","function","result","is","to","be","zero","whereas","inequality","means","that","it","is","to","be","non-negative",".","Note","that","COBYLA","only","supports","inequality","constraints",".","tol",":","float",",","optional","Tolerance","for","termination",".","For","detailed","control",",","use","solver-specific","options",".","callback",":","callable",",","optional","Called","after","each","iteration",",","as","``","callback","(","xk",")","``",",","where","``","xk","``","is","the","current","parameter","vector",".","Only","available","using","Scipy",">","=","0.12.","options",":","dict",",","optional","A","dictionary","of","solver","options",".","All","methods","accept","the","following","generic","options",":","maxiter",":","int","Maximum","number","of","iterations","to","perform",".","disp",":","bool","Set","to","True","to","print","convergence","messages",".","For","method-specific","options",",","see","`","show_options","(","'minimize","'",",","method",")","`",".","evolution",":","bool",",","optional","save","history","of","x","for","each","iteration",".","Only","available","using","Scipy",">","=","0.12",".","See","Also","--","--","--","--","scipy.optimize.minimize"]
code: def __init__(
      self,
      fun,
      x0,
      args=(),
      method="L-BFGS-B",
      jac=None,
      hess=None,
      hessp=None,
      bounds=None,
      constraints=(),
      tol=None,
      callback=None,
      options=None,
      evolution=False,
  ):
      """A class for handling minimization of scalar function of one or more
      variables.
  
      Parameters
      ----------
      fun : callable
          Objective function.
  
      x0 : ndarray
          Initial guess.
  
      args : tuple, optional
          Extra arguments passed to the objective function and its
          derivatives (Jacobian, Hessian).
  
      method : str, optional
          Type of solver.  Should be one of
  
              - 'Nelder-Mead'
              - 'Powell'
              - 'CG'
              - 'BFGS'
              - 'Newton-CG'
              - 'Anneal'
              - 'L-BFGS-B'
              - 'TNC'
              - 'COBYLA'
              - 'SLSQP'
              - 'dogleg'
              - 'trust-ncg'
  
      jac : bool or callable, optional
          Jacobian of objective function. Only for CG, BFGS, Newton-CG,
          dogleg, trust-ncg.
          If `jac` is a Boolean and is True, `fun` is assumed to return the
          value of Jacobian along with the objective function. If False, the
          Jacobian will be estimated numerically.
          `jac` can also be a callable returning the Jacobian of the
          objective. In this case, it must accept the same arguments
          as `fun`.
  
      hess, hessp : callable, optional
          Hessian of objective function or Hessian of objective function
          times an arbitrary vector p.  Only for Newton-CG,
          dogleg, trust-ncg.
          Only one of `hessp` or `hess` needs to be given.  If `hess` is
          provided, then `hessp` will be ignored.  If neither `hess` nor
          `hessp` is provided, then the hessian product will be approximated
          using finite differences on `jac`. `hessp` must compute the Hessian
          times an arbitrary vector.
  
      bounds : sequence, optional
          Bounds for variables (only for L-BFGS-B, TNC and SLSQP).
          ``(min, max)`` pairs for each element in ``x``, defining
          the bounds on that parameter. Use None for one of ``min`` or
          ``max`` when there is no bound in that direction.
  
      constraints : dict or sequence of dict, optional
          Constraints definition (only for COBYLA and SLSQP).
          Each constraint is defined in a dictionary with fields:
              type : str
                  Constraint type: 'eq' for equality, 'ineq' for inequality.
              fun : callable
                  The function defining the constraint.
              jac : callable, optional
                  The Jacobian of `fun` (only for SLSQP).
              args : sequence, optional
                  Extra arguments to be passed to the function and Jacobian.
          Equality constraint means that the constraint function result is to
          be zero whereas inequality means that it is to be non-negative.
          Note that COBYLA only supports inequality constraints.
  
      tol : float, optional
          Tolerance for termination. For detailed control, use
          solver-specific options.
  
      callback : callable, optional
          Called after each iteration, as ``callback(xk)``, where ``xk`` is
          the current parameter vector. Only available using Scipy >= 0.12.
  
      options : dict, optional
          A dictionary of solver options. All methods accept the following
          generic options:
              maxiter : int
                  Maximum number of iterations to perform.
              disp : bool
                  Set to True to print convergence messages.
          For method-specific options, see
          `show_options('minimize', method)`.
  
      evolution : bool, optional
          save history of x for each iteration. Only available using Scipy
          >= 0.12.
  
      See Also
      --------
      scipy.optimize.minimize
  
      """
      self.size_of_x = len(x0)
      self._evol_kx = None
  
      if evolution is True:
          self._evol_kx = []
  
          def history_of_x(kx):
              self._evol_kx.append(kx)
  
          res = minimize(
              fun,
              x0,
              args,
              method,
              jac,
              hess,
              hessp,
              bounds,
              constraints,
              tol,
              callback=history_of_x,
              options=options,
          )
  
      else:
          res = minimize(
              fun,
              x0,
              args,
              method,
              jac,
              hess,
              hessp,
              bounds,
              constraints,
              tol,
              callback,
              options,
          )
  
      self.res = res
  
imports: import abc
  import warnings
  import numpy
  import scipy.sparse
  import scipy.optimize
  from scipy.optimize import minimize
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 1 to create a new Optimizer object  with example: obj = Optimizer(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options, evolution)