class_docstr: A general minimizer for curve fitting and optimization.
class_docstr_tok: ["A","general","minimizer","for","curve","fitting","and","optimization","."]
docstr: Use the `dual_annealing` algorithm to find the global minimum.
  
  This method calls :scipydoc:`optimize.dual_annealing` using its
  default arguments.
  
  Parameters
  ----------
  params : Parameters, optional
      Contains the Parameters for the model. If None, then the
      Parameters used to initialize the Minimizer object are used.
  max_nfev : int or None, optional
      Maximum number of function evaluations. Defaults to
      ``200000*(nvars+1)``, where ``nvars`` is the number of variables.
  **kws : dict, optional
      Minimizer options to pass to the dual_annealing algorithm.
  
  Returns
  -------
  MinimizerResult
      Object containing the parameters from the dual_annealing
      method. The return values specific to
      :scipydoc:`optimize.dual_annealing` (``x``, ``fun``, ``nfev``,
      ``nhev``, ``njev``, and ``nit``) are stored as
      ``da_<parname>`` attributes.
  
  
  .. versionadded:: 0.9.14
docstr_tok: ["Use","the","`","dual_annealing","`","algorithm","to","find","the","global","minimum",".","This","method","calls",":","scipydoc",":","`","optimize.dual_annealing","`","using","its","default","arguments",".","Parameters","--","--","--","--","--","params",":","Parameters",",","optional","Contains","the","Parameters","for","the","model",".","If","None",",","then","the","Parameters","used","to","initialize","the","Minimizer","object","are","used",".","max_nfev",":","int","or","None",",","optional","Maximum","number","of","function","evaluations",".","Defaults","to","``","200000","*","(","nvars+1",")","``",",","where","``","nvars","``","is","the","number","of","variables",".","*","*","kws",":","dict",",","optional","Minimizer","options","to","pass","to","the","dual_annealing","algorithm",".","Returns","--","--","--","-","MinimizerResult","Object","containing","the","parameters","from","the","dual_annealing","method",".","The","return","values","specific","to",":","scipydoc",":","`","optimize.dual_annealing","`","(","``","x","``",",","``","fun","``",",","``","nfev","``",",","``","nhev","``",",","``","njev","``",",","and","``","nit","``",")","are","stored","as","``","da_","<","parname",">","``","attributes",".","..","versionadded",":",":","0.9.14"]
code: def dual_annealing(self, params=None, max_nfev=None, **kws):
      """Use the `dual_annealing` algorithm to find the global minimum.
  
      This method calls :scipydoc:`optimize.dual_annealing` using its
      default arguments.
  
      Parameters
      ----------
      params : Parameters, optional
          Contains the Parameters for the model. If None, then the
          Parameters used to initialize the Minimizer object are used.
      max_nfev : int or None, optional
          Maximum number of function evaluations. Defaults to
          ``200000*(nvars+1)``, where ``nvars`` is the number of variables.
      **kws : dict, optional
          Minimizer options to pass to the dual_annealing algorithm.
  
      Returns
      -------
      MinimizerResult
          Object containing the parameters from the dual_annealing
          method. The return values specific to
          :scipydoc:`optimize.dual_annealing` (``x``, ``fun``, ``nfev``,
          ``nhev``, ``njev``, and ``nit``) are stored as
          ``da_<parname>`` attributes.
  
  
      .. versionadded:: 0.9.14
  
      """
      result = self.prepare_fit(params=params)
      result.method = "dual_annealing"
      self.set_max_nfev(max_nfev, 200000 * (result.nvarys + 1))
  
      da_kws = dict(
          maxiter=1000,
          minimizer_kwargs=None,
          initial_temp=5230.0,
          restart_temp_ratio=2e-05,
          visit=2.62,
          accept=-5.0,
          maxfun=2 * self.max_nfev,
          seed=None,
          no_local_search=False,
          callback=None,
          x0=None,
      )
  
      da_kws.update(self.kws)
      da_kws.update(kws)
  
      varying = np.asarray([par.vary for par in self.params.values()])
      bounds = np.asarray(
          [(par.min, par.max) for par in self.params.values()]
      )[varying]
  
      if not np.all(np.isfinite(bounds)):
          raise ValueError(
              "dual_annealing requires finite bounds for all"
              " varying parameters"
          )
      result.call_kws = da_kws
      try:
          ret = scipy_dual_annealing(self.penalty, bounds, **da_kws)
      except AbortFitException:
          pass
  
      if not result.aborted:
          for attr, value in ret.items():
              if attr in ["success", "message"]:
                  setattr(result, attr, value)
              else:
                  setattr(result, f"da_{attr}", value)
  
          result.residual = self.__residual(result.da_x, False)
          result.nfev -= 1
      elif result.nfev > self.max_nfev - 5:
          result.nfev -= 2
          _best = result.last_internal_values
          result.residual = self.__residual(_best, False)
  
      result._calculate_statistics()
  
      # calculate the cov_x and estimate uncertainties/correlations
      if (
          not result.aborted
          and self.calc_covar
          and HAS_NUMDIFFTOOLS
          and len(result.residual) > len(result.var_names)
      ):
          result.covar = self._calculate_covariance_matrix(result.da_x)
          if result.covar is not None:
              self._calculate_uncertainties_correlations()
  
      return result
  
imports: from collections import namedtuple
  from copy import deepcopy
  import inspect
  import multiprocessing
  import numbers
  import warnings
  import numpy
  from scipy.linalg import LinAlgError, inv
  from scipy.optimize import basinhopping
  from scipy.optimize import brute
  from scipy.optimize import differential_evolution
  from scipy.optimize import dual_annealing
  from scipy.optimize import least_squares
  from scipy.optimize import leastsq
  from scipy.optimize import minimize
  from scipy.optimize import shgo
  from scipy.sparse import issparse
  from scipy.sparse.linalg import LinearOperator
  from scipy.stats import cauchy
  from scipy.stats import norm
  from ._ampgo import ampgo
  from .parameter import Parameter, Parameters
  from .printfuncs import fitreport_html_table
label_desc: Use image node_id 21 for calling the Minimizer obj's underlying member method code with example usage: obj.dual_annealing(params, max_nfev) and returns: result