diff --git a/eo/src/eoCombinedInit.h b/eo/src/eoCombinedInit.h index 3d2441322..7acbe3795 100644 --- a/eo/src/eoCombinedInit.h +++ b/eo/src/eoCombinedInit.h @@ -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 */ diff --git a/eo/src/eoDetTournamentSelect.h b/eo/src/eoDetTournamentSelect.h index 4a197b3ab..7042a3394 100644 --- a/eo/src/eoDetTournamentSelect.h +++ b/eo/src/eoDetTournamentSelect.h @@ -33,6 +33,7 @@ #include #include +#include #include //----------------------------------------------------------------------------- @@ -50,7 +51,7 @@ template class eoDetTournamentSelect: public eoSelectOne eoDetTournamentSelect(unsigned _tSize = 2 ):eoSelectOne(), 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; } } diff --git a/eo/src/eoEvalContinue.h b/eo/src/eoEvalContinue.h index 7ee38dee0..c8af79fe3 100644 --- a/eo/src/eoEvalContinue.h +++ b/eo/src/eoEvalContinue.h @@ -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; diff --git a/eo/src/eoGenContinue.h b/eo/src/eoGenContinue.h index c578fcc9c..e670cf317 100644 --- a/eo/src/eoGenContinue.h +++ b/eo/src/eoGenContinue.h @@ -57,7 +57,7 @@ public: (void)_vEO; thisGeneration++; value() = thisGeneration; - // std::cout << " [" << thisGeneration << "] "; + if (thisGeneration >= repTotalGenerations) { if (verbose) diff --git a/eo/src/eoMGGReplacement.h b/eo/src/eoMGGReplacement.h index c436f4ce3..55eaaa54b 100644 --- a/eo/src/eoMGGReplacement.h +++ b/eo/src/eoMGGReplacement.h @@ -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; } } diff --git a/eo/src/eoMerge.h b/eo/src/eoMerge.h index defd1fc56..0e359ae53 100644 --- a/eo/src/eoMerge.h +++ b/eo/src/eoMerge.h @@ -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; } } diff --git a/eo/src/eoProportionalCombinedOp.h b/eo/src/eoProportionalCombinedOp.h index e1f3053c7..79b74111d 100644 --- a/eo/src/eoProportionalCombinedOp.h +++ b/eo/src/eoProportionalCombinedOp.h @@ -29,6 +29,7 @@ #include #include #include +#include /** \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 & _op, const double _rate, bool _verbose=false) unsigned i; for (i=0; iclassName() << " 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 & _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 diff --git a/eo/src/eoReduce.h b/eo/src/eoReduce.h index 31ecd7767..9d5ff97b4 100644 --- a/eo/src/eoReduce.h +++ b/eo/src/eoReduce.h @@ -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; } } diff --git a/eo/src/eoReduceSplit.h b/eo/src/eoReduceSplit.h index 62a6f142f..915de4741 100644 --- a/eo/src/eoReduceSplit.h +++ b/eo/src/eoReduceSplit.h @@ -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; } } diff --git a/eo/src/eoVariableLengthCrossover.h b/eo/src/eoVariableLengthCrossover.h index 1e0772da8..ff86c60f6 100644 --- a/eo/src/eoVariableLengthCrossover.h +++ b/eo/src/eoVariableLengthCrossover.h @@ -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()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()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; } diff --git a/eo/src/eoVector.h b/eo/src/eoVector.h index a3a634531..ce85391f6 100644 --- a/eo/src/eoVector.h +++ b/eo/src/eoVector.h @@ -26,6 +26,7 @@ Old contact: todos@geneura.ugr.es, http://geneura.ugr.es #include #include #include +#include /** 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"<