Last modified: December 2023

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.16 Sherpa


Context: methods


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


Example 1

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()
sherpa> print(get_method())
name     = gridsearch
num      = 16
sequence = None
numcores = 1
maxfev   = None
ftol     = 1.19209289551e-07
method   = None
verbose  = 0

Example 2

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.

See Also

levmar, list_iter_methods, list_methods, moncar, neldermead, set_method, set_method_opt