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/eoFDCStat.h>
|
||||||
#include <utils/eoMOFitnessStat.h>
|
#include <utils/eoMOFitnessStat.h>
|
||||||
#include <utils/eoPopStat.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 <string>
|
||||||
#include <strstream>
|
#include <strstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
#include <eoScalarFitness.h> // for specializations
|
#include <eoScalarFitness.h> // for specializations
|
||||||
/**
|
/**
|
||||||
eoParam: Base class for monitoring and parsing parameters
|
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;
|
is >> repValue.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The vector<vector<double> >
|
||||||
|
//////////////////////////////////
|
||||||
/// Because MSVC does not support partial specialization, the vector is a vector of doubles, not a T
|
/// Because MSVC does not support partial specialization, the vector is a vector of doubles, not a T
|
||||||
template <>
|
template <>
|
||||||
std::string eoValueParam<std::vector<std::vector<double> > >::getValue(void) const
|
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
|
/// Because MSVC does not support partial specialization, the vector is a double, not a T
|
||||||
template <>
|
template <>
|
||||||
std::string eoValueParam<std::vector<double> >::getValue(void) const
|
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());
|
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
|
/// Because MSVC does not support partial specialization, the vector is a eoMinimizingFitness, not a T
|
||||||
template <>
|
template <>
|
||||||
std::string eoValueParam<std::vector<eoMinimizingFitness> >::getValue(void) const
|
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());
|
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>
|
/*template <class ContainerType>
|
||||||
class eoContainerParam : public eoParam
|
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)
|
void operator()(const eoPop<EOT>& _pop)
|
||||||
{
|
{
|
||||||
char buffer[1023]; // about one K of space per member
|
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();
|
unsigned howMany=combien?combien:_pop.size();
|
||||||
for (unsigned i = 0; i < howMany; ++i)
|
for (unsigned i = 0; i < howMany; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -95,19 +95,23 @@ class eoSortedPopStat : public eoSortedStat<EOT, string>
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
/** default Ctor, void string by default, as it appears
|
/** default Ctor, void string by default, as it appears
|
||||||
on the description line once at beginning of evolution. and
|
* on the description line once at beginning of evolution. and
|
||||||
is meaningless there */
|
* is meaningless there _howMany defaults to 0, that is, the whole
|
||||||
eoSortedPopStat(string _desc ="") : eoSortedStat<EOT, string>("", _desc) {}
|
* 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.
|
/** 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
|
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.
|
that are written by the monitor it is probably used from.
|
||||||
*/
|
*/
|
||||||
void operator()(const vector<const EOT*>& _pop)
|
void operator()(const vector<const EOT*>& _pop)
|
||||||
{
|
{
|
||||||
char buffer[1023]; // about one K of space per member
|
char buffer[1023]; // about one K of space per member
|
||||||
value() = "\n====== Pop dump =====\n";
|
value() = ""; // empty
|
||||||
for (unsigned i = 0; i < _pop.size(); ++i)
|
unsigned howMany=combien?combien:_pop.size();
|
||||||
|
for (unsigned i = 0; i < howMany; ++i)
|
||||||
{
|
{
|
||||||
std::ostrstream os(buffer, 1022); // leave space for emergency terminate
|
std::ostrstream os(buffer, 1022); // leave space for emergency terminate
|
||||||
os << *_pop[i] << endl << ends;
|
os << *_pop[i] << endl << ends;
|
||||||
|
|
@ -116,7 +120,9 @@ void operator()(const vector<const EOT*>& _pop)
|
||||||
buffer[1022] = '\0';
|
buffer[1022] = '\0';
|
||||||
value() += buffer;
|
value() += buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
unsigned combien;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Reference in a new issue