using eo::log instead of std::cout
This commit is contained in:
parent
ffc6efeb97
commit
ac0a909d1d
12 changed files with 27 additions and 24 deletions
|
|
@ -53,7 +53,7 @@ public:
|
|||
rates.push_back(_rate);
|
||||
// compute the relative rates in percent - to warn the user!
|
||||
if (_verbose)
|
||||
printOn(std::cout);
|
||||
printOn( eo::log << eo::logging );
|
||||
}
|
||||
|
||||
/** outputs the operators and percentages */
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
#include <eoPop.h>
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/selectors.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -50,7 +51,7 @@ template <class EOT> class eoDetTournamentSelect: public eoSelectOne<EOT>
|
|||
eoDetTournamentSelect(unsigned _tSize = 2 ):eoSelectOne<EOT>(), tSize(_tSize) {
|
||||
// consistency check
|
||||
if (tSize < 2) {
|
||||
std::cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||
eo::log << eo::warnings << "Tournament size should be >= 2, adjusted to 2" << std::endl;
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
(void)_vEO;
|
||||
if (eval.value() >= repTotalEvaluations)
|
||||
{
|
||||
std::cout << "STOP in eoEvalContinue: Reached maximum number of evaluations [" << repTotalEvaluations << "]\n";
|
||||
eo::log << eo::progress << "STOP in eoEvalContinue: Reached maximum number of evaluations [" << repTotalEvaluations << "]" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public:
|
|||
(void)_vEO;
|
||||
thisGeneration++;
|
||||
value() = thisGeneration;
|
||||
// std::cout << " [" << thisGeneration << "] ";
|
||||
|
||||
if (thisGeneration >= repTotalGenerations)
|
||||
{
|
||||
if (verbose)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
{
|
||||
if (tSize < 2)
|
||||
{
|
||||
std::cout << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2\n";
|
||||
eo::log << eo::warnings << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2" << std::endl;
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public :
|
|||
throw std::logic_error("Negative number of offspring in eoElitism!");
|
||||
combien = (unsigned int)_rate;
|
||||
if (combien != _rate)
|
||||
std::cout << "Warning: Number of guys to merge in eoElitism was rounded";
|
||||
eo::log << eo::warnings << "Warning: Number of guys to merge in eoElitism was rounded" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <eoFunctor.h>
|
||||
#include <eoOp.h>
|
||||
#include <utils/eoRNG.h>
|
||||
#include <utils/eoLogger.h>
|
||||
/**
|
||||
\defgroup PropCombinedOperators
|
||||
Combination of same-type Genetic Operators - Proportional choice
|
||||
|
|
@ -73,7 +74,7 @@ public:
|
|||
rates.push_back(_rate);
|
||||
// compute the relative rates in percent - to warn the user!
|
||||
if (_verbose)
|
||||
printOn(std::cout);
|
||||
printOn( eo::log << eo::logging );
|
||||
}
|
||||
|
||||
// outputs the operators and percentages
|
||||
|
|
@ -129,9 +130,9 @@ virtual void add(eoBinOp<EOT> & _op, const double _rate, bool _verbose=false)
|
|||
unsigned i;
|
||||
for (i=0; i<ops.size(); i++)
|
||||
total += rates[i];
|
||||
std::cout << "In " << className() << "\n" ;
|
||||
eo::log << eo::logging << "In " << className() << std::endl ;
|
||||
for (i=0; i<ops.size(); i++)
|
||||
std::cout << ops[i]->className() << " with rate " << 100*rates[i]/total << " %\n";
|
||||
eo::log << eo::logging << ops[i]->className() << " with rate " << 100*rates[i]/total << " %" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +180,7 @@ virtual void add(eoQuadOp<EOT> & _op, const double _rate, bool _verbose=false)
|
|||
rates.push_back(_rate);
|
||||
// compute the relative rates in percent - to warn the user!
|
||||
if (_verbose)
|
||||
printOn(std::cout);
|
||||
printOn( eo::log << eo::logging );
|
||||
}
|
||||
|
||||
// outputs the operators and percentages
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ typedef typename EOT::Fitness Fitness;
|
|||
{
|
||||
if (t_size < 2)
|
||||
{
|
||||
std::cout << "Warning: EP tournament size should be >= 2. Adjusted" << std::endl;
|
||||
eo::log << eo::warnings << "Warning: EP tournament size should be >= 2. Adjusted" << std::endl;
|
||||
t_size = 2;
|
||||
}
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ public:
|
|||
{
|
||||
if (t_size < 2)
|
||||
{
|
||||
std::cout << "Warning, Size for eoDetTournamentTruncate adjusted to 2\n";
|
||||
eo::log << eo::warnings << "Warning, Size for eoDetTournamentTruncate adjusted to 2" << std::endl;
|
||||
t_size = 2;
|
||||
}
|
||||
}
|
||||
|
|
@ -241,12 +241,12 @@ public:
|
|||
{
|
||||
if (t_rate <= 0.5)
|
||||
{
|
||||
std::cout << "Warning, Rate for eoStochTournamentTruncate adjusted to 0.51\n";
|
||||
eo::log << eo::warnings << "Warning, Rate for eoStochTournamentTruncate adjusted to 0.51" << std::endl;
|
||||
t_rate = 0.51;
|
||||
}
|
||||
if (t_rate > 1)
|
||||
{
|
||||
std::cout << "Warning, Rate for eoStochTournamentTruncate adjusted to 1\n";
|
||||
eo::log << eo::warnings << "Warning, Rate for eoStochTournamentTruncate adjusted to 1" << std::endl;
|
||||
t_rate = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public:
|
|||
{
|
||||
if (t_size < 2)
|
||||
{
|
||||
std::cout << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2\n";
|
||||
eo::log << eo::warnings << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2" << std::endl;
|
||||
t_size = 2;
|
||||
}
|
||||
}
|
||||
|
|
@ -266,12 +266,12 @@ public:
|
|||
{
|
||||
if (t_rate <= 0.5)
|
||||
{
|
||||
std::cout << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 0.51\n";
|
||||
eo::log << eo:warnings << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 0.51" << std::endl;
|
||||
t_rate = 0.51;
|
||||
}
|
||||
if (t_rate > 1)
|
||||
{
|
||||
std::cout << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 1\n";
|
||||
eo::log << eo::warnings << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 1" << std::endl;
|
||||
t_rate = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public :
|
|||
&& (index<10000) );
|
||||
if (index >= 10000)
|
||||
{
|
||||
std::cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
|
||||
eo::log << eo::warnings << "Warning: impossible to generate individual of the right size in 10000 trials" << std::endl;
|
||||
return false;
|
||||
}
|
||||
// here we know we have the right sizes: do the actual exchange
|
||||
|
|
@ -251,9 +251,10 @@ public :
|
|||
} while ( ( (tmp1.size()<Min) || (tmp2.size()<Min) ||
|
||||
(tmp1.size()>Max) || (tmp2.size()>Max) )
|
||||
&& (index<10000) );
|
||||
// FIXME bad hardcoded limit, should use an algorithm that guarantee a correct size in a finite number of tries
|
||||
if (index >= 10000)
|
||||
{
|
||||
std::cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
|
||||
eo::log << eo::warnings << "Warning: impossible to generate individual of the right size in 10000 trials" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -318,10 +319,10 @@ public :
|
|||
index++;
|
||||
} while ( ( (tmp1.size()<Min) || (tmp1.size()>Max) )
|
||||
&& (index<10000) );
|
||||
// this while condition is not optimal, as it may take some time
|
||||
// this while condition is not optimal, as it may take some time, see the FIXME above
|
||||
if (index >= 10000)
|
||||
{
|
||||
std::cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
|
||||
eo::log << eo::warnings << "Warning: impossible to generate individual of the right size in 10000 trials" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ Old contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
|||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <EO.h>
|
||||
#include <utils/eoLogger.h>
|
||||
|
||||
/** Base class for fixed length chromosomes
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ public:
|
|||
if (_v.size() != size()) // safety check
|
||||
{
|
||||
if (size()) // NOT an initial empty std::vector
|
||||
std::cout << "Warning: Changing size in eoVector assignation"<<std::endl;
|
||||
eo::log << eo::warnings << "Warning: Changing size in eoVector assignation" << std::endl;
|
||||
resize(_v.size());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ public:
|
|||
if (_v.size () != size ()) // safety check
|
||||
{
|
||||
if (size ()) // NOT an initial empty std::vector
|
||||
std::
|
||||
cout <<
|
||||
eo::log << eo::warnings <<
|
||||
"Warning: Changing position size in eoVectorParticle assignation"
|
||||
<< std::endl;
|
||||
resize (_v.size ());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue