# parameters.h

    00001 /*
    00002     This library is free software; you can redistribute it and/or modify
    00003     it under the terms of the GNU General Public License as published by
    00004     the Free Software Foundation; either version 2 of the License, or
    00005     (at your option) any later version.
    00006
    00007     This library is distributed in the hope that it will be useful,
    00008     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00009     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00010     Lesser General Public License for more details.
    00011
    00012     You should have received a copy of the GNU General Public License
    00013     along with this library; if not, write to the Free Software
    00014     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00015
    00016     Contact: todos@geneura.ugr.es, http://geneura.ugr.es
    00017              jeggermo@liacs.nl
    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;      // -G
    00031                         unsigned population_size;       // -P
    00032                         unsigned offspring_size;        // -O
    00033                         unsigned int MaxSize;           // -S
    00034                         unsigned int InitMaxDepth;      // -D
    00035                         unsigned int randomseed;        // -R
    00036                         double xover_rate;              // -x
    00037                         double mutation_rate;           // -y
    00038                         unsigned int tournamentsize;    // -t
    00039
    00040
    00041                         Parameters(int argc, char **argv)
    00042                         {
    00043                                 eoParser parser(argc,argv);
    00044
    00045                                 // generations
    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                                 // populationsize
    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                                 // offspringsize
    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                                 // maxsize
    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                                 // initialmaxdepth
    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                                 // randomseed
    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                                 // crossover-rate
    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                                 //mutation-rate
    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                                 //tournament size
    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