This executable gives an example of a very simple use of the genetic algorithm of TMVA.
- Project : TMVA - a Root-integrated toolkit for multivariate data analysis
- Package : TMVA
- Executable: TMVAGAexample
Start Test TMVAGAexample
========================
EXAMPLE
range: 0 15
range: 0 13
range: 0 5
FitterBase : <GeneticFitter> Optimisation, please be patient ... (inaccurate progress timing for GA)
: Elapsed time: 0.0113 sec
FACTOR 0 : 15
FACTOR 1 : 13
FACTOR 2 : 0
#include <iostream>
#include <vector>
using namespace std;
class MyFitness : public IFitterTarget {
public:
MyFitness() : IFitterTarget() {
}
Double_t EstimatorFunction( std::vector<Double_t> & factors ){
return (10.- factors.at(0) *factors.at(1) + factors.at(2));
}
};
void exampleGA(){
std::cout << "\nEXAMPLE" << std::endl;
vector<Interval*> ranges;
ranges.push_back( new Interval(0,15,30) );
ranges.push_back( new Interval(0,13) );
ranges.push_back( new Interval(0,5,3) );
for( std::vector<Interval*>::iterator it = ranges.begin(); it != ranges.end(); it++ ){
std::cout << " range: " << (*it)->GetMin() << " " << (*it)->GetMax() << std::endl;
}
IFitterTarget* myFitness = new MyFitness();
const TString opts(
"PopSize=100:Steps=30" );
GeneticFitter mg( *myFitness,
name, ranges, opts);
for( std::vector<Double_t>::iterator it =
result.begin(); it<
result.end(); it++ ){
std::cout <<
"FACTOR " <<
n <<
" : " << (*it) << std::endl;
}
}
}
void TMVAGAexample2() {
cout << "Start Test TMVAGAexample" << endl
<< "========================" << endl
<< endl;
TMVA::exampleGA();
}
int main(
int argc,
char** argv )
{
TMVAGAexample2();
return 0;
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
create variable transformations
- Author
- Andreas Hoecker
Definition in file TMVAGAexample2.C.