eoParam, added specialization for eoValueParam<string>::getValue

FDCStat and FileSnapshot: better error messageing
Scalar fitness: is now a vector of doubles
exercise3.1 added gnuplot again

Don't know about eoCombinedContinue
This commit is contained in:
maartenkeijzer 2001-03-28 09:00:54 +00:00
commit 195ad72838
6 changed files with 56 additions and 46 deletions

View file

@ -43,7 +43,7 @@ public:
/// Define Fitness /// Define Fitness
typedef typename EOT::Fitness FitnessType; typedef typename EOT::Fitness FitnessType;
/// Ctor /// Ctor, make sure that at least on continuator is present
eoCombinedContinue( eoContinue<EOT>& _cont) eoCombinedContinue( eoContinue<EOT>& _cont)
: eoContinue<EOT> () : eoContinue<EOT> ()
{ {

View file

@ -119,14 +119,14 @@ public:
eoFileSnapshot(_dirname, _frequency, _filename, _delim), eoFileSnapshot(_dirname, _frequency, _filename, _delim),
FDCstat(_FDCstat) FDCstat(_FDCstat)
{ {
eoMonitor::add(FDCstat.theDist()); eoFileSnapshot::add(FDCstat.theDist());
eoMonitor::add(FDCstat.theFit()); eoFileSnapshot::add(FDCstat.theFit());
} }
/** just to be sure the add method is not called further /** just to be sure the add method is not called further
*/ */
virtual void add(const eoParam& _param) virtual void add(const eoParam& _param)
{ throw runtime_error("Trying to add stats to an eoFDCFileSnapshot"); } { throw runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); }
private: private:
eoFDCStat<EOT> & FDCstat; eoFDCStat<EOT> & FDCstat;

View file

@ -166,7 +166,7 @@ public :
{ {
if (!dynamic_cast<const eoValueParam<vector<double> >*>(&_param)) if (!dynamic_cast<const eoValueParam<vector<double> >*>(&_param))
{ {
throw logic_error("eoFileSnapshot: I can only monitor vectors of doubles, sorry"); throw logic_error(string("eoFileSnapshot: I can only monitor vectors of doubles, sorry. The offending parameter name = ") + _param.longName());
} }
eoMonitor::add(_param); eoMonitor::add(_param);
} }

View file

@ -170,6 +170,16 @@ private :
ValueType repValue; ValueType repValue;
}; };
/*
Specialization for string
*/
template <>
std::string eoValueParam<std::string>::getValue(void) const
{
return repValue;
}
template <> template <>
void eoValueParam<bool>::setValue(std::string _value) void eoValueParam<bool>::setValue(std::string _value)
{ {

View file

@ -33,11 +33,11 @@
The fitnesses of a whole population, as a vector The fitnesses of a whole population, as a vector
*/ */
template <class EOT, class FitT = typename EOT::Fitness> template <class EOT, class FitT = typename EOT::Fitness>
class eoScalarFitnessStat : public eoSortedStat<EOT, vector<FitT> > class eoScalarFitnessStat : public eoSortedStat<EOT, vector<double> >
{ {
public : public :
eoScalarFitnessStat(std::string _description = "FitnessES") : eoScalarFitnessStat(std::string _description = "FitnessES") :
eoSortedStat<EOT, vector<FitT> >(vector<FitT>(0), _description) {} eoSortedStat<EOT, vector<double> >(vector<double>(0), _description) {}
virtual void operator()(const vector<const EOT*>& _popPters) virtual void operator()(const vector<const EOT*>& _popPters)
{ {

View file

@ -318,7 +318,7 @@ void main_function(int argc, char **argv)
// send a scaling command to gnuplot // send a scaling command to gnuplot
gnuMonitor.gnuplotCommand("set yrange [0:500]"); gnuMonitor.gnuplotCommand("set yrange [0:500]");
/*
// a specific plot monitor for FDC // a specific plot monitor for FDC
// first into a file (it adds everything ti itself // first into a file (it adds everything ti itself
eoFDCFileSnapshot<Indi> fdcFileSnapshot(fdcStat); eoFDCFileSnapshot<Indi> fdcFileSnapshot(fdcStat);
@ -338,7 +338,7 @@ void main_function(int argc, char **argv)
fitSnapshot.add(fitStat); fitSnapshot.add(fitStat);
// and of course add it to the checkpoint // and of course add it to the checkpoint
checkpoint.add(fitSnapshot); checkpoint.add(fitSnapshot);
*/
// Last type of item the eoCheckpoint can handle: state savers: // Last type of item the eoCheckpoint can handle: state savers:
eoState outState; eoState outState;
// Register the algorithm into the state (so it has something to save!!) // Register the algorithm into the state (so it has something to save!!)