BornAgain  1.18.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 scattering at grazing incidence
4 //
5 //! @file Fit/RootAdapter/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 #ifndef BORNAGAIN_FIT_ROOTADAPTER_GENETICMINIMIZER_H
16 #define BORNAGAIN_FIT_ROOTADAPTER_GENETICMINIMIZER_H
17 
19 
20 namespace ROOT
21 {
22 namespace Math
23 {
24 class GeneticMinimizer;
25 }
26 } // namespace ROOT
27 
28 //! Wrapper for the CERN ROOT Genetic minimizer.
29 //! @ingroup fitting_internal
30 
32 {
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 
67  using RootMinimizerAdapter::setParameter;
68  void setParameter(unsigned int index, const Fit::Parameter& par) override;
69 
70 private:
71  std::unique_ptr<ROOT::Math::GeneticMinimizer> m_genetic_minimizer;
72 };
73 
74 #endif // BORNAGAIN_FIT_ROOTADAPTER_GENETICMINIMIZER_H
Declares class RootMinimizerAdapter.
A fittable parameter with value, error, step, and limits.
Definition: Parameter.h:28
Wrapper for the CERN ROOT Genetic minimizer.
void setTolerance(double value)
Sets tolerance on the function value at the minimum.
void setPopulationSize(int value)
Sets population size.
std::map< std::string, std::string > statusMap() const override
Returns map of string representing different minimizer statuses.
std::string statusToString() const override
Returns string representation of current minimizer status.
void setPrintLevel(int value)
Sets minimizer internal print level.
void setRandomSeed(int value)
Sets random seed.
void setMaxIterations(int value)
Sets maximum number of iterations to try at each step.
Pure virtual interface that adapts the CERN ROOT minimizer to our IMinimizer.