* indentations + whitespace cleanup

This commit is contained in:
Caner Candan 2011-05-05 16:54:00 +02:00
commit 56c6edab04
285 changed files with 6068 additions and 6223 deletions

View file

@ -11,14 +11,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(EO_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib) SET(EO_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${EO_LIB_OUTPUT_PATH}) SET(LIBRARY_OUTPUT_PATH ${EO_LIB_OUTPUT_PATH})
SET (EO_SOURCES eoFunctorStore.cpp SET(EO_SOURCES
eoPersistent.cpp eoFunctorStore.cpp
eoPrintable.cpp eoPersistent.cpp
eoCtrlCContinue.cpp eoPrintable.cpp
eoScalarFitnessAssembled.cpp eoCtrlCContinue.cpp
eoSIGContinue.cpp) eoScalarFitnessAssembled.cpp
eoSIGContinue.cpp
)
ADD_LIBRARY(eo STATIC ${EO_SOURCES}) ADD_LIBRARY(eo STATIC ${EO_SOURCES})
INSTALL(TARGETS eo ARCHIVE DESTINATION lib COMPONENT libraries) INSTALL(TARGETS eo ARCHIVE DESTINATION lib COMPONENT libraries)
@ -42,6 +43,6 @@ ADD_SUBDIRECTORY(ga)
ADD_SUBDIRECTORY(gp) ADD_SUBDIRECTORY(gp)
ADD_SUBDIRECTORY(other) ADD_SUBDIRECTORY(other)
ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(pyeo)
###################################################################################### ######################################################################################

View file

@ -40,17 +40,17 @@
*/ */
/** EO is the base class for objects with a fitness. /** EO is the base class for objects with a fitness.
Those evolvable objects are the subjects of Those evolvable objects are the subjects of
evolution. EOs have only got a fitness, which at the same time needs to be evolution. EOs have only got a fitness, which at the same time needs to be
only an object with the operation less than (<) defined. Fitness says how only an object with the operation less than (<) defined. Fitness says how
good is the object; evolution or change of these objects is left to the good is the object; evolution or change of these objects is left to the
genetic operators. genetic operators.
A fitness less than another means a worse fitness, in A fitness less than another means a worse fitness, in
whatever the context; thus, fitness is always maximized; although it can whatever the context; thus, fitness is always maximized; although it can
be minimized with a proper definition of the < operator. be minimized with a proper definition of the < operator.
A fitness can be invalid if undefined, trying to read an invalid fitness will raise an error. A fitness can be invalid if undefined, trying to read an invalid fitness will raise an error.
@ref Operators that effectively modify EO objects must invalidate them. @ref Operators that effectively modify EO objects must invalidate them.
@ -123,23 +123,23 @@ public:
* @throw runtime_std::exception If a valid object can't be read. * @throw runtime_std::exception If a valid object can't be read.
*/ */
virtual void readFrom(std::istream& _is) { virtual void readFrom(std::istream& _is) {
// the new version of the reafFrom function. // the new version of the reafFrom function.
// It can distinguish between valid and invalid fitness values. // It can distinguish between valid and invalid fitness values.
std::string fitness_str; std::string fitness_str;
int pos = _is.tellg(); int pos = _is.tellg();
_is >> fitness_str; _is >> fitness_str;
if (fitness_str == "INVALID") if (fitness_str == "INVALID")
{ {
invalidFitness = true; invalidFitness = true;
} }
else else
{ {
invalidFitness = false; invalidFitness = false;
_is.seekg(pos); // rewind _is.seekg(pos); // rewind
_is >> repFitness; _is >> repFitness;
} }
} }
/** /**
@ -151,13 +151,13 @@ public:
// the latest version of the code. Very similar to the old code // the latest version of the code. Very similar to the old code
if (invalid()) { if (invalid()) {
_os << "INVALID "; _os << "INVALID ";
} }
else else
{ {
_os << repFitness << ' '; _os << repFitness << ' ';
} }
} }
//@} //@}
@ -171,4 +171,3 @@ private:
#endif #endif
/** @} */ /** @} */

View file

@ -1,5 +1,5 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// PO.h // PO.h
// (c) OPAC 2007 // (c) OPAC 2007
@ -43,11 +43,11 @@ template < class F > class PO:public EO < F >
public: public:
#if defined(__CUDACC__) #if defined(__CUDACC__)
typedef typename EO < F >::Fitness Fitness; typedef typename EO < F >::Fitness Fitness;
#else #else
typedef typename PO<F>::Fitness Fitness; typedef typename PO<F>::Fitness Fitness;
#endif #endif
/** Default constructor. /** Default constructor.
Fitness must have a ctor which takes 0 as a value. Best fitness mush also have the same constructor. Fitness must have a ctor which takes 0 as a value. Best fitness mush also have the same constructor.

View file

@ -9,11 +9,11 @@ the functions here for eoBit<double> AND eoBit<eoMinimizingFitness>
and in EO test dir the t-eoGA.cpp file that is a sample program that uses and in EO test dir the t-eoGA.cpp file that is a sample program that uses
the whole facility. the whole facility.
All make_XXX.h file define some parser-based constructions of basic All make_XXX.h file define some parser-based constructions of basic
Evolutionary Algorithms components, using state-based memory management Evolutionary Algorithms components, using state-based memory management
(see in src/utils dir, or read the tutorial). (see in src/utils dir, or read the tutorial).
In this src/do dir, the following ***representation indedendent*** code In this src/do dir, the following ***representation indedendent*** code
is defined is defined
make_algo_scalar.h The selection/replacement for scalar fitnesses make_algo_scalar.h The selection/replacement for scalar fitnesses
@ -23,7 +23,7 @@ make_pop.h Init of the population (from an EOT initializer)
make_run.h Run the algorithm make_run.h Run the algorithm
See also (NOW MOVED TO util DIR, as it was useful everywhere) See also (NOW MOVED TO util DIR, as it was useful everywhere)
make_help.cpp Help on demand (+ status file) make_help.cpp Help on demand (+ status file)
Note: Note:
----- -----

View file

@ -3,7 +3,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// make_algo_easea.h // make_algo_easea.h
// (c) Marc Schoenauer and Pierre Collet, 2002 // (c) Marc Schoenauer and Pierre Collet, 2002
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -81,18 +81,18 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> > eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> >
eoSelectOne<EOT>* select ; eoSelectOne<EOT>* select ;
if (ppSelect.first == std::string("DetTour")) if (ppSelect.first == std::string("DetTour"))
{ {
unsigned detSize; unsigned detSize;
if (!ppSelect.second.size()) // no parameter added if (!ppSelect.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl; std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
detSize = 2; detSize = 2;
// put back 2 in parameter for consistency (and status file) // put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("2")); ppSelect.second.push_back(std::string("2"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
detSize = atoi(ppSelect.second[0].c_str()); detSize = atoi(ppSelect.second[0].c_str());
select = new eoDetTournamentSelect<EOT>(detSize); select = new eoDetTournamentSelect<EOT>(detSize);
} }
@ -100,57 +100,57 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
{ {
double p; double p;
if (!ppSelect.second.size()) // no parameter added if (!ppSelect.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl; std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
p = 1; p = 1;
// put back p in parameter for consistency (and status file) // put back p in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("1")); ppSelect.second.push_back(std::string("1"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
p = atof(ppSelect.second[0].c_str()); p = atof(ppSelect.second[0].c_str());
select = new eoStochTournamentSelect<EOT>(p); select = new eoStochTournamentSelect<EOT>(p);
} }
else if (ppSelect.first == std::string("Ranking")) else if (ppSelect.first == std::string("Ranking"))
{ {
double p,e; double p,e;
if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent
{ {
p = atof(ppSelect.second[0].c_str()); p = atof(ppSelect.second[0].c_str());
e = atof(ppSelect.second[1].c_str()); e = atof(ppSelect.second[1].c_str());
} }
else if (ppSelect.second.size()==1) // 1 parameter: pressure else if (ppSelect.second.size()==1) // 1 parameter: pressure
{ {
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl; std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
e = 1; e = 1;
ppSelect.second.push_back(std::string("1")); ppSelect.second.push_back(std::string("1"));
p = atof(ppSelect.second[0].c_str()); p = atof(ppSelect.second[0].c_str());
} }
else // no parameters ... or garbage else // no parameters ... or garbage
{ {
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl; std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
p=2; p=2;
e=1; e=1;
// put back in parameter for consistency (and status file) // put back in parameter for consistency (and status file)
ppSelect.second.resize(2); // just in case ppSelect.second.resize(2); // just in case
ppSelect.second[0] = (std::string("2")); ppSelect.second[0] = (std::string("2"));
ppSelect.second[1] = (std::string("1")); ppSelect.second[1] = (std::string("1"));
} }
// check for authorized values // check for authorized values
// pressure in (0,1] // pressure in (0,1]
if ( (p<=1) || (p>2) ) if ( (p<=1) || (p>2) )
{ {
std::cerr << "WARNING, selective pressure must be in (1,2] in Ranking, using 2\n"; std::cerr << "WARNING, selective pressure must be in (1,2] in Ranking, using 2\n";
p=2; p=2;
ppSelect.second[0] = (std::string("2")); ppSelect.second[0] = (std::string("2"));
} }
// exponent >0 // exponent >0
if (e<=0) if (e<=0)
{ {
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n"; std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
e=1; e=1;
ppSelect.second[1] = (std::string("1")); ppSelect.second[1] = (std::string("1"));
} }
// now we're OK // now we're OK
eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) ); eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) );
select = new eoRouletteWorthSelect<EOT>(p2w); select = new eoRouletteWorthSelect<EOT>(p2w);
@ -159,13 +159,13 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
{ {
bool b; bool b;
if (ppSelect.second.size() == 0) // no argument -> default = ordered if (ppSelect.second.size() == 0) // no argument -> default = ordered
{ {
b=true; b=true;
// put back in parameter for consistency (and status file) // put back in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("ordered")); ppSelect.second.push_back(std::string("ordered"));
} }
else else
b = !(ppSelect.second[0] == std::string("unordered")); b = !(ppSelect.second[0] == std::string("unordered"));
select = new eoSequentialSelect<EOT>(b); select = new eoSequentialSelect<EOT>(b);
} }
else if (ppSelect.first == std::string("EliteSequential")) // Best first, one after the other in random order afterwards else if (ppSelect.first == std::string("EliteSequential")) // Best first, one after the other in random order afterwards
@ -188,7 +188,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
_state.storeFunctor(select); _state.storeFunctor(select);
// the number of offspring // the number of offspring
eoValueParam<eoHowMany>& offspringRateParam = _parser.createParam(eoHowMany(1.0), "nbOffspring", "Nb of offspring (percentage or absolute)", 'O', "Evolution Engine"); eoValueParam<eoHowMany>& offspringRateParam = _parser.createParam(eoHowMany(1.0), "nbOffspring", "Nb of offspring (percentage or absolute)", 'O', "Evolution Engine");
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -196,7 +196,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
/** Replacement type - high level: predefined replacements /** Replacement type - high level: predefined replacements
* ESComma : * ESComma :
* elite = 0 * elite = 0
* surviveParents=0 (no reduce) * surviveParents=0 (no reduce)
* surviveOffspring=100% (no reduce) * surviveOffspring=100% (no reduce)
@ -208,8 +208,8 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
* GGA : generational GA - idem ESComma except for * GGA : generational GA - idem ESComma except for
* offspringRate = 100% * offspringRate = 100%
* all reducers are unused * all reducers are unused
* *
* SSGA(T/t) : Steady-State GA * SSGA(T/t) : Steady-State GA
* surviveParents = 1.0 - offspringRate * surviveParents = 1.0 - offspringRate
* reduceFinal = DetTour(T>1) ou StochTour(0.5<t<1) * reduceFinal = DetTour(T>1) ou StochTour(0.5<t<1)
* *
@ -246,28 +246,28 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
// the tournament size // the tournament size
if (!replacementParam.second.size()) // no parameter added if (!replacementParam.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to MGG replacement, using 2" << std::endl; std::cerr << "WARNING, no parameter passed to MGG replacement, using 2" << std::endl;
tSize = 2; tSize = 2;
// put back 2 in parameter for consistency (and status file) // put back 2 in parameter for consistency (and status file)
replacementParam.second.push_back(std::string("2")); replacementParam.second.push_back(std::string("2"));
} }
else else
{ {
t = atof(replacementParam.second[0].c_str()); t = atof(replacementParam.second[0].c_str());
if (t>=2) if (t>=2)
{ // build the appropriate deafult value { // build the appropriate deafult value
tSize = unsigned(t); tSize = unsigned(t);
} }
else else
{ {
throw std::runtime_error("Sorry, only deterministic tournament available at the moment"); throw std::runtime_error("Sorry, only deterministic tournament available at the moment");
} }
} }
ptReplace = new eoMGGReplacement<EOT>(-surviveParents, tSize); ptReplace = new eoMGGReplacement<EOT>(-surviveParents, tSize);
_state.storeFunctor(ptReplace); _state.storeFunctor(ptReplace);
} }
else { // until the end of what was the only loop/switch else { // until the end of what was the only loop/switch
// the default deafult values // the default deafult values
eoHowMany elite (0.0); eoHowMany elite (0.0);
bool strongElitism (false); bool strongElitism (false);
@ -283,12 +283,12 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
// ---------- General // ---------- General
if (replacementParam.first == std::string("General")) if (replacementParam.first == std::string("General"))
{ {
; // defaults OK ; // defaults OK
} }
// ---------- ESComma // ---------- ESComma
else if (replacementParam.first == std::string("ESComma")) else if (replacementParam.first == std::string("ESComma"))
{ {
; // OK too ; // OK too
} }
// ---------- ESPlus // ---------- ESPlus
else if (replacementParam.first == std::string("ESPlus")) else if (replacementParam.first == std::string("ESPlus"))
@ -298,16 +298,16 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
// ---------- Generational // ---------- Generational
else if (replacementParam.first == std::string("Generational")) else if (replacementParam.first == std::string("Generational"))
{ {
; // OK too (we should check nb of offspring) ; // OK too (we should check nb of offspring)
} }
// ---------- EP // ---------- EP
else if (replacementParam.first == std::string("EP")) else if (replacementParam.first == std::string("EP"))
{ {
if (!replacementParam.second.size()) // no parameter added if (!replacementParam.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to EP replacement, using 6" << std::endl; std::cerr << "WARNING, no parameter passed to EP replacement, using 6" << std::endl;
// put back 6 in parameter for consistency (and status file) // put back 6 in parameter for consistency (and status file)
replacementParam.second.push_back(std::string("6")); replacementParam.second.push_back(std::string("6"));
} }
// by coincidence, the syntax for the EP reducer is the same than here: // by coincidence, the syntax for the EP reducer is the same than here:
reduceFinalType = replacementParam; reduceFinalType = replacementParam;
@ -318,28 +318,28 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
{ {
if (!replacementParam.second.size()) // no parameter added if (!replacementParam.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to SSGA replacement, using 2" << std::endl; std::cerr << "WARNING, no parameter passed to SSGA replacement, using 2" << std::endl;
// put back 2 in parameter for consistency (and status file) // put back 2 in parameter for consistency (and status file)
replacementParam.second.push_back(std::string("2")); replacementParam.second.push_back(std::string("2"));
reduceParentType = eoParamParamType(std::string("DetTour(2)")); reduceParentType = eoParamParamType(std::string("DetTour(2)"));
} }
else else
{ {
t = atof(replacementParam.second[0].c_str()); t = atof(replacementParam.second[0].c_str());
if (t>=2) if (t>=2)
{ // build the appropriate deafult value { // build the appropriate deafult value
reduceParentType = eoParamParamType(std::string("DetTour(") + replacementParam.second[0].c_str() + ")"); reduceParentType = eoParamParamType(std::string("DetTour(") + replacementParam.second[0].c_str() + ")");
} }
else // check for [0.5,1] will be made in make_general_replacement else // check for [0.5,1] will be made in make_general_replacement
{ // build the appropriate deafult value { // build the appropriate deafult value
reduceParentType = eoParamParamType(std::string("StochTour(") + replacementParam.second[0].c_str() + ")"); reduceParentType = eoParamParamType(std::string("StochTour(") + replacementParam.second[0].c_str() + ")");
} }
} }
// //
surviveParents = eoHowMany(-1); surviveParents = eoHowMany(-1);
surviveOffspring = eoHowMany(1); surviveOffspring = eoHowMany(1);
} }
else // no replacement recognized else // no replacement recognized
{ {
throw std::runtime_error("Invalid replacement type " + replacementParam.first); throw std::runtime_error("Invalid replacement type " + replacementParam.first);
} }
@ -353,7 +353,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
/////////////////////////////// ///////////////////////////////
// the general breeder // the general breeder
/////////////////////////////// ///////////////////////////////
eoGeneralBreeder<EOT> *breed = eoGeneralBreeder<EOT> *breed =
new eoGeneralBreeder<EOT>(*select, _op, offspringRateParam.value()); new eoGeneralBreeder<EOT>(*select, _op, offspringRateParam.value());
_state.storeFunctor(breed); _state.storeFunctor(breed);
@ -381,7 +381,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
template <class EOT> template <class EOT>
eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<EOT>& _eval, eoContinue<EOT>& _continue, eoGenOp<EOT>& _op) eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<EOT>& _eval, eoContinue<EOT>& _continue, eoGenOp<EOT>& _op)
{ {
do_make_algo_scalar( _parser, _state, *(new eoPopLoopEval<EOT>(_eval)), _continue, _op); do_make_algo_scalar( _parser, _state, *(new eoPopLoopEval<EOT>(_eval)), _continue, _op);
} }

View file

@ -3,7 +3,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// make_algo_scalar.h // make_algo_scalar.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001 // (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -84,42 +84,42 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
if (_dist == NULL) if (_dist == NULL)
comment = "Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e) or Sequential(ordered/unordered)"; comment = "Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e) or Sequential(ordered/unordered)";
else else
comment = "Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e), Sharing(sigma_share) or Sequential(ordered/unordered)"; comment = "Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e), Sharing(sigma_share) or Sequential(ordered/unordered)";
eoValueParam<eoParamParamType>& selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection", comment, 'S', "Evolution Engine"); eoValueParam<eoParamParamType>& selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection", comment, 'S', "Evolution Engine");
eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> > eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> >
eoSelectOne<EOT>* select ; eoSelectOne<EOT>* select ;
if (ppSelect.first == std::string("DetTour")) if (ppSelect.first == std::string("DetTour"))
{ {
unsigned detSize; unsigned detSize;
if (!ppSelect.second.size()) // no parameter added if (!ppSelect.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl; std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
detSize = 2; detSize = 2;
// put back 2 in parameter for consistency (and status file) // put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("2")); ppSelect.second.push_back(std::string("2"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
detSize = atoi(ppSelect.second[0].c_str()); detSize = atoi(ppSelect.second[0].c_str());
select = new eoDetTournamentSelect<EOT>(detSize); select = new eoDetTournamentSelect<EOT>(detSize);
} }
else if (ppSelect.first == std::string("Sharing")) else if (ppSelect.first == std::string("Sharing"))
{ {
double nicheSize; double nicheSize;
if (!ppSelect.second.size()) // no parameter added if (!ppSelect.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to Sharing, using 0.5" << std::endl; std::cerr << "WARNING, no parameter passed to Sharing, using 0.5" << std::endl;
nicheSize = 0.5; nicheSize = 0.5;
// put back 2 in parameter for consistency (and status file) // put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("0.5")); ppSelect.second.push_back(std::string("0.5"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
nicheSize = atof(ppSelect.second[0].c_str()); nicheSize = atof(ppSelect.second[0].c_str());
if (_dist == NULL) // no distance if (_dist == NULL) // no distance
throw std::runtime_error("You didn't specify a distance when calling make_algo_scalar and using sharing"); throw std::runtime_error("You didn't specify a distance when calling make_algo_scalar and using sharing");
select = new eoSharingSelect<EOT>(nicheSize, *_dist); select = new eoSharingSelect<EOT>(nicheSize, *_dist);
} }
@ -127,57 +127,57 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
{ {
double p; double p;
if (!ppSelect.second.size()) // no parameter added if (!ppSelect.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl; std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
p = 1; p = 1;
// put back p in parameter for consistency (and status file) // put back p in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("1")); ppSelect.second.push_back(std::string("1"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
p = atof(ppSelect.second[0].c_str()); p = atof(ppSelect.second[0].c_str());
select = new eoStochTournamentSelect<EOT>(p); select = new eoStochTournamentSelect<EOT>(p);
} }
else if (ppSelect.first == std::string("Ranking")) else if (ppSelect.first == std::string("Ranking"))
{ {
double p,e; double p,e;
if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent
{ {
p = atof(ppSelect.second[0].c_str()); p = atof(ppSelect.second[0].c_str());
e = atof(ppSelect.second[1].c_str()); e = atof(ppSelect.second[1].c_str());
} }
else if (ppSelect.second.size()==1) // 1 parameter: pressure else if (ppSelect.second.size()==1) // 1 parameter: pressure
{ {
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl; std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
e = 1; e = 1;
ppSelect.second.push_back(std::string("1")); ppSelect.second.push_back(std::string("1"));
p = atof(ppSelect.second[0].c_str()); p = atof(ppSelect.second[0].c_str());
} }
else // no parameters ... or garbage else // no parameters ... or garbage
{ {
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl; std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
p=2; p=2;
e=1; e=1;
// put back in parameter for consistency (and status file) // put back in parameter for consistency (and status file)
ppSelect.second.resize(2); // just in case ppSelect.second.resize(2); // just in case
ppSelect.second[0] = (std::string("2")); ppSelect.second[0] = (std::string("2"));
ppSelect.second[1] = (std::string("1")); ppSelect.second[1] = (std::string("1"));
} }
// check for authorized values // check for authorized values
// pressure in (0,1] // pressure in (0,1]
if ( (p<=1) || (p>2) ) if ( (p<=1) || (p>2) )
{ {
std::cerr << "WARNING, selective pressure must be in (0,1] in Ranking, using 2\n"; std::cerr << "WARNING, selective pressure must be in (0,1] in Ranking, using 2\n";
p=2; p=2;
ppSelect.second[0] = (std::string("2")); ppSelect.second[0] = (std::string("2"));
} }
// exponent >0 // exponent >0
if (e<=0) if (e<=0)
{ {
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n"; std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
e=1; e=1;
ppSelect.second[1] = (std::string("1")); ppSelect.second[1] = (std::string("1"));
} }
// now we're OK // now we're OK
eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) ); eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) );
select = new eoRouletteWorthSelect<EOT>(p2w); select = new eoRouletteWorthSelect<EOT>(p2w);
@ -186,13 +186,13 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
{ {
bool b; bool b;
if (ppSelect.second.size() == 0) // no argument -> default = ordered if (ppSelect.second.size() == 0) // no argument -> default = ordered
{ {
b=true; b=true;
// put back in parameter for consistency (and status file) // put back in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("ordered")); ppSelect.second.push_back(std::string("ordered"));
} }
else else
b = !(ppSelect.second[0] == std::string("unordered")); b = !(ppSelect.second[0] == std::string("unordered"));
select = new eoSequentialSelect<EOT>(b); select = new eoSequentialSelect<EOT>(b);
} }
else if (ppSelect.first == std::string("Roulette")) // no argument (yet) else if (ppSelect.first == std::string("Roulette")) // no argument (yet)
@ -211,7 +211,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
_state.storeFunctor(select); _state.storeFunctor(select);
// the number of offspring // the number of offspring
eoValueParam<eoHowMany>& offspringRateParam = _parser.createParam(eoHowMany(1.0), "nbOffspring", "Nb of offspring (percentage or absolute)", 'O', "Evolution Engine"); eoValueParam<eoHowMany>& offspringRateParam = _parser.createParam(eoHowMany(1.0), "nbOffspring", "Nb of offspring (percentage or absolute)", 'O', "Evolution Engine");
// the replacement // the replacement
@ -231,16 +231,16 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
else if (ppReplace.first == std::string("EPTour")) else if (ppReplace.first == std::string("EPTour"))
{ {
unsigned detSize; unsigned detSize;
if (!ppReplace.second.size()) // no parameter added if (!ppReplace.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to EPTour, using 6" << std::endl; std::cerr << "WARNING, no parameter passed to EPTour, using 6" << std::endl;
detSize = 6; detSize = 6;
// put back in parameter for consistency (and status file) // put back in parameter for consistency (and status file)
ppReplace.second.push_back(std::string("6")); ppReplace.second.push_back(std::string("6"));
} }
else // parameter passed by user as EPTour(T) else // parameter passed by user as EPTour(T)
detSize = atoi(ppSelect.second[0].c_str()); detSize = atoi(ppSelect.second[0].c_str());
replace = new eoEPReplacement<EOT>(detSize); replace = new eoEPReplacement<EOT>(detSize);
} }
@ -251,32 +251,32 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
else if (ppReplace.first == std::string("SSGADet")) else if (ppReplace.first == std::string("SSGADet"))
{ {
unsigned detSize; unsigned detSize;
if (!ppReplace.second.size()) // no parameter added if (!ppReplace.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to SSGADet, using 2" << std::endl; std::cerr << "WARNING, no parameter passed to SSGADet, using 2" << std::endl;
detSize = 2; detSize = 2;
// put back in parameter for consistency (and status file) // put back in parameter for consistency (and status file)
ppReplace.second.push_back(std::string("2")); ppReplace.second.push_back(std::string("2"));
} }
else // parameter passed by user as SSGADet(T) else // parameter passed by user as SSGADet(T)
detSize = atoi(ppSelect.second[0].c_str()); detSize = atoi(ppSelect.second[0].c_str());
replace = new eoSSGADetTournamentReplacement<EOT>(detSize); replace = new eoSSGADetTournamentReplacement<EOT>(detSize);
} }
else if (ppReplace.first == std::string("SSGAStoch")) else if (ppReplace.first == std::string("SSGAStoch"))
{ {
double p; double p;
if (!ppReplace.second.size()) // no parameter added if (!ppReplace.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to SSGAStoch, using 1" << std::endl; std::cerr << "WARNING, no parameter passed to SSGAStoch, using 1" << std::endl;
p = 1; p = 1;
// put back in parameter for consistency (and status file) // put back in parameter for consistency (and status file)
ppReplace.second.push_back(std::string("1")); ppReplace.second.push_back(std::string("1"));
} }
else // parameter passed by user as SSGADet(T) else // parameter passed by user as SSGADet(T)
p = atof(ppSelect.second[0].c_str()); p = atof(ppSelect.second[0].c_str());
replace = new eoSSGAStochTournamentReplacement<EOT>(p); replace = new eoSSGAStochTournamentReplacement<EOT>(p);
} }
else else
@ -294,10 +294,10 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
eoReplacement<EOT> *replaceTmp = replace; eoReplacement<EOT> *replaceTmp = replace;
replace = new eoWeakElitistReplacement<EOT>(*replaceTmp); replace = new eoWeakElitistReplacement<EOT>(*replaceTmp);
_state.storeFunctor(replace); _state.storeFunctor(replace);
} }
// the general breeder // the general breeder
eoGeneralBreeder<EOT> *breed = eoGeneralBreeder<EOT> *breed =
new eoGeneralBreeder<EOT>(*select, _op, offspringRateParam.value()); new eoGeneralBreeder<EOT>(*select, _op, offspringRateParam.value());
_state.storeFunctor(breed); _state.storeFunctor(breed);

View file

@ -129,7 +129,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
eoValueParam<bool>& eraseParam = _parser.createParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk"); eoValueParam<bool>& eraseParam = _parser.createParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk");
bool dirOK = false; // not tested yet bool dirOK = false; // not tested yet
@ -179,15 +179,15 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
{ {
bestStat = new eoBestFitnessStat<EOT>; bestStat = new eoBestFitnessStat<EOT>;
// store it // store it
_state.storeFunctor(bestStat); _state.storeFunctor(bestStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*bestStat); checkpoint->add(*bestStat);
} }
@ -203,15 +203,15 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
{ {
averageStat = new eoAverageStat<EOT>; averageStat = new eoAverageStat<EOT>;
// store it // store it
_state.storeFunctor(averageStat); _state.storeFunctor(averageStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*averageStat); checkpoint->add(*averageStat);
} }
@ -223,19 +223,19 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
eoSecondMomentStats<EOT> *secondStat = NULL; eoSecondMomentStats<EOT> *secondStat = NULL;
if ( printBestParam.value() || fileBestParam.value() ) // we need it for screen output or file output if ( printBestParam.value() || fileBestParam.value() ) // we need it for screen output or file output
{ {
secondStat = new eoSecondMomentStats<EOT>; secondStat = new eoSecondMomentStats<EOT>;
// store it // store it
_state.storeFunctor(secondStat); _state.storeFunctor(secondStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*secondStat); checkpoint->add(*secondStat);
} }
@ -255,15 +255,15 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
{ {
popStat = new eoSortedPopStat<EOT>; popStat = new eoSortedPopStat<EOT>;
// store it // store it
_state.storeFunctor(popStat); _state.storeFunctor(popStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*popStat); checkpoint->add(*popStat);
} }
@ -287,7 +287,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
bool needStdoutMonitor = printBestParam.value() bool needStdoutMonitor = printBestParam.value()
|| printPopParam.value() ; || printPopParam.value() ;
@ -297,53 +297,53 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
{ {
eoStdoutMonitor *monitor = new eoStdoutMonitor(false); eoStdoutMonitor *monitor = new eoStdoutMonitor(false);
_state.storeFunctor(monitor); _state.storeFunctor(monitor);
// when called by the checkpoint (i.e. at every generation) // when called by the checkpoint (i.e. at every generation)
checkpoint->add(*monitor); checkpoint->add(*monitor);
// the monitor will output a series of parameters: add them // the monitor will output a series of parameters: add them
monitor->add(*generationCounter); monitor->add(*generationCounter);
if (useEvalParam.value()) // we want nb of evaluations if (useEvalParam.value()) // we want nb of evaluations
monitor->add(_eval); monitor->add(_eval);
if (useTimeParam.value()) // we want time if (useTimeParam.value()) // we want time
{ {
tCounter = new eoTimeCounter; tCounter = new eoTimeCounter;
_state.storeFunctor(tCounter); _state.storeFunctor(tCounter);
checkpoint->add(*tCounter); checkpoint->add(*tCounter);
monitor->add(*tCounter); monitor->add(*tCounter);
} }
if (printBestParam.value()) if (printBestParam.value())
{ {
monitor->add(*bestStat); monitor->add(*bestStat);
monitor->add(*secondStat); monitor->add(*secondStat);
} }
if ( printPopParam.value()) if ( printPopParam.value())
monitor->add(*popStat); monitor->add(*popStat);
} }
@ -353,9 +353,9 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
if ( ( fileBestParam.value() || plotBestParam.value() || if ( ( fileBestParam.value() || plotBestParam.value() ||
plotHistogramParam.value() ) plotHistogramParam.value() )
&& !dirOK ) // just in case we add something before && !dirOK ) // just in case we add something before
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
@ -367,41 +367,41 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
#ifdef _MSVC #ifdef _MSVC
std::string stmp = dirNameParam.value() + "\best.xg"; std::string stmp = dirNameParam.value() + "\best.xg";
#else #else
std::string stmp = dirNameParam.value() + "/best.xg"; std::string stmp = dirNameParam.value() + "/best.xg";
#endif #endif
eoFileMonitor *fileMonitor = new eoFileMonitor(stmp); eoFileMonitor *fileMonitor = new eoFileMonitor(stmp);
// save and give to checkpoint // save and give to checkpoint
_state.storeFunctor(fileMonitor); _state.storeFunctor(fileMonitor);
checkpoint->add(*fileMonitor); checkpoint->add(*fileMonitor);
// and feed with some statistics // and feed with some statistics
fileMonitor->add(*generationCounter); fileMonitor->add(*generationCounter);
fileMonitor->add(_eval); fileMonitor->add(_eval);
if (tCounter) // we want the time as well if (tCounter) // we want the time as well
{ {
// std::cout << "On met timecounter\n"; // std::cout << "On met timecounter\n";
fileMonitor->add(*tCounter); fileMonitor->add(*tCounter);
} }
fileMonitor->add(*bestStat); fileMonitor->add(*bestStat);
fileMonitor->add(*secondStat); fileMonitor->add(*secondStat);
} }
@ -413,33 +413,33 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
{ {
std::string stmp = dirNameParam.value() + "/gnu_best.xg"; std::string stmp = dirNameParam.value() + "/gnu_best.xg";
eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>()); eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>());
// save and give to checkpoint // save and give to checkpoint
_state.storeFunctor(gnuMonitor); _state.storeFunctor(gnuMonitor);
checkpoint->add(*gnuMonitor); checkpoint->add(*gnuMonitor);
// and feed with some statistics // and feed with some statistics
if (useEvalParam.value()) // do we want eval as X coordinate if (useEvalParam.value()) // do we want eval as X coordinate
gnuMonitor->add(_eval); gnuMonitor->add(_eval);
else if (tCounter) // or time? else if (tCounter) // or time?
gnuMonitor->add(*tCounter); gnuMonitor->add(*tCounter);
else // default: generation else // default: generation
gnuMonitor->add(*generationCounter); gnuMonitor->add(*generationCounter);
gnuMonitor->add(*bestStat); gnuMonitor->add(*bestStat);
gnuMonitor->add(*averageStat); gnuMonitor->add(*averageStat);
} }
@ -451,25 +451,25 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
{ {
eoScalarFitnessStat<EOT> *fitStat = new eoScalarFitnessStat<EOT>; eoScalarFitnessStat<EOT> *fitStat = new eoScalarFitnessStat<EOT>;
_state.storeFunctor(fitStat); _state.storeFunctor(fitStat);
checkpoint->add(*fitStat); checkpoint->add(*fitStat);
// a gnuplot-based monitor for snapshots: needs a dir name // a gnuplot-based monitor for snapshots: needs a dir name
eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value()); eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value());
_state.storeFunctor(fitSnapshot); _state.storeFunctor(fitSnapshot);
// add any stat that is a std::vector<double> to it // add any stat that is a std::vector<double> to it
fitSnapshot->add(*fitStat); fitSnapshot->add(*fitStat);
// and of course add it to the checkpoint // and of course add it to the checkpoint
checkpoint->add(*fitSnapshot); checkpoint->add(*fitSnapshot);
} }
@ -499,7 +499,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
if (! dirOK ) if (! dirOK )
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
@ -537,7 +537,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
if (! dirOK ) if (! dirOK )
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
@ -570,4 +570,3 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
#endif #endif

View file

@ -70,7 +70,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
eoValueParam<std::string>& dirNameParam = _parser.createParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk"); eoValueParam<std::string>& dirNameParam = _parser.createParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk");
// shoudl we empty it if exists // shoudl we empty it if exists
eoValueParam<bool>& eraseParam = _parser.createParam(false, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk"); eoValueParam<bool>& eraseParam = _parser.createParam(false, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk");
bool dirOK = false; // not tested yet bool dirOK = false; // not tested yet
///////////////////////////////////////// /////////////////////////////////////////
// now some statistics on the population: // now some statistics on the population:
@ -98,11 +98,11 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
if ( printBestParam.value() || plotBestParam.value() || fileBestParam.value() ) if ( printBestParam.value() || plotBestParam.value() || fileBestParam.value() )
// we need the bestStat for at least one of the 3 above // we need the bestStat for at least one of the 3 above
{ {
bestStat = new eoBestFitnessStat<EOT>; bestStat = new eoBestFitnessStat<EOT>;
// store it // store it
_state.storeFunctor(bestStat); _state.storeFunctor(bestStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*bestStat); checkpoint->add(*bestStat);
} }
// Average fitness alone // Average fitness alone
@ -110,11 +110,11 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
eoAverageStat<EOT> *averageStat = NULL; // do we need averageStat? eoAverageStat<EOT> *averageStat = NULL; // do we need averageStat?
if ( plotBestParam.value() ) // we need it for gnuplot output if ( plotBestParam.value() ) // we need it for gnuplot output
{ {
averageStat = new eoAverageStat<EOT>; averageStat = new eoAverageStat<EOT>;
// store it // store it
_state.storeFunctor(averageStat); _state.storeFunctor(averageStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*averageStat); checkpoint->add(*averageStat);
} }
// Second moment stats: average and stdev // Second moment stats: average and stdev
@ -122,11 +122,11 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
eoSecondMomentStats<EOT> *secondStat = NULL; eoSecondMomentStats<EOT> *secondStat = NULL;
if ( printBestParam.value() ) // we need it for sreen output if ( printBestParam.value() ) // we need it for sreen output
{ {
secondStat = new eoSecondMomentStats<EOT>; secondStat = new eoSecondMomentStats<EOT>;
// store it // store it
_state.storeFunctor(secondStat); _state.storeFunctor(secondStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*secondStat); checkpoint->add(*secondStat);
} }
@ -136,11 +136,11 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
eoValueParam<bool>& printPopParam = _parser.createParam(false, "printPop", "Print sorted pop. every gen.", '\0', "Output"); eoValueParam<bool>& printPopParam = _parser.createParam(false, "printPop", "Print sorted pop. every gen.", '\0', "Output");
if ( printPopParam.value() ) // we do want pop dump if ( printPopParam.value() ) // we do want pop dump
{ {
popStat = new eoSortedPopStat<EOT>("Dump of whole population"); popStat = new eoSortedPopStat<EOT>("Dump of whole population");
// store it // store it
_state.storeFunctor(popStat); _state.storeFunctor(popStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*popStat); checkpoint->add(*popStat);
} }
@ -152,14 +152,14 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
eoFDCStat<EOT> *fdcStat = NULL; eoFDCStat<EOT> *fdcStat = NULL;
if ( printFDCParam.value() || plotFDCParam.value() ) // we need FDCStat if ( printFDCParam.value() || plotFDCParam.value() ) // we need FDCStat
{ {
// need first an object to compute the distances - here Hamming dist. // need first an object to compute the distances - here Hamming dist.
eoQuadDistance<EOT> *dist = new eoQuadDistance<EOT>; eoQuadDistance<EOT> *dist = new eoQuadDistance<EOT>;
_state.storeFunctor(dist); _state.storeFunctor(dist);
fdcStat = new eoFDCStat<EOT>(*dist); fdcStat = new eoFDCStat<EOT>(*dist);
// storeFunctor it // storeFunctor it
_state.storeFunctor(fdcStat); _state.storeFunctor(fdcStat);
// add it to the checkpoint // add it to the checkpoint
checkpoint->add(*fdcStat); checkpoint->add(*fdcStat);
} }
// do we wnat some histogram of fitnesses snpashots? // do we wnat some histogram of fitnesses snpashots?
@ -170,95 +170,95 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
/////////////// ///////////////
// do we want an eoStdoutMonitor? // do we want an eoStdoutMonitor?
bool needStdoutMonitor = printBestParam.value() || printFDCParam.value() bool needStdoutMonitor = printBestParam.value() || printFDCParam.value()
|| printPopParam.value() ; || printPopParam.value() ;
// The Stdout monitor will print parameters to the screen ... // The Stdout monitor will print parameters to the screen ...
if ( needStdoutMonitor ) if ( needStdoutMonitor )
{ {
eoStdoutMonitor *monitor = new eoStdoutMonitor(false); eoStdoutMonitor *monitor = new eoStdoutMonitor(false);
_state.storeFunctor(monitor); _state.storeFunctor(monitor);
// when called by the checkpoint (i.e. at every generation) // when called by the checkpoint (i.e. at every generation)
checkpoint->add(*monitor); checkpoint->add(*monitor);
// the monitor will output a series of parameters: add them // the monitor will output a series of parameters: add them
monitor->add(*generationCounter); monitor->add(*generationCounter);
if (useEvalParam.value()) // we want nb of evaluations if (useEvalParam.value()) // we want nb of evaluations
monitor->add(_eval); monitor->add(_eval);
if (printBestParam.value()) if (printBestParam.value())
{ {
monitor->add(*bestStat); monitor->add(*bestStat);
monitor->add(*secondStat); monitor->add(*secondStat);
} }
if (printFDCParam.value()) if (printFDCParam.value())
monitor->add(*fdcStat); monitor->add(*fdcStat);
if ( printPopParam.value()) if ( printPopParam.value())
monitor->add(*popStat); monitor->add(*popStat);
} }
// first handle the dir test - if we need at least one file // first handle the dir test - if we need at least one file
if ( ( fileBestParam.value() || plotBestParam.value() || if ( ( fileBestParam.value() || plotBestParam.value() ||
plotFDCParam.value() || plotHistogramParam.value() ) plotFDCParam.value() || plotHistogramParam.value() )
&& !dirOK ) // just in case we add something before && !dirOK ) // just in case we add something before
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
if (fileBestParam.value()) // A file monitor for best & secondMoment if (fileBestParam.value()) // A file monitor for best & secondMoment
{ {
std::string stmp = dirNameParam.value() + "/best.xg"; std::string stmp = dirNameParam.value() + "/best.xg";
eoFileMonitor *fileMonitor = new eoFileMonitor(stmp); eoFileMonitor *fileMonitor = new eoFileMonitor(stmp);
// save and give to checkpoint // save and give to checkpoint
_state.storeFunctor(fileMonitor); _state.storeFunctor(fileMonitor);
checkpoint->add(*fileMonitor); checkpoint->add(*fileMonitor);
// and feed with some statistics // and feed with some statistics
fileMonitor->add(*generationCounter); fileMonitor->add(*generationCounter);
fileMonitor->add(_eval); fileMonitor->add(_eval);
fileMonitor->add(*bestStat); fileMonitor->add(*bestStat);
fileMonitor->add(*secondStat); fileMonitor->add(*secondStat);
} }
if (plotBestParam.value()) // an eoGnuplot1DMonitor for best & average if (plotBestParam.value()) // an eoGnuplot1DMonitor for best & average
{ {
std::string stmp = dirNameParam.value() + "_gnu_best.xg"; std::string stmp = dirNameParam.value() + "_gnu_best.xg";
eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>()); eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>());
// save and give to checkpoint // save and give to checkpoint
_state.storeFunctor(gnuMonitor); _state.storeFunctor(gnuMonitor);
checkpoint->add(*gnuMonitor); checkpoint->add(*gnuMonitor);
// and feed with some statistics // and feed with some statistics
if (useEvalParam.value()) if (useEvalParam.value())
gnuMonitor->add(_eval); gnuMonitor->add(_eval);
else else
gnuMonitor->add(*generationCounter); gnuMonitor->add(*generationCounter);
gnuMonitor->add(*bestStat); gnuMonitor->add(*bestStat);
gnuMonitor->add(*averageStat); gnuMonitor->add(*averageStat);
} }
if (plotFDCParam.value()) // a specific plot monitor for FDC if (plotFDCParam.value()) // a specific plot monitor for FDC
{ {
// first into a file (it adds everything ti itself // first into a file (it adds everything ti itself
eoFDCFileSnapshot<EOT> *fdcFileSnapshot = new eoFDCFileSnapshot<EOT>(*fdcStat, dirNameParam.value()); eoFDCFileSnapshot<EOT> *fdcFileSnapshot = new eoFDCFileSnapshot<EOT>(*fdcStat, dirNameParam.value());
_state.storeFunctor(fdcFileSnapshot); _state.storeFunctor(fdcFileSnapshot);
// then to a Gnuplot monitor // then to a Gnuplot monitor
eoGnuplot1DSnapshot *fdcGnuplot = new eoGnuplot1DSnapshot(*fdcFileSnapshot); eoGnuplot1DSnapshot *fdcGnuplot = new eoGnuplot1DSnapshot(*fdcFileSnapshot);
_state.storeFunctor(fdcGnuplot); _state.storeFunctor(fdcGnuplot);
// and of course add them to the checkPoint // and of course add them to the checkPoint
checkpoint->add(*fdcFileSnapshot); checkpoint->add(*fdcFileSnapshot);
checkpoint->add(*fdcGnuplot); checkpoint->add(*fdcGnuplot);
} }
// historgram? // historgram?
if (plotHistogramParam.value()) // want to see how the fitness is spread? if (plotHistogramParam.value()) // want to see how the fitness is spread?
{ {
eoScalarFitnessStat<EOT> *fitStat = new eoScalarFitnessStat<EOT>; eoScalarFitnessStat<EOT> *fitStat = new eoScalarFitnessStat<EOT>;
_state.storeFunctor(fitStat); _state.storeFunctor(fitStat);
checkpoint->add(*fitStat); checkpoint->add(*fitStat);
// a gnuplot-based monitor for snapshots: needs a dir name // a gnuplot-based monitor for snapshots: needs a dir name
eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value()); eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value());
_state.storeFunctor(fitSnapshot); _state.storeFunctor(fitSnapshot);
// add any stat that is a std::vector<double> to it // add any stat that is a std::vector<double> to it
fitSnapshot->add(*fitStat); fitSnapshot->add(*fitStat);
// and of course add it to the checkpoint // and of course add it to the checkpoint
checkpoint->add(*fitSnapshot); checkpoint->add(*fitSnapshot);
} }
////////////////////////////////// //////////////////////////////////
@ -273,7 +273,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
{ {
// first make sure dirName is OK // first make sure dirName is OK
if (! dirOK ) if (! dirOK )
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX ); unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
std::string stmp = dirNameParam.value() + "/generations"; std::string stmp = dirNameParam.value() + "/generations";
@ -288,7 +288,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
{ {
// first make sure dirName is OK // first make sure dirName is OK
if (! dirOK ) if (! dirOK )
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
std::string stmp = dirNameParam.value() + "/time"; std::string stmp = dirNameParam.value() + "/time";
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp); eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);

View file

@ -49,7 +49,7 @@
bool testDirRes(std::string _dirName, bool _erase); bool testDirRes(std::string _dirName, bool _erase);
/////////////////// The checkpoint and other I/O ////////////// /////////////////// The checkpoint and other I/O //////////////
/** Of course, Fitness needs to be an eoScalarFitnessAssembled!!! /** Of course, Fitness needs to be an eoScalarFitnessAssembled!!!
* *
* *
* @ingroup Builders * @ingroup Builders
@ -153,7 +153,7 @@ eoCheckPoint<EOT>& do_make_checkpoint_assembled(eoParser& _parser, eoState& _sta
_state.storeFunctor(fitStat); _state.storeFunctor(fitStat);
checkpoint->add(*fitStat); checkpoint->add(*fitStat);
#ifdef HAVE_GNUPLOT #ifdef HAVE_GNUPLOT
// a gnuplot-based monitor for snapshots: needs a dir name // a gnuplot-based monitor for snapshots: needs a dir name
eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirName); eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirName);
_state.storeFunctor(fitSnapshot); _state.storeFunctor(fitSnapshot);
// add any stat that is a vector<double> to it // add any stat that is a vector<double> to it

View file

@ -55,7 +55,7 @@ It can then be instantiated, and compiled on its own for a given EOType
template <class Indi> template <class Indi>
eoCombinedContinue<Indi> * make_combinedContinue(eoCombinedContinue<Indi> *_combined, eoContinue<Indi> *_cont) eoCombinedContinue<Indi> * make_combinedContinue(eoCombinedContinue<Indi> *_combined, eoContinue<Indi> *_cont)
{ {
if (_combined) // already exists if (_combined) // already exists
_combined->add(*_cont); _combined->add(*_cont);
else else
_combined = new eoCombinedContinue<Indi>(*_cont); _combined = new eoCombinedContinue<Indi>(*_cont);
@ -81,10 +81,10 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
if (maxGenParam.value()) // positive: -> define and store if (maxGenParam.value()) // positive: -> define and store
{ {
eoGenContinue<Indi> *genCont = new eoGenContinue<Indi>(maxGenParam.value()); eoGenContinue<Indi> *genCont = new eoGenContinue<Indi>(maxGenParam.value());
_state.storeFunctor(genCont); _state.storeFunctor(genCont);
// and "add" to combined // and "add" to combined
continuator = make_combinedContinue<Indi>(continuator, genCont); continuator = make_combinedContinue<Indi>(continuator, genCont);
} }
// the steadyGen continue - only if user imput // the steadyGen continue - only if user imput
@ -92,12 +92,12 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
eoValueParam<unsigned>& minGenParam = _parser.createParam(unsigned(0), "minGen", "Minimum number of generations",'g', "Stopping criterion"); eoValueParam<unsigned>& minGenParam = _parser.createParam(unsigned(0), "minGen", "Minimum number of generations",'g', "Stopping criterion");
if (_parser.isItThere(steadyGenParam)) if (_parser.isItThere(steadyGenParam))
{ {
eoSteadyFitContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi> eoSteadyFitContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi>
(minGenParam.value(), steadyGenParam.value()); (minGenParam.value(), steadyGenParam.value());
// store // store
_state.storeFunctor(steadyCont); _state.storeFunctor(steadyCont);
// add to combinedContinue // add to combinedContinue
continuator = make_combinedContinue<Indi>(continuator, steadyCont); continuator = make_combinedContinue<Indi>(continuator, steadyCont);
} }
// Same thing with Eval - but here default value is 0 // Same thing with Eval - but here default value is 0
@ -108,10 +108,10 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
if (maxEvalParam.value()) // positive: -> define and store if (maxEvalParam.value()) // positive: -> define and store
{ {
eoEvalContinue<Indi> *evalCont = new eoEvalContinue<Indi>(_eval, maxEvalParam.value()); eoEvalContinue<Indi> *evalCont = new eoEvalContinue<Indi>(_eval, maxEvalParam.value());
_state.storeFunctor(evalCont); _state.storeFunctor(evalCont);
// and "add" to combined // and "add" to combined
continuator = make_combinedContinue<Indi>(continuator, evalCont); continuator = make_combinedContinue<Indi>(continuator, evalCont);
} }
/* /*
// the steadyEval continue - only if user imput // the steadyEval continue - only if user imput
@ -119,12 +119,12 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
eoValueParam<unsigned>& minGenParam = _parser.createParam(unsigned(0), "minGen", "Minimum number of generations",'g', "Stopping criterion"); eoValueParam<unsigned>& minGenParam = _parser.createParam(unsigned(0), "minGen", "Minimum number of generations",'g', "Stopping criterion");
if (_parser.isItThere(steadyGenParam)) if (_parser.isItThere(steadyGenParam))
{ {
eoSteadyGenContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi> eoSteadyGenContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi>
(minGenParam.value(), steadyGenParam.value()); (minGenParam.value(), steadyGenParam.value());
// store // store
_state.storeFunctor(steadyCont); _state.storeFunctor(steadyCont);
// add to combinedContinue // add to combinedContinue
continuator = make_combinedContinue<Indi>(continuator, steadyCont); continuator = make_combinedContinue<Indi>(continuator, steadyCont);
} }
*/ */
// the target fitness // the target fitness
@ -132,12 +132,12 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
eoValueParam<double>& targetFitnessParam = _parser.createParam(double(0.0), "targetFitness", "Stop when fitness reaches",'T', "Stopping criterion"); eoValueParam<double>& targetFitnessParam = _parser.createParam(double(0.0), "targetFitness", "Stop when fitness reaches",'T', "Stopping criterion");
if (_parser.isItThere(targetFitnessParam)) if (_parser.isItThere(targetFitnessParam))
{ {
fitCont = new eoFitContinue<Indi> fitCont = new eoFitContinue<Indi>
(targetFitnessParam.value()); (targetFitnessParam.value());
// store // store
_state.storeFunctor(fitCont); _state.storeFunctor(fitCont);
// add to combinedContinue // add to combinedContinue
continuator = make_combinedContinue<Indi>(continuator, fitCont); continuator = make_combinedContinue<Indi>(continuator, fitCont);
} }
#ifndef _MSC_VER #ifndef _MSC_VER
@ -146,11 +146,11 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
eoValueParam<bool>& ctrlCParam = _parser.createParam(false, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion"); eoValueParam<bool>& ctrlCParam = _parser.createParam(false, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion");
if (ctrlCParam.value()) if (ctrlCParam.value())
{ {
ctrlCCont = new eoCtrlCContinue<Indi>; ctrlCCont = new eoCtrlCContinue<Indi>;
// store // store
_state.storeFunctor(ctrlCCont); _state.storeFunctor(ctrlCCont);
// add to combinedContinue // add to combinedContinue
continuator = make_combinedContinue<Indi>(continuator, ctrlCCont); continuator = make_combinedContinue<Indi>(continuator, ctrlCCont);
} }
#endif #endif

View file

@ -3,7 +3,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// make_general_replacement.h // make_general_replacement.h
// (c) Marc Schoenauer and Pierre Collet, 2002 // (c) Marc Schoenauer and Pierre Collet, 2002
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -49,8 +49,8 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
eoReduce<EOT> * ptReduce; eoReduce<EOT> * ptReduce;
// ---------- Deterministic // ---------- Deterministic
if ( (_ppReduce.first == std::string("Deterministic")) || if ( (_ppReduce.first == std::string("Deterministic")) ||
(_ppReduce.first == std::string("Sequential")) (_ppReduce.first == std::string("Sequential"))
) )
{ {
ptReduce = new eoTruncate<EOT>; ptReduce = new eoTruncate<EOT>;
@ -65,7 +65,7 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
// put back 6 in parameter for consistency (and status file) // put back 6 in parameter for consistency (and status file)
_ppReduce.second.push_back(std::string("6")); _ppReduce.second.push_back(std::string("6"));
} }
else // parameter passed by user as EP(T) else // parameter passed by user as EP(T)
detSize = atoi(_ppReduce.second[0].c_str()); detSize = atoi(_ppReduce.second[0].c_str());
ptReduce = new eoEPReduce<EOT>(detSize); ptReduce = new eoEPReduce<EOT>(detSize);
} }
@ -74,12 +74,12 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
{ {
if (!_ppReduce.second.size()) // no parameter added if (!_ppReduce.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl; std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
detSize = 2; detSize = 2;
// put back 2 in parameter for consistency (and status file) // put back 2 in parameter for consistency (and status file)
_ppReduce.second.push_back(std::string("2")); _ppReduce.second.push_back(std::string("2"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
detSize = atoi(_ppReduce.second[0].c_str()); detSize = atoi(_ppReduce.second[0].c_str());
ptReduce = new eoDetTournamentTruncate<EOT>(detSize); ptReduce = new eoDetTournamentTruncate<EOT>(detSize);
} }
@ -87,24 +87,24 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
{ {
double p; double p;
if (!_ppReduce.second.size()) // no parameter added if (!_ppReduce.second.size()) // no parameter added
{ {
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl; std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
p = 1; p = 1;
// put back p in parameter for consistency (and status file) // put back p in parameter for consistency (and status file)
_ppReduce.second.push_back(std::string("1")); _ppReduce.second.push_back(std::string("1"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
{ {
p = atof(_ppReduce.second[0].c_str()); p = atof(_ppReduce.second[0].c_str());
if ( (p<=0.5) || (p>1) ) if ( (p<=0.5) || (p>1) )
throw std::runtime_error("Stochastic tournament size should be in [0.5,1]"); throw std::runtime_error("Stochastic tournament size should be in [0.5,1]");
} }
ptReduce = new eoStochTournamentTruncate<EOT>(p); ptReduce = new eoStochTournamentTruncate<EOT>(p);
} }
else if ( (_ppReduce.first == std::string("Uniform")) || else if ( (_ppReduce.first == std::string("Uniform")) ||
(_ppReduce.first == std::string("Random")) (_ppReduce.first == std::string("Random"))
) )
{ {
ptReduce = new eoRandomReduce<EOT>; ptReduce = new eoRandomReduce<EOT>;
} }
@ -117,10 +117,10 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
return (*ptReduce); return (*ptReduce);
} }
/** Helper function that creates a replacement from the class /** Helper function that creates a replacement from the class
* eoReduceMergeReduce using 6 parameters * eoReduceMergeReduce using 6 parameters
* (after the usual eoState and eoParser) * (after the usual eoState and eoParser)
* *
* eoHowMany _elite the number of elite parents (0 = no elitism) * eoHowMany _elite the number of elite parents (0 = no elitism)
* see below * see below
* bool _strongElitism if elite > 0, std::string elitism or weak elitism * bool _strongElitism if elite > 0, std::string elitism or weak elitism
@ -136,15 +136,15 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
*/ */
template <class EOT> template <class EOT>
eoReplacement<EOT> & make_general_replacement( eoReplacement<EOT> & make_general_replacement(
eoParser& _parser, eoState& _state, eoParser& _parser, eoState& _state,
eoHowMany _elite = eoHowMany(0), eoHowMany _elite = eoHowMany(0),
bool _strongElitism = false, bool _strongElitism = false,
eoHowMany _surviveParents = eoHowMany(0.0), eoHowMany _surviveParents = eoHowMany(0.0),
eoParamParamType & _reduceParentType = eoParamParamType("Deterministic"), eoParamParamType & _reduceParentType = eoParamParamType("Deterministic"),
eoHowMany _surviveOffspring = eoHowMany(1.0), eoHowMany _surviveOffspring = eoHowMany(1.0),
eoParamParamType & _reduceOffspringType = eoParamParamType("Deterministic"), eoParamParamType & _reduceOffspringType = eoParamParamType("Deterministic"),
eoParamParamType & _reduceFinalType = eoParamParamType("Deterministic") eoParamParamType & _reduceFinalType = eoParamParamType("Deterministic")
) )
{ {
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// the replacement // the replacement
@ -157,14 +157,14 @@ eoReplacement<EOT> & make_general_replacement(
// reduce the parents // reduce the parents
eoHowMany surviveParents = _parser.createParam(_surviveParents, "surviveParents", "Nb of surviving parents (percentage or absolute)", '\0', "Evolution Engine / Replacement").value(); eoHowMany surviveParents = _parser.createParam(_surviveParents, "surviveParents", "Nb of surviving parents (percentage or absolute)", '\0', "Evolution Engine / Replacement").value();
eoParamParamType & reduceParentType = _parser.createParam(_reduceParentType, "reduceParents", "Parents reducer: Deterministic, EP(T), DetTour(T), StochTour(t), Uniform", '\0', "Evolution Engine / Replacement").value(); eoParamParamType & reduceParentType = _parser.createParam(_reduceParentType, "reduceParents", "Parents reducer: Deterministic, EP(T), DetTour(T), StochTour(t), Uniform", '\0', "Evolution Engine / Replacement").value();
eoReduce<EOT> & reduceParent = decode_reduce<EOT>(reduceParentType, _state); eoReduce<EOT> & reduceParent = decode_reduce<EOT>(reduceParentType, _state);
// reduce the offspring // reduce the offspring
eoHowMany surviveOffspring = _parser.createParam(_surviveOffspring, "surviveOffspring", "Nb of surviving offspring (percentage or absolute)", '\0', "Evolution Engine / Replacement").value(); eoHowMany surviveOffspring = _parser.createParam(_surviveOffspring, "surviveOffspring", "Nb of surviving offspring (percentage or absolute)", '\0', "Evolution Engine / Replacement").value();
eoParamParamType & reduceOffspringType = _parser.createParam(_reduceOffspringType, "reduceOffspring", "Offspring reducer: Deterministic, EP(T), DetTour(T), StochTour(t), Uniform", '\0', "Evolution Engine / Replacement").value(); eoParamParamType & reduceOffspringType = _parser.createParam(_reduceOffspringType, "reduceOffspring", "Offspring reducer: Deterministic, EP(T), DetTour(T), StochTour(t), Uniform", '\0', "Evolution Engine / Replacement").value();
eoReduce<EOT> & reduceOffspring = decode_reduce<EOT>(reduceOffspringType, _state); eoReduce<EOT> & reduceOffspring = decode_reduce<EOT>(reduceOffspringType, _state);

View file

@ -59,7 +59,7 @@ eoPop<EOT>& do_make_pop(eoParser & _parser, eoState& _state, eoInit<EOT> & _ini
// random seed // random seed
eoValueParam<uint32_t>& seedParam = _parser.getORcreateParam(uint32_t(0), "seed", "Random number seed", 'S'); eoValueParam<uint32_t>& seedParam = _parser.getORcreateParam(uint32_t(0), "seed", "Random number seed", 'S');
if (seedParam.value() == 0) if (seedParam.value() == 0)
seedParam.value() = time(0); seedParam.value() = time(0);
eoValueParam<unsigned>& popSize = _parser.getORcreateParam(unsigned(20), "popSize", "Population Size", 'P', "Evolution Engine"); eoValueParam<unsigned>& popSize = _parser.getORcreateParam(unsigned(20), "popSize", "Population Size", 'P', "Evolution Engine");
// Either load or initialize // Either load or initialize
@ -82,17 +82,17 @@ eoPop<EOT>& do_make_pop(eoParser & _parser, eoState& _state, eoInit<EOT> & _ini
// the fitness is read in the file: // the fitness is read in the file:
// do only evaluate the pop if the fitness has changed // do only evaluate the pop if the fitness has changed
if (recomputeFitnessParam.value()) if (recomputeFitnessParam.value())
{ {
for (unsigned i=0; i<pop.size(); i++) for (unsigned i=0; i<pop.size(); i++)
pop[i].invalidate(); pop[i].invalidate();
} }
if (pop.size() < popSize.value()) if (pop.size() < popSize.value())
std::cerr << "WARNING, only " << pop.size() << " individuals read in file " << loadNameParam.value() << "\nThe remaining " << popSize.value() - pop.size() << " will be randomly drawn" << std::endl; std::cerr << "WARNING, only " << pop.size() << " individuals read in file " << loadNameParam.value() << "\nThe remaining " << popSize.value() - pop.size() << " will be randomly drawn" << std::endl;
if (pop.size() > popSize.value()) if (pop.size() > popSize.value())
{ {
std::cerr << "WARNING, Load file contained too many individuals. Only the best will be retained" << std::endl; std::cerr << "WARNING, Load file contained too many individuals. Only the best will be retained" << std::endl;
pop.resize(popSize.value()); pop.resize(popSize.value());
} }
} }
else // nothing loaded from a file else // nothing loaded from a file
{ {

View file

@ -3,7 +3,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// make_run.h // make_run.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001 // (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either

View file

@ -8,16 +8,16 @@
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. 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 WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A 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 with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: cahon@lifl.fr Contact: cahon@lifl.fr
*/ */
@ -32,26 +32,26 @@
#include <eoOp.h> #include <eoOp.h>
/** /**
The abstract cellular easy algorithm. The abstract cellular easy algorithm.
@ingroup Algorithms @ingroup Algorithms
*/ */
template <class EOT> class eoCellularEasyEA : public eoAlgo <EOT> { template <class EOT> class eoCellularEasyEA : public eoAlgo <EOT> {
public : public :
/** /**
Two constructors Two constructors
*/ */
eoCellularEasyEA (eoContinue <EOT> & _cont, // Stop. criterion eoCellularEasyEA (eoContinue <EOT> & _cont, // Stop. criterion
eoEvalFunc <EOT> & _eval, // Evaluation function eoEvalFunc <EOT> & _eval, // Evaluation function
eoSelectOne <EOT> & _sel_neigh, // To choose a partner eoSelectOne <EOT> & _sel_neigh, // To choose a partner
eoBinOp <EOT> & _cross, // Cross-over operator eoBinOp <EOT> & _cross, // Cross-over operator
eoMonOp <EOT> & _mut, // Mutation operator eoMonOp <EOT> & _mut, // Mutation operator
eoSelectOne <EOT> & _sel_repl /* Which to keep between the new eoSelectOne <EOT> & _sel_repl /* Which to keep between the new
child and the old individual ? */ child and the old individual ? */
) : ) :
cont (_cont), cont (_cont),
eval (_eval), eval (_eval),
popEval (_eval), popEval (_eval),
@ -60,18 +60,18 @@ public :
mut (_mut), mut (_mut),
sel_child (eoSelectFirstOne ()), sel_child (eoSelectFirstOne ()),
sel_repl (_sel_repl) { sel_repl (_sel_repl) {
} }
eoCellularEasyEA (eoContinue <EOT> & _cont, eoCellularEasyEA (eoContinue <EOT> & _cont,
eoEvalFunc <EOT> & _eval, eoEvalFunc <EOT> & _eval,
eoSelectOne <EOT> & _sel_neigh, eoSelectOne <EOT> & _sel_neigh,
eoQuadOp <EOT> & _cross, eoQuadOp <EOT> & _cross,
eoMonOp <EOT> & _mut, eoMonOp <EOT> & _mut,
eoSelectOne <EOT> & _sel_child, /* To choose one from eoSelectOne <EOT> & _sel_child, /* To choose one from
the both children */ the both children */
eoSelectOne <EOT> & _sel_repl eoSelectOne <EOT> & _sel_repl
) : ) :
cont (_cont), cont (_cont),
eval (_eval), eval (_eval),
popEval (_eval), popEval (_eval),
@ -80,7 +80,7 @@ public :
mut (_mut), mut (_mut),
sel_child (_sel_child), sel_child (_sel_child),
sel_repl (_sel_repl) { sel_repl (_sel_repl) {
} }
/** /**
@ -88,55 +88,55 @@ public :
*/ */
void operator () (eoPop <EOT> & pop) { void operator () (eoPop <EOT> & pop) {
do { do {
for (unsigned i = 0 ; i < pop.size () ; i ++) { for (unsigned i = 0 ; i < pop.size () ; i ++) {
// Who are neighbouring to the current individual ?
eoPop <EOT> neigh = neighbours (pop, i) ;
// To select a partner
EOT part, old_sol = pop [i] ;
part = sel_neigh (neigh) ;
// To perform cross-over // Who are neighbouring to the current individual ?
cross (pop [i], part) ; eoPop <EOT> neigh = neighbours (pop, i) ;
// To perform mutation // To select a partner
mut (pop [i]) ; EOT part, old_sol = pop [i] ;
mut (part) ; part = sel_neigh (neigh) ;
pop [i].invalidate () ;
part.invalidate () ;
eval (pop [i]) ;
eval (part) ;
// To choose one of the two children ... // To perform cross-over
eoPop <EOT> pop_loc ; cross (pop [i], part) ;
pop_loc.push_back (pop [i]) ;
pop_loc.push_back (part) ;
pop [i] = sel_child (pop_loc) ; // To perform mutation
mut (pop [i]) ;
mut (part) ;
// To choose only one between the new made child and the old individual pop [i].invalidate () ;
pop_loc.clear () ; part.invalidate () ;
pop_loc.push_back (pop [i]) ; eval (pop [i]) ;
eval (part) ;
pop_loc.push_back (old_sol) ;
// To choose one of the two children ...
pop [i] = sel_repl (pop_loc) ; eoPop <EOT> pop_loc ;
pop_loc.push_back (pop [i]) ;
pop_loc.push_back (part) ;
pop [i] = sel_child (pop_loc) ;
// To choose only one between the new made child and the old individual
pop_loc.clear () ;
pop_loc.push_back (pop [i]) ;
pop_loc.push_back (old_sol) ;
pop [i] = sel_repl (pop_loc) ;
} }
} while (cont (pop)) ; } while (cont (pop)) ;
} }
protected : protected :
virtual eoPop <EOT> neighbours (const eoPop <EOT> & pop, int rank) = 0 ; virtual eoPop <EOT> neighbours (const eoPop <EOT> & pop, int rank) = 0 ;
private : private :
eoContinue <EOT> & cont ; eoContinue <EOT> & cont ;
eoEvalFunc <EOT> & eval ; eoEvalFunc <EOT> & eval ;
eoPopLoopEval <EOT> popEval ; eoPopLoopEval <EOT> popEval ;
@ -145,18 +145,18 @@ private :
eoMonOp <EOT> & mut ; eoMonOp <EOT> & mut ;
eoSelectOne <EOT> & sel_child ; eoSelectOne <EOT> & sel_child ;
eoSelectOne <EOT> & sel_repl ; eoSelectOne <EOT> & sel_repl ;
class eoSelectFirstOne : public eoSelectOne <EOT> { class eoSelectFirstOne : public eoSelectOne <EOT> {
public : public :
const EOT & operator () (const eoPop <EOT> & pop) { const EOT & operator () (const eoPop <EOT> & pop) {
return pop [0] ; return pop [0] ;
} }
} ; } ;
} ; } ;
#endif #endif

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// eoCloneOps.h // eoCloneOps.h
// (c) GeNeura Team, 1998 // (c) GeNeura Team, 1998
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -18,7 +18,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es Contact: todos@geneura.ugr.es, http://geneura.ugr.es
CVS Info: $Date: 2003-02-27 19:26:09 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoCloneOps.h,v 1.2 2003-02-27 19:26:09 okoenig Exp $ $Author: okoenig $ CVS Info: $Date: 2003-02-27 19:26:09 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoCloneOps.h,v 1.2 2003-02-27 19:26:09 okoenig Exp $ $Author: okoenig $
*/ */
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -29,9 +29,9 @@
/** /**
* The different null-variation operators (i.e. they do nothing) * The different null-variation operators (i.e. they do nothing)
* *
* eoQuadCloneOp at least is useful to emulate the standard * eoQuadCloneOp at least is useful to emulate the standard
* crossover(pCross) + mutation(pMut) * crossover(pCross) + mutation(pMut)
* within the eoGenOp framework * within the eoGenOp framework
* eoMonCloneOp will probably be useful as the copy operator * eoMonCloneOp will probably be useful as the copy operator
* eoBinCloneOp will certainly never been used - but let's be complete :-) * eoBinCloneOp will certainly never been used - but let's be complete :-)
@ -80,4 +80,3 @@ virtual bool operator()(EOT& , EOT& ) {return false;}
#endif #endif
/** @} */ /** @} */

View file

@ -3,7 +3,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// eoCombinedContinue.h // eoCombinedContinue.h
// (c) Maarten Keijzer, GeNeura Team, 1999, 2000 // (c) Maarten Keijzer, GeNeura Team, 1999, 2000
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -27,7 +27,7 @@
#include <eoContinue.h> #include <eoContinue.h>
/** /**
Combined continuators - logical AND: Combined continuators - logical AND:
Continues until one of the embedded continuators says halt! Continues until one of the embedded continuators says halt!
@ -35,7 +35,7 @@
to be consistent with other Combined constructs to be consistent with other Combined constructs
and allow to easily handle more than 2 continuators and allow to easily handle more than 2 continuators
02/2003 Ramón Casero Cañas - added the removeLast() method 02/2003 Ramón Casero Cañas - added the removeLast() method
@ingroup Combination @ingroup Combination
*/ */
@ -90,4 +90,3 @@ private:
}; };
#endif #endif

View file

@ -3,7 +3,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// eoCombinedInit.h // eoCombinedInit.h
// (c) Maarten Keijzer, GeNeura Team, Marc Schoenauer 2004 // (c) Maarten Keijzer, GeNeura Team, Marc Schoenauer 2004
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -27,7 +27,7 @@
#include <eoInit.h> #include <eoInit.h>
/** /**
Combined INIT: a proportional recombination of eoInit objects Combined INIT: a proportional recombination of eoInit objects
@ingroup Initializators @ingroup Initializators
@ -49,7 +49,7 @@ public:
eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoCombinedInit::add is deprecated and will be removed in the next release." << std::endl; eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoCombinedInit::add is deprecated and will be removed in the next release." << std::endl;
add( _init, _rate ); add( _init, _rate );
} }
/** The usual method to add objects to the combination /** The usual method to add objects to the combination
*/ */
void add(eoInit<EOT> & _init, double _rate) void add(eoInit<EOT> & _init, double _rate)
@ -78,7 +78,7 @@ public:
virtual void operator() ( EOT & _eo ) virtual void operator() ( EOT & _eo )
{ {
unsigned what = rng.roulette_wheel(rates); // choose one op unsigned what = rng.roulette_wheel(rates); // choose one op
(*initializers[what])(_eo); // apply it (*initializers[what])(_eo); // apply it
return; return;
} }
@ -90,4 +90,3 @@ std::vector<double> rates;
}; };
#endif #endif

View file

@ -56,9 +56,9 @@ public:
* @param _topology - The topology to get the global/local/other best * @param _topology - The topology to get the global/local/other best
* @param _coeff - The constriction coefficient * @param _coeff - The constriction coefficient
* @param _weightUpdater - An eoWeightUpdater used to update the inertia weight * @param _weightUpdater - An eoWeightUpdater used to update the inertia weight
* @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType
* @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
* @param _bndsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only). * @param _bndsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only).
* @param _gen - The eo random generator, default=rng * @param _gen - The eo random generator, default=rng
@ -85,9 +85,9 @@ public:
* @param _topology - The topology to get the global/local/other best * @param _topology - The topology to get the global/local/other best
* @param _coeff - The constriction coefficient * @param _coeff - The constriction coefficient
* @param _weightUpdater - An eoWeightUpdater used to update the inertia weight * @param _weightUpdater - An eoWeightUpdater used to update the inertia weight
* @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType
* @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
* @param _gen - The eo random generator, default=rng * @param _gen - The eo random generator, default=rng
*/ */
@ -112,8 +112,8 @@ public:
* @param _topology - The topology to get the global/local/other best* * @param _topology - The topology to get the global/local/other best*
* @param _coeff - The constriction coefficient * @param _coeff - The constriction coefficient
* @param _weightUpdater - An eoWeightUpdater used to update the inertia weight * @param _weightUpdater - An eoWeightUpdater used to update the inertia weight
* @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType
* @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType
* @param _gen - The eo random generator, default=rng * @param _gen - The eo random generator, default=rng
*/ */
eoConstrictedVariableWeightVelocity (eoTopology < POT > & _topology, eoConstrictedVariableWeightVelocity (eoTopology < POT > & _topology,
@ -134,7 +134,7 @@ public:
/** /**
* Evaluate the new velocities of the given particle. Need an indice to identify the particle * Evaluate the new velocities of the given particle. Need an indice to identify the particle
* into the topology. Steps are : * into the topology. Steps are :
* - evaluate r1 and r2, the customed learning factors * - evaluate r1 and r2, the customed learning factors
* - adjust the size of the bounds (even if dummy) * - adjust the size of the bounds (even if dummy)
* - update the weight with the weightUpdater (use the dummy updater if there's no updater provided) * - update the weight with the weightUpdater (use the dummy updater if there's no updater provided)
@ -189,22 +189,21 @@ public:
protected: protected:
eoTopology < POT > & topology; eoTopology < POT > & topology;
const VelocityType & coeff; // the fixed constriction coefficient const VelocityType & coeff; // the fixed constriction coefficient
eoWeightUpdater<VelocityType> & weightUpdater; // the updater used to make the weight evoluate eoWeightUpdater<VelocityType> & weightUpdater; // the updater used to make the weight evoluate
const VelocityType & c1; // learning factor 1 const VelocityType & c1; // learning factor 1
const VelocityType & c2; // learning factor 2 const VelocityType & c2; // learning factor 2
eoRealVectorBounds & bounds; // REAL bounds even if the velocity could be of another type. eoRealVectorBounds & bounds; // REAL bounds even if the velocity could be of another type.
eoRealBoundModifier & bndsModifier; eoRealBoundModifier & bndsModifier;
VelocityType weight; VelocityType weight;
eoRng & gen; // the random generator eoRng & gen; // the random generator
// If the bound modifier doesn't need to be used, use the dummy instance // If the bound modifier doesn't need to be used, use the dummy instance
eoDummyRealBoundModifier dummyModifier; eoDummyRealBoundModifier dummyModifier;
}; };
#endif /*EOCONSTRICTEDVARIABLEWEIGHTVELOCITY_H*/ #endif /*EOCONSTRICTEDVARIABLEWEIGHTVELOCITY_H*/

View file

@ -56,9 +56,9 @@ public:
/** Full constructor: Bounds and bound modifier required /** Full constructor: Bounds and bound modifier required
* @param _topology - The topology to get the global/local/other best * @param _topology - The topology to get the global/local/other best
* @param _coeff - The constriction coefficient * @param _coeff - The constriction coefficient
* @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType
* @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
* @param _bndsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only). * @param _bndsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only).
* @param _gen - The eo random generator, default=rng * @param _gen - The eo random generator, default=rng
@ -82,9 +82,9 @@ public:
/** Constructor: No bound updater required <-> fixed bounds /** Constructor: No bound updater required <-> fixed bounds
* @param _topology - The topology to get the global/local/other best * @param _topology - The topology to get the global/local/other best
* @param _coeff - The constriction coefficient * @param _coeff - The constriction coefficient
* @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType
* @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
* @param _gen - The eo random generator, default=rng * @param _gen - The eo random generator, default=rng
*/ */
@ -106,8 +106,8 @@ public:
/** Constructor: Neither bounds nor bound updater required <-> free velocity /** Constructor: Neither bounds nor bound updater required <-> free velocity
* @param _topology - The topology to get the global/local/other best * @param _topology - The topology to get the global/local/other best
* @param _coeff - The constriction coefficient * @param _coeff - The constriction coefficient
* @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType
* @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType
* @param _gen - The eo random generator, default=rng * @param _gen - The eo random generator, default=rng
*/ */
eoConstrictedVelocity (eoTopology < POT > & _topology, eoConstrictedVelocity (eoTopology < POT > & _topology,
@ -126,7 +126,7 @@ public:
/** /**
* Evaluate the new velocities of the given particle. Need an indice to identify the particle * Evaluate the new velocities of the given particle. Need an indice to identify the particle
* into the topology. Steps are : * into the topology. Steps are :
* - evaluate r1 and r2, the customed learning factors * - evaluate r1 and r2, the customed learning factors
* - adjust the size of the bounds (even if dummy) * - adjust the size of the bounds (even if dummy)
* - modify the bounds with the bounds modifier (use the dummy modifier if there's no modifier provided) * - modify the bounds with the bounds modifier (use the dummy modifier if there's no modifier provided)
@ -173,20 +173,20 @@ public:
topology.updateNeighborhood(_po,_indice); topology.updateNeighborhood(_po,_indice);
} }
//! eoTopology<POT> getTopology //! eoTopology<POT> getTopology
//! @return topology //! @return topology
eoTopology<POT> & getTopology () eoTopology<POT> & getTopology ()
{ {
return topology; return topology;
} }
protected: protected:
eoTopology < POT > & topology; eoTopology < POT > & topology;
const VelocityType & c1; // learning factor 1 const VelocityType & c1; // learning factor 1
const VelocityType & c2; // learning factor 2 const VelocityType & c2; // learning factor 2
const VelocityType & coeff; // the fixed constriction coefficient const VelocityType & coeff; // the fixed constriction coefficient
eoRng & gen; // the random generator eoRng & gen; // the random generator
eoRealVectorBounds & bounds; // REAL bounds even if the velocity could be of another type. eoRealVectorBounds & bounds; // REAL bounds even if the velocity could be of another type.
eoRealBoundModifier & bndsModifier; eoRealBoundModifier & bndsModifier;
@ -197,4 +197,3 @@ protected:
#endif /*EOCONSTRICTEDVELOCITY_H */ #endif /*EOCONSTRICTEDVELOCITY_H */

View file

@ -3,7 +3,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// eoContinue.h // eoContinue.h
// (c) Maarten Keijzer, Geneura Team, 1999, 2000 // (c) Maarten Keijzer, Geneura Team, 1999, 2000
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -31,7 +31,7 @@
/** @defgroup Continuators Stopping criteria /** @defgroup Continuators Stopping criteria
* *
* A stopping criterion is called a "continue". This is a functor that is called at each generation end * A stopping criterion is called a "continue". This is a functor that is called at each generation end
* and that return true if one should stop the search. * and that return true if one should stop the search.
* *
* @ingroup Utilities * @ingroup Utilities
@ -39,13 +39,13 @@
/** Termination condition for the genetic algorithm /** Termination condition for the genetic algorithm
* Takes the population as input, returns true for continue, * Takes the population as input, returns true for continue,
* false for termination * false for termination
* *
* @ingroup Continuators * @ingroup Continuators
* @ingroup Core * @ingroup Core
*/ */
template< class EOT> template< class EOT>
class eoContinue : public eoUF<const eoPop<EOT>&, bool>, public eoPersistent class eoContinue : public eoUF<const eoPop<EOT>&, bool>, public eoPersistent
{ {
public: public:
virtual std::string className(void) const { return "eoContinue"; } virtual std::string className(void) const { return "eoContinue"; }
@ -57,7 +57,7 @@ public:
(void)__is; (void)__is;
/* It should be implemented by subclasses ! */ /* It should be implemented by subclasses ! */
} }
/** Print on a stream /** Print on a stream
* @param __os ostream to print on * @param __os ostream to print on
*/ */
@ -68,4 +68,3 @@ public:
}; };
#endif #endif

Some files were not shown because too many files have changed in this diff Show more