This exectutable 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
- Exectuable: TMVAGAexample
0.0100378990173
3.77066087723
Processing /mnt/build/workspace/root-makedoc-v612/rootspi/rdoc/src/v6-12-00-patches/tutorials/tmva/TMVAGAexample2.C...
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.0321 sec
FACTOR 0 : 15
FACTOR 1 : 13
FACTOR 2 : 0
#include <iostream>
#include <vector>
public:
}
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,5,3) );
for( std::vector<Interval*>::iterator it = ranges.begin(); it != ranges.end(); it++ ){
std::cout << " range: " << (*it)->GetMin() << " " << (*it)->GetMax() << std::endl;
}
const TString
name(
"exampleGA" );
const TString opts( "PopSize=100:Steps=30" );
GeneticFitter
mg( *myFitness, name, ranges, opts);
std::vector<Double_t> result;
int n = 0;
for( std::vector<Double_t>::iterator it = result.begin(); it<result.end(); it++ ){
std::cout << "FACTOR " << n << " : " << (*it) << std::endl;
n++;
}
}
}
void TMVAGAexample2() {
cout << "Start Test TMVAGAexample" << endl
<< "========================" << endl
<< endl;
TMVA::exampleGA();
}
int main(
int argc,
char** argv )
{
TMVAGAexample2();
return 0;
}
- Author
- Andreas Hoecker
Definition in file TMVAGAexample2.C.