File indexing completed on 2025-12-16 10:29:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef ROOT_Math_BasicMinimizer
0015 #define ROOT_Math_BasicMinimizer
0016
0017 #include "Math/Minimizer.h"
0018
0019
0020 #include "Math/IFunctionfwd.h"
0021
0022 #include "Math/IParamFunctionfwd.h"
0023
0024 #include "Math/MinimTransformVariable.h"
0025
0026
0027 #include <vector>
0028 #include <map>
0029 #include <string>
0030
0031
0032
0033 namespace ROOT {
0034
0035 namespace Math {
0036
0037 class MinimTransformFunction;
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 class BasicMinimizer : public ROOT::Math::Minimizer {
0055
0056 public:
0057
0058
0059
0060
0061 BasicMinimizer ( );
0062
0063
0064
0065
0066
0067 ~BasicMinimizer () override;
0068
0069
0070 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
0071
0072
0073 bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) override;
0074
0075
0076
0077 bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower ) override;
0078
0079 bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper ) override;
0080
0081 bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double , double ) override;
0082
0083 bool SetFixedVariable(unsigned int , const std::string & , double ) override;
0084
0085 bool SetVariableValue(unsigned int ivar, double val ) override;
0086
0087 bool SetVariableValues(const double * x) override;
0088
0089 bool SetVariableStepSize(unsigned int ivar, double step ) override;
0090
0091 bool SetVariableLowerLimit(unsigned int ivar, double lower) override;
0092
0093 bool SetVariableUpperLimit(unsigned int ivar, double upper) override;
0094
0095 bool SetVariableLimits(unsigned int ivar, double lower, double upper) override;
0096
0097 bool FixVariable(unsigned int ivar) override;
0098
0099 bool ReleaseVariable(unsigned int ivar) override;
0100
0101
0102 bool IsFixedVariable(unsigned int ivar) const override;
0103
0104 bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings & varObj) const override;
0105
0106 std::string VariableName(unsigned int ivar) const override;
0107
0108
0109 int VariableIndex(const std::string & name) const override;
0110
0111
0112 bool Minimize() override;
0113
0114
0115 double MinValue() const override { return fMinVal; }
0116
0117
0118 const double * X() const override { return &fValues.front(); }
0119
0120
0121 unsigned int NDim() const override { return fDim; }
0122
0123
0124 unsigned int NFree() const override;
0125
0126
0127 virtual unsigned int NPar() const { return fValues.size(); }
0128
0129
0130 const ROOT::Math::IMultiGenFunction * ObjFunction() const { return fObjFunc; }
0131
0132
0133 const ROOT::Math::IMultiGradFunction * GradObjFunction() const;
0134
0135
0136
0137 void PrintResult() const;
0138
0139
0140 virtual const double * StepSizes() const { return &fSteps.front(); }
0141
0142 protected:
0143
0144 bool CheckDimension() const;
0145
0146 bool CheckObjFunction() const;
0147
0148 MinimTransformFunction * CreateTransformation(std::vector<double> & startValues, const ROOT::Math::IMultiGradFunction * func = nullptr);
0149
0150 void SetFinalValues(const double * x, const MinimTransformFunction * func = nullptr);
0151
0152 void SetMinValue(double val) { fMinVal = val; }
0153
0154 private:
0155
0156
0157 unsigned int fDim;
0158
0159 const ROOT::Math::IMultiGenFunction * fObjFunc;
0160
0161 double fMinVal;
0162 std::vector<double> fValues;
0163 std::vector<double> fSteps;
0164 std::vector<std::string> fNames;
0165 std::vector<ROOT::Math::EMinimVariableType> fVarTypes;
0166 std::map< unsigned int, std::pair<double, double> > fBounds;
0167
0168 };
0169
0170 }
0171
0172 }
0173
0174
0175
0176 #endif