cleanup, prepare vecSigmaInit change
This commit is contained in:
parent
e9324fdb07
commit
4510b6d712
4 changed files with 126 additions and 118 deletions
2
eo/NEWS
2
eo/NEWS
|
|
@ -4,7 +4,7 @@
|
||||||
clean up the code considerably. Assume availability of sstream and limits.
|
clean up the code considerably. Assume availability of sstream and limits.
|
||||||
|
|
||||||
|
|
||||||
* releases 0.9.3... (latest release is 0.9.3zz, 1. Oct. 2005)
|
* release 0.9.3z.1 (1. Oct. 2005)
|
||||||
- Support gcc-3.4 and gcc.4.x.
|
- Support gcc-3.4 and gcc.4.x.
|
||||||
- Provide full automake/autoconf/configure support.
|
- Provide full automake/autoconf/configure support.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,27 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
/* (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
This library is free software; you can redistribute it and/or modify it under
|
||||||
// eoParser.h
|
the terms of the GNU Lesser General Public License as published by the Free
|
||||||
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
|
Software Foundation; either version 2 of the License, or (at your option) any
|
||||||
/*
|
later version.
|
||||||
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,
|
This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public License along
|
||||||
License along with this library; if not, write to the Free Software
|
with this library; if not, write to the Free Software Foundation, Inc., 59
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
Contact: http://eodev.sourceforge.net
|
||||||
Marc.Schoenauer@polytechnique.fr
|
todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
mkeijzer@dhi.dk
|
Marc.Schoenauer@polytechnique.fr
|
||||||
*/
|
mkeijzer@dhi.dk
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
CVS Info: $Date: 2005-09-28 21:49:26 $ $Version$ $Author: kuepper $
|
|
||||||
*/
|
*/
|
||||||
#ifndef eoParser_h
|
|
||||||
#define eoParser_h
|
|
||||||
|
#ifndef EO_PARSER_H
|
||||||
|
#define EO_PARSER_H
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
@ -37,10 +31,11 @@ CVS Info: $Date: 2005-09-28 21:49:26 $ $Version$ $Author: kuepper $
|
||||||
#include "eoObject.h"
|
#include "eoObject.h"
|
||||||
#include "eoPersistent.h"
|
#include "eoPersistent.h"
|
||||||
|
|
||||||
/**
|
/** Parameter saving and loading
|
||||||
eoParameterLoader is an abstract class that can be used as a base for your own
|
|
||||||
parameter loading and saving. The command line parser eoParser is derived from
|
eoParameterLoader is an abstract class that can be used as a base for your own
|
||||||
this class.
|
parameter loading and saving. The command line parser eoParser is derived from
|
||||||
|
this class.
|
||||||
*/
|
*/
|
||||||
class eoParameterLoader
|
class eoParameterLoader
|
||||||
{
|
{
|
||||||
|
|
@ -49,11 +44,10 @@ public :
|
||||||
/** Need a virtual destructor */
|
/** Need a virtual destructor */
|
||||||
virtual ~eoParameterLoader();
|
virtual ~eoParameterLoader();
|
||||||
|
|
||||||
/**
|
/** Register a parameter and set its value if it is known
|
||||||
* processParam is used to register a parameter and set its value if it is known
|
|
||||||
*
|
@param param the parameter to process
|
||||||
* @param param the parameter to process
|
@param section the section where this parameter belongs
|
||||||
* @param section the section where this parameter belongs
|
|
||||||
*/
|
*/
|
||||||
virtual void processParam(eoParam& param, std::string section = "") = 0;
|
virtual void processParam(eoParam& param, std::string section = "") = 0;
|
||||||
|
|
||||||
|
|
@ -147,11 +141,12 @@ public:
|
||||||
|
|
||||||
std::string ProgramName() { return programName; }
|
std::string ProgramName() { return programName; }
|
||||||
|
|
||||||
/**
|
/** Has param been entered by user?
|
||||||
* checks if _param has been actually entered by the user
|
|
||||||
*/
|
Checks if _param has been actually entered by the user
|
||||||
virtual bool isItThere(eoParam& _param) const
|
*/
|
||||||
{ return getValue(_param).first; }
|
virtual bool isItThere(eoParam& _param) const
|
||||||
|
{ return getValue(_param).first; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a handle on a param from its longName
|
* get a handle on a param from its longName
|
||||||
|
|
@ -278,4 +273,15 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
#endif // EO_PARSER_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// coding: iso-8859-1
|
||||||
|
// mode:C++
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// comment-column: 35
|
||||||
|
// fill-column: 80
|
||||||
|
// End:
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,9 @@ EXTRA_DIST = run_tests
|
||||||
|
|
||||||
# extra flags for specific targets
|
# extra flags for specific targets
|
||||||
t_eoVirus_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)/contrib
|
t_eoVirus_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)/contrib
|
||||||
|
t_MGE_CXXFLAGS = -I$(top_srcdir)/contrib/MGE
|
||||||
|
t_MGE1bit_CXXFLAGS = -I$(top_srcdir)/contrib/MGE
|
||||||
|
t_MGE_control_CXXFLAGS = -I$(top_srcdir)/contrib/MGE
|
||||||
|
|
||||||
# Specify source-files,
|
# Specify source-files,
|
||||||
# otherwise automake/make looks for C sources
|
# otherwise automake/make looks for C sources
|
||||||
|
|
@ -63,11 +66,8 @@ t_eofitness_SOURCES = t-eofitness.cpp
|
||||||
t_eoFitnessAssembledEA_SOURCES = t-eoFitnessAssembledEA.cpp
|
t_eoFitnessAssembledEA_SOURCES = t-eoFitnessAssembledEA.cpp
|
||||||
t_eobin_SOURCES = t-eobin.cpp
|
t_eobin_SOURCES = t-eobin.cpp
|
||||||
t_eoVirus_SOURCES = t-eoVirus.cpp
|
t_eoVirus_SOURCES = t-eoVirus.cpp
|
||||||
t_MGE1bit_CXXFLAGS = -I$(top_srcdir)/contrib/MGE
|
|
||||||
t_MGE1bit_SOURCES = t-MGE1bit.cpp
|
t_MGE1bit_SOURCES = t-MGE1bit.cpp
|
||||||
t_MGE_CXXFLAGS = -I$(top_srcdir)/contrib/MGE
|
|
||||||
t_MGE_SOURCES = t-MGE.cpp
|
t_MGE_SOURCES = t-MGE.cpp
|
||||||
t_MGE_control_CXXFLAGS = -I$(top_srcdir)/contrib/MGE
|
|
||||||
t_MGE_control_SOURCES = t-MGE-control.cpp
|
t_MGE_control_SOURCES = t-MGE-control.cpp
|
||||||
t_eoStateAndParser_SOURCES = t-eoStateAndParser.cpp
|
t_eoStateAndParser_SOURCES = t-eoStateAndParser.cpp
|
||||||
t_eoCheckpointing_SOURCES = t-eoCheckpointing.cpp
|
t_eoCheckpointing_SOURCES = t-eoCheckpointing.cpp
|
||||||
|
|
|
||||||
|
|
@ -33,53 +33,54 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state);
|
||||||
|
|
||||||
int main_function(int argc, char *argv[])
|
int main_function(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Create the command-line parser
|
// Create the command-line parser
|
||||||
eoParser parser(argc, argv); // for user-parameter reading
|
eoParser parser(argc, argv); // for user-parameter reading
|
||||||
|
eoState state; // keeps all things allocated
|
||||||
eoState state; // keeps all things allocated
|
eoValueParam<bool>& simpleParam = parser.getORcreateParam(true, "Isotropic",
|
||||||
|
"Isotropic self-adaptive mutation",
|
||||||
|
'i', "ES mutation");
|
||||||
eoValueParam<bool>& simpleParam = parser.createParam(true, "Isotropic", "Isotropic self-adaptive mutation", 'i', "ES mutation");
|
eoValueParam<bool>& stdevsParam = parser.getORcreateParam(false, "Stdev",
|
||||||
eoValueParam<bool>& stdevsParam = parser.createParam(false, "Stdev", "One self-adaptive stDev per variable", 's', "ES mutation");
|
"One self-adaptive stDev per variable",
|
||||||
eoValueParam<bool>& corrParam = parser.createParam(false, "Correl", "Use correlated mutations", 'c', "ES mutation");
|
's', "ES mutation");
|
||||||
|
eoValueParam<bool>& corrParam = parser.getORcreateParam(false, "Correl",
|
||||||
|
"Use correlated mutations",
|
||||||
|
'c', "ES mutation");
|
||||||
// Run the appropriate algorithm
|
// Run the appropriate algorithm
|
||||||
if (simpleParam.value() == false)
|
if (simpleParam.value() == false)
|
||||||
{
|
{
|
||||||
std::cout << "Using eoReal" << std::endl;
|
std::cout << "Using eoReal" << std::endl;
|
||||||
runAlgorithm(eoReal<FitT>(), parser, state);
|
runAlgorithm(eoReal<FitT>(), parser, state);
|
||||||
}
|
}
|
||||||
else if (stdevsParam.value() == false)
|
else if (stdevsParam.value() == false)
|
||||||
{
|
{
|
||||||
std::cout << "Using eoEsSimple" << std::endl;
|
std::cout << "Using eoEsSimple" << std::endl;
|
||||||
runAlgorithm(eoEsSimple<FitT>(), parser, state);
|
runAlgorithm(eoEsSimple<FitT>(), parser, state);
|
||||||
}
|
}
|
||||||
else if (corrParam.value() == false)
|
else if (corrParam.value() == false)
|
||||||
{
|
{
|
||||||
std::cout << "Using eoEsStdev" << std::endl;
|
std::cout << "Using eoEsStdev" << std::endl;
|
||||||
runAlgorithm(eoEsStdev<FitT>(), parser, state);
|
runAlgorithm(eoEsStdev<FitT>(), parser, state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Using eoEsFull" << std::endl;
|
std::cout << "Using eoEsFull" << std::endl;
|
||||||
runAlgorithm(eoEsFull<FitT>(), parser, state);
|
runAlgorithm(eoEsFull<FitT>(), parser, state);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A main that catches the exceptions
|
|
||||||
|
|
||||||
|
|
||||||
|
// A main that catches the exceptions
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// rng.reseed(42);
|
// rng.reseed(42);
|
||||||
int flag = _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
|
int flag = _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
|
||||||
flag |= _CRTDBG_LEAK_CHECK_DF;
|
flag |= _CRTDBG_LEAK_CHECK_DF;
|
||||||
_CrtSetDbgFlag(flag);
|
_CrtSetDbgFlag(flag);
|
||||||
// _CrtSetBreakAlloc(100);
|
// _CrtSetBreakAlloc(100);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
main_function(argc, argv);
|
main_function(argc, argv);
|
||||||
|
|
@ -88,61 +89,62 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
std::cout << "Exception: " << e.what() << '\n';
|
std::cout << "Exception: " << e.what() << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** The templatized main (sort of)
|
/** The templatized main (sort of)
|
||||||
* quite similar to the main of other genotypes
|
|
||||||
* (e.g. t-eoReal and t-eoGA in test dir)
|
quite similar to the main of other genotypes (e.g. t-eoReal and t-eoGA
|
||||||
*/
|
in test dir)
|
||||||
|
*/
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state)
|
void runAlgorithm(EOT, eoParser& _parser, eoState& _state)
|
||||||
{
|
{
|
||||||
typedef typename EOT::Fitness FitT;
|
typedef typename EOT::Fitness FitT;
|
||||||
|
|
||||||
///// FIRST, problem or representation dependent stuff
|
///// FIRST, problem or representation dependent stuff
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
// The evaluation fn - encapsulated into an eval counter for output
|
// The evaluation fn - encapsulated into an eval counter for output
|
||||||
eoEvalFuncPtr<EOT, double, const std::vector<double>&>
|
eoEvalFuncPtr<EOT, double, const std::vector<double>&> mainEval( real_value );
|
||||||
mainEval( real_value );
|
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
|
||||||
|
|
||||||
// the genotype - through a genotype initializer
|
// the genotype - through a genotype initializer
|
||||||
eoRealInitBounded<EOT>& init = make_genotype(_parser, _state, EOT());
|
eoRealInitBounded<EOT>& init = make_genotype(_parser, _state, EOT());
|
||||||
|
|
||||||
// Build the variation operator (any seq/prop construct)
|
// Build the variation operator (any seq/prop construct)
|
||||||
eoGenOp<EOT>& op = make_op(_parser, _state, init);
|
eoGenOp<EOT>& op = make_op(_parser, _state, init);
|
||||||
|
|
||||||
//// Now the representation-independent things
|
//// Now the representation-independent things
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
// initialize the population - and evaluate
|
// initialize the population - and evaluate
|
||||||
// yes, this is representation indepedent once you have an eoInit
|
// yes, this is representation indepedent once you have an eoInit
|
||||||
eoPop<EOT>& pop = make_pop(_parser, _state, init);
|
eoPop<EOT>& pop = make_pop(_parser, _state, init);
|
||||||
apply<EOT>(eval, pop);
|
apply<EOT>(eval, pop);
|
||||||
|
|
||||||
// stopping criteria
|
// stopping criteria
|
||||||
eoContinue<EOT> & term = make_continue(_parser, _state, eval);
|
eoContinue<EOT> & term = make_continue(_parser, _state, eval);
|
||||||
// output
|
// output
|
||||||
eoCheckPoint<EOT> & checkpoint = make_checkpoint(_parser, _state, eval, term);
|
eoCheckPoint<EOT> & checkpoint = make_checkpoint(_parser, _state, eval, term);
|
||||||
// algorithm (need the operator!)
|
// algorithm (need the operator!)
|
||||||
eoAlgo<EOT>& ga = make_algo_scalar(_parser, _state, eval, checkpoint, op);
|
eoAlgo<EOT>& ga = make_algo_scalar(_parser, _state, eval, checkpoint, op);
|
||||||
|
|
||||||
///// End of construction of the algorith
|
///// End of construction of the algorith
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// to be called AFTER all parameters have been read!!!
|
// to be called AFTER all parameters have been read!!!
|
||||||
make_help(_parser);
|
make_help(_parser);
|
||||||
|
|
||||||
//// GO
|
//// GO
|
||||||
///////
|
///////
|
||||||
std::cout << "Initial Population\n";
|
std::cout << "Initial Population\n";
|
||||||
pop.sortedPrintOn(std::cout);
|
pop.sortedPrintOn(std::cout);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
run_ea(ga, pop); // run the ga
|
run_ea(ga, pop); // run the ga
|
||||||
|
|
||||||
std::cout << "Final Population\n";
|
std::cout << "Final Population\n";
|
||||||
pop.sortedPrintOn(std::cout);
|
pop.sortedPrintOn(std::cout);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue