Scipy_Direct

class sherpa.optmethods.optscipy.Scipy_Direct(name: str | None = None, **kwargs)[source] [edit on github]

Bases: ScipyBase

Optimizer using scipy.optimize.direct.

The scipy.optimize.direct function implements the DIRECT algorithm for global optimization.

Sherpa will automatically convert statistics functions, input values, parameter limits etc. to the format required by the scipy function and those cannot be set by the user. Below is a list of attributes most likely to be be of interest for Sherpa users, see scipy.optimize.direct documentation for details of all parameters.

eps

Minimal required difference between steps. Default is 1e-4.

Type:

float

maxfun

Approximate upper bound on objective function evaluations.

Type:

int or None

maxiter

Maximum number of iterations.

Type:

int

locally_biased

If True (default), use the locally biased variant of the algorithm known as DIRECT_L.

Type:

bool

vol_tol

Terminate the optimization once the volume of the hyperrectangle containing the lowest function value is smaller than vol_tol of the complete search space. Must lie between 0 and 1. Default is 1e-16.

Type:

float

len_tol

Allowed range is 0 to 1. Default is 1e-6.

Type:

float

Attributes Summary

default_config

The default settings for the optimiser.

Methods Summary

fit(statfunc, pars, parmins, parmaxes[, ...])

Run the optimiser.

Attributes Documentation

default_config

The default settings for the optimiser.

Methods Documentation

fit(statfunc: Callable[[Sequence[float] | ndarray], tuple[float, ndarray]], pars: Sequence[float] | ndarray, parmins: Sequence[float] | ndarray, parmaxes: Sequence[float] | ndarray, statargs: Any | None = None, statkwargs: Any | None = None) tuple[bool, ndarray, float, str, dict[str, Any]] [edit on github]

Run the optimiser.

Changed in version 4.18.0: The statargs and statkwargs arguments are now ignored.

Changed in version 4.16.0: The statkwargs argument now defaults to None rather than {}.

Parameters:
  • statfunc (function) – Given a list of parameter values as the first argument and, as the remaining positional arguments, statargs and statkwargs as keyword arguments, return the statistic value.

  • pars (sequence) – The start position of the model parameter values.

  • parmins (sequence) – The minimum allowed values for each model parameter. This must match the length of pars.

  • parmaxes (sequence) – The maximum allowed values for each model parameter. This must match the length of pars.

  • statargs (optional) – This is currently unused.

  • statkwargs (dict, optional) – This is currently unused.

Returns:

newpars – The tuple contains: boolean indicating whether the optimization succeeded or not, the best fit parameters as a NumPy array, the statistic value at the best-fit location, a string message indicating the status, and a dictionary containing information about the optimisation (this depends on the optimiser).

Return type:

tuple