Some changes in names, before too many users have to modify their code :-)
Changed es.h in src/es into make_es.h (was ambiguous with src/es.h) Changed the interface of make_genotype - now templatized by the EOT and not the fitness - this is mandatory for ES genoptypes as it allows to choose the type of gentype at run-time (from existing types, of course!) Also moved make_help.cpp into utils dir (otherwise you'd had to maintain a copy into each representation dir!).
This commit is contained in:
parent
1c75344197
commit
d90286d890
13 changed files with 53 additions and 140 deletions
|
|
@ -1,54 +0,0 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_help.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <utils/eoParser.h>
|
||||
#include <fstream.h>
|
||||
|
||||
/** Generation of the status file, and output of the help message if needed
|
||||
*
|
||||
* MUST be called after ALL parameters have been read in order to list them
|
||||
*
|
||||
* Warning: this is a plain .cpp file and shoudl NOT be included anywhere,
|
||||
* but compiled separately and stored in a library.
|
||||
*/
|
||||
void make_help(eoParser & _parser)
|
||||
{
|
||||
// name of the "status" file where all actual parameter values will be saved
|
||||
string str_status = _parser.ProgramName() + ".status"; // default value
|
||||
eoValueParam<string>& statusParam = _parser.createParam(str_status, "status","Status file",'\0', "Persistence" );
|
||||
|
||||
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
|
||||
// i.e. in case you need parameters somewhere else, postpone these
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(cout);
|
||||
exit(1);
|
||||
}
|
||||
if (statusParam.value() != "")
|
||||
{
|
||||
ofstream os(statusParam.value().c_str());
|
||||
os << _parser; // and you can use that file as parameter file
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
INCLUDES = -I$(top_builddir)/src
|
||||
lib_LIBRARIES = libes.a
|
||||
libes_a_SOURCES = make_algo_scalar_real.cpp make_checkpoint_real.cpp \
|
||||
make_continue_real.cpp make_genotype_real.cpp make_help.cpp \
|
||||
make_continue_real.cpp make_genotype_real.cpp \
|
||||
make_op_real.cpp make_pop_real.cpp make_run_real.cpp \
|
||||
make_algo_scalar_es.cpp make_checkpoint_es.cpp \
|
||||
make_continue_es.cpp make_pop_es.cpp make_run_es.cpp
|
||||
|
|
|
|||
132
eo/src/es/make_es.h
Normal file
132
eo/src/es/make_es.h
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// es.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** This file contains all ***INSTANCIATED*** declarations of all components
|
||||
* of the library for ***ES-like gnptype*** evolution inside EO.
|
||||
* It should be included in the file that calls any of the corresponding fns
|
||||
*
|
||||
* The corresponding ***INSTANCIATED*** definitions are contained in
|
||||
* the different .cpp files in the src/es dir,
|
||||
* while the TEMPLATIZED code is define in the different make_XXX.h files
|
||||
* either in hte src/do dir for representation independant functions,
|
||||
* or in the src/es dir for representation dependent stuff.
|
||||
*
|
||||
* See also real.h for the similar declarations of eoReal genotypes
|
||||
* i.e. ***without*** mutation parameters attached to individuals
|
||||
*
|
||||
* Unlike most EO .h files, it does not (and should not) contain any code,
|
||||
* just declarations
|
||||
*/
|
||||
|
||||
#ifndef es_h
|
||||
#define es_h
|
||||
|
||||
#include <eoAlgo.h>
|
||||
#include <eoScalarFitness.h>
|
||||
#include <utils/eoParser.h>
|
||||
#include <eoEvalFuncPtr.h>
|
||||
#include <eoEvalFuncCounter.h>
|
||||
#include <utils/eoCheckPoint.h>
|
||||
#include <eoGenOp.h>
|
||||
#include <eoPop.h>
|
||||
|
||||
#include <es/eoEsSimple.h> // one Sigma per individual
|
||||
#include <es/eoEsStdev.h> // one sigmal per object variable
|
||||
#include <es/eoEsFull.h> // full correlation matrix per indi
|
||||
|
||||
//Representation dependent - rewrite everything anew for each representation
|
||||
//////////////////////////
|
||||
|
||||
/*
|
||||
// the genotypes
|
||||
eoInit<eoEsSimple<double> > & make_genotype(eoParameterLoader& _parser, eoState& _state, double _d);
|
||||
eoInit<eoEsSimple<eoMinimizingFitness> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoMinimizingFitness _d);
|
||||
|
||||
// the operators
|
||||
eoGenOp<eoEsStdev<double> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoEsStdev<double> >& _init);
|
||||
eoGenOp<eoEsStdev<eoMinimizingFitness> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoEsStdev<eoMinimizingFitness> >& _init);
|
||||
*/
|
||||
|
||||
//Representation INdependent
|
||||
////////////////////////////
|
||||
// you don't need to modify that part even if you use your own representation
|
||||
|
||||
// init pop
|
||||
eoPop<eoEsSimple<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoEsSimple<double> >&);
|
||||
eoPop<eoEsSimple<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoEsSimple<eoMinimizingFitness> >&);
|
||||
|
||||
eoPop<eoEsStdev<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoEsStdev<double> >&);
|
||||
eoPop<eoEsStdev<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoEsStdev<eoMinimizingFitness> >&);
|
||||
|
||||
eoPop<eoEsFull<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoEsFull<double> >&);
|
||||
eoPop<eoEsFull<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoEsFull<eoMinimizingFitness> >&);
|
||||
|
||||
// the continue's
|
||||
eoContinue<eoEsSimple<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoEsSimple<double> > & _eval);
|
||||
eoContinue<eoEsSimple<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoEsSimple<eoMinimizingFitness> > & _eval);
|
||||
|
||||
eoContinue<eoEsStdev<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoEsStdev<double> > & _eval);
|
||||
eoContinue<eoEsStdev<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoEsStdev<eoMinimizingFitness> > & _eval);
|
||||
|
||||
eoContinue<eoEsFull<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoEsFull<double> > & _eval);
|
||||
eoContinue<eoEsFull<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoEsFull<eoMinimizingFitness> > & _eval);
|
||||
|
||||
// the checkpoint
|
||||
eoCheckPoint<eoEsSimple<double> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoEsSimple<double> >& _eval, eoContinue<eoEsSimple<double> >& _continue);
|
||||
eoCheckPoint<eoEsSimple<eoMinimizingFitness> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoEsSimple<eoMinimizingFitness> >& _eval, eoContinue<eoEsSimple<eoMinimizingFitness> >& _continue);
|
||||
|
||||
eoCheckPoint<eoEsStdev<double> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoEsStdev<double> >& _eval, eoContinue<eoEsStdev<double> >& _continue);
|
||||
eoCheckPoint<eoEsStdev<eoMinimizingFitness> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoEsStdev<eoMinimizingFitness> >& _eval, eoContinue<eoEsStdev<eoMinimizingFitness> >& _continue);
|
||||
|
||||
eoCheckPoint<eoEsFull<double> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoEsFull<double> >& _eval, eoContinue<eoEsFull<double> >& _continue);
|
||||
eoCheckPoint<eoEsFull<eoMinimizingFitness> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoEsFull<eoMinimizingFitness> >& _eval, eoContinue<eoEsFull<eoMinimizingFitness> >& _continue);
|
||||
|
||||
|
||||
// the algo
|
||||
eoAlgo<eoEsSimple<double> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoEsSimple<double> >& _eval, eoContinue<eoEsSimple<double> >& _ccontinue, eoGenOp<eoEsSimple<double> >& _op);
|
||||
eoAlgo<eoEsSimple<eoMinimizingFitness> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoEsSimple<eoMinimizingFitness> >& _eval, eoContinue<eoEsSimple<eoMinimizingFitness> >& _ccontinue, eoGenOp<eoEsSimple<eoMinimizingFitness> >& _op);
|
||||
|
||||
eoAlgo<eoEsStdev<double> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoEsStdev<double> >& _eval, eoContinue<eoEsStdev<double> >& _ccontinue, eoGenOp<eoEsStdev<double> >& _op);
|
||||
eoAlgo<eoEsStdev<eoMinimizingFitness> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoEsStdev<eoMinimizingFitness> >& _eval, eoContinue<eoEsStdev<eoMinimizingFitness> >& _ccontinue, eoGenOp<eoEsStdev<eoMinimizingFitness> >& _op);
|
||||
|
||||
eoAlgo<eoEsFull<double> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoEsFull<double> >& _eval, eoContinue<eoEsFull<double> >& _ccontinue, eoGenOp<eoEsFull<double> >& _op);
|
||||
eoAlgo<eoEsFull<eoMinimizingFitness> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoEsFull<eoMinimizingFitness> >& _eval, eoContinue<eoEsFull<eoMinimizingFitness> >& _ccontinue, eoGenOp<eoEsFull<eoMinimizingFitness> >& _op);
|
||||
|
||||
// run
|
||||
void run_ea(eoAlgo<eoEsSimple<double> >& _ga, eoPop<eoEsSimple<double> >& _pop);
|
||||
void run_ea(eoAlgo<eoEsSimple<eoMinimizingFitness> >& _ga, eoPop<eoEsSimple<eoMinimizingFitness> >& _pop);
|
||||
|
||||
void run_ea(eoAlgo<eoEsStdev<double> >& _ga, eoPop<eoEsStdev<double> >& _pop);
|
||||
void run_ea(eoAlgo<eoEsStdev<eoMinimizingFitness> >& _ga, eoPop<eoEsStdev<eoMinimizingFitness> >& _pop);
|
||||
|
||||
void run_ea(eoAlgo<eoEsFull<double> >& _ga, eoPop<eoEsFull<double> >& _pop);
|
||||
void run_ea(eoAlgo<eoEsFull<eoMinimizingFitness> >& _ga, eoPop<eoEsFull<eoMinimizingFitness> >& _pop);
|
||||
|
||||
// end of parameter input (+ .status + help)
|
||||
// that one is not templatized, but is here for completeness
|
||||
void make_help(eoParser & _parser);
|
||||
|
||||
#endif
|
||||
|
|
@ -30,23 +30,33 @@
|
|||
* files that you just need to link with your own main and fitness code).
|
||||
*
|
||||
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
|
||||
* in src/es/es.h
|
||||
* while the TEMPLATIZED code is define in make_genotype_real.h in the src/es dir
|
||||
* in src/es/make_real.h
|
||||
* while the TEMPLATIZED code is define in make_genotype_real.h
|
||||
*
|
||||
* Unlike most EO .h files, it does not (and should not) contain any code,
|
||||
* just declarations
|
||||
*/
|
||||
* It is instanciated in src/es/make_genotype_real.cpp -
|
||||
* and incorporated in the ga/libga.a
|
||||
*
|
||||
* It returns an eoInit<EOT> that can later be used to initialize
|
||||
* the population (see make_pop.h).
|
||||
*
|
||||
* It uses a parser (to get user parameters) and a state (to store the memory)
|
||||
* the last argument is to disambiguate the call upon different instanciations.
|
||||
*
|
||||
* WARNING: that last argument will generally be the result of calling
|
||||
* the default ctor of EOT, resulting in most cases in an EOT
|
||||
* that is ***not properly initialized***
|
||||
*/
|
||||
|
||||
// the templatized code
|
||||
#include <es/make_genotype.h>
|
||||
#include <es/make_genotype_real.h>
|
||||
|
||||
/// The following function merely call the templatized do_* functions
|
||||
|
||||
eoInit<eoReal<double> > & make_genotype(eoParameterLoader& _parser, eoState& _state, double _d)
|
||||
eoInit<eoReal<double> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoReal<double> _eo)
|
||||
{
|
||||
return do_make_genotype(_parser, _state, _d);
|
||||
return do_make_genotype(_parser, _state, _eo);
|
||||
}
|
||||
eoInit<eoReal<eoMinimizingFitness> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoMinimizingFitness _d)
|
||||
eoInit<eoReal<eoMinimizingFitness> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoReal<eoMinimizingFitness> _eo)
|
||||
{
|
||||
return do_make_genotype(_parser, _state, _d);
|
||||
return do_make_genotype(_parser, _state, _eo);
|
||||
}
|
||||
|
|
|
|||
98
eo/src/es/make_genotype_real.h
Normal file
98
eo/src/es/make_genotype_real.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_genotype.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _make_genotype_h
|
||||
#define _make_genotype_h
|
||||
|
||||
#include <es/eoReal.h>
|
||||
#include <eoRealInitBounded.h>
|
||||
// also need the parser and param includes
|
||||
#include <utils/eoParser.h>
|
||||
#include <utils/eoState.h>
|
||||
|
||||
|
||||
/*
|
||||
* This fuction does the initialization of what's needed for a particular
|
||||
* genotype (here, vector<double> == eoReal).
|
||||
* It could be here tempatied only on the fitness, as it can be used to evolve
|
||||
* bitstrings with any fitness.
|
||||
* However, for consistency reasons, it was finally chosen, as in
|
||||
* the rest of EO, to templatize by the full EOT, as this eventually
|
||||
* allows to choose the type of genotype at run time (see in es dir)
|
||||
*
|
||||
* It is instanciated in src/es/make_genotyupe_real.cpp
|
||||
* and incorporated in the src/es/libes.a
|
||||
*
|
||||
* It returns an eoInit<EOT> tha can later be used to initialize
|
||||
* the population (see make_pop.h).
|
||||
*
|
||||
* It uses a parser (to get user parameters) and a state (to store the memory)
|
||||
* the last argument is to disambiguate the call upon different instanciations.
|
||||
*
|
||||
* WARNING: that last argument will generally be the result of calling
|
||||
* the default ctor of EOT, resulting in most cases in an EOT
|
||||
* that is ***not properly initialized***
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
eoInit<EOT> & do_make_genotype(eoParameterLoader& _parser, eoState& _state, EOT)
|
||||
{
|
||||
// the fitness type
|
||||
typedef typename EOT::Fitness FitT;
|
||||
|
||||
// for eoReal, only thing needed is the size
|
||||
eoValueParam<unsigned>& vecSize = _parser.createParam(unsigned(10), "vecSize", "The number of variables ", 'n',"initialization");
|
||||
|
||||
// to build an eoReal Initializer, we need bounds
|
||||
eoValueParam<eoParamParamType>& boundsParam = _parser.createParam(eoParamParamType("(0,1)"), "initBounds", "Bounds for uniform initialization", 'B', "initialization");
|
||||
|
||||
eoParamParamType & ppBounds = boundsParam.value(); // pair<string,vector<string> >
|
||||
// transform into a vector<double>
|
||||
vector<double> v;
|
||||
vector<string>::iterator it;
|
||||
for (it=ppBounds.second.begin(); it<ppBounds.second.end(); it++)
|
||||
{
|
||||
istrstream is(it->c_str());
|
||||
double r;
|
||||
is >> r;
|
||||
v.push_back(r);
|
||||
}
|
||||
// now create the eoRealVectorBounds object
|
||||
eoRealVectorBounds * ptBounds = NULL;
|
||||
if (v.size() == 2) // a min and a max for all variables
|
||||
ptBounds = new eoRealVectorBounds(vecSize.value(), v[0], v[1]);
|
||||
else // no time now
|
||||
throw runtime_error("Sorry, only unique bounds for all variables implemented at the moment. Come back later");
|
||||
// we need to give ownership of this pointer to somebody
|
||||
|
||||
eoRealInitBounded<FitT> * init =
|
||||
new eoRealInitBounded<FitT>(*ptBounds);
|
||||
// satore in state
|
||||
_state.storeFunctor(init);
|
||||
return *init;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_help.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <utils/eoParser.h>
|
||||
#include <fstream.h>
|
||||
|
||||
/** Generation of the status file, and output of the help message if needed
|
||||
*
|
||||
* MUST be called after ALL parameters have been read in order to list them
|
||||
*
|
||||
* Warning: this is a plain .cpp file and shoudl NOT be included anywhere,
|
||||
* but compiled separately and stored in a library.
|
||||
*/
|
||||
void make_help(eoParser & _parser)
|
||||
{
|
||||
// name of the "status" file where all actual parameter values will be saved
|
||||
string str_status = _parser.ProgramName() + ".status"; // default value
|
||||
eoValueParam<string>& statusParam = _parser.createParam(str_status, "status","Status file",'\0', "Persistence" );
|
||||
|
||||
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
|
||||
// i.e. in case you need parameters somewhere else, postpone these
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(cout);
|
||||
exit(1);
|
||||
}
|
||||
if (statusParam.value() != "")
|
||||
{
|
||||
ofstream os(statusParam.value().c_str());
|
||||
os << _parser; // and you can use that file as parameter file
|
||||
}
|
||||
}
|
||||
100
eo/src/es/make_real.h
Normal file
100
eo/src/es/make_real.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// real.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** This file contains all ***INSTANCIATED*** declarations of all components
|
||||
* of the library for ***vector<RealValues>*** evolution inside EO.
|
||||
* It should be included in the file that calls any of the corresponding fns
|
||||
*
|
||||
* The corresponding ***INSTANCIATED*** definitions are contained in
|
||||
* the different .cpp files in the src/es dir,
|
||||
* while the TEMPLATIZED code is define in the different make_XXX.h files
|
||||
* either in hte src/do dir for representation independant functions,
|
||||
* or in the src/es dir for representation dependent stuff.
|
||||
*
|
||||
* See also es.h for the similar declarations of ES-like genotypes
|
||||
* i.e. ***with*** mutation parameters attached to individuals
|
||||
*
|
||||
* Unlike most EO .h files, it does not (and should not) contain any code,
|
||||
* just declarations
|
||||
*/
|
||||
|
||||
#ifndef real_h
|
||||
#define real_h
|
||||
|
||||
#include <eoAlgo.h>
|
||||
#include <eoScalarFitness.h>
|
||||
#include <utils/eoParser.h>
|
||||
#include <eoEvalFuncPtr.h>
|
||||
#include <eoEvalFuncCounter.h>
|
||||
#include <utils/eoCheckPoint.h>
|
||||
#include <eoGenOp.h>
|
||||
#include <eoPop.h>
|
||||
|
||||
#include <es/eoReal.h>
|
||||
|
||||
//Representation dependent - rewrite everything anew for each representation
|
||||
//////////////////////////
|
||||
|
||||
// the genotypes
|
||||
eoInit<eoReal<double> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoReal<double> _eo);
|
||||
eoInit<eoReal<eoMinimizingFitness> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoReal<eoMinimizingFitness> _eo);
|
||||
|
||||
// the operators
|
||||
eoGenOp<eoReal<double> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoReal<double> >& _init);
|
||||
eoGenOp<eoReal<eoMinimizingFitness> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoReal<eoMinimizingFitness> >& _init);
|
||||
|
||||
//Representation INdependent
|
||||
////////////////////////////
|
||||
// you don't need to modify that part even if you use your own representation
|
||||
|
||||
// init pop
|
||||
eoPop<eoReal<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoReal<double> >&);
|
||||
eoPop<eoReal<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoReal<eoMinimizingFitness> >&);
|
||||
|
||||
// the continue's
|
||||
eoContinue<eoReal<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoReal<double> > & _eval);
|
||||
eoContinue<eoReal<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoReal<eoMinimizingFitness> > & _eval);
|
||||
|
||||
// the checkpoint
|
||||
eoCheckPoint<eoReal<double> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoReal<double> >& _eval, eoContinue<eoReal<double> >& _continue);
|
||||
eoCheckPoint<eoReal<eoMinimizingFitness> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoReal<eoMinimizingFitness> >& _eval, eoContinue<eoReal<eoMinimizingFitness> >& _continue);
|
||||
|
||||
|
||||
// the algo
|
||||
eoAlgo<eoReal<double> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoReal<double> >& _eval, eoContinue<eoReal<double> >& _ccontinue, eoGenOp<eoReal<double> >& _op);
|
||||
|
||||
eoAlgo<eoReal<eoMinimizingFitness> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoReal<eoMinimizingFitness> >& _eval, eoContinue<eoReal<eoMinimizingFitness> >& _ccontinue, eoGenOp<eoReal<eoMinimizingFitness> >& _op);
|
||||
|
||||
// run
|
||||
void run_ea(eoAlgo<eoReal<double> >& _ga, eoPop<eoReal<double> >& _pop);
|
||||
void run_ea(eoAlgo<eoReal<eoMinimizingFitness> >& _ga, eoPop<eoReal<eoMinimizingFitness> >& _pop);
|
||||
|
||||
// end of parameter input (+ .status + help)
|
||||
// that one is not templatized
|
||||
// Because of that, the source is in src/utils dir
|
||||
void make_help(eoParser & _parser);
|
||||
|
||||
#endif
|
||||
|
|
@ -10,7 +10,6 @@ libga_a_SOURCES = make_algo_scalar_ga.cpp \
|
|||
make_checkpoint_ga.cpp \
|
||||
make_continue_ga.cpp \
|
||||
make_genotype_ga.cpp \
|
||||
make_help.cpp \
|
||||
make_op_ga.cpp \
|
||||
make_pop_ga.cpp \
|
||||
make_run_ga.cpp
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ void run_ea(eoAlgo<eoBit<double> >& _ga, eoPop<eoBit<double> >& _pop);
|
|||
void run_ea(eoAlgo<eoBit<eoMinimizingFitness> >& _ga, eoPop<eoBit<eoMinimizingFitness> >& _pop);
|
||||
|
||||
// end of parameter input (+ .status + help)
|
||||
// that one is not templatized, but is here for the sake of completeness
|
||||
// that one is not templatized
|
||||
// Because of that, the source is in src/utils dir
|
||||
void make_help(eoParser & _parser);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
/////////////////// the bitstring ////////////////
|
||||
/*
|
||||
* This fuciont does the initialization of what's needed for a particular
|
||||
* This fuction does the initialization of what's needed for a particular
|
||||
* genotype (here, bitstrings).
|
||||
* It could be here tempatied only on the fitness, as it can be used to evolve
|
||||
* bitstrings with any fitness.
|
||||
|
|
@ -55,7 +55,6 @@
|
|||
* WARNING: that last argument will generally be the result of calling
|
||||
* the default ctor of EOT, resulting in most cases in an EOT
|
||||
* that is ***not properly initialized***
|
||||
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
INCLUDES = -I$(top_builddir)/src
|
||||
CPPFLAGS = -O2 -Wall
|
||||
lib_LIBRARIES = libeoutils.a
|
||||
libeoutils_a_SOURCES = eoParser.cpp eoRNG.cpp eoState.cpp eoUpdater.cpp eoFileMonitor.cpp eoStdoutMonitor.cpp eoRealBounds.cpp
|
||||
libeoutils_a_SOURCES = eoParser.cpp eoRNG.cpp eoState.cpp eoUpdater.cpp eoFileMonitor.cpp eoStdoutMonitor.cpp eoRealBounds.cpp make_help.cpp
|
||||
|
||||
libeoincdir = $(includedir)/eo/utils
|
||||
libeoinc_HEADERS = checkpointing *.h
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <ga/ga.h>
|
||||
#include <ga/make_ga.h>
|
||||
#include "binary_value.h"
|
||||
#include <apply.h>
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ int main(int argc, char* argv[])
|
|||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
// the genotype - through a genotype initializer
|
||||
eoInit<EOT>& init = make_genotype(parser, state, double());
|
||||
eoInit<EOT>& init = make_genotype(parser, state, EOT());
|
||||
|
||||
// Build the variation operator (any seq/prop construct)
|
||||
eoGenOp<EOT>& op = make_op(parser, state, init);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <es/real.h>
|
||||
#include <es/make_real.h>
|
||||
#include "real_value.h"
|
||||
#include <apply.h>
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ int main(int argc, char* argv[])
|
|||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
// the genotype - through a genotype initializer
|
||||
eoInit<EOT>& init = make_genotype(parser, state, eoMinimizingFitness());
|
||||
eoInit<EOT>& init = make_genotype(parser, state, EOT());
|
||||
|
||||
// Build the variation operator (any seq/prop construct)
|
||||
eoGenOp<EOT>& op = make_op(parser, state, init);
|
||||
|
|
|
|||
Reference in a new issue