Investigate FitSuite refactoring in the context of external minimizer
|Status:||Resolved||Start date:||11 Apr 2018|
|Target version:||Sprint 37|
- Rearrange BornAgain fit machinery so it could support external minimizers (i.e. lmfit).
- Make switch between external/internal minimizers as painless as possible.
- Provide the possibility to use our internal minimizer for BornAgain unrelated tasks.
Ideally, BornAgain own minimization engine should not have any access to address space inside a Simulation.
Values of parameters to minimize should be propagated from the minimizer to a kind of SimulationBuilder via dictionaries.
Within this item consider the following:
- Expose MinimizerKernel to Python.
- Make FitSuite interface look similar to lmfit.
- Consider dropping of translation mechanism in GUI in the favor of SimulationBuilder leaving in GUI.
- Consider dropping of IParameterized::registerParameter machinery, onChange() signaling etc.
- #2018 Revise RealDataItem and the way it handles cropped experimental data.
- #2014 Provide uniform access interface for simulation/fitting results.
- #2011 API changes to access the simulation results.
- #1675 Get rid of ctypes.addressof in PySampleBuilder.
- #1918 Revise IHistogram class family.
- #1754 Investigate fitting with Log-Likelihood.
- #1704 Revise chi squared module.
- #1495 GUI: extend GUISuite functional test machinery with standard fits.
- #1494 GUI: Implement export of fitting setup to python script.
- #1493 GUI: Implement tranform from domain for fitting objects.
- #1415 onChange() should invalidate cache, and not immediately execute precompute().
- #1210 GSLLMA minimizer sometimes doesn't respect fit parameter limits attribute.
- #587 Investigate objective function alternatives.
#2 Updated by pospelov almost 2 years ago
Suggested goals for the future refactoring:
- Get rid from bulky FitSuite/SampleBuilder part of the minimizer machinery.
- Provide interface which looks "more or less" like in other minimizers.
- Make possible the usage of external minimizers.
- Promote user experiments in the direction leading away from BornAgain fitting kernel.
Steps for this release:¶
1) Make BornAgain minimizer interface look similar to lmfit.¶
It will consist of three thin classes: Parameter, Parameters and Minimizer
- Parameter class
- Describes single fit parameter, looks very much as current IFitParameter.
- It's Python constructor (or counterpart) should look like lmfit.Parameter.
- Parameters class
- Just a container with all fit parameters.
- Capable of generating dictionary (name : value) to feed user FCN functions.
- Minimizer class
- Internally it will contain our current FitKernel.
- It will accept user fcn function (or Python callback).
- FCN function should accept simple parameter dictionary (name : current_value) and allways return vector of residuals.
- Minimizer will either calculate chi2 from FCN residuals, or use residuals directly.
parameters = Parameters() parameters.add("length", 5.0, RealLimits.limited()) minimizer = Minimizer() minimizer.setOptions("Minuit2", "Migrad", "maxIterations=5") minimizer.minimize(parameters, fcn)
2) Switch FitSuite to the new Minimizer class.¶
- FitParameter will remain the same as it is now, but will have no relations to the refactored Minimizer's Parameter.
- FitSuite interface will remain the same for the moment (to keep GUI alive).
- FitKernel will be removed from class members.
- FitSuite will have an FCN function on board, whose task will be to propagate current parameter dictionary to old FitParameter to trigger linked parameter mechanism.
3) Remove FitSuite from all Python examples/tutorials.¶
- Python examples should rely on our new Minimizer and/or lmfit.
- Remove all description of linked parameters, FitSuite and SampleBuilder from tutorials.
Steps for the next release:¶
- Implement FCN function in GUI and use refactored Minimizer instead of FitSuite.
- Eliminate all traces of translation mechanism.
- Provide ExportToPython in GUI.
- Provide ExportToPython in GUI for fitting jobs.
- In princile, IParameterized, ParameterPool, SampleBuilder in Python, etc are getting useless and can be removed.