Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:59

0001 // @(#)root/tmva $Id$
0002 // Author: Peter Speckmayer
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : GeneticFitter                                                         *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *       Fitter using a Genetic Algorithm                                         *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Peter Speckmayer <speckmay@mail.cern.ch>  - CERN, Switzerland             *
0015  *                                                                                *
0016  * Copyright (c) 2005:                                                            *
0017  *      CERN, Switzerland                                                         *
0018  *      MPI-K Heidelberg, Germany                                                 *
0019  *                                                                                *
0020  * Redistribution and use in source and binary forms, with or without             *
0021  * modification, are permitted according to the terms listed in LICENSE           *
0022  * (see tmva/doc/LICENSE)                                          *
0023  **********************************************************************************/
0024 
0025 #ifndef ROOT_TMVA_GeneticFitter
0026 #define ROOT_TMVA_GeneticFitter
0027 
0028 //////////////////////////////////////////////////////////////////////////
0029 //                                                                      //
0030 // GeneticFitter                                                        //
0031 //                                                                      //
0032 // Fitter using a Genetic Algorithm                                     //
0033 //                                                                      //
0034 //////////////////////////////////////////////////////////////////////////
0035 
0036 #include "TMVA/FitterBase.h"
0037 #include <vector>
0038 
0039 namespace TMVA {
0040 
0041    class IFitterTarget;
0042    class Interval;
0043 
0044    class GeneticFitter : public FitterBase {
0045 
0046    public:
0047 
0048       GeneticFitter( IFitterTarget& target, const TString& name,
0049                      const std::vector<TMVA::Interval*>& ranges, const TString& theOption );
0050 
0051       virtual ~GeneticFitter() {}
0052 
0053       void SetParameters( Int_t cycles,
0054                           Int_t nsteps,
0055                           Int_t popSize,
0056                           Int_t SC_steps,
0057                           Int_t SC_rate,
0058                           Double_t SC_factor,
0059                           Double_t convCrit );
0060 
0061       Double_t Run( std::vector<Double_t>& pars );
0062 
0063       Double_t NewFitness( Double_t oldF, Double_t newF ) { return oldF + newF; }
0064 
0065    private:
0066 
0067       void DeclareOptions();
0068 
0069       Int_t fCycles;                    ///< number of (nearly) independent calculation cycles
0070       Int_t fNsteps;                    ///< convergence criteria: if no improvements > fConvCrit was achieved within the last fNsteps: cycle has "converged"
0071       Int_t fPopSize;                   ///< number of individuals to start with
0072       Int_t fSC_steps;                  ///< regulates how strong the mutations for the coordinates are: if within fSC_steps there were more than...
0073       Int_t fSC_rate;                   ///< ... fSC_rate improvements, than multiply the sigma of the gaussian which defines how the random numbers are generated ...
0074       Double_t fSC_factor;              ///< ... with fSC_factor; if there were less improvements: divide by that factor; if there were exactly fSC_rate improvements, dont change anything
0075       Double_t fConvCrit;               ///< improvements bigger than fConvCrit are counted as "improvement"
0076       Int_t fSaveBestFromGeneration;    ///< store the best individuals from one generation (these are included as "hints" in the last cycle of GA calculation)
0077       Int_t fSaveBestFromCycle;         ///< store the best individuals from one cycle (these are included as "hints" in the last cycle of GA calculation)
0078       Bool_t fTrim;                     ///< take care, that the number of individuals is less fPopSize (trimming is done after the fitness of the individuals is assessed)
0079       UInt_t fSeed;                     ///< Seed for the random generator (0 takes random seeds)
0080 
0081       ClassDef(GeneticFitter,0); // Fitter using a Genetic Algorithm
0082    };
0083 
0084 } // namespace TMVA
0085 
0086 #endif
0087 
0088