Added make_help in checkpointing, included stdexcept in eoParam. Comments
updates ...
This commit is contained in:
parent
62dfe13c3a
commit
e79edcffe7
3 changed files with 51 additions and 19 deletions
|
|
@ -14,3 +14,6 @@
|
|||
#include <utils/eoFDCStat.h>
|
||||
#include <utils/eoMOFitnessStat.h>
|
||||
#include <utils/eoPopStat.h>
|
||||
|
||||
// and make_help - any better suggestion to include it?
|
||||
void make_help(eoParser & _parser);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <string>
|
||||
#include <strstream>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <eoScalarFitness.h> // for specializations
|
||||
/**
|
||||
eoParam: Base class for monitoring and parsing parameters
|
||||
|
|
@ -215,6 +216,8 @@ void eoValueParam<std::pair<double, double> >::setValue(std::string _value)
|
|||
is >> repValue.second;
|
||||
}
|
||||
|
||||
// The vector<vector<double> >
|
||||
//////////////////////////////////
|
||||
/// Because MSVC does not support partial specialization, the vector is a vector of doubles, not a T
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<std::vector<double> > >::getValue(void) const
|
||||
|
|
@ -252,6 +255,8 @@ void eoValueParam<std::vector<std::vector<double> > >::setValue(std::string _val
|
|||
}
|
||||
}
|
||||
|
||||
// The vector<double>
|
||||
//////////////////////////////////
|
||||
/// Because MSVC does not support partial specialization, the vector is a double, not a T
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<double> >::getValue(void) const
|
||||
|
|
@ -274,6 +279,8 @@ void eoValueParam<std::vector<double> >::setValue(std::string _value)
|
|||
std::copy(std::istream_iterator<double>(is), std::istream_iterator<double>(), repValue.begin());
|
||||
}
|
||||
|
||||
// The vector<eoMinimizingFitness>
|
||||
//////////////////////////////////
|
||||
/// Because MSVC does not support partial specialization, the vector is a eoMinimizingFitness, not a T
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<eoMinimizingFitness> >::getValue(void) const
|
||||
|
|
@ -297,6 +304,22 @@ void eoValueParam<std::vector<eoMinimizingFitness> >::setValue(std::string _valu
|
|||
std::copy(std::istream_iterator<eoMinimizingFitness>(is), std::istream_iterator<eoMinimizingFitness>(), repValue.begin());
|
||||
}
|
||||
|
||||
// The vector<const EOT*>
|
||||
//////////////////////////////////
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<void*> >::getValue(void) const
|
||||
{
|
||||
throw runtime_error("I cannot getValue for a vector<EOT*>");
|
||||
return string("");
|
||||
}
|
||||
|
||||
template <>
|
||||
void eoValueParam<std::vector<void*> >::setValue(std::string)
|
||||
{
|
||||
throw runtime_error("I cannot setValue for a vector<EOT*>");
|
||||
return;
|
||||
}
|
||||
|
||||
/*template <class ContainerType>
|
||||
class eoContainerParam : public eoParam
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ that are written by the monitor it is probably used from.
|
|||
void operator()(const eoPop<EOT>& _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<EOT, string>
|
|||
{
|
||||
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<EOT, string>("", _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<EOT, string>("", _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<const EOT*>& _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<const EOT*>& _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
|
||||
|
|
|
|||
Reference in a new issue