using eo::log instead of std::cout

This commit is contained in:
Johann Dreo 2010-09-29 22:52:30 +02:00
commit ac0a909d1d
12 changed files with 27 additions and 24 deletions

View file

@ -53,7 +53,7 @@ public:
rates.push_back(_rate); rates.push_back(_rate);
// compute the relative rates in percent - to warn the user! // compute the relative rates in percent - to warn the user!
if (_verbose) if (_verbose)
printOn(std::cout); printOn( eo::log << eo::logging );
} }
/** outputs the operators and percentages */ /** outputs the operators and percentages */

View file

@ -33,6 +33,7 @@
#include <eoFunctor.h> #include <eoFunctor.h>
#include <eoPop.h> #include <eoPop.h>
#include <utils/eoLogger.h>
#include <utils/selectors.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) { eoDetTournamentSelect(unsigned _tSize = 2 ):eoSelectOne<EOT>(), tSize(_tSize) {
// consistency check // consistency check
if (tSize < 2) { 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; tSize = 2;
} }
} }

View file

@ -46,7 +46,7 @@ public:
(void)_vEO; (void)_vEO;
if (eval.value() >= repTotalEvaluations) 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 false;
} }
return true; return true;

View file

@ -57,7 +57,7 @@ public:
(void)_vEO; (void)_vEO;
thisGeneration++; thisGeneration++;
value() = thisGeneration; value() = thisGeneration;
// std::cout << " [" << thisGeneration << "] ";
if (thisGeneration >= repTotalGenerations) if (thisGeneration >= repTotalGenerations)
{ {
if (verbose) if (verbose)

View file

@ -58,7 +58,7 @@ public:
{ {
if (tSize < 2) 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; tSize = 2;
} }
} }

View file

@ -70,7 +70,7 @@ public :
throw std::logic_error("Negative number of offspring in eoElitism!"); throw std::logic_error("Negative number of offspring in eoElitism!");
combien = (unsigned int)_rate; combien = (unsigned int)_rate;
if (combien != _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;
} }
} }

View file

@ -29,6 +29,7 @@
#include <eoFunctor.h> #include <eoFunctor.h>
#include <eoOp.h> #include <eoOp.h>
#include <utils/eoRNG.h> #include <utils/eoRNG.h>
#include <utils/eoLogger.h>
/** /**
\defgroup PropCombinedOperators \defgroup PropCombinedOperators
Combination of same-type Genetic Operators - Proportional choice Combination of same-type Genetic Operators - Proportional choice
@ -73,7 +74,7 @@ public:
rates.push_back(_rate); rates.push_back(_rate);
// compute the relative rates in percent - to warn the user! // compute the relative rates in percent - to warn the user!
if (_verbose) if (_verbose)
printOn(std::cout); printOn( eo::log << eo::logging );
} }
// outputs the operators and percentages // outputs the operators and percentages
@ -129,9 +130,9 @@ virtual void add(eoBinOp<EOT> & _op, const double _rate, bool _verbose=false)
unsigned i; unsigned i;
for (i=0; i<ops.size(); i++) for (i=0; i<ops.size(); i++)
total += rates[i]; total += rates[i];
std::cout << "In " << className() << "\n" ; eo::log << eo::logging << "In " << className() << std::endl ;
for (i=0; i<ops.size(); i++) 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); rates.push_back(_rate);
// compute the relative rates in percent - to warn the user! // compute the relative rates in percent - to warn the user!
if (_verbose) if (_verbose)
printOn(std::cout); printOn( eo::log << eo::logging );
} }
// outputs the operators and percentages // outputs the operators and percentages

View file

@ -90,7 +90,7 @@ typedef typename EOT::Fitness Fitness;
{ {
if (t_size < 2) 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; t_size = 2;
} }
} }
@ -193,7 +193,7 @@ public:
{ {
if (t_size < 2) 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; t_size = 2;
} }
} }
@ -241,12 +241,12 @@ public:
{ {
if (t_rate <= 0.5) 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; t_rate = 0.51;
} }
if (t_rate > 1) 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; t_rate = 1;
} }
} }

View file

@ -215,7 +215,7 @@ public:
{ {
if (t_size < 2) 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; t_size = 2;
} }
} }
@ -266,12 +266,12 @@ public:
{ {
if (t_rate <= 0.5) 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; t_rate = 0.51;
} }
if (t_rate > 1) 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; t_rate = 1;
} }
} }

View file

@ -128,7 +128,7 @@ public :
&& (index<10000) ); && (index<10000) );
if (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; return false;
} }
// here we know we have the right sizes: do the actual exchange // here we know we have the right sizes: do the actual exchange
@ -251,9 +251,10 @@ public :
} while ( ( (tmp1.size()<Min) || (tmp2.size()<Min) || } while ( ( (tmp1.size()<Min) || (tmp2.size()<Min) ||
(tmp1.size()>Max) || (tmp2.size()>Max) ) (tmp1.size()>Max) || (tmp2.size()>Max) )
&& (index<10000) ); && (index<10000) );
// FIXME bad hardcoded limit, should use an algorithm that guarantee a correct size in a finite number of tries
if (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; return false;
} }
@ -318,10 +319,10 @@ public :
index++; index++;
} while ( ( (tmp1.size()<Min) || (tmp1.size()>Max) ) } while ( ( (tmp1.size()<Min) || (tmp1.size()>Max) )
&& (index<10000) ); && (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) 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; return false;
} }

View file

@ -26,6 +26,7 @@ Old contact: todos@geneura.ugr.es, http://geneura.ugr.es
#include <vector> #include <vector>
#include <iterator> #include <iterator>
#include <EO.h> #include <EO.h>
#include <utils/eoLogger.h>
/** Base class for fixed length chromosomes /** Base class for fixed length chromosomes
@ -71,7 +72,7 @@ public:
if (_v.size() != size()) // safety check if (_v.size() != size()) // safety check
{ {
if (size()) // NOT an initial empty std::vector 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()); resize(_v.size());
} }

View file

@ -78,8 +78,7 @@ public:
if (_v.size () != size ()) // safety check if (_v.size () != size ()) // safety check
{ {
if (size ()) // NOT an initial empty std::vector if (size ()) // NOT an initial empty std::vector
std:: eo::log << eo::warnings <<
cout <<
"Warning: Changing position size in eoVectorParticle assignation" "Warning: Changing position size in eoVectorParticle assignation"
<< std::endl; << std::endl;
resize (_v.size ()); resize (_v.size ());