00001 // @(#)root/tmva $Id: GeneticFitter.h 20882 2007-11-19 11:31:26Z rdm $ 00002 // Author: Peter Speckmayer 00003 00004 /********************************************************************************** 00005 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * 00006 * Package: TMVA * 00007 * Class : GeneticFitter * 00008 * Web : http://tmva.sourceforge.net * 00009 * * 00010 * Description: * 00011 * Fitter using a Genetic Algorithm * 00012 * * 00013 * Authors (alphabetical): * 00014 * Peter Speckmayer <speckmay@mail.cern.ch> - CERN, Switzerland * 00015 * * 00016 * Copyright (c) 2005: * 00017 * CERN, Switzerland * 00018 * MPI-K Heidelberg, Germany * 00019 * * 00020 * Redistribution and use in source and binary forms, with or without * 00021 * modification, are permitted according to the terms listed in LICENSE * 00022 * (http://tmva.sourceforge.net/LICENSE) * 00023 **********************************************************************************/ 00024 00025 #ifndef ROOT_TMVA_GeneticFitter 00026 #define ROOT_TMVA_GeneticFitter 00027 00028 ////////////////////////////////////////////////////////////////////////// 00029 // // 00030 // GeneticFitter // 00031 // // 00032 // Fitter using a Genetic Algorithm // 00033 // // 00034 ////////////////////////////////////////////////////////////////////////// 00035 00036 #ifndef ROOT_TMVA_FitterBase 00037 #include "TMVA/FitterBase.h" 00038 #endif 00039 00040 namespace TMVA { 00041 00042 class IFitterTarget; 00043 class Interval; 00044 00045 class GeneticFitter : public FitterBase { 00046 00047 public: 00048 00049 GeneticFitter( IFitterTarget& target, const TString& name, 00050 const std::vector<TMVA::Interval*>& ranges, const TString& theOption ); 00051 00052 virtual ~GeneticFitter() {} 00053 00054 void SetParameters( Int_t cycles, 00055 Int_t nsteps, 00056 Int_t popSize, 00057 Int_t SC_steps, 00058 Int_t SC_rate, 00059 Double_t SC_factor, 00060 Double_t convCrit ); 00061 00062 Double_t Run( std::vector<Double_t>& pars ); 00063 00064 Double_t NewFitness( Double_t oldF, Double_t newF ) { return oldF + newF; } 00065 00066 private: 00067 00068 void DeclareOptions(); 00069 00070 Int_t fCycles; // number of (nearly) independent calculation cycles 00071 Int_t fNsteps; // convergence criteria: if no improvements > fConvCrit was achieved within the last fNsteps: cycle has "converged" 00072 Int_t fPopSize; // number of individuals to start with 00073 Int_t fSC_steps; // regulates how strong the mutations for the coordinates are: if within fSC_steps there were more than... 00074 Int_t fSC_rate; // ... fSC_rate improvements, than multiply the sigma of the gaussion which defines how the random numbers are generated ... 00075 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 00076 Double_t fConvCrit; // improvements bigger than fConvCrit are counted as "improvement" 00077 Int_t fSaveBestFromGeneration; // store the best individuals from one generation (these are included as "hints" in the last cycle of GA calculation) 00078 Int_t fSaveBestFromCycle; // store the best individuals from one cycle (these are included as "hints" in the last cycle of GA calculation) 00079 Bool_t fTrim; // take care, that the number of individuals is less fPopSize (trimming is done after the fitness of the individuals is assessed) 00080 UInt_t fSeed; // Seed for the random generator (0 takes random seeds) 00081 00082 ClassDef(GeneticFitter,0) // Fitter using a Genetic Algorithm 00083 }; 00084 00085 } // namespace TMVA 00086 00087 #endif 00088 00089