Updated documentation to give proper include file in doxygen and define a module selectors

Also added a load(stream) and save(stream) to eoState
This commit is contained in:
mac 2000-04-09 09:46:20 +00:00
commit f357a908bf
7 changed files with 46 additions and 9 deletions

View file

@ -8,7 +8,7 @@
using namespace std; using namespace std;
void eoFileMonitor::operator()(void) eoMonitor& eoFileMonitor::operator()(void)
{ {
if (firsttime) if (firsttime)
{ {
@ -53,6 +53,6 @@ void eoFileMonitor::operator()(void)
os << ',' << (*it)->getValue(); os << ',' << (*it)->getValue();
} }
// and we're there return *this;
} }

View file

@ -45,7 +45,8 @@ public :
virtual ~eoMonitor() {} virtual ~eoMonitor() {}
virtual void operator()(void) = 0; /** Just do it! */
virtual eoMonitor& operator()(void) = 0;
void add(const eoParam& _param) { push_back(&_param); } void add(const eoParam& _param) { push_back(&_param); }
}; };

View file

@ -86,7 +86,7 @@
#include "../eoObject.h" #include "../eoObject.h"
// TODO: check for various compilers if this is exactly 32 bits // TODO: check for various compilers if this is exactly 32 bits
// Unfortunately MSVC's preprocessor does not comprehends sizeof() // Unfortunately MSVC's preprocessor does not comprehend sizeof()
// so neat preprocessing tricks will not work // so neat preprocessing tricks will not work
typedef unsigned long uint32; // Compiler and platform dependent! typedef unsigned long uint32; // Compiler and platform dependent!
@ -95,7 +95,8 @@ typedef unsigned long uint32; // Compiler and platform dependent!
// eoRng // eoRng
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** /**
eoRng is a persitent class that uses the ``Mersenne Twister'' random number generator MT19937 \class eoRng eoRNG.h utils/eoRNG.h
eoRng is a persistent class that uses the ``Mersenne Twister'' random number generator MT19937
for generating random numbers. The various member functions implement useful functions for generating random numbers. The various member functions implement useful functions
for evolutionary algorithms. Included are: rand(), random(), flip() and normal(). for evolutionary algorithms. Included are: rand(), random(), flip() and normal().

View file

@ -36,6 +36,9 @@ class eoStatBase
public : public :
virtual ~eoStatBase(){} virtual ~eoStatBase(){}
/**
calculate some statistic on the population
*/
virtual void operator()(const eoPop<EOT>& _pop) = 0; virtual void operator()(const eoPop<EOT>& _pop) = 0;
}; };
@ -44,8 +47,6 @@ class eoStat : public eoValueParam<T>, public eoStatBase<EOT>
{ {
public : public :
eoStat(T _value, std::string _description) : eoValueParam<T>(_value, _description) {} eoStat(T _value, std::string _description) : eoValueParam<T>(_value, _description) {}
virtual void operator()(const eoPop<EOT>& _pop) = 0;
}; };
#include <numeric> #include <numeric>

View file

@ -61,7 +61,18 @@ void eoState::registerObject(eoPersistent& registrant)
void eoState::load(const string& _filename) void eoState::load(const string& _filename)
{ {
ifstream is (_filename.c_str()); ifstream is (_filename.c_str());
if (!is)
{
string str = "Could not open file " + _filename;
throw runtime_error(str);
}
load(is);
}
void eoState::load(std::istream& is)
{
string str; string str;
string name; string name;
@ -69,7 +80,7 @@ void eoState::load(const string& _filename)
if (is.fail()) if (is.fail())
{ {
string str = "Could not open file " + _filename; string str = "Error while reading stream";
throw runtime_error(str); throw runtime_error(str);
} }
@ -119,12 +130,17 @@ void eoState::save(const string& filename) const
{ // saves in order of insertion { // saves in order of insertion
ofstream os(filename.c_str()); ofstream os(filename.c_str());
if (os.fail()) if (!os)
{ {
string msg = "Could not open file: " + filename + " for writing!"; string msg = "Could not open file: " + filename + " for writing!";
throw runtime_error(msg); throw runtime_error(msg);
} }
save(os);
}
void eoState::save(std::ostream& os) const
{ // saves in order of insertion
for (vector<ObjectMap::iterator>::const_iterator it = creationOrder.begin(); it != creationOrder.end(); ++it) for (vector<ObjectMap::iterator>::const_iterator it = creationOrder.begin(); it != creationOrder.end(); ++it)
{ {
os << "\\section{" << (*it)->first << "}\n"; os << "\\section{" << (*it)->first << "}\n";

View file

@ -66,12 +66,26 @@ public :
*/ */
void load(const std::string& _filename); void load(const std::string& _filename);
/**
* Reads the file specified
*
* @param is the stream to load from
*/
void load(std::istream& is);
/** /**
* Saves the state in file specified * Saves the state in file specified
* *
* @param _filename the name of the file to save into * @param _filename the name of the file to save into
*/ */
void save(const std::string& _filename) const; void save(const std::string& _filename) const;
/**
* Saves the state in file specified
*
* @param os the stream to save into
*/
void save(std::ostream& os) const;
private : private :
std::string createObjectName(eoObject* obj); std::string createObjectName(eoObject* obj);

View file

@ -42,6 +42,10 @@
#include "eoRNG.h" #include "eoRNG.h"
/**
\defgroup selectors
*/
template <class EOT> template <class EOT>
bool minimizing_fitness() bool minimizing_fitness()
{ {