* indentations + whitespace cleanup
This commit is contained in:
parent
8457e39efe
commit
56c6edab04
285 changed files with 6068 additions and 6223 deletions
|
|
@ -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
|
||||
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
|
||||
(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
|
||||
|
||||
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
|
||||
|
||||
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:
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// make_algo_easea.h
|
||||
// (c) Marc Schoenauer and Pierre Collet, 2002
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -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> >
|
||||
|
||||
eoSelectOne<EOT>* select ;
|
||||
if (ppSelect.first == std::string("DetTour"))
|
||||
if (ppSelect.first == std::string("DetTour"))
|
||||
{
|
||||
unsigned detSize;
|
||||
|
||||
if (!ppSelect.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("2"));
|
||||
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
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());
|
||||
select = new eoDetTournamentSelect<EOT>(detSize);
|
||||
}
|
||||
|
|
@ -100,57 +100,57 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
|||
{
|
||||
double p;
|
||||
if (!ppSelect.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back p in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back p in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
|
||||
select = new eoStochTournamentSelect<EOT>(p);
|
||||
}
|
||||
else if (ppSelect.first == std::string("Ranking"))
|
||||
{
|
||||
double p,e;
|
||||
if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent
|
||||
{
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
e = atof(ppSelect.second[1].c_str());
|
||||
}
|
||||
else if (ppSelect.second.size()==1) // 1 parameter: pressure
|
||||
{
|
||||
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
|
||||
e = 1;
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
}
|
||||
{
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
e = atof(ppSelect.second[1].c_str());
|
||||
}
|
||||
else if (ppSelect.second.size()==1) // 1 parameter: pressure
|
||||
{
|
||||
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
|
||||
e = 1;
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
}
|
||||
else // no parameters ... or garbage
|
||||
{
|
||||
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
|
||||
p=2;
|
||||
e=1;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.resize(2); // just in case
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
{
|
||||
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
|
||||
p=2;
|
||||
e=1;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.resize(2); // just in case
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
// check for authorized values
|
||||
// pressure in (0,1]
|
||||
if ( (p<=1) || (p>2) )
|
||||
{
|
||||
std::cerr << "WARNING, selective pressure must be in (1,2] in Ranking, using 2\n";
|
||||
p=2;
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
}
|
||||
{
|
||||
std::cerr << "WARNING, selective pressure must be in (1,2] in Ranking, using 2\n";
|
||||
p=2;
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
}
|
||||
// exponent >0
|
||||
if (e<=0)
|
||||
{
|
||||
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
|
||||
e=1;
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
{
|
||||
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
|
||||
e=1;
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
// now we're OK
|
||||
eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) );
|
||||
select = new eoRouletteWorthSelect<EOT>(p2w);
|
||||
|
|
@ -159,13 +159,13 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
|||
{
|
||||
bool b;
|
||||
if (ppSelect.second.size() == 0) // no argument -> default = ordered
|
||||
{
|
||||
b=true;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("ordered"));
|
||||
}
|
||||
{
|
||||
b=true;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("ordered"));
|
||||
}
|
||||
else
|
||||
b = !(ppSelect.second[0] == std::string("unordered"));
|
||||
b = !(ppSelect.second[0] == std::string("unordered"));
|
||||
select = new eoSequentialSelect<EOT>(b);
|
||||
}
|
||||
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);
|
||||
|
||||
// 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");
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -196,7 +196,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
|||
/////////////////////////////////////////////////////
|
||||
|
||||
/** Replacement type - high level: predefined replacements
|
||||
* ESComma :
|
||||
* ESComma :
|
||||
* elite = 0
|
||||
* surviveParents=0 (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
|
||||
* offspringRate = 100%
|
||||
* all reducers are unused
|
||||
*
|
||||
* SSGA(T/t) : Steady-State GA
|
||||
*
|
||||
* SSGA(T/t) : Steady-State GA
|
||||
* surviveParents = 1.0 - offspringRate
|
||||
* 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
|
||||
if (!replacementParam.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to MGG replacement, using 2" << std::endl;
|
||||
tSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
replacementParam.second.push_back(std::string("2"));
|
||||
std::cerr << "WARNING, no parameter passed to MGG replacement, using 2" << std::endl;
|
||||
tSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
replacementParam.second.push_back(std::string("2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
t = atof(replacementParam.second[0].c_str());
|
||||
if (t>=2)
|
||||
{ // build the appropriate deafult value
|
||||
tSize = unsigned(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Sorry, only deterministic tournament available at the moment");
|
||||
}
|
||||
t = atof(replacementParam.second[0].c_str());
|
||||
if (t>=2)
|
||||
{ // build the appropriate deafult value
|
||||
tSize = unsigned(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
else { // until the end of what was the only loop/switch
|
||||
|
||||
|
||||
// the default deafult values
|
||||
eoHowMany elite (0.0);
|
||||
bool strongElitism (false);
|
||||
|
|
@ -283,12 +283,12 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
|||
// ---------- General
|
||||
if (replacementParam.first == std::string("General"))
|
||||
{
|
||||
; // defaults OK
|
||||
; // defaults OK
|
||||
}
|
||||
// ---------- ESComma
|
||||
else if (replacementParam.first == std::string("ESComma"))
|
||||
{
|
||||
; // OK too
|
||||
; // OK too
|
||||
}
|
||||
// ---------- ESPlus
|
||||
else if (replacementParam.first == std::string("ESPlus"))
|
||||
|
|
@ -298,16 +298,16 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
|||
// ---------- 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
|
||||
else if (replacementParam.first == std::string("EP"))
|
||||
{
|
||||
if (!replacementParam.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to EP replacement, using 6" << std::endl;
|
||||
// put back 6 in parameter for consistency (and status file)
|
||||
replacementParam.second.push_back(std::string("6"));
|
||||
std::cerr << "WARNING, no parameter passed to EP replacement, using 6" << std::endl;
|
||||
// put back 6 in parameter for consistency (and status file)
|
||||
replacementParam.second.push_back(std::string("6"));
|
||||
}
|
||||
// by coincidence, the syntax for the EP reducer is the same than here:
|
||||
reduceFinalType = replacementParam;
|
||||
|
|
@ -318,28 +318,28 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
|||
{
|
||||
if (!replacementParam.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to SSGA replacement, using 2" << std::endl;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
replacementParam.second.push_back(std::string("2"));
|
||||
reduceParentType = eoParamParamType(std::string("DetTour(2)"));
|
||||
std::cerr << "WARNING, no parameter passed to SSGA replacement, using 2" << std::endl;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
replacementParam.second.push_back(std::string("2"));
|
||||
reduceParentType = eoParamParamType(std::string("DetTour(2)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
t = atof(replacementParam.second[0].c_str());
|
||||
if (t>=2)
|
||||
{ // build the appropriate deafult value
|
||||
reduceParentType = eoParamParamType(std::string("DetTour(") + replacementParam.second[0].c_str() + ")");
|
||||
}
|
||||
else // check for [0.5,1] will be made in make_general_replacement
|
||||
{ // build the appropriate deafult value
|
||||
reduceParentType = eoParamParamType(std::string("StochTour(") + replacementParam.second[0].c_str() + ")");
|
||||
}
|
||||
t = atof(replacementParam.second[0].c_str());
|
||||
if (t>=2)
|
||||
{ // build the appropriate deafult value
|
||||
reduceParentType = eoParamParamType(std::string("DetTour(") + replacementParam.second[0].c_str() + ")");
|
||||
}
|
||||
else // check for [0.5,1] will be made in make_general_replacement
|
||||
{ // build the appropriate deafult value
|
||||
reduceParentType = eoParamParamType(std::string("StochTour(") + replacementParam.second[0].c_str() + ")");
|
||||
}
|
||||
}
|
||||
//
|
||||
//
|
||||
surviveParents = eoHowMany(-1);
|
||||
surviveOffspring = eoHowMany(1);
|
||||
}
|
||||
else // no replacement recognized
|
||||
else // no replacement recognized
|
||||
{
|
||||
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
|
||||
///////////////////////////////
|
||||
eoGeneralBreeder<EOT> *breed =
|
||||
eoGeneralBreeder<EOT> *breed =
|
||||
new eoGeneralBreeder<EOT>(*select, _op, offspringRateParam.value());
|
||||
_state.storeFunctor(breed);
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
|||
template <class EOT>
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// make_algo_scalar.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -84,42 +84,42 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
|||
if (_dist == NULL)
|
||||
comment = "Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e) or Sequential(ordered/unordered)";
|
||||
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");
|
||||
|
||||
eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> >
|
||||
|
||||
eoSelectOne<EOT>* select ;
|
||||
if (ppSelect.first == std::string("DetTour"))
|
||||
if (ppSelect.first == std::string("DetTour"))
|
||||
{
|
||||
unsigned detSize;
|
||||
|
||||
if (!ppSelect.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("2"));
|
||||
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
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());
|
||||
select = new eoDetTournamentSelect<EOT>(detSize);
|
||||
}
|
||||
else if (ppSelect.first == std::string("Sharing"))
|
||||
else if (ppSelect.first == std::string("Sharing"))
|
||||
{
|
||||
double nicheSize;
|
||||
|
||||
if (!ppSelect.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to Sharing, using 0.5" << std::endl;
|
||||
nicheSize = 0.5;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("0.5"));
|
||||
std::cerr << "WARNING, no parameter passed to Sharing, using 0.5" << std::endl;
|
||||
nicheSize = 0.5;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
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());
|
||||
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");
|
||||
select = new eoSharingSelect<EOT>(nicheSize, *_dist);
|
||||
}
|
||||
|
|
@ -127,57 +127,57 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
|||
{
|
||||
double p;
|
||||
if (!ppSelect.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back p in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back p in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
|
||||
select = new eoStochTournamentSelect<EOT>(p);
|
||||
}
|
||||
else if (ppSelect.first == std::string("Ranking"))
|
||||
{
|
||||
double p,e;
|
||||
if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent
|
||||
{
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
e = atof(ppSelect.second[1].c_str());
|
||||
}
|
||||
else if (ppSelect.second.size()==1) // 1 parameter: pressure
|
||||
{
|
||||
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
|
||||
e = 1;
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
}
|
||||
{
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
e = atof(ppSelect.second[1].c_str());
|
||||
}
|
||||
else if (ppSelect.second.size()==1) // 1 parameter: pressure
|
||||
{
|
||||
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
|
||||
e = 1;
|
||||
ppSelect.second.push_back(std::string("1"));
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
}
|
||||
else // no parameters ... or garbage
|
||||
{
|
||||
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
|
||||
p=2;
|
||||
e=1;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.resize(2); // just in case
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
{
|
||||
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
|
||||
p=2;
|
||||
e=1;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.resize(2); // just in case
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
// check for authorized values
|
||||
// pressure in (0,1]
|
||||
if ( (p<=1) || (p>2) )
|
||||
{
|
||||
std::cerr << "WARNING, selective pressure must be in (0,1] in Ranking, using 2\n";
|
||||
p=2;
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
}
|
||||
{
|
||||
std::cerr << "WARNING, selective pressure must be in (0,1] in Ranking, using 2\n";
|
||||
p=2;
|
||||
ppSelect.second[0] = (std::string("2"));
|
||||
}
|
||||
// exponent >0
|
||||
if (e<=0)
|
||||
{
|
||||
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
|
||||
e=1;
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
{
|
||||
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
|
||||
e=1;
|
||||
ppSelect.second[1] = (std::string("1"));
|
||||
}
|
||||
// now we're OK
|
||||
eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) );
|
||||
select = new eoRouletteWorthSelect<EOT>(p2w);
|
||||
|
|
@ -186,13 +186,13 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
|||
{
|
||||
bool b;
|
||||
if (ppSelect.second.size() == 0) // no argument -> default = ordered
|
||||
{
|
||||
b=true;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("ordered"));
|
||||
}
|
||||
{
|
||||
b=true;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back(std::string("ordered"));
|
||||
}
|
||||
else
|
||||
b = !(ppSelect.second[0] == std::string("unordered"));
|
||||
b = !(ppSelect.second[0] == std::string("unordered"));
|
||||
select = new eoSequentialSelect<EOT>(b);
|
||||
}
|
||||
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);
|
||||
|
||||
// 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");
|
||||
|
||||
// the replacement
|
||||
|
|
@ -231,16 +231,16 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
|||
else if (ppReplace.first == std::string("EPTour"))
|
||||
{
|
||||
unsigned detSize;
|
||||
|
||||
|
||||
if (!ppReplace.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to EPTour, using 6" << std::endl;
|
||||
detSize = 6;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppReplace.second.push_back(std::string("6"));
|
||||
}
|
||||
else // parameter passed by user as EPTour(T)
|
||||
detSize = atoi(ppSelect.second[0].c_str());
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to EPTour, using 6" << std::endl;
|
||||
detSize = 6;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppReplace.second.push_back(std::string("6"));
|
||||
}
|
||||
else // parameter passed by user as EPTour(T)
|
||||
detSize = atoi(ppSelect.second[0].c_str());
|
||||
|
||||
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"))
|
||||
{
|
||||
unsigned detSize;
|
||||
|
||||
|
||||
if (!ppReplace.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to SSGADet, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppReplace.second.push_back(std::string("2"));
|
||||
}
|
||||
else // parameter passed by user as SSGADet(T)
|
||||
detSize = atoi(ppSelect.second[0].c_str());
|
||||
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to SSGADet, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppReplace.second.push_back(std::string("2"));
|
||||
}
|
||||
else // parameter passed by user as SSGADet(T)
|
||||
detSize = atoi(ppSelect.second[0].c_str());
|
||||
|
||||
replace = new eoSSGADetTournamentReplacement<EOT>(detSize);
|
||||
}
|
||||
else if (ppReplace.first == std::string("SSGAStoch"))
|
||||
{
|
||||
double p;
|
||||
if (!ppReplace.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to SSGAStoch, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppReplace.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as SSGADet(T)
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to SSGAStoch, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back in parameter for consistency (and status file)
|
||||
ppReplace.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as SSGADet(T)
|
||||
p = atof(ppSelect.second[0].c_str());
|
||||
|
||||
replace = new eoSSGAStochTournamentReplacement<EOT>(p);
|
||||
}
|
||||
else
|
||||
|
|
@ -294,10 +294,10 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
|||
eoReplacement<EOT> *replaceTmp = replace;
|
||||
replace = new eoWeakElitistReplacement<EOT>(*replaceTmp);
|
||||
_state.storeFunctor(replace);
|
||||
}
|
||||
}
|
||||
|
||||
// the general breeder
|
||||
eoGeneralBreeder<EOT> *breed =
|
||||
eoGeneralBreeder<EOT> *breed =
|
||||
new eoGeneralBreeder<EOT>(*select, _op, offspringRateParam.value());
|
||||
_state.storeFunctor(breed);
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
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;
|
||||
|
||||
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()
|
||||
|
||||
|| 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() ||
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -367,41 +367,41 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
|
|||
|
||||
#ifdef _MSVC
|
||||
|
||||
std::string stmp = dirNameParam.value() + "\best.xg";
|
||||
std::string stmp = dirNameParam.value() + "\best.xg";
|
||||
|
||||
#else
|
||||
|
||||
std::string stmp = dirNameParam.value() + "/best.xg";
|
||||
std::string stmp = dirNameParam.value() + "/best.xg";
|
||||
|
||||
#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 )
|
||||
|
||||
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 )
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
// shoudl we empty it if exists
|
||||
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:
|
||||
|
|
@ -98,11 +98,11 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
|
|||
if ( printBestParam.value() || plotBestParam.value() || fileBestParam.value() )
|
||||
// we need the bestStat for at least one of the 3 above
|
||||
{
|
||||
bestStat = new eoBestFitnessStat<EOT>;
|
||||
// store it
|
||||
_state.storeFunctor(bestStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*bestStat);
|
||||
bestStat = new eoBestFitnessStat<EOT>;
|
||||
// store it
|
||||
_state.storeFunctor(bestStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*bestStat);
|
||||
}
|
||||
|
||||
// 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?
|
||||
if ( plotBestParam.value() ) // we need it for gnuplot output
|
||||
{
|
||||
averageStat = new eoAverageStat<EOT>;
|
||||
// store it
|
||||
_state.storeFunctor(averageStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*averageStat);
|
||||
averageStat = new eoAverageStat<EOT>;
|
||||
// store it
|
||||
_state.storeFunctor(averageStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*averageStat);
|
||||
}
|
||||
|
||||
// Second moment stats: average and stdev
|
||||
|
|
@ -122,11 +122,11 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
|
|||
eoSecondMomentStats<EOT> *secondStat = NULL;
|
||||
if ( printBestParam.value() ) // we need it for sreen output
|
||||
{
|
||||
secondStat = new eoSecondMomentStats<EOT>;
|
||||
// store it
|
||||
_state.storeFunctor(secondStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*secondStat);
|
||||
secondStat = new eoSecondMomentStats<EOT>;
|
||||
// store it
|
||||
_state.storeFunctor(secondStat);
|
||||
// add it to the checkpoint
|
||||
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");
|
||||
if ( printPopParam.value() ) // we do want pop dump
|
||||
{
|
||||
popStat = new eoSortedPopStat<EOT>("Dump of whole population");
|
||||
// store it
|
||||
_state.storeFunctor(popStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*popStat);
|
||||
popStat = new eoSortedPopStat<EOT>("Dump of whole population");
|
||||
// store it
|
||||
_state.storeFunctor(popStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*popStat);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -152,14 +152,14 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
|
|||
eoFDCStat<EOT> *fdcStat = NULL;
|
||||
if ( printFDCParam.value() || plotFDCParam.value() ) // we need FDCStat
|
||||
{
|
||||
// need first an object to compute the distances - here Hamming dist.
|
||||
eoQuadDistance<EOT> *dist = new eoQuadDistance<EOT>;
|
||||
_state.storeFunctor(dist);
|
||||
fdcStat = new eoFDCStat<EOT>(*dist);
|
||||
// storeFunctor it
|
||||
_state.storeFunctor(fdcStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*fdcStat);
|
||||
// need first an object to compute the distances - here Hamming dist.
|
||||
eoQuadDistance<EOT> *dist = new eoQuadDistance<EOT>;
|
||||
_state.storeFunctor(dist);
|
||||
fdcStat = new eoFDCStat<EOT>(*dist);
|
||||
// storeFunctor it
|
||||
_state.storeFunctor(fdcStat);
|
||||
// add it to the checkpoint
|
||||
checkpoint->add(*fdcStat);
|
||||
}
|
||||
|
||||
// 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?
|
||||
bool needStdoutMonitor = printBestParam.value() || printFDCParam.value()
|
||||
|| printPopParam.value() ;
|
||||
|| printPopParam.value() ;
|
||||
|
||||
// The Stdout monitor will print parameters to the screen ...
|
||||
if ( needStdoutMonitor )
|
||||
{
|
||||
eoStdoutMonitor *monitor = new eoStdoutMonitor(false);
|
||||
_state.storeFunctor(monitor);
|
||||
eoStdoutMonitor *monitor = new eoStdoutMonitor(false);
|
||||
_state.storeFunctor(monitor);
|
||||
|
||||
// when called by the checkpoint (i.e. at every generation)
|
||||
checkpoint->add(*monitor);
|
||||
// when called by the checkpoint (i.e. at every generation)
|
||||
checkpoint->add(*monitor);
|
||||
|
||||
// the monitor will output a series of parameters: add them
|
||||
monitor->add(*generationCounter);
|
||||
if (useEvalParam.value()) // we want nb of evaluations
|
||||
monitor->add(_eval);
|
||||
if (printBestParam.value())
|
||||
{
|
||||
monitor->add(*bestStat);
|
||||
monitor->add(*secondStat);
|
||||
}
|
||||
if (printFDCParam.value())
|
||||
monitor->add(*fdcStat);
|
||||
if ( printPopParam.value())
|
||||
monitor->add(*popStat);
|
||||
// the monitor will output a series of parameters: add them
|
||||
monitor->add(*generationCounter);
|
||||
if (useEvalParam.value()) // we want nb of evaluations
|
||||
monitor->add(_eval);
|
||||
if (printBestParam.value())
|
||||
{
|
||||
monitor->add(*bestStat);
|
||||
monitor->add(*secondStat);
|
||||
}
|
||||
if (printFDCParam.value())
|
||||
monitor->add(*fdcStat);
|
||||
if ( printPopParam.value())
|
||||
monitor->add(*popStat);
|
||||
}
|
||||
|
||||
// first handle the dir test - if we need at least one file
|
||||
if ( ( fileBestParam.value() || plotBestParam.value() ||
|
||||
plotFDCParam.value() || plotHistogramParam.value() )
|
||||
&& !dirOK ) // just in case we add something before
|
||||
plotFDCParam.value() || plotHistogramParam.value() )
|
||||
&& !dirOK ) // just in case we add something before
|
||||
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
|
||||
|
||||
if (fileBestParam.value()) // A file monitor for best & secondMoment
|
||||
{
|
||||
std::string stmp = dirNameParam.value() + "/best.xg";
|
||||
eoFileMonitor *fileMonitor = new eoFileMonitor(stmp);
|
||||
// save and give to checkpoint
|
||||
_state.storeFunctor(fileMonitor);
|
||||
checkpoint->add(*fileMonitor);
|
||||
// and feed with some statistics
|
||||
fileMonitor->add(*generationCounter);
|
||||
fileMonitor->add(_eval);
|
||||
fileMonitor->add(*bestStat);
|
||||
fileMonitor->add(*secondStat);
|
||||
std::string stmp = dirNameParam.value() + "/best.xg";
|
||||
eoFileMonitor *fileMonitor = new eoFileMonitor(stmp);
|
||||
// save and give to checkpoint
|
||||
_state.storeFunctor(fileMonitor);
|
||||
checkpoint->add(*fileMonitor);
|
||||
// and feed with some statistics
|
||||
fileMonitor->add(*generationCounter);
|
||||
fileMonitor->add(_eval);
|
||||
fileMonitor->add(*bestStat);
|
||||
fileMonitor->add(*secondStat);
|
||||
}
|
||||
|
||||
if (plotBestParam.value()) // an eoGnuplot1DMonitor for best & average
|
||||
{
|
||||
std::string stmp = dirNameParam.value() + "_gnu_best.xg";
|
||||
eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>());
|
||||
// save and give to checkpoint
|
||||
_state.storeFunctor(gnuMonitor);
|
||||
checkpoint->add(*gnuMonitor);
|
||||
// and feed with some statistics
|
||||
if (useEvalParam.value())
|
||||
gnuMonitor->add(_eval);
|
||||
else
|
||||
gnuMonitor->add(*generationCounter);
|
||||
gnuMonitor->add(*bestStat);
|
||||
gnuMonitor->add(*averageStat);
|
||||
std::string stmp = dirNameParam.value() + "_gnu_best.xg";
|
||||
eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>());
|
||||
// save and give to checkpoint
|
||||
_state.storeFunctor(gnuMonitor);
|
||||
checkpoint->add(*gnuMonitor);
|
||||
// and feed with some statistics
|
||||
if (useEvalParam.value())
|
||||
gnuMonitor->add(_eval);
|
||||
else
|
||||
gnuMonitor->add(*generationCounter);
|
||||
gnuMonitor->add(*bestStat);
|
||||
gnuMonitor->add(*averageStat);
|
||||
}
|
||||
|
||||
if (plotFDCParam.value()) // a specific plot monitor for FDC
|
||||
{
|
||||
// first into a file (it adds everything ti itself
|
||||
eoFDCFileSnapshot<EOT> *fdcFileSnapshot = new eoFDCFileSnapshot<EOT>(*fdcStat, dirNameParam.value());
|
||||
_state.storeFunctor(fdcFileSnapshot);
|
||||
// then to a Gnuplot monitor
|
||||
eoGnuplot1DSnapshot *fdcGnuplot = new eoGnuplot1DSnapshot(*fdcFileSnapshot);
|
||||
_state.storeFunctor(fdcGnuplot);
|
||||
// first into a file (it adds everything ti itself
|
||||
eoFDCFileSnapshot<EOT> *fdcFileSnapshot = new eoFDCFileSnapshot<EOT>(*fdcStat, dirNameParam.value());
|
||||
_state.storeFunctor(fdcFileSnapshot);
|
||||
// then to a Gnuplot monitor
|
||||
eoGnuplot1DSnapshot *fdcGnuplot = new eoGnuplot1DSnapshot(*fdcFileSnapshot);
|
||||
_state.storeFunctor(fdcGnuplot);
|
||||
|
||||
// and of course add them to the checkPoint
|
||||
checkpoint->add(*fdcFileSnapshot);
|
||||
checkpoint->add(*fdcGnuplot);
|
||||
// and of course add them to the checkPoint
|
||||
checkpoint->add(*fdcFileSnapshot);
|
||||
checkpoint->add(*fdcGnuplot);
|
||||
}
|
||||
|
||||
// historgram?
|
||||
if (plotHistogramParam.value()) // want to see how the fitness is spread?
|
||||
{
|
||||
eoScalarFitnessStat<EOT> *fitStat = new eoScalarFitnessStat<EOT>;
|
||||
_state.storeFunctor(fitStat);
|
||||
checkpoint->add(*fitStat);
|
||||
// a gnuplot-based monitor for snapshots: needs a dir name
|
||||
eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value());
|
||||
_state.storeFunctor(fitSnapshot);
|
||||
// add any stat that is a std::vector<double> to it
|
||||
fitSnapshot->add(*fitStat);
|
||||
// and of course add it to the checkpoint
|
||||
checkpoint->add(*fitSnapshot);
|
||||
eoScalarFitnessStat<EOT> *fitStat = new eoScalarFitnessStat<EOT>;
|
||||
_state.storeFunctor(fitStat);
|
||||
checkpoint->add(*fitStat);
|
||||
// a gnuplot-based monitor for snapshots: needs a dir name
|
||||
eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value());
|
||||
_state.storeFunctor(fitSnapshot);
|
||||
// add any stat that is a std::vector<double> to it
|
||||
fitSnapshot->add(*fitStat);
|
||||
// and of course add it to the checkpoint
|
||||
checkpoint->add(*fitSnapshot);
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
|
|
@ -273,7 +273,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
|
|||
{
|
||||
// first make sure dirName is OK
|
||||
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 );
|
||||
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
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
|
||||
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
|
||||
|
||||
std::string stmp = dirNameParam.value() + "/time";
|
||||
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
bool testDirRes(std::string _dirName, bool _erase);
|
||||
/////////////////// The checkpoint and other I/O //////////////
|
||||
|
||||
/** Of course, Fitness needs to be an eoScalarFitnessAssembled!!!
|
||||
/** Of course, Fitness needs to be an eoScalarFitnessAssembled!!!
|
||||
*
|
||||
*
|
||||
* @ingroup Builders
|
||||
|
|
@ -153,7 +153,7 @@ eoCheckPoint<EOT>& do_make_checkpoint_assembled(eoParser& _parser, eoState& _sta
|
|||
_state.storeFunctor(fitStat);
|
||||
checkpoint->add(*fitStat);
|
||||
#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);
|
||||
_state.storeFunctor(fitSnapshot);
|
||||
// add any stat that is a vector<double> to it
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ It can then be instantiated, and compiled on its own for a given EOType
|
|||
template <class Indi>
|
||||
eoCombinedContinue<Indi> * make_combinedContinue(eoCombinedContinue<Indi> *_combined, eoContinue<Indi> *_cont)
|
||||
{
|
||||
if (_combined) // already exists
|
||||
if (_combined) // already exists
|
||||
_combined->add(*_cont);
|
||||
else
|
||||
_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
|
||||
{
|
||||
eoGenContinue<Indi> *genCont = new eoGenContinue<Indi>(maxGenParam.value());
|
||||
_state.storeFunctor(genCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<Indi>(continuator, genCont);
|
||||
eoGenContinue<Indi> *genCont = new eoGenContinue<Indi>(maxGenParam.value());
|
||||
_state.storeFunctor(genCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<Indi>(continuator, genCont);
|
||||
}
|
||||
|
||||
// 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");
|
||||
if (_parser.isItThere(steadyGenParam))
|
||||
{
|
||||
eoSteadyFitContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi>
|
||||
(minGenParam.value(), steadyGenParam.value());
|
||||
// store
|
||||
_state.storeFunctor(steadyCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, steadyCont);
|
||||
eoSteadyFitContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi>
|
||||
(minGenParam.value(), steadyGenParam.value());
|
||||
// store
|
||||
_state.storeFunctor(steadyCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, steadyCont);
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
eoEvalContinue<Indi> *evalCont = new eoEvalContinue<Indi>(_eval, maxEvalParam.value());
|
||||
_state.storeFunctor(evalCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<Indi>(continuator, evalCont);
|
||||
eoEvalContinue<Indi> *evalCont = new eoEvalContinue<Indi>(_eval, maxEvalParam.value());
|
||||
_state.storeFunctor(evalCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<Indi>(continuator, evalCont);
|
||||
}
|
||||
/*
|
||||
// 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");
|
||||
if (_parser.isItThere(steadyGenParam))
|
||||
{
|
||||
eoSteadyGenContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi>
|
||||
(minGenParam.value(), steadyGenParam.value());
|
||||
// store
|
||||
_state.storeFunctor(steadyCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, steadyCont);
|
||||
eoSteadyGenContinue<Indi> *steadyCont = new eoSteadyFitContinue<Indi>
|
||||
(minGenParam.value(), steadyGenParam.value());
|
||||
// store
|
||||
_state.storeFunctor(steadyCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, steadyCont);
|
||||
}
|
||||
*/
|
||||
// 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");
|
||||
if (_parser.isItThere(targetFitnessParam))
|
||||
{
|
||||
fitCont = new eoFitContinue<Indi>
|
||||
(targetFitnessParam.value());
|
||||
// store
|
||||
_state.storeFunctor(fitCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, fitCont);
|
||||
fitCont = new eoFitContinue<Indi>
|
||||
(targetFitnessParam.value());
|
||||
// store
|
||||
_state.storeFunctor(fitCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, fitCont);
|
||||
}
|
||||
|
||||
#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");
|
||||
if (ctrlCParam.value())
|
||||
{
|
||||
ctrlCCont = new eoCtrlCContinue<Indi>;
|
||||
// store
|
||||
_state.storeFunctor(ctrlCCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, ctrlCCont);
|
||||
ctrlCCont = new eoCtrlCContinue<Indi>;
|
||||
// store
|
||||
_state.storeFunctor(ctrlCCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, ctrlCCont);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// make_general_replacement.h
|
||||
// (c) Marc Schoenauer and Pierre Collet, 2002
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -49,8 +49,8 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
|
|||
eoReduce<EOT> * ptReduce;
|
||||
|
||||
// ---------- Deterministic
|
||||
if ( (_ppReduce.first == std::string("Deterministic")) ||
|
||||
(_ppReduce.first == std::string("Sequential"))
|
||||
if ( (_ppReduce.first == std::string("Deterministic")) ||
|
||||
(_ppReduce.first == std::string("Sequential"))
|
||||
)
|
||||
{
|
||||
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)
|
||||
_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());
|
||||
ptReduce = new eoEPReduce<EOT>(detSize);
|
||||
}
|
||||
|
|
@ -74,12 +74,12 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
|
|||
{
|
||||
if (!_ppReduce.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
_ppReduce.second.push_back(std::string("2"));
|
||||
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
|
||||
detSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
_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());
|
||||
ptReduce = new eoDetTournamentTruncate<EOT>(detSize);
|
||||
}
|
||||
|
|
@ -87,24 +87,24 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
|
|||
{
|
||||
double p;
|
||||
if (!_ppReduce.second.size()) // no parameter added
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back p in parameter for consistency (and status file)
|
||||
_ppReduce.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
{
|
||||
p = atof(_ppReduce.second[0].c_str());
|
||||
if ( (p<=0.5) || (p>1) )
|
||||
throw std::runtime_error("Stochastic tournament size should be in [0.5,1]");
|
||||
}
|
||||
|
||||
{
|
||||
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
|
||||
p = 1;
|
||||
// put back p in parameter for consistency (and status file)
|
||||
_ppReduce.second.push_back(std::string("1"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
{
|
||||
p = atof(_ppReduce.second[0].c_str());
|
||||
if ( (p<=0.5) || (p>1) )
|
||||
throw std::runtime_error("Stochastic tournament size should be in [0.5,1]");
|
||||
}
|
||||
|
||||
ptReduce = new eoStochTournamentTruncate<EOT>(p);
|
||||
}
|
||||
else if ( (_ppReduce.first == std::string("Uniform")) ||
|
||||
(_ppReduce.first == std::string("Random"))
|
||||
)
|
||||
else if ( (_ppReduce.first == std::string("Uniform")) ||
|
||||
(_ppReduce.first == std::string("Random"))
|
||||
)
|
||||
{
|
||||
ptReduce = new eoRandomReduce<EOT>;
|
||||
}
|
||||
|
|
@ -117,10 +117,10 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
|
|||
return (*ptReduce);
|
||||
}
|
||||
|
||||
/** Helper function that creates a replacement from the class
|
||||
* eoReduceMergeReduce using 6 parameters
|
||||
/** Helper function that creates a replacement from the class
|
||||
* eoReduceMergeReduce using 6 parameters
|
||||
* (after the usual eoState and eoParser)
|
||||
*
|
||||
*
|
||||
* eoHowMany _elite the number of elite parents (0 = no elitism)
|
||||
* see below
|
||||
* 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>
|
||||
eoReplacement<EOT> & make_general_replacement(
|
||||
eoParser& _parser, eoState& _state,
|
||||
eoHowMany _elite = eoHowMany(0),
|
||||
eoParser& _parser, eoState& _state,
|
||||
eoHowMany _elite = eoHowMany(0),
|
||||
bool _strongElitism = false,
|
||||
eoHowMany _surviveParents = eoHowMany(0.0),
|
||||
eoParamParamType & _reduceParentType = eoParamParamType("Deterministic"),
|
||||
eoHowMany _surviveOffspring = eoHowMany(1.0),
|
||||
eoParamParamType & _reduceOffspringType = eoParamParamType("Deterministic"),
|
||||
eoParamParamType & _reduceFinalType = eoParamParamType("Deterministic")
|
||||
)
|
||||
)
|
||||
{
|
||||
/////////////////////////////////////////////////////
|
||||
// the replacement
|
||||
|
|
@ -157,14 +157,14 @@ eoReplacement<EOT> & make_general_replacement(
|
|||
|
||||
// reduce the parents
|
||||
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();
|
||||
|
||||
eoReduce<EOT> & reduceParent = decode_reduce<EOT>(reduceParentType, _state);
|
||||
|
||||
// reduce the offspring
|
||||
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();
|
||||
|
||||
eoReduce<EOT> & reduceOffspring = decode_reduce<EOT>(reduceOffspringType, _state);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ eoPop<EOT>& do_make_pop(eoParser & _parser, eoState& _state, eoInit<EOT> & _ini
|
|||
// random seed
|
||||
eoValueParam<uint32_t>& seedParam = _parser.getORcreateParam(uint32_t(0), "seed", "Random number seed", 'S');
|
||||
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");
|
||||
|
||||
// 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:
|
||||
// do only evaluate the pop if the fitness has changed
|
||||
if (recomputeFitnessParam.value())
|
||||
{
|
||||
for (unsigned i=0; i<pop.size(); i++)
|
||||
pop[i].invalidate();
|
||||
}
|
||||
{
|
||||
for (unsigned i=0; i<pop.size(); i++)
|
||||
pop[i].invalidate();
|
||||
}
|
||||
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())
|
||||
{
|
||||
std::cerr << "WARNING, Load file contained too many individuals. Only the best will be retained" << std::endl;
|
||||
pop.resize(popSize.value());
|
||||
}
|
||||
{
|
||||
std::cerr << "WARNING, Load file contained too many individuals. Only the best will be retained" << std::endl;
|
||||
pop.resize(popSize.value());
|
||||
}
|
||||
}
|
||||
else // nothing loaded from a file
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// make_run.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue