* 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,13 +11,14 @@ 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

@ -128,18 +128,18 @@ public:
// 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,11 +151,11 @@ 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

@ -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

@ -87,12 +87,12 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
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,14 +100,14 @@ 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);
} }
@ -115,42 +115,42 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
{ {
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
@ -246,22 +246,22 @@ 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);
@ -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);
} }
@ -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

@ -84,7 +84,7 @@ 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");
@ -97,12 +97,12 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
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);
} }
@ -112,14 +112,14 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
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,14 +127,14 @@ 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);
} }
@ -142,42 +142,42 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
{ {
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)
@ -233,14 +233,14 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
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);
} }
@ -253,14 +253,14 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
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);
} }
@ -268,14 +268,14 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
{ {
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);
} }

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

@ -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

@ -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>;
} }
@ -144,7 +144,7 @@ eoReplacement<EOT> & make_general_replacement(
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

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

@ -45,13 +45,13 @@ public :
*/ */
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),
@ -64,14 +64,14 @@ public :
} }
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),
@ -93,39 +93,39 @@ public :
for (unsigned i = 0 ; i < pop.size () ; i ++) { for (unsigned i = 0 ; i < pop.size () ; i ++) {
// Who are neighbouring to the current individual ? // Who are neighbouring to the current individual ?
eoPop <EOT> neigh = neighbours (pop, i) ; eoPop <EOT> neigh = neighbours (pop, i) ;
// To select a partner // To select a partner
EOT part, old_sol = pop [i] ; EOT part, old_sol = pop [i] ;
part = sel_neigh (neigh) ; part = sel_neigh (neigh) ;
// To perform cross-over // To perform cross-over
cross (pop [i], part) ; cross (pop [i], part) ;
// To perform mutation // To perform mutation
mut (pop [i]) ; mut (pop [i]) ;
mut (part) ; mut (part) ;
pop [i].invalidate () ; pop [i].invalidate () ;
part.invalidate () ; part.invalidate () ;
eval (pop [i]) ; eval (pop [i]) ;
eval (part) ; eval (part) ;
// To choose one of the two children ... // To choose one of the two children ...
eoPop <EOT> pop_loc ; eoPop <EOT> pop_loc ;
pop_loc.push_back (pop [i]) ; pop_loc.push_back (pop [i]) ;
pop_loc.push_back (part) ; pop_loc.push_back (part) ;
pop [i] = sel_child (pop_loc) ; pop [i] = sel_child (pop_loc) ;
// To choose only one between the new made child and the old individual // To choose only one between the new made child and the old individual
pop_loc.clear () ; pop_loc.clear () ;
pop_loc.push_back (pop [i]) ; pop_loc.push_back (pop [i]) ;
pop_loc.push_back (old_sol) ; pop_loc.push_back (old_sol) ;
pop [i] = sel_repl (pop_loc) ; pop [i] = sel_repl (pop_loc) ;
} }
} while (cont (pop)) ; } while (cont (pop)) ;

View file

@ -80,4 +80,3 @@ virtual bool operator()(EOT& , EOT& ) {return false;}
#endif #endif
/** @} */ /** @} */

View file

@ -90,4 +90,3 @@ private:
}; };
#endif #endif

View file

@ -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

@ -191,20 +191,19 @@ 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

@ -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

@ -68,4 +68,3 @@ public:
}; };
#endif #endif

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