00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_TMVA_GeneticPopulation
00026 #define ROOT_TMVA_GeneticPopulation
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <string>
00037 #include <vector>
00038
00039 #ifndef ROOT_Riosfwd
00040 #include "Riosfwd.h"
00041 #endif
00042 #ifndef ROOT_TMVA_GeneticGenes
00043 #include "TMVA/GeneticGenes.h"
00044 #endif
00045 #ifndef ROOT_TMVA_Interval
00046 #include "TMVA/Interval.h"
00047 #endif
00048 #ifndef ROOT_TMVA_GeneticRange
00049 #include "TMVA/GeneticRange.h"
00050 #endif
00051
00052 class TH1F;
00053
00054 namespace TMVA {
00055
00056 class MsgLogger;
00057
00058 class GeneticPopulation {
00059
00060 public:
00061
00062 GeneticPopulation(const std::vector<TMVA::Interval*>& ranges, Int_t size, UInt_t seed = 0);
00063 virtual ~GeneticPopulation();
00064
00065 void SetRandomSeed( UInt_t seed = 0);
00066
00067 void MakeChildren();
00068 void Mutate( Double_t probability = 20, Int_t startIndex = 0, Bool_t near = kFALSE,
00069 Double_t spread = 0.1, Bool_t mirror = kFALSE );
00070
00071 GeneticGenes* GetGenes( Int_t index );
00072 Int_t GetPopulationSize() const { return fGenePool.size(); }
00073 Double_t GetFitness() const { return fGenePool.size()>0? fGenePool[0].GetFitness() : 0; }
00074
00075 const std::vector<TMVA::GeneticGenes>& GetGenePool() const { return fGenePool; }
00076 const std::vector<TMVA::GeneticRange*>& GetRanges() const { return fRanges; }
00077
00078 std::vector<TMVA::GeneticGenes>& GetGenePool() { return fGenePool; }
00079 std::vector<TMVA::GeneticRange*>& GetRanges() { return fRanges; }
00080
00081 void Print( Int_t untilIndex = -1 );
00082 void Print( ostream & out, Int_t utilIndex = -1 );
00083
00084 TH1F* VariableDistribution( Int_t varNumber, Int_t bins, Int_t min, Int_t max );
00085 std::vector< Double_t > VariableDistribution( Int_t varNumber );
00086
00087
00088
00089
00090
00091 void MakeCopies( int number );
00092 void NextGeneration() {}
00093 void AddPopulation( GeneticPopulation *strangers );
00094 void AddPopulation( GeneticPopulation &strangers );
00095 void TrimPopulation();
00096 void GiveHint( std::vector< Double_t >& hint, Double_t fitness = 0 );
00097 void Sort();
00098
00099 private:
00100 GeneticGenes MakeSex( GeneticGenes male, GeneticGenes female );
00101
00102 private:
00103
00104 std::vector<TMVA::GeneticGenes> fGenePool;
00105 std::vector<TMVA::GeneticRange*> fRanges;
00106
00107 TRandom3*fRandomGenerator;
00108
00109 mutable MsgLogger* fLogger;
00110 MsgLogger& Log() const { return *fLogger; }
00111
00112 Int_t fPopulationSizeLimit;
00113
00114 ClassDef(GeneticPopulation,0)
00115 };
00116
00117 }
00118
00119 #endif