fitters - Wrappers for various optimization algorithms¶
BFGSFit |
BFGS quasi-newton optimizer. |
ConsoleMonitor |
Display fit progress on the console |
DEFit |
Classic Storn and Price differential evolution optimizer. |
DreamFit |
|
DreamModel |
DREAM wrapper for fit problems. |
FitBase |
FitBase defines the interface from bumps models to the various fitting engines available within bumps. |
FitDriver |
|
LevenbergMarquardtFit |
Levenberg-Marquardt optimizer. |
MonitorRunner |
Adaptor which allows solvers to accept progress monitors. |
MultiStart |
Multi-start monte carlo fitter. |
PSFit |
Particle swarm optimizer. |
PTFit |
Parallel tempering optimizer. |
RLFit |
Random lines optimizer. |
Resampler |
|
SimplexFit |
Nelder-Mead simplex optimizer. |
SnobFit |
|
StepMonitor |
Collect information at every step of the fit and save it to a file. |
f |
alias of SnobFit |
load_history |
Load fitter details from a history file. |
parse_tolerance |
|
save_history |
Save fitter details to a history file as JSON. |
Interfaces to various optimizers.
-
class
bumps.fitters.
BFGSFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
BFGS quasi-newton optimizer.
-
id
= 'newton'¶
-
name
= 'Quasi-Newton BFGS'¶
-
settings
= [('steps', 3000), ('starts', 1), ('ftol', 1e-06), ('xtol', 1e-12)]¶
-
-
class
bumps.fitters.
ConsoleMonitor
(problem, progress=1, improvement=30)[source]¶ Bases:
bumps.monitor.TimedUpdate
Display fit progress on the console
-
config_history
(history)¶
-
-
class
bumps.fitters.
DEFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
Classic Storn and Price differential evolution optimizer.
-
id
= 'de'¶
-
name
= 'Differential Evolution'¶
-
settings
= [('steps', 1000), ('pop', 10), ('CR', 0.9), ('F', 2.0), ('ftol', 1e-08), ('xtol', 1e-06)]¶
-
-
class
bumps.fitters.
DreamFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
-
id
= 'dream'¶
-
name
= 'DREAM'¶
-
settings
= [('samples', 10000), ('burn', 100), ('pop', 10), ('init', 'eps'), ('thin', 1), ('steps', 0)]¶
-
-
class
bumps.fitters.
DreamModel
(problem=None, mapper=None)[source]¶ Bases:
bumps.dream.model.MCMCModel
DREAM wrapper for fit problems.
-
bounds
= None¶
-
labels
= None¶
-
plot
(x)¶
-
-
class
bumps.fitters.
FitBase
(problem)[source]¶ Bases:
object
FitBase defines the interface from bumps models to the various fitting engines available within bumps.
Each engine is defined in its own class with a specific set of attributes and methods.
The name attribute is the name of the optimizer. This is just a simple string.
The settings attribute is a list of pairs (name, default), where the names are defined as fields in FitOptions. A best attempt should be made to map the fit options for the optimizer to the standard fit options, since each of these becomes a new command line option when running bumps. If that is not possible, then a new option should be added to FitOptions. A plugin architecture might be appropriate here, if there are reasons why specific problem domains might need custom fitters, but this is not yet supported.
Each engine takes a fit problem in its constructor.
The
solve()
method runs the fit. It accepts a monitor to track updates, a mapper to distribute work and key-value pairs defining the settings.There are a number of optional methods for the fitting engines. Basically, all the methods in
FitDriver
first check if they are specialized in the fit engine before performing a default action.The load/save methods load and save the fitter state in a given directory with a specific base file name. The fitter can choose a file extension to add to the base name. Some care is needed to be sure that the extension doesn’t collide with other extensions such as .mon for the fit monitor.
The plot method shows any plots to help understand the performance of the fitter, such as a convergence plot showing the the range of values in the population over time, as well as plots of the parameter uncertainty if available. The plot should work within is given a figure canvas to work with
The stderr/cov methods should provide summary statistics for the parameter uncertainties. Some fitters, such as MCMC, will compute these directly from the population. Others, such as BFGS, will produce an estimate of the uncertainty as they go along. If the fitter does not provide these estimates, then they will be computed from numerical derivatives at the minimum in the FitDriver method.
-
class
bumps.fitters.
FitDriver
(fitclass=None, problem=None, monitors=None, abort_test=None, mapper=None, **options)[source]¶ Bases:
object
-
cov
()[source]¶ Return an estimate of the covariance of the fit.
Depending on the fitter and the problem, this may be computed from existing evaluations within the fitter, or from numerical differentiation around the minimum. The numerical differentiation will use the Hessian estimated from nllf. If the problem uses \(\chi^2/2\) as its nllf, then you may want to instead compute the covariance from the Jacobian:
J = lsqerror.jacobian(fitdriver.result[0]) cov = lsqerror.cov(J)
This should be faster and more accurate than the Hessian of nllf when you can use it.
-
-
class
bumps.fitters.
LevenbergMarquardtFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
Levenberg-Marquardt optimizer.
-
id
= 'lm'¶
-
name
= 'Levenberg-Marquardt'¶
-
settings
= [('steps', 200), ('ftol', 1.5e-08), ('xtol', 1.5e-08)]¶
-
-
class
bumps.fitters.
MonitorRunner
(monitors, problem)[source]¶ Bases:
object
Adaptor which allows solvers to accept progress monitors.
-
class
bumps.fitters.
MultiStart
(fitter)[source]¶ Bases:
bumps.fitters.FitBase
Multi-start monte carlo fitter.
This fitter wraps a local optimizer, restarting it a number of times to give it a chance to find a different local minimum. If the keep_best option is True, then restart near the best fit, otherwise restart at random.
-
name
= 'Multistart Monte Carlo'¶
-
settings
= [('starts', 100)]¶
-
-
class
bumps.fitters.
PSFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
Particle swarm optimizer.
-
id
= 'ps'¶
-
name
= 'Particle Swarm'¶
-
settings
= [('steps', 3000), ('pop', 1)]¶
-
-
class
bumps.fitters.
PTFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
Parallel tempering optimizer.
-
id
= 'pt'¶
-
name
= 'Parallel Tempering'¶
-
settings
= [('steps', 400), ('nT', 24), ('CR', 0.9), ('burn', 100), ('Tmin', 0.1), ('Tmax', 10)]¶
-
-
class
bumps.fitters.
RLFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
Random lines optimizer.
-
id
= 'rl'¶
-
name
= 'Random Lines'¶
-
settings
= [('steps', 3000), ('starts', 20), ('pop', 0.5), ('CR', 0.9)]¶
-
-
class
bumps.fitters.
Resampler
(fitter)[source]¶ Bases:
bumps.fitters.FitBase
-
class
bumps.fitters.
SimplexFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
Nelder-Mead simplex optimizer.
-
id
= 'amoeba'¶
-
name
= 'Nelder-Mead Simplex'¶
-
settings
= [('steps', 1000), ('starts', 1), ('radius', 0.15), ('xtol', 1e-06), ('ftol', 1e-08)]¶
-
-
class
bumps.fitters.
SnobFit
(problem)[source]¶ Bases:
bumps.fitters.FitBase
-
id
= 'snobfit'¶
-
name
= 'SNOBFIT'¶
-
settings
= [('steps', 200)]¶
-
-
class
bumps.fitters.
StepMonitor
(problem, fid, fields=['step', 'time', 'value', 'point'])[source]¶ Bases:
bumps.monitor.Monitor
Collect information at every step of the fit and save it to a file.
fid is the file to save the information to fields is the list of “step|time|value|point” fields to save
The point field should be last in the list.
-
FIELDS
= ['step', 'time', 'value', 'point']¶
-