00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _PARAMETERS_FUNCTION_H
00021 #define _PARAMETERS_FUNCTION_H
00022
00023 #include <gp/eoParseTree.h>
00024 #include <eo>
00025
00026 using namespace gp_parse_tree;
00027 using namespace std;
00028
00029 struct Parameters{
00030 unsigned int nGenerations;
00031 unsigned population_size;
00032 unsigned offspring_size;
00033 unsigned int MaxSize;
00034 unsigned int InitMaxDepth;
00035 unsigned int randomseed;
00036 double xover_rate;
00037 double mutation_rate;
00038 unsigned int tournamentsize;
00039
00040
00041 Parameters(int argc, char **argv)
00042 {
00043 eoParser parser(argc,argv);
00044
00045
00046 eoValueParam<unsigned int> paramGenerations(1, "generations", "Generations", 'G', false);
00047 parser.processParam( paramGenerations );
00048 nGenerations = paramGenerations.value();
00049 cerr << "nGenerations= " << nGenerations << endl;
00050
00051
00052 eoValueParam<unsigned int> paramPopulationSize(10, "populationsize", "PopulationSize", 'P', false);
00053 parser.processParam( paramPopulationSize );
00054 population_size = paramPopulationSize.value();
00055 cerr << "population_size= " << population_size << endl;
00056
00057
00058 eoValueParam<unsigned int> paramOffspringSize(population_size, "offspringsize", "OffspringSize", 'O', false);
00059 parser.processParam( paramOffspringSize );
00060 offspring_size = paramOffspringSize.value();
00061 cerr << "offspring_size= " << offspring_size << endl;
00062
00063
00064 eoValueParam<unsigned int> paramMaxSize(15, "maxsize", "MaxSize", 'S', false);
00065 parser.processParam( paramMaxSize );
00066 MaxSize = paramMaxSize.value();
00067 cerr << "MaxSize= " << MaxSize << endl;
00068
00069
00070 eoValueParam<unsigned int> paramInitialMaxDepth(4, "initialmaxdepth", "InitialMaxDepth", 'D', false);
00071 parser.processParam( paramInitialMaxDepth );
00072 InitMaxDepth = paramInitialMaxDepth.value();
00073 cerr << "InitMaxDepth= " << InitMaxDepth << endl;
00074
00075
00076 eoValueParam<unsigned int> paramRandomSeed(1, "randomseed", "Random Seed", 'R', false);
00077 parser.processParam( paramRandomSeed );
00078 randomseed = paramRandomSeed.value();
00079 cerr << "randomseed= " << randomseed << endl;
00080
00081
00082
00083 eoValueParam<double> paramXover(0.75, "crossoverrate", "crossover rate", 'x', false);
00084 parser.processParam(paramXover );
00085 xover_rate = paramXover.value();
00086 cerr << "xover_rate= " << xover_rate << endl;
00087
00088
00089 eoValueParam<double> paramMutation(0.25, "mutationrate", "mutation rate", 'm', false);
00090 parser.processParam(paramMutation );
00091 mutation_rate = paramMutation.value();
00092 cerr << "mutation_rate= " << mutation_rate << endl;
00093
00094
00095 eoValueParam<unsigned int > paramTournamentSize(5, "tournamentsize", "tournament size", 't', false);
00096 parser.processParam(paramTournamentSize );
00097 tournamentsize = paramTournamentSize.value();
00098 cerr << "Tournament Size= " << tournamentsize << endl;
00099
00100
00101 if (parser.userNeedsHelp())
00102 {
00103 parser.printHelp(cout);
00104 exit(1);
00105 }
00106
00107 };
00108
00109 ~Parameters(){};
00110 };
00111
00112 #endif