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:
parent
6e925bedea
commit
f357a908bf
7 changed files with 46 additions and 9 deletions
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
void eoFileMonitor::operator()(void)
|
||||
eoMonitor& eoFileMonitor::operator()(void)
|
||||
{
|
||||
if (firsttime)
|
||||
{
|
||||
|
|
@ -53,6 +53,6 @@ void eoFileMonitor::operator()(void)
|
|||
os << ',' << (*it)->getValue();
|
||||
}
|
||||
|
||||
// and we're there
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ public :
|
|||
|
||||
virtual ~eoMonitor() {}
|
||||
|
||||
virtual void operator()(void) = 0;
|
||||
/** Just do it! */
|
||||
virtual eoMonitor& operator()(void) = 0;
|
||||
|
||||
void add(const eoParam& _param) { push_back(&_param); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
#include "../eoObject.h"
|
||||
|
||||
// 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
|
||||
|
||||
typedef unsigned long uint32; // Compiler and platform dependent!
|
||||
|
|
@ -95,7 +95,8 @@ typedef unsigned long uint32; // Compiler and platform dependent!
|
|||
// 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 evolutionary algorithms. Included are: rand(), random(), flip() and normal().
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ class eoStatBase
|
|||
public :
|
||||
virtual ~eoStatBase(){}
|
||||
|
||||
/**
|
||||
calculate some statistic on the population
|
||||
*/
|
||||
virtual void operator()(const eoPop<EOT>& _pop) = 0;
|
||||
};
|
||||
|
||||
|
|
@ -44,8 +47,6 @@ class eoStat : public eoValueParam<T>, public eoStatBase<EOT>
|
|||
{
|
||||
public :
|
||||
eoStat(T _value, std::string _description) : eoValueParam<T>(_value, _description) {}
|
||||
|
||||
virtual void operator()(const eoPop<EOT>& _pop) = 0;
|
||||
};
|
||||
|
||||
#include <numeric>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,18 @@ void eoState::registerObject(eoPersistent& registrant)
|
|||
void eoState::load(const string& _filename)
|
||||
{
|
||||
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 name;
|
||||
|
||||
|
|
@ -69,7 +80,7 @@ void eoState::load(const string& _filename)
|
|||
|
||||
if (is.fail())
|
||||
{
|
||||
string str = "Could not open file " + _filename;
|
||||
string str = "Error while reading stream";
|
||||
throw runtime_error(str);
|
||||
}
|
||||
|
||||
|
|
@ -119,12 +130,17 @@ void eoState::save(const string& filename) const
|
|||
{ // saves in order of insertion
|
||||
ofstream os(filename.c_str());
|
||||
|
||||
if (os.fail())
|
||||
if (!os)
|
||||
{
|
||||
string msg = "Could not open file: " + filename + " for writing!";
|
||||
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)
|
||||
{
|
||||
os << "\\section{" << (*it)->first << "}\n";
|
||||
|
|
|
|||
|
|
@ -66,12 +66,26 @@ public :
|
|||
*/
|
||||
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
|
||||
*
|
||||
* @param _filename the name of the file to save into
|
||||
*/
|
||||
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 :
|
||||
std::string createObjectName(eoObject* obj);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@
|
|||
|
||||
#include "eoRNG.h"
|
||||
|
||||
/**
|
||||
\defgroup selectors
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
bool minimizing_fitness()
|
||||
{
|
||||
|
|
|
|||
Reference in a new issue