     Grid searching optimization method

The Sherpa grid searching optimization method, "gridsearch", is meant to be used with the Sherpa template model (see 'ahelp load_template_model). This method evaluates the fit statistic for each point in the parameter space grid; the best match is the grid point with the lowest value of the fit statistic. gridsearch reports back the parameter values associated with this point.

Method Options

num - used to generate a sequence of parameters to evaluate when the sequence parameter is set to 'None'. A uniform grid of size npar^num elements is generated. Default is 16.
sequence - a list which the gridsearch method should iterate through to evaluate the model function; the minimum parameter within this sequence is returned. Default is 'None', in which case the num parameter is utilized.
numcores - the number of cores on the user's system which should be used in the execution of the gridsearch method. Default is to use one core ('1'); 'None' will use all available cores.
maxfev - the maximum number of function evaluations using the optimization method specified in the method parameter; default is 'None'.
ftol - the function tolerance to terminate the search for the minimum, using the optimization method specified in the method parameter. Default is sqrt( DBL_EPSILON ) ~ 1.19209289551e-07, where DBL_EPSILON is the smallest number x such that 1.0 != 1.0 + x.
method - optimization method to use after the grid has been evaluated; used together with maxfev and ftol parameters. If set to 'neldermead' or 'levmar', the grid search calls the requested method after the grid has been evaluated. The minimum parameter of the grid is passed as the initial parameter to the optimization method. maxfev and ftol are not used within the grid search optimization method but are passed to the neldermead or levmar method. Default is 'None'.

verbose - the amount of information to print about the fit progress. Default is 0 (no output).
sherpa> set_method("gridsearch")

Set the optimization method to 'gridsearch', confirm the new value, and check method settings.

sherpa> set_method("gridsearch") sherpa> get_method_name() 'gridsearch' sherpa> print(get_method()) name = gridsearch num = 16 sequence = None numcores = 1 maxfev = None ftol = 1.19209289551e-07 method = None verbose = 0
sherpa> set_method("gridsearch")
sherpa> fit()

Load a collection of template models into the Sherpa model instance 'tbl', and fit to data set 'source.dat' using the Sherpa grid-searching optimization method. The parameters of the template model which best matches the data are returned.

sherpa> load_ascii('source.dat', ncols=3, dstype=Data1D) sherpa> load_template_model('tbl', 'table.txt') sherpa> set_source(tbl) sherpa> set_method('gridsearch') sherpa> set_method_opt('sequence', tbl.parvals) sherpa> fit() Dataset = 1 Method = gridsearch Statistic = chi2gehrels Initial fit statistic = 1.53806e+12 Final fit statistic = 212.321 at function evaluation 106 Data points = 7 Degrees of freedom = 4 Probability [Q-value] = 8.41533e-45 Reduced statistic = 53.0803 Change in statistic = 1.53806e+12 tbl.mass 9 tbl.rate 0.3 tbl.angle 1 WARNING: parameter value tbl.angle is at its maximum boundary 1.0

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

December 2023