BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
GeneticMinimizer.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Fit/Adapter/GeneticMinimizer.h
6 //! @brief Declares class GeneticMinimizer.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_FIT_ADAPTER_GENETICMINIMIZER_H
21 #define BORNAGAIN_FIT_ADAPTER_GENETICMINIMIZER_H
22 
24 
25 namespace ROOT::Math {
26 class GeneticMinimizer;
27 }
28 
29 //! Wrapper for the CERN ROOT Genetic minimizer.
30 //! @ingroup fitting_internal
31 
33 public:
36 
37  //! Sets tolerance on the function value at the minimum.
38  //! Minimization will stop when the estimated vertical distance to the minimum (EDM) is less
39  //! than 0.001*tolerance*ErrorDef. Here ErrorDef=1.0 for chi squared fit and ErrorDef=0.5
40  //! for negative log likelihood fit.
41  void setTolerance(double value);
42  double tolerance() const;
43 
44  //! Sets minimizer internal print level.
45  void setPrintLevel(int value);
46  int printLevel() const;
47 
48  //! Sets maximum number of iterations to try at each step.
49  void setMaxIterations(int value);
50  int maxIterations() const;
51 
52  //! Sets population size.
53  void setPopulationSize(int value);
54  int populationSize() const;
55 
56  //! Sets random seed.
57  void setRandomSeed(int value);
58  int randomSeed() const;
59 
60  std::string statusToString() const override;
61  std::map<std::string, std::string> statusMap() const override;
62 
63 protected:
64  void propagateOptions() override;
65  const root_minimizer_t* rootMinimizer() const override;
66 
68  void setParameter(unsigned int index, const mumufit::Parameter& par) override;
69 
70 private:
71  std::unique_ptr<ROOT::Math::GeneticMinimizer> m_genetic_minimizer;
72 };
73 
74 #endif // BORNAGAIN_FIT_ADAPTER_GENETICMINIMIZER_H
75 #endif // USER_API
Declares class MinimizerAdapter.
Wrapper for the CERN ROOT Genetic minimizer.
void setTolerance(double value)
Sets tolerance on the function value at the minimum.
int printLevel() const
double tolerance() const
void setPopulationSize(int value)
Sets population size.
virtual void setParameter(unsigned int index, const mumufit::Parameter &par)
std::unique_ptr< ROOT::Math::GeneticMinimizer > m_genetic_minimizer
std::map< std::string, std::string > statusMap() const override
Returns map of string representing different minimizer statuses.
const root_minimizer_t * rootMinimizer() const override
std::string statusToString() const override
Returns string representation of current minimizer status.
void propagateOptions() override
int randomSeed() const
void setPrintLevel(int value)
Sets minimizer internal print level.
void setRandomSeed(int value)
Sets random seed.
int populationSize() const
void setMaxIterations(int value)
Sets maximum number of iterations to try at each step.
int maxIterations() const
Abstract base class that adapts the CERN ROOT minimizer to our IMinimizer.
virtual void setParameter(unsigned int index, const mumufit::Parameter &par)
ROOT::Math::Minimizer root_minimizer_t
A fittable parameter with value, error, step, and limits.
Definition: Parameter.h:26