diff --git a/eo/src/utils/checkpointing b/eo/src/utils/checkpointing index dfa65934..7e08af36 100644 --- a/eo/src/utils/checkpointing +++ b/eo/src/utils/checkpointing @@ -14,3 +14,6 @@ #include #include #include + +// and make_help - any better suggestion to include it? +void make_help(eoParser & _parser); diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index c4f87351..c0e2d428 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -32,6 +32,7 @@ #include #include #include +#include #include // for specializations /** eoParam: Base class for monitoring and parsing parameters @@ -215,6 +216,8 @@ void eoValueParam >::setValue(std::string _value) is >> repValue.second; } +// The vector > +////////////////////////////////// /// Because MSVC does not support partial specialization, the vector is a vector of doubles, not a T template <> std::string eoValueParam > >::getValue(void) const @@ -252,6 +255,8 @@ void eoValueParam > >::setValue(std::string _val } } +// The vector +////////////////////////////////// /// Because MSVC does not support partial specialization, the vector is a double, not a T template <> std::string eoValueParam >::getValue(void) const @@ -274,6 +279,8 @@ void eoValueParam >::setValue(std::string _value) std::copy(std::istream_iterator(is), std::istream_iterator(), repValue.begin()); } +// The vector +////////////////////////////////// /// Because MSVC does not support partial specialization, the vector is a eoMinimizingFitness, not a T template <> std::string eoValueParam >::getValue(void) const @@ -297,6 +304,22 @@ void eoValueParam >::setValue(std::string _valu std::copy(std::istream_iterator(is), std::istream_iterator(), repValue.begin()); } +// The vector +////////////////////////////////// +template <> +std::string eoValueParam >::getValue(void) const +{ + throw runtime_error("I cannot getValue for a vector"); + return string(""); +} + +template <> +void eoValueParam >::setValue(std::string) +{ + throw runtime_error("I cannot setValue for a vector"); + return; +} + /*template class eoContainerParam : public eoParam { diff --git a/eo/src/utils/eoPopStat.h b/eo/src/utils/eoPopStat.h index 8907ded7..abe51459 100644 --- a/eo/src/utils/eoPopStat.h +++ b/eo/src/utils/eoPopStat.h @@ -65,7 +65,7 @@ that are written by the monitor it is probably used from. void operator()(const eoPop& _pop) { char buffer[1023]; // about one K of space per member - value() = "\n====== Pop dump =====\n"; + value() = "\n# ====== Pop dump =====\n"; unsigned howMany=combien?combien:_pop.size(); for (unsigned i = 0; i < howMany; ++i) { @@ -95,28 +95,34 @@ class eoSortedPopStat : public eoSortedStat { public : /** default Ctor, void string by default, as it appears - on the description line once at beginning of evolution. and - is meaningless there */ - eoSortedPopStat(string _desc ="") : eoSortedStat("", _desc) {} + * on the description line once at beginning of evolution. and + * is meaningless there _howMany defaults to 0, that is, the whole + * population + */ + eoSortedPopStat(unsigned _howMany = 0, string _desc ="") : + eoSortedStat("", _desc) , combien( _howMany) {} -/** Fills the value() of the eoParam with the dump of the population. -Adds a \n before so it does not get mixed up with the rest of the stats -that are written by the monitor it is probably used from. -*/ -void operator()(const vector& _pop) -{ - char buffer[1023]; // about one K of space per member - value() = "\n====== Pop dump =====\n"; - for (unsigned i = 0; i < _pop.size(); ++i) + /** Fills the value() of the eoParam with the dump of the population. + Adds a \n before so it does not get mixed up with the rest of the stats + that are written by the monitor it is probably used from. + */ + void operator()(const vector& _pop) { - std::ostrstream os(buffer, 1022); // leave space for emergency terminate - os << *_pop[i] << endl << ends; + char buffer[1023]; // about one K of space per member + value() = ""; // empty + unsigned howMany=combien?combien:_pop.size(); + for (unsigned i = 0; i < howMany; ++i) + { + std::ostrstream os(buffer, 1022); // leave space for emergency terminate + os << *_pop[i] << endl << ends; - // paranoid: - buffer[1022] = '\0'; - value() += buffer; + // paranoid: + buffer[1022] = '\0'; + value() += buffer; + } } -} +private: + unsigned combien; }; #endif