BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MinimizerItem.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Job/MinimizerItem.h
6 //! @brief Defines MinimizerItem class
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_GUI_MODEL_JOB_MINIMIZERITEM_H
16 #define BORNAGAIN_GUI_MODEL_JOB_MINIMIZERITEM_H
17 
22 #include <variant>
23 
24 class IMinimizer;
25 class ObjectiveMetric;
26 
28  QList<std::variant<DoubleDescriptor, UIntDescriptor, SelectionDescriptor<QString>>>;
29 
30 //! The MinimizerItem class is the base item to hold minimizer settings.
31 
32 class BA_CORE_API_ MinimizerItem : public SessionItem {
33 public:
34  virtual std::unique_ptr<IMinimizer> createMinimizer() const = 0;
35 
36  virtual ValueDescriptors valueDescriptorsForUI() const { return {}; }
37 
38 protected:
39  explicit MinimizerItem(const QString& model_type);
40 };
41 
42 //! The MinimizerContainerItem class holds collection of minimizers.
43 
45 private:
46  static constexpr auto P_MINIMIZERS{"Minimizer"};
47  static constexpr auto P_METRIC{"Objective metric"};
48  static constexpr auto P_NORM{"Norm function"};
49 
50 public:
51  static constexpr auto M_TYPE{"MinimizerContainer"};
52 
54 
58 
59  std::unique_ptr<IMinimizer> createMinimizer() const override;
60  std::unique_ptr<ObjectiveMetric> createMetric() const;
61 };
62 
63 //! The MinuitMinimizerItem class represents settings for ROOT Minuit2 minimizer.
64 
66 private:
67  static constexpr auto P_ALGORITHMS{"Algorithms"};
68  static constexpr auto P_STRATEGY{"Strategy"};
69  static constexpr auto P_ERRORDEF{"ErrorDef"};
70  static constexpr auto P_TOLERANCE{"Tolerance"};
71  static constexpr auto P_PRECISION{"Precision"};
72  static constexpr auto P_MAXFUNCTIONCALLS{"MaxFunctionCalls"};
73 
74 public:
75  static constexpr auto M_TYPE{"Minuit2"};
76 
78  std::unique_ptr<IMinimizer> createMinimizer() const override;
79  ValueDescriptors valueDescriptorsForUI() const override;
80 };
81 
82 //! The GSLMinimizerItem class represents settings for GSL MultiMin minimizer family.
83 
85 private:
86  static constexpr auto P_ALGORITHMS{"Algorithms"};
87  static constexpr auto P_MAXITERATIONS{"MaxIterations"};
88 
89 public:
90  static constexpr auto M_TYPE{"GSLMultiMin"};
91 
93  std::unique_ptr<IMinimizer> createMinimizer() const override;
94  ValueDescriptors valueDescriptorsForUI() const override;
95 };
96 
97 //! The GeneticMinimizerItem class represents settings for TMVA/Genetic minimizer.
98 
100 private:
101  static constexpr auto P_TOLERANCE{"Tolerance"};
102  static constexpr auto P_MAXITERATIONS{"MaxIterations"};
103  static constexpr auto P_POPULATIONSIZE{"PopSize"};
104  static constexpr auto P_RANDOMSEED{"RandomSeed"};
105 
106 public:
107  static constexpr auto M_TYPE{"Genetic"};
108 
110  std::unique_ptr<IMinimizer> createMinimizer() const override;
111  ValueDescriptors valueDescriptorsForUI() const override;
112 };
113 
114 //! The SimAnMinimizerItem class represents settings for GSL's simulated annealing minimizer.
115 
117 private:
118  static constexpr auto P_MAXITERATIONS{"MaxIterations"};
119  static constexpr auto P_ITERATIONSTEMP{"IterationsAtTemp"};
120  static constexpr auto P_STEPSIZE{"StepSize"};
121  static constexpr auto P_BOLTZMANN_K{"k"};
122  static constexpr auto P_BOLTZMANN_TINIT{"t_init"};
123  static constexpr auto P_BOLTZMANN_MU{"mu"};
124  static constexpr auto P_BOLTZMANN_TMIN{"t_min"};
125 
126 public:
127  static constexpr auto M_TYPE{"GSLSimAn"};
128 
130 
131  std::unique_ptr<IMinimizer> createMinimizer() const override;
132  ValueDescriptors valueDescriptorsForUI() const override;
133 };
134 
135 //! The GSLLMAMinimizerItem class represents settings for GSL's version of Levenberg-Marquardt.
136 
138 private:
139  static constexpr auto P_TOLERANCE{"Tolerance"};
140  static constexpr auto P_MAXITERATIONS{"MaxIterations"};
141 
142 public:
143  static constexpr auto M_TYPE{"GSLLMA"};
144 
146  std::unique_ptr<IMinimizer> createMinimizer() const override;
147  ValueDescriptors valueDescriptorsForUI() const override;
148 };
149 
150 #endif // BORNAGAIN_GUI_MODEL_JOB_MINIMIZERITEM_H
Defines class DoubleDescriptor.
QList< std::variant< DoubleDescriptor, UIntDescriptor, SelectionDescriptor< QString > >> ValueDescriptors
Definition: MinimizerItem.h:28
Defines class SelectionDescriptor.
Defines class SessionItem.
Defines class UIntDescriptor.
The GSLLMAMinimizerItem class represents settings for GSL's version of Levenberg-Marquardt.
std::unique_ptr< IMinimizer > createMinimizer() const override
static constexpr auto P_TOLERANCE
ValueDescriptors valueDescriptorsForUI() const override
static constexpr auto P_MAXITERATIONS
static constexpr auto M_TYPE
The GSLMinimizerItem class represents settings for GSL MultiMin minimizer family.
Definition: MinimizerItem.h:84
std::unique_ptr< IMinimizer > createMinimizer() const override
static constexpr auto M_TYPE
Definition: MinimizerItem.h:90
static constexpr auto P_ALGORITHMS
Definition: MinimizerItem.h:86
static constexpr auto P_MAXITERATIONS
Definition: MinimizerItem.h:87
ValueDescriptors valueDescriptorsForUI() const override
The GeneticMinimizerItem class represents settings for TMVA/Genetic minimizer.
Definition: MinimizerItem.h:99
static constexpr auto P_RANDOMSEED
static constexpr auto M_TYPE
std::unique_ptr< IMinimizer > createMinimizer() const override
ValueDescriptors valueDescriptorsForUI() const override
static constexpr auto P_TOLERANCE
static constexpr auto P_MAXITERATIONS
static constexpr auto P_POPULATIONSIZE
The MinimizerContainerItem class holds collection of minimizers.
Definition: MinimizerItem.h:44
SelectionDescriptor< QString > objectiveMetric() const
static constexpr auto M_TYPE
Definition: MinimizerItem.h:51
static constexpr auto P_METRIC
Definition: MinimizerItem.h:47
static constexpr auto P_NORM
Definition: MinimizerItem.h:48
static constexpr auto P_MINIMIZERS
Definition: MinimizerItem.h:46
SelectionDescriptor< MinimizerItem * > minimizers() const
std::unique_ptr< IMinimizer > createMinimizer() const override
std::unique_ptr< ObjectiveMetric > createMetric() const
SelectionDescriptor< QString > normFunction() const
The MinimizerItem class is the base item to hold minimizer settings.
Definition: MinimizerItem.h:32
virtual std::unique_ptr< IMinimizer > createMinimizer() const =0
virtual ValueDescriptors valueDescriptorsForUI() const
Definition: MinimizerItem.h:36
The MinuitMinimizerItem class represents settings for ROOT Minuit2 minimizer.
Definition: MinimizerItem.h:65
static constexpr auto M_TYPE
Definition: MinimizerItem.h:75
static constexpr auto P_TOLERANCE
Definition: MinimizerItem.h:70
static constexpr auto P_MAXFUNCTIONCALLS
Definition: MinimizerItem.h:72
static constexpr auto P_PRECISION
Definition: MinimizerItem.h:71
static constexpr auto P_ALGORITHMS
Definition: MinimizerItem.h:67
std::unique_ptr< IMinimizer > createMinimizer() const override
ValueDescriptors valueDescriptorsForUI() const override
static constexpr auto P_STRATEGY
Definition: MinimizerItem.h:68
static constexpr auto P_ERRORDEF
Definition: MinimizerItem.h:69
Describes a selection (various possibilities and the current one).
Base class for a GUI data item.
Definition: SessionItem.h:204
The SimAnMinimizerItem class represents settings for GSL's simulated annealing minimizer.
static constexpr auto P_BOLTZMANN_TINIT
ValueDescriptors valueDescriptorsForUI() const override
static constexpr auto P_BOLTZMANN_MU
static constexpr auto M_TYPE
static constexpr auto P_ITERATIONSTEMP
static constexpr auto P_BOLTZMANN_TMIN
std::unique_ptr< IMinimizer > createMinimizer() const override
static constexpr auto P_BOLTZMANN_K
static constexpr auto P_MAXITERATIONS
static constexpr auto P_STEPSIZE