File indexing completed on 2025-01-18 10:10:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_Math_GeneticMinimizer
0013 #define ROOT_Math_GeneticMinimizer
0014
0015 #include "Math/Minimizer.h"
0016
0017 #include "RtypesCore.h"
0018
0019 #include <vector>
0020 #include <string>
0021
0022 namespace TMVA {
0023 class IFitterTarget;
0024 class Interval;
0025 }
0026
0027 namespace ROOT {
0028 namespace Math {
0029
0030
0031
0032
0033
0034
0035 struct GeneticMinimizerParameters {
0036
0037 Int_t fPopSize;
0038 Int_t fNsteps;
0039 Int_t fCycles;
0040 Int_t fSC_steps;
0041 Int_t fSC_rate;
0042 Double_t fSC_factor;
0043 Double_t fConvCrit;
0044 Int_t fSeed;
0045
0046
0047
0048 GeneticMinimizerParameters();
0049 };
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 class GeneticMinimizer: public ROOT::Math::Minimizer {
0062
0063 public:
0064
0065
0066 GeneticMinimizer (int i = 0);
0067 ~GeneticMinimizer () override;
0068
0069 void Clear() override;
0070 using ROOT::Math::Minimizer::SetFunction;
0071 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
0072
0073 bool SetLimitedVariable(unsigned int , const std::string& , double , double , double, double) override;
0074 bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) override;
0075 bool SetFixedVariable(unsigned int ivar , const std::string & name , double val) override;
0076
0077 bool Minimize() override;
0078 double MinValue() const override;
0079 double Edm() const override;
0080 const double * X() const override;
0081 const double * MinGradient() const override;
0082 unsigned int NCalls() const override;
0083
0084 unsigned int NDim() const override;
0085 unsigned int NFree() const override;
0086
0087 bool ProvidesError() const override;
0088 const double * Errors() const override;
0089
0090 double CovMatrix(unsigned int i, unsigned int j) const override;
0091
0092 void SetParameters(const GeneticMinimizerParameters & params );
0093
0094 void SetRandomSeed(int seed) { fParameters.fSeed = seed; }
0095
0096 const GeneticMinimizerParameters & MinimizerParameters() const { return fParameters; }
0097
0098 ROOT::Math::MinimizerOptions Options() const override;
0099
0100 virtual void SetOptions(const ROOT::Math::MinimizerOptions & opt);
0101
0102 protected:
0103
0104 void GetGeneticOptions(ROOT::Math::MinimizerOptions & opt) const;
0105
0106 std::vector<TMVA::Interval*> fRanges;
0107 TMVA::IFitterTarget* fFitness;
0108 double fMinValue;
0109 std::vector<double> fResult;
0110
0111 GeneticMinimizerParameters fParameters;
0112
0113 };
0114
0115
0116 }
0117 }
0118
0119 #endif