* indentations + whitespace cleanup
This commit is contained in:
parent
8457e39efe
commit
56c6edab04
46 changed files with 6068 additions and 6223 deletions
|
|
@ -1,42 +1,42 @@
|
|||
2007-08-22 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
* eoRNG.h (eoRng::random): Add comment on truncation as standard way of
|
||||
floating point to integer conversion.
|
||||
* eoRNG.h (eoRng::random): Add comment on truncation as standard way of
|
||||
floating point to integer conversion.
|
||||
|
||||
2006-12-04 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
* eoRNG.h (eoRng::normal(stdev)): Revert erroneous change.
|
||||
* eoRNG.h (eoRng::normal(stdev)): Revert erroneous change.
|
||||
|
||||
2006-12-02 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
* eoTimedMonitor.h (eoTimedMonitor::seconds): Make unsigned.
|
||||
* eoTimedMonitor.h (eoTimedMonitor::seconds): Make unsigned.
|
||||
|
||||
* eoRNG.h: Cleanup docs and document /all/ members.
|
||||
* eoRNG.h: Cleanup docs and document /all/ members.
|
||||
|
||||
* eoRNG.cpp, eoRNG.h (K, M, N): Declare static and initialize in cpp.
|
||||
* eoRNG.cpp, eoRNG.h (K, M, N): Declare static and initialize in cpp.
|
||||
|
||||
2006-12-01 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
* eoRNG.cpp: Use C++ style cast.
|
||||
* eoRNG.cpp: Use C++ style cast.
|
||||
|
||||
* Makefile.am: Add missing header for distribution.
|
||||
* Makefile.am: Add missing header for distribution.
|
||||
|
||||
2006-11-30 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
* eoRNG.h: Generally include <cmath>
|
||||
* eoRNG.h: Generally include <cmath>
|
||||
|
||||
2006-11-16 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
* eoParser.h (eoParser::getORcreateParam): Make this a real if-then-else
|
||||
clause around ptParam (found or not).
|
||||
* eoParser.h (eoParser::getORcreateParam): Make this a real if-then-else
|
||||
clause around ptParam (found or not).
|
||||
|
||||
* eoParam.h (eoValueParam::setValue): Document.
|
||||
(eoValueParam<std::vector<double> >::setValue): Allow delimiters ',' and
|
||||
';'. A plain ' ' does not work, as it is not correctly read by
|
||||
eoParser::readFrom.
|
||||
* eoParam.h (eoValueParam::setValue): Document.
|
||||
(eoValueParam<std::vector<double> >::setValue): Allow delimiters ',' and
|
||||
';'. A plain ' ' does not work, as it is not correctly read by
|
||||
eoParser::readFrom.
|
||||
|
||||
* Local Variables:
|
||||
* coding: iso-8859-1
|
||||
* mode: flyspell
|
||||
* fill-column: 80
|
||||
* End:
|
||||
* Local Variables:
|
||||
* coding: iso-8859-1
|
||||
* mode: flyspell
|
||||
* fill-column: 80
|
||||
* End:
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
-----------------------------------------------------------------------------
|
||||
compatibility.h
|
||||
File to store some compiler specific stuff in. Currently handles, or
|
||||
File to store some compiler specific stuff in. Currently handles, or
|
||||
least tries to handle the min() max() problems when using MSVC
|
||||
|
||||
|
||||
(c) Maarten Keijzer (mak@dhi.dk) and GeNeura Team, 1999, 2000
|
||||
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -33,15 +33,15 @@
|
|||
|
||||
#ifdef __GNUC__
|
||||
#if __GNUC__ < 3
|
||||
// check for stdlibc++v3 which does have ios_base
|
||||
#ifndef _CPP_BITS_IOSBASE_H
|
||||
typedef ios ios_base; // not currently defined in GCC
|
||||
#endif
|
||||
// check for stdlibc++v3 which does have ios_base
|
||||
#ifndef _CPP_BITS_IOSBASE_H
|
||||
typedef ios ios_base; // not currently defined in GCC
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||
/*
|
||||
/*
|
||||
Maarten: added this code here because Mirkosoft has the
|
||||
nasty habit of #define min and max in stdlib.h (and windows.h)
|
||||
I'm trying to undo this horrible macro magic (microsoft yet macrohard)
|
||||
|
|
@ -67,7 +67,7 @@ namespace std
|
|||
// else
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
template <class T> const T& max(const T& a, const T& b)
|
||||
{
|
||||
if(a > b)
|
||||
|
|
@ -79,4 +79,4 @@ namespace std
|
|||
|
||||
#endif
|
||||
// _MSC_VER
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoCheckPoint.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2000
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -52,12 +52,12 @@
|
|||
*/
|
||||
|
||||
/** eoCheckPoint is a container class.
|
||||
It contains std::vectors of (pointers to)
|
||||
It contains std::vectors of (pointers to)
|
||||
eoContinue (modif. MS July 16. 2002)
|
||||
eoStats, eoUpdater and eoMonitor
|
||||
it is an eoContinue, so its operator() will be called every generation -
|
||||
it is an eoContinue, so its operator() will be called every generation -
|
||||
and will return the contained-combined-eoContinue result
|
||||
but before that it will call in turn every single
|
||||
but before that it will call in turn every single
|
||||
{statistics, updaters, monitors} that it has been given,
|
||||
and after that, if stopping, all lastCall methods of the above.
|
||||
*/
|
||||
|
|
@ -66,7 +66,7 @@ class eoCheckPoint : public eoContinue<EOT>
|
|||
{
|
||||
public :
|
||||
|
||||
eoCheckPoint(eoContinue<EOT>& _cont)
|
||||
eoCheckPoint(eoContinue<EOT>& _cont)
|
||||
{
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
|
@ -118,31 +118,31 @@ bool eoCheckPoint<EOT>::operator()(const eoPop<EOT>& _pop)
|
|||
|
||||
bool bContinue = true;
|
||||
for (i = 0; i < continuators.size(); ++i)
|
||||
if ( !(*continuators[i])(_pop) )
|
||||
bContinue = false;
|
||||
if ( !(*continuators[i])(_pop) )
|
||||
bContinue = false;
|
||||
|
||||
if (! bContinue) // we're going to stop: lastCall, gentlemen
|
||||
if (! bContinue) // we're going to stop: lastCall, gentlemen
|
||||
{
|
||||
if (!sorted.empty())
|
||||
{
|
||||
for (i = 0; i < sorted.size(); ++i)
|
||||
{
|
||||
sorted[i]->lastCall(sorted_pop);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < stats.size(); ++i)
|
||||
stats[i]->lastCall(_pop);
|
||||
if (!sorted.empty())
|
||||
{
|
||||
for (i = 0; i < sorted.size(); ++i)
|
||||
{
|
||||
sorted[i]->lastCall(sorted_pop);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < stats.size(); ++i)
|
||||
stats[i]->lastCall(_pop);
|
||||
|
||||
for (i = 0; i < updaters.size(); ++i)
|
||||
updaters[i]->lastCall();
|
||||
for (i = 0; i < updaters.size(); ++i)
|
||||
updaters[i]->lastCall();
|
||||
|
||||
for (i = 0; i < monitors.size(); ++i)
|
||||
monitors[i]->lastCall();
|
||||
for (i = 0; i < monitors.size(); ++i)
|
||||
monitors[i]->lastCall();
|
||||
}
|
||||
return bContinue;
|
||||
}
|
||||
|
||||
/** returns a string with all className()
|
||||
/** returns a string with all className()
|
||||
* of data separated with "\n" (for debugging)
|
||||
*/
|
||||
template <class EOT>
|
||||
|
|
|
|||
|
|
@ -45,4 +45,3 @@
|
|||
#define eo_is_an_integer false
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoDistance.h
|
||||
// (c) GeNeura Team, 1998, Marc Schoenauer 2001
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -28,11 +28,11 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/** @addtogroup Stats
|
||||
/** @addtogroup Stats
|
||||
* @{
|
||||
* */
|
||||
|
||||
/**
|
||||
/**
|
||||
This is a generic class for distance functors:
|
||||
takes 2 things and returns a double
|
||||
*/
|
||||
|
|
@ -41,8 +41,8 @@ class eoDistance : public eoBF<const EOT &, const EOT &, double>
|
|||
{};
|
||||
|
||||
|
||||
/**
|
||||
This is a generic class for Euclidain distance (L2 norm) computation:
|
||||
/**
|
||||
This is a generic class for Euclidain distance (L2 norm) computation:
|
||||
assumes the 2 things are std::vectors of something that is double-castable
|
||||
*/
|
||||
template< class EOT >
|
||||
|
|
@ -54,16 +54,16 @@ public:
|
|||
double sum=0.0;
|
||||
for (unsigned i=0; i<_v1.size(); i++)
|
||||
{
|
||||
double r = static_cast<double> (_v1[i]) - static_cast<double> (_v2[i]);
|
||||
sum += r*r;
|
||||
double r = static_cast<double> (_v1[i]) - static_cast<double> (_v2[i]);
|
||||
sum += r*r;
|
||||
}
|
||||
return sqrt(sum);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
This is a generic class for L1 distance computation:
|
||||
assumes the 2 things are std::vectors of something
|
||||
/**
|
||||
This is a generic class for L1 distance computation:
|
||||
assumes the 2 things are std::vectors of something
|
||||
that is double-castable
|
||||
For bitstrings, this is the Hamming distance
|
||||
*/
|
||||
|
|
@ -76,15 +76,15 @@ public:
|
|||
double sum=0.0;
|
||||
for (unsigned i=0; i<_v1.size(); i++)
|
||||
{
|
||||
double r = static_cast<double> (_v1[i]) - static_cast<double> (_v2[i]);
|
||||
sum += fabs(r);
|
||||
double r = static_cast<double> (_v1[i]) - static_cast<double> (_v2[i]);
|
||||
sum += fabs(r);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
};
|
||||
|
||||
/* this distance measures the difference in fitness
|
||||
* I am not sure it can be of any use, though ...
|
||||
/* this distance measures the difference in fitness
|
||||
* I am not sure it can be of any use, though ...
|
||||
* except for some testing
|
||||
*/
|
||||
template< class EOT >
|
||||
|
|
@ -100,5 +100,5 @@ public:
|
|||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
/**
|
||||
The Fitness Distance Correlation computation.
|
||||
|
||||
|
||||
Stores the values into eoValueParam<EOT,double>
|
||||
so they can be snapshot by some eoGnuplotSnapshot ...
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public:
|
|||
/** Ctor with the optimum
|
||||
*/
|
||||
eoFDCStat(eoDistance<EOT> & _dist, EOT & _theBest,
|
||||
std::string _description = "FDC") :
|
||||
std::string _description = "FDC") :
|
||||
eoStat<EOT,double>(0, _description), dist(_dist),
|
||||
theBest(_theBest), boolOpt(true) {}
|
||||
|
||||
|
|
@ -63,30 +63,30 @@ public:
|
|||
virtual void operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
unsigned i;
|
||||
if (!boolOpt) // take the local best
|
||||
theBest = _pop.best_element();
|
||||
if (!boolOpt) // take the local best
|
||||
theBest = _pop.best_element();
|
||||
unsigned int pSize = _pop.size();
|
||||
distToBest.value().resize(pSize);
|
||||
fitnesses.value().resize(pSize);
|
||||
double sumFit = 0.0, sumDist = 0.0;
|
||||
for (i=0; i<pSize; i++)
|
||||
{
|
||||
sumDist += (distToBest.value()[i] = dist(_pop[i], theBest));
|
||||
sumFit += (fitnesses.value()[i] = _pop[i].fitness());
|
||||
}
|
||||
{
|
||||
sumDist += (distToBest.value()[i] = dist(_pop[i], theBest));
|
||||
sumFit += (fitnesses.value()[i] = _pop[i].fitness());
|
||||
}
|
||||
// now the FDC coefficient
|
||||
double avgDist = sumDist/pSize;
|
||||
double avgFit = sumFit/pSize;
|
||||
sumDist = sumFit = 0.0;
|
||||
double num = 0.0;
|
||||
for (i=0; i<pSize; i++)
|
||||
{
|
||||
double devDist = distToBest.value()[i] - avgDist ;
|
||||
double devFit = fitnesses.value()[i] - avgFit ;
|
||||
sumDist += devDist*devDist;
|
||||
sumFit += devFit * devFit;
|
||||
num += devDist * devFit ;
|
||||
}
|
||||
{
|
||||
double devDist = distToBest.value()[i] - avgDist ;
|
||||
double devFit = fitnesses.value()[i] - avgFit ;
|
||||
sumDist += devDist*devDist;
|
||||
sumFit += devFit * devFit;
|
||||
num += devDist * devFit ;
|
||||
}
|
||||
value() = num/(sqrt(sumDist)*sqrt(sumFit));
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ public:
|
|||
private:
|
||||
eoDistance<EOT> & dist;
|
||||
EOT theBest;
|
||||
bool boolOpt; // whether the best is known or not
|
||||
bool boolOpt; // whether the best is known or not
|
||||
eoValueParam<std::vector<double> > distToBest;
|
||||
eoValueParam<std::vector<double> > fitnesses;
|
||||
};
|
||||
|
|
@ -119,12 +119,12 @@ class eoFDCFileSnapshot : public eoFileSnapshot // is an eoMonitor
|
|||
public:
|
||||
/** Ctor: in addition to the parameters of the ctor of an eoFileSnapshot
|
||||
we need here an eoFDCStat. The 2 std::vectors (distances to optimum
|
||||
and fitnesses) are added to the monitor so they can be processed
|
||||
and fitnesses) are added to the monitor so they can be processed
|
||||
later to a file - and eventually by gnuplot
|
||||
*/
|
||||
eoFDCFileSnapshot(eoFDCStat<EOT> & _FDCstat,
|
||||
std::string _dirname = "tmpFDC", unsigned _frequency = 1,
|
||||
std::string _filename = "FDC", std::string _delim = " "):
|
||||
std::string _dirname = "tmpFDC", unsigned _frequency = 1,
|
||||
std::string _filename = "FDC", std::string _delim = " "):
|
||||
eoFileSnapshot(_dirname, _frequency, _filename, _delim),
|
||||
FDCstat(_FDCstat)
|
||||
{
|
||||
|
|
@ -142,4 +142,3 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
/*
|
||||
|
||||
(c) 2010 Thales group
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; version 2
|
||||
License as published by the Free Software Foundation; version 2
|
||||
of the License.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
|
|
@ -46,11 +45,11 @@ public:
|
|||
|
||||
eoFeasibleRatioStat( std::string description = "FeasibleRatio" ) : eoStat<EOT,double>( 0.0, description ) {}
|
||||
|
||||
virtual void operator()( const eoPop<EOT> & pop )
|
||||
virtual void operator()( const eoPop<EOT> & pop )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
assert( pop.size() > 0 );
|
||||
|
||||
|
||||
double count = static_cast<double>( std::count_if( pop.begin(), pop.end(), eoIsFeasible<EOT> ) );
|
||||
double size = static_cast<double>( pop.size() );
|
||||
double ratio = count/size;
|
||||
|
|
@ -60,9 +59,8 @@ public:
|
|||
value() = static_cast<double>( std::count_if( pop.begin(), pop.end(), eoIsFeasible<EOT> ) ) / static_cast<double>( pop.size() );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
virtual std::string className(void) const { return "eoFeasibleRatioStat"; }
|
||||
};
|
||||
|
||||
#endif // _eoFeasibleRatioStat_h_
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifdef _MSC_VER
|
||||
// to avoid long name warnings
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -32,21 +32,21 @@ void eoFileMonitor::printHeader(std::ostream& os)
|
|||
void eoFileMonitor::printHeader()
|
||||
{
|
||||
// create file
|
||||
ofstream os(filename.c_str());
|
||||
ofstream os(filename.c_str());
|
||||
|
||||
if (!os)
|
||||
{
|
||||
string str = "eoFileMonitor could not open: " + filename;
|
||||
throw runtime_error(str);
|
||||
}
|
||||
|
||||
|
||||
printHeader(os);
|
||||
}
|
||||
|
||||
eoMonitor& eoFileMonitor::operator()(void)
|
||||
{
|
||||
ofstream os(filename.c_str(),
|
||||
overwrite ?
|
||||
ofstream os(filename.c_str(),
|
||||
overwrite ?
|
||||
ios_base::out|ios_base::trunc // truncate
|
||||
:
|
||||
ios_base::out|ios_base::app // append
|
||||
|
|
@ -58,7 +58,7 @@ eoMonitor& eoFileMonitor::operator()(void)
|
|||
throw runtime_error(str);
|
||||
}
|
||||
|
||||
if (
|
||||
if (
|
||||
header // we want to write headers
|
||||
&& firstcall // we do not want to write headers twice
|
||||
&& !keep // if we append to an existing file, headers are useless
|
||||
|
|
@ -67,17 +67,17 @@ eoMonitor& eoFileMonitor::operator()(void)
|
|||
printHeader();
|
||||
firstcall = false;
|
||||
}
|
||||
|
||||
|
||||
return operator()(os);
|
||||
}
|
||||
|
||||
eoMonitor& eoFileMonitor::operator()(std::ostream& os)
|
||||
{
|
||||
|
||||
|
||||
iterator it = vec.begin();
|
||||
|
||||
|
||||
os << (*it)->getValue();
|
||||
|
||||
|
||||
for(++it; it != vec.end(); ++it)
|
||||
{
|
||||
os << delim.c_str() << (*it)->getValue();
|
||||
|
|
@ -87,4 +87,3 @@ eoMonitor& eoFileMonitor::operator()(std::ostream& os)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,16 +58,16 @@ public :
|
|||
* @param _overwrite if true, overwrite the existing file
|
||||
*/
|
||||
eoFileMonitor(
|
||||
std::string _filename,
|
||||
std::string _delim = " ",
|
||||
bool _keep_existing = false,
|
||||
std::string _filename,
|
||||
std::string _delim = " ",
|
||||
bool _keep_existing = false,
|
||||
bool _header = false,
|
||||
bool _overwrite = false
|
||||
)
|
||||
: filename(_filename),
|
||||
delim(_delim),
|
||||
keep(_keep_existing),
|
||||
header(_header),
|
||||
: filename(_filename),
|
||||
delim(_delim),
|
||||
keep(_keep_existing),
|
||||
header(_header),
|
||||
firstcall(true),
|
||||
overwrite(_overwrite)
|
||||
{
|
||||
|
|
@ -84,7 +84,7 @@ public :
|
|||
//! Called first, try to open the file in append mode and write the header if asked
|
||||
virtual eoMonitor& operator()(void);
|
||||
|
||||
/*! Main call, normally called at each generation.
|
||||
/*! Main call, normally called at each generation.
|
||||
Write the content of the registered vector into the file, each item being separated by delim
|
||||
*/
|
||||
virtual eoMonitor& operator()(std::ostream& os);
|
||||
|
|
@ -104,13 +104,13 @@ private :
|
|||
|
||||
//! delimiter to use between each write
|
||||
std::string delim;
|
||||
|
||||
|
||||
//! should we append or create a new file
|
||||
bool keep;
|
||||
|
||||
bool keep;
|
||||
|
||||
//! printing header at begin of file?
|
||||
bool header;
|
||||
|
||||
|
||||
//! flag to avoid calling twice operator()(void)
|
||||
bool firstcall;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public :
|
|||
typedef eoValueParam<std::vector<double> > vDoubleParam;
|
||||
|
||||
eoFileSnapshot(std::string _dirname, unsigned _frequency = 1, std::string _filename = "gen",
|
||||
std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true):
|
||||
std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true):
|
||||
dirname(_dirname), frequency(_frequency),
|
||||
filename(_filename), delim(_delim), counter(_counter), boolChanged(true)
|
||||
{
|
||||
|
|
@ -71,11 +71,11 @@ public :
|
|||
// now make sure there is a dir without any genXXX file in it
|
||||
if (res) // no dir present
|
||||
{
|
||||
s = std::string("mkdir ")+dirname;
|
||||
s = std::string("mkdir ")+dirname;
|
||||
}
|
||||
else if (!res && _rmFiles)
|
||||
{
|
||||
s = std::string("/bin/rm ")+dirname+ "/" + filename + "*";
|
||||
s = std::string("/bin/rm ")+dirname+ "/" + filename + "*";
|
||||
}
|
||||
else
|
||||
s = " ";
|
||||
|
|
@ -111,9 +111,9 @@ public :
|
|||
{
|
||||
if (counter % frequency)
|
||||
{
|
||||
boolChanged = false; // subclass with gnuplot will do nothing
|
||||
counter++;
|
||||
return (*this);
|
||||
boolChanged = false; // subclass with gnuplot will do nothing
|
||||
counter++;
|
||||
return (*this);
|
||||
}
|
||||
counter++;
|
||||
boolChanged = true;
|
||||
|
|
@ -137,35 +137,35 @@ public :
|
|||
static_cast<const eoValueParam<std::vector<double> >* >(vec[0]);
|
||||
|
||||
const std::vector<double> v = ptParam->value();
|
||||
if (vec.size() == 1) // only one std::vector: -> add number in front
|
||||
if (vec.size() == 1) // only one std::vector: -> add number in front
|
||||
{
|
||||
for (unsigned k=0; k<v.size(); k++)
|
||||
_os << k << " " << v[k] << "\n" ;
|
||||
for (unsigned k=0; k<v.size(); k++)
|
||||
_os << k << " " << v[k] << "\n" ;
|
||||
}
|
||||
else // need to get all other std::vectors
|
||||
else // need to get all other std::vectors
|
||||
{
|
||||
std::vector<std::vector<double> > vv(vec.size());
|
||||
vv[0]=v;
|
||||
for (unsigned i=1; i<vec.size(); i++)
|
||||
{
|
||||
ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
|
||||
vv[i] = ptParam->value();
|
||||
if (vv[i].size() != v.size())
|
||||
throw std::runtime_error("Dimension error in eoSnapshotMonitor");
|
||||
}
|
||||
for (unsigned k=0; k<v.size(); k++)
|
||||
{
|
||||
for (unsigned i=0; i<vec.size(); i++)
|
||||
_os << vv[i][k] << " " ;
|
||||
_os << "\n";
|
||||
}
|
||||
std::vector<std::vector<double> > vv(vec.size());
|
||||
vv[0]=v;
|
||||
for (unsigned i=1; i<vec.size(); i++)
|
||||
{
|
||||
ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
|
||||
vv[i] = ptParam->value();
|
||||
if (vv[i].size() != v.size())
|
||||
throw std::runtime_error("Dimension error in eoSnapshotMonitor");
|
||||
}
|
||||
for (unsigned k=0; k<v.size(); k++)
|
||||
{
|
||||
for (unsigned i=0; i<vec.size(); i++)
|
||||
_os << vv[i][k] << " " ;
|
||||
_os << "\n";
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual const std::string getDirName() // for eoGnuPlot
|
||||
virtual const std::string getDirName() // for eoGnuPlot
|
||||
{ return dirname;}
|
||||
virtual const std::string baseFileName() // the title for eoGnuPlot
|
||||
virtual const std::string baseFileName() // the title for eoGnuPlot
|
||||
{ return filename;}
|
||||
|
||||
/// add checks whether it is a std::vector of doubles
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#ifndef eoFuncPtrStat_h
|
||||
#define eoFuncPtrStat_h
|
||||
|
||||
|
|
@ -21,9 +20,9 @@ public :
|
|||
eoFuncPtrStat(func_t f, std::string _description = "func_ptr")
|
||||
: eoStat<EOT, T>(T(), _description), func(f)
|
||||
{}
|
||||
|
||||
|
||||
using eoStat<EOT, T>::value;
|
||||
|
||||
|
||||
void operator()(const eoPop<EOT>& pop) {
|
||||
value() = func(pop);
|
||||
}
|
||||
|
|
@ -32,7 +31,7 @@ private:
|
|||
func_t func;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ingroup Stats
|
||||
*/
|
||||
template <class EOT, class T>
|
||||
|
|
@ -43,4 +42,3 @@ eoFuncPtrStat<EOT, T>& makeFuncPtrStat( T (*func)(const eoPop<EOT>&), eoFunctorS
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
|||
|
||||
// Ctor
|
||||
eoGnuplot1DSnapshot(std::string _dirname, eoRealVectorBounds & _bounds,
|
||||
unsigned _frequency = 1, std::string _filename = "gen",
|
||||
std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true ) :
|
||||
unsigned _frequency = 1, std::string _filename = "gen",
|
||||
std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true ) :
|
||||
eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles),
|
||||
eoGnuplot(_filename,"set data style points"),
|
||||
pointSize(5)
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public:
|
|||
if (count == 0)
|
||||
{
|
||||
unsigned int res = static_cast<unsigned int>( std::ceil( rate * _size ) );
|
||||
|
||||
|
||||
if( res == 0 ) {
|
||||
eo::log << eo::warnings << "Call to a eoHowMany instance returns 0 (rate=" << rate << ", size=" << _size << ")" << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
|
|||
std::string sMinBounds = sBounds.substr(0,posDelim);
|
||||
|
||||
if ( (sMinBounds != std::string("-inf")) &&
|
||||
(sMinBounds != std::string("-infinity"))
|
||||
)
|
||||
{
|
||||
minBounded = true;
|
||||
minBound = read_int(sMinBounds);
|
||||
}
|
||||
(sMinBounds != std::string("-infinity"))
|
||||
)
|
||||
{
|
||||
minBounded = true;
|
||||
minBound = read_int(sMinBounds);
|
||||
}
|
||||
|
||||
// max bound
|
||||
size_t posEndDelim = sBounds.find_first_not_of(delim,posDelim);
|
||||
|
|
@ -73,26 +73,26 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
|
|||
std::string sMaxBounds = sBounds.substr(posEndDelim);
|
||||
|
||||
if ( (sMaxBounds != std::string("+inf")) &&
|
||||
(sMaxBounds != std::string("+infinity"))
|
||||
)
|
||||
{
|
||||
maxBounded = true;
|
||||
maxBound = read_int(sMaxBounds);
|
||||
}
|
||||
(sMaxBounds != std::string("+infinity"))
|
||||
)
|
||||
{
|
||||
maxBounded = true;
|
||||
maxBound = read_int(sMaxBounds);
|
||||
}
|
||||
|
||||
// now create the embedded eoIntBounds object
|
||||
eoIntBounds * locBound;
|
||||
if (minBounded && maxBounded)
|
||||
{
|
||||
if (maxBound <= minBound)
|
||||
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
|
||||
locBound = new eoIntInterval(minBound, maxBound);
|
||||
}
|
||||
{
|
||||
if (maxBound <= minBound)
|
||||
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
|
||||
locBound = new eoIntInterval(minBound, maxBound);
|
||||
}
|
||||
else if (!minBounded && !maxBounded) // no bound at all
|
||||
locBound = new eoIntNoBounds;
|
||||
locBound = new eoIntNoBounds;
|
||||
else if (!minBounded && maxBounded)
|
||||
locBound = new eoIntAboveBound(maxBound);
|
||||
locBound = new eoIntAboveBound(maxBound);
|
||||
else if (minBounded && !maxBounded)
|
||||
locBound = new eoIntBelowBound(minBound);
|
||||
locBound = new eoIntBelowBound(minBound);
|
||||
return locBound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoIntBounds.h
|
||||
// (c) Marc Schoenauer 2001, Maarten Keijzer 2000, GeNeura Team, 1998
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef _eoIntBounds_h
|
||||
#define _eoIntBounds_h
|
||||
|
||||
#include <stdexcept> // std::exceptions!
|
||||
#include <stdexcept> // std::exceptions!
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
|
|
@ -42,24 +42,24 @@ Scalar type:
|
|||
Basic class is eoIntBounds, a pure virtual.
|
||||
|
||||
The following pure virtual methods are to be used in mutations:
|
||||
- void foldsInBounds(long int &) that folds any value that falls out of
|
||||
- void foldsInBounds(long int &) that folds any value that falls out of
|
||||
the bounds back into the bounds, by bouncing on the limit (if any)
|
||||
- bool isInBounds(long int) that simply says whether or not the argument
|
||||
- bool isInBounds(long int) that simply says whether or not the argument
|
||||
is in the bounds
|
||||
- void truncate(long int &) that set the argument to the bound value it
|
||||
it exceeds it
|
||||
|
||||
So mutation can choose
|
||||
- iterate trying until they fall in bounds,
|
||||
So mutation can choose
|
||||
- iterate trying until they fall in bounds,
|
||||
- only try once and "restd::pair" by using the foldsInBounds method
|
||||
- only try once and restd::pair using the truncate method (will create a
|
||||
huge bias toward the bound if the soluiton is not far from the bounds)
|
||||
|
||||
There is also a uniform() method that generates a uniform value
|
||||
There is also a uniform() method that generates a uniform value
|
||||
(if possible, i.e. if bounded) in the interval.
|
||||
|
||||
Derived class are
|
||||
eoIntInterval that holds a minimum and maximum value,
|
||||
Derived class are
|
||||
eoIntInterval that holds a minimum and maximum value,
|
||||
eoIntNoBounds the "unbounded bounds" (-infinity, +infinity)
|
||||
eoIntBelowBound the half-bounded interval [min, +infinity)
|
||||
eoIntAboveBound the half-bounded interval (-infinity, max]
|
||||
|
|
@ -68,7 +68,7 @@ THis file also contains the declaration of *the* global object that
|
|||
is the unbounded bound
|
||||
*/
|
||||
class eoIntBounds : public eoPersistent
|
||||
{
|
||||
{
|
||||
public:
|
||||
virtual ~eoIntBounds(){}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ public:
|
|||
*/
|
||||
virtual void foldsInBounds(double &) const = 0;
|
||||
|
||||
/** foldsInBounds for ints:
|
||||
/** foldsInBounds for ints:
|
||||
* call the method for double and convert back */
|
||||
virtual void foldsInBounds(long int & i) const
|
||||
{
|
||||
|
|
@ -112,24 +112,24 @@ public:
|
|||
|
||||
/** truncate for ints: call the method for double and convert back
|
||||
*/
|
||||
virtual void truncate(long int & i) const
|
||||
virtual void truncate(long int & i) const
|
||||
{
|
||||
double r = double(i);
|
||||
truncate(r);
|
||||
i = (long int)(r);
|
||||
}
|
||||
|
||||
/** get minimum value
|
||||
/** get minimum value
|
||||
* std::exception if does not exist
|
||||
*/
|
||||
*/
|
||||
virtual long int minimum() const = 0 ;
|
||||
/** get maximum value
|
||||
* std::exception if does not exist
|
||||
*/
|
||||
*/
|
||||
virtual long int maximum() const = 0 ;
|
||||
/** get range
|
||||
* std::exception if unbounded
|
||||
*/
|
||||
*/
|
||||
virtual long int range() const = 0;
|
||||
|
||||
/** random generator of uniform numbers in bounds
|
||||
|
|
@ -165,11 +165,11 @@ public:
|
|||
{
|
||||
throw std::logic_error("Trying to get minimum of unbounded eoIntBounds");
|
||||
}
|
||||
virtual long int maximum() const
|
||||
virtual long int maximum() const
|
||||
{
|
||||
throw std::logic_error("Trying to get maximum of unbounded eoIntBounds");
|
||||
}
|
||||
virtual long int range() const
|
||||
virtual long int range() const
|
||||
{
|
||||
throw std::logic_error("Trying to get range of unbounded eoIntBounds");
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ public:
|
|||
}
|
||||
|
||||
/** for memory managements - ugly */
|
||||
virtual eoIntBounds * dup() const
|
||||
virtual eoIntBounds * dup() const
|
||||
{
|
||||
return new eoIntNoBounds(*this);
|
||||
}
|
||||
|
|
@ -236,18 +236,18 @@ class eoIntInterval : public eoIntBounds
|
|||
{
|
||||
public :
|
||||
virtual ~eoIntInterval(){}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
Simple bounds = minimum and maximum (allowed)
|
||||
*/
|
||||
eoIntInterval(long int _min=0, long int _max=1) :
|
||||
repMinimum(_min), repMaximum(_max), repRange(_max-_min)
|
||||
eoIntInterval(long int _min=0, long int _max=1) :
|
||||
repMinimum(_min), repMaximum(_max), repRange(_max-_min)
|
||||
{
|
||||
if (repRange<=0)
|
||||
throw std::logic_error("Void range in eoIntBounds");
|
||||
}
|
||||
|
||||
// accessors
|
||||
// accessors
|
||||
virtual long int minimum() const { return repMinimum; }
|
||||
virtual long int maximum() const { return repMaximum; }
|
||||
virtual long int range() const { return repRange; }
|
||||
|
|
@ -258,18 +258,18 @@ public :
|
|||
virtual bool isMinBounded(void) const {return true;}
|
||||
virtual bool isMaxBounded(void) const {return true;}
|
||||
|
||||
virtual double uniform(eoRng & _rng = eo::rng) const
|
||||
virtual double uniform(eoRng & _rng = eo::rng) const
|
||||
{
|
||||
return repMinimum + _rng.uniform(repRange);
|
||||
}
|
||||
}
|
||||
|
||||
virtual long int random(eoRng & _rng = eo::rng) const
|
||||
virtual long int random(eoRng & _rng = eo::rng) const
|
||||
{
|
||||
return repMinimum + _rng.random(repRange);
|
||||
}
|
||||
}
|
||||
|
||||
// says if a given double is within the bounds
|
||||
virtual bool isInBounds(double _r) const
|
||||
virtual bool isInBounds(double _r) const
|
||||
{
|
||||
if (_r < repMinimum)
|
||||
return false;
|
||||
|
|
@ -279,36 +279,36 @@ public :
|
|||
}
|
||||
|
||||
// folds a value into bounds
|
||||
virtual void foldsInBounds(double & _r) const
|
||||
virtual void foldsInBounds(double & _r) const
|
||||
{
|
||||
long iloc;
|
||||
double dlargloc = 2 * range() ;
|
||||
|
||||
if (fabs(_r) > 1.0E9) // iloc too large!
|
||||
{
|
||||
_r = uniform();
|
||||
return;
|
||||
_r = uniform();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (_r > maximum()) )
|
||||
{
|
||||
iloc = (long) ( (_r-minimum()) / dlargloc ) ;
|
||||
_r -= dlargloc * iloc ;
|
||||
if ( _r > maximum() )
|
||||
_r = 2*maximum() - _r ;
|
||||
iloc = (long) ( (_r-minimum()) / dlargloc ) ;
|
||||
_r -= dlargloc * iloc ;
|
||||
if ( _r > maximum() )
|
||||
_r = 2*maximum() - _r ;
|
||||
}
|
||||
|
||||
if (_r < minimum())
|
||||
|
||||
if (_r < minimum())
|
||||
{
|
||||
iloc = (long) ( (maximum()-_r) / dlargloc ) ;
|
||||
_r += dlargloc * iloc ;
|
||||
if (_r < minimum())
|
||||
_r = 2*minimum() - _r ;
|
||||
iloc = (long) ( (maximum()-_r) / dlargloc ) ;
|
||||
_r += dlargloc * iloc ;
|
||||
if (_r < minimum())
|
||||
_r = 2*minimum() - _r ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// truncates to the bounds
|
||||
virtual void truncate(double & _r) const
|
||||
virtual void truncate(double & _r) const
|
||||
{
|
||||
if (_r < repMinimum)
|
||||
_r = repMinimum;
|
||||
|
|
@ -341,7 +341,7 @@ public :
|
|||
}
|
||||
|
||||
/** for memory managements - ugly */
|
||||
virtual eoIntBounds * dup() const
|
||||
virtual eoIntBounds * dup() const
|
||||
{
|
||||
return new eoIntInterval(*this);
|
||||
}
|
||||
|
|
@ -349,7 +349,7 @@ public :
|
|||
private :
|
||||
long int repMinimum;
|
||||
long int repMaximum;
|
||||
long int repRange; // to minimize operations ???
|
||||
long int repRange; // to minimize operations ???
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -361,22 +361,22 @@ private :
|
|||
class eoIntBelowBound : public eoIntBounds
|
||||
{
|
||||
public :
|
||||
virtual ~eoIntBelowBound(){}
|
||||
/**
|
||||
virtual ~eoIntBelowBound(){}
|
||||
/**
|
||||
Simple bounds = minimum
|
||||
*/
|
||||
eoIntBelowBound(long int _min=0) :
|
||||
eoIntBelowBound(long int _min=0) :
|
||||
repMinimum(_min)
|
||||
{}
|
||||
|
||||
// accessors
|
||||
// accessors
|
||||
virtual long int minimum() const { return repMinimum; }
|
||||
|
||||
virtual long int maximum() const
|
||||
virtual long int maximum() const
|
||||
{
|
||||
throw std::logic_error("Trying to get maximum of eoIntBelowBound");
|
||||
}
|
||||
virtual long int range() const
|
||||
virtual long int range() const
|
||||
{
|
||||
throw std::logic_error("Trying to get range of eoIntBelowBound");
|
||||
}
|
||||
|
|
@ -402,7 +402,7 @@ public :
|
|||
virtual bool isMaxBounded(void) const {return false;}
|
||||
|
||||
// says if a given double is within the bounds
|
||||
virtual bool isInBounds(double _r) const
|
||||
virtual bool isInBounds(double _r) const
|
||||
{
|
||||
if (_r < repMinimum)
|
||||
return false;
|
||||
|
|
@ -410,16 +410,16 @@ public :
|
|||
}
|
||||
|
||||
// folds a value into bounds
|
||||
virtual void foldsInBounds(double & _r) const
|
||||
virtual void foldsInBounds(double & _r) const
|
||||
{
|
||||
// easy as a pie: symmetry w.r.t. minimum
|
||||
if (_r < repMinimum) // nothing to do otherwise
|
||||
if (_r < repMinimum) // nothing to do otherwise
|
||||
_r = 2*repMinimum - _r;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
// truncates to the bounds
|
||||
virtual void truncate(double & _r) const
|
||||
virtual void truncate(double & _r) const
|
||||
{
|
||||
if (_r < repMinimum)
|
||||
_r = repMinimum;
|
||||
|
|
@ -450,7 +450,7 @@ public :
|
|||
}
|
||||
|
||||
/** for memory managements - ugly */
|
||||
virtual eoIntBounds * dup() const
|
||||
virtual eoIntBounds * dup() const
|
||||
{
|
||||
return new eoIntBelowBound(*this);
|
||||
}
|
||||
|
|
@ -469,22 +469,22 @@ class eoIntAboveBound : public eoIntBounds
|
|||
{
|
||||
public :
|
||||
virtual ~eoIntAboveBound(){}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
Simple bounds = minimum
|
||||
*/
|
||||
eoIntAboveBound(long int _max=0) :
|
||||
eoIntAboveBound(long int _max=0) :
|
||||
repMaximum(_max)
|
||||
{}
|
||||
|
||||
// accessors
|
||||
// accessors
|
||||
virtual long int maximum() const { return repMaximum; }
|
||||
|
||||
virtual long int minimum() const
|
||||
virtual long int minimum() const
|
||||
{
|
||||
throw std::logic_error("Trying to get minimum of eoIntAboveBound");
|
||||
}
|
||||
virtual long int range() const
|
||||
virtual long int range() const
|
||||
{
|
||||
throw std::logic_error("Trying to get range of eoIntAboveBound");
|
||||
}
|
||||
|
|
@ -510,7 +510,7 @@ public :
|
|||
virtual bool isMaxBounded(void) const {return true;}
|
||||
|
||||
// says if a given double is within the bounds
|
||||
virtual bool isInBounds(double _r) const
|
||||
virtual bool isInBounds(double _r) const
|
||||
{
|
||||
if (_r > repMaximum)
|
||||
return false;
|
||||
|
|
@ -518,16 +518,16 @@ public :
|
|||
}
|
||||
|
||||
// folds a value into bounds
|
||||
virtual void foldsInBounds(double & _r) const
|
||||
virtual void foldsInBounds(double & _r) const
|
||||
{
|
||||
// easy as a pie: symmetry w.r.t. maximum
|
||||
if (_r > repMaximum) // nothing to do otherwise
|
||||
if (_r > repMaximum) // nothing to do otherwise
|
||||
_r = 2*repMaximum - _r;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
// truncates to the bounds
|
||||
virtual void truncate(double & _r) const
|
||||
virtual void truncate(double & _r) const
|
||||
{
|
||||
if (_r > repMaximum)
|
||||
_r = repMaximum;
|
||||
|
|
@ -558,7 +558,7 @@ public :
|
|||
}
|
||||
|
||||
/** for memory managements - ugly */
|
||||
virtual eoIntBounds * dup() const
|
||||
virtual eoIntBounds * dup() const
|
||||
{
|
||||
return new eoIntAboveBound(*this);
|
||||
}
|
||||
|
|
@ -598,13 +598,13 @@ public:
|
|||
if (maxBounded) maximum = bb.maximum();
|
||||
|
||||
if (minBounded && maxBounded)
|
||||
repBound = new eoIntInterval(minimum, maximum);
|
||||
repBound = new eoIntInterval(minimum, maximum);
|
||||
else if (!minBounded && !maxBounded) // no bound at all
|
||||
repBound = new eoIntNoBounds;
|
||||
repBound = new eoIntNoBounds;
|
||||
else if (!minBounded && maxBounded)
|
||||
repBound = new eoIntAboveBound(maximum);
|
||||
repBound = new eoIntAboveBound(maximum);
|
||||
else if (minBounded && !maxBounded)
|
||||
repBound = new eoIntBelowBound(minimum);
|
||||
repBound = new eoIntBelowBound(minimum);
|
||||
}
|
||||
|
||||
eoGeneralIntBounds& operator=(const eoGeneralIntBounds& _b)
|
||||
|
|
@ -624,13 +624,13 @@ public:
|
|||
delete repBound;
|
||||
// now reallocate
|
||||
if (minBounded && maxBounded)
|
||||
repBound = new eoIntInterval(minimum, maximum);
|
||||
repBound = new eoIntInterval(minimum, maximum);
|
||||
else if (!minBounded && !maxBounded) // no bound at all
|
||||
repBound = new eoIntNoBounds;
|
||||
repBound = new eoIntNoBounds;
|
||||
else if (!minBounded && maxBounded)
|
||||
repBound = new eoIntAboveBound(maximum);
|
||||
repBound = new eoIntAboveBound(maximum);
|
||||
else if (minBounded && !maxBounded)
|
||||
repBound = new eoIntBelowBound(minimum);
|
||||
repBound = new eoIntBelowBound(minimum);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
|
@ -671,17 +671,17 @@ public:
|
|||
*/
|
||||
virtual void truncate(double & _x) const {return repBound->truncate(_x);}
|
||||
|
||||
/** get minimum value
|
||||
/** get minimum value
|
||||
* std::exception if does not exist
|
||||
*/
|
||||
*/
|
||||
virtual long int minimum() const {return repBound->minimum();}
|
||||
/** get maximum value
|
||||
* std::exception if does not exist
|
||||
*/
|
||||
*/
|
||||
virtual long int maximum() const {return repBound->maximum();}
|
||||
/** get range
|
||||
* std::exception if unbounded
|
||||
*/
|
||||
*/
|
||||
virtual long int range() const {return repBound->range();}
|
||||
|
||||
/** random generator of uniform doubles in bounds
|
||||
|
|
@ -698,9 +698,9 @@ public:
|
|||
virtual eoIntBounds * dup() const {return repBound->dup();}
|
||||
|
||||
/** for efficiency, it's better to use the embedded boud directly */
|
||||
const eoIntBounds & theBounds() const { return *repBound;}
|
||||
const eoIntBounds & theBounds() const { return *repBound;}
|
||||
|
||||
/** don't forget the printOn method -
|
||||
/** don't forget the printOn method -
|
||||
* again that of the embedded bound
|
||||
*/
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
|
|
@ -709,7 +709,7 @@ public:
|
|||
}
|
||||
|
||||
/** no readFrom ??? Have to check that later */
|
||||
virtual void readFrom(std::istream& _is)
|
||||
virtual void readFrom(std::istream& _is)
|
||||
{
|
||||
std::string s;
|
||||
_is >> s;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
(c) Thales group, 2010
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
Contact: http://eodev.sourceforge.net
|
||||
|
||||
Authors:
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
|
||||
|
|
@ -87,10 +87,10 @@ void eoLogger::printLevels() const
|
|||
std::cout << "Available verbose levels:" << std::endl;
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = _sortedLevels.begin(), end = _sortedLevels.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
std::cout << "\t" << *it << std::endl;
|
||||
}
|
||||
it != end; ++it)
|
||||
{
|
||||
std::cout << "\t" << *it << std::endl;
|
||||
}
|
||||
|
||||
::exit(0);
|
||||
}
|
||||
|
|
@ -116,15 +116,15 @@ eoLogger& operator<<(eoLogger& l, eo::setlevel v)
|
|||
eoLogger& operator<<(eoLogger& l, std::ostream& os)
|
||||
{
|
||||
if (l._standard_io_streams.find(&os) != l._standard_io_streams.end())
|
||||
{
|
||||
l._fd = l._standard_io_streams[&os];
|
||||
}
|
||||
{
|
||||
l._fd = l._standard_io_streams[&os];
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
eoLogger::outbuf::outbuf(const int& fd,
|
||||
const eo::Levels& contexlvl,
|
||||
const eo::Levels& selectedlvl)
|
||||
const eo::Levels& contexlvl,
|
||||
const eo::Levels& selectedlvl)
|
||||
: _fd(fd), _contextLevel(contexlvl), _selectedLevel(selectedlvl)
|
||||
{}
|
||||
|
||||
|
|
@ -132,11 +132,11 @@ int eoLogger::outbuf::overflow(int_type c)
|
|||
{
|
||||
if (_selectedLevel >= _contextLevel)
|
||||
{
|
||||
if (_fd >= 0 && c != EOF)
|
||||
{
|
||||
ssize_t num;
|
||||
num = ::write(_fd, &c, 1);
|
||||
}
|
||||
if (_fd >= 0 && c != EOF)
|
||||
{
|
||||
ssize_t num;
|
||||
num = ::write(_fd, &c, 1);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
|
@ -144,14 +144,14 @@ int eoLogger::outbuf::overflow(int_type c)
|
|||
namespace eo
|
||||
{
|
||||
file::file(const std::string f)
|
||||
: _f(f)
|
||||
: _f(f)
|
||||
{}
|
||||
|
||||
setlevel::setlevel(const std::string v)
|
||||
: _v(v), _lvl((Levels)-1)
|
||||
: _v(v), _lvl((Levels)-1)
|
||||
{}
|
||||
|
||||
setlevel::setlevel(const Levels lvl)
|
||||
: _v(std::string("")), _lvl(lvl)
|
||||
: _v(std::string("")), _lvl(lvl)
|
||||
{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
/*
|
||||
/*
|
||||
(c) Thales group, 2010
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
Contact: http://eodev.sourceforge.net
|
||||
|
||||
Authors:
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
|
||||
|
|
@ -106,12 +106,12 @@ namespace eo
|
|||
* /!\ If you want to add a level dont forget to add it at the implementation of the class eoLogger in the ctor
|
||||
*/
|
||||
enum Levels {quiet = 0,
|
||||
errors,
|
||||
warnings,
|
||||
progress,
|
||||
logging,
|
||||
debug,
|
||||
xdebug};
|
||||
errors,
|
||||
warnings,
|
||||
progress,
|
||||
logging,
|
||||
debug,
|
||||
xdebug};
|
||||
|
||||
/**
|
||||
* file
|
||||
|
|
@ -119,8 +119,8 @@ namespace eo
|
|||
*/
|
||||
struct file
|
||||
{
|
||||
file(const std::string f);
|
||||
const std::string _f;
|
||||
file(const std::string f);
|
||||
const std::string _f;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -129,10 +129,10 @@ namespace eo
|
|||
*/
|
||||
struct setlevel
|
||||
{
|
||||
setlevel(const std::string v);
|
||||
setlevel(const Levels lvl);
|
||||
const std::string _v;
|
||||
const Levels _lvl;
|
||||
setlevel(const std::string v);
|
||||
setlevel(const Levels lvl);
|
||||
const std::string _v;
|
||||
const Levels _lvl;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ namespace eo
|
|||
* Use of a global variable eo::log to easily use the logger like std::cout
|
||||
*/
|
||||
class eoLogger : public eoObject,
|
||||
public std::ostream
|
||||
public std::ostream
|
||||
{
|
||||
public:
|
||||
eoLogger();
|
||||
|
|
@ -159,7 +159,7 @@ public:
|
|||
* if( eo::log.getLevelSelected() >= eo::progress ) {...}
|
||||
*/
|
||||
eo::Levels getLevelSelected() const { return _selectedLevel; }
|
||||
|
||||
|
||||
/*! Returns the current level of the context
|
||||
* the one given when you output message with the logger
|
||||
*/
|
||||
|
|
@ -176,15 +176,15 @@ private:
|
|||
class outbuf : public std::streambuf
|
||||
{
|
||||
public:
|
||||
outbuf(const int& fd,
|
||||
const eo::Levels& contexlvl,
|
||||
const eo::Levels& selectedlvl);
|
||||
outbuf(const int& fd,
|
||||
const eo::Levels& contexlvl,
|
||||
const eo::Levels& selectedlvl);
|
||||
protected:
|
||||
virtual int overflow(int_type c);
|
||||
virtual int overflow(int_type c);
|
||||
private:
|
||||
const int& _fd;
|
||||
const eo::Levels& _contextLevel;
|
||||
const eo::Levels& _selectedLevel;
|
||||
const int& _fd;
|
||||
const eo::Levels& _contextLevel;
|
||||
const eo::Levels& _selectedLevel;
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public:
|
|||
}
|
||||
}
|
||||
private:
|
||||
unsigned int objective; // The objective we're storing
|
||||
unsigned int objective; // The objective we're storing
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
/** @defgroup Monitors Monitoring
|
||||
*
|
||||
* Monitors take a set of value parameters (eoValueParam) objects and
|
||||
* Monitors take a set of value parameters (eoValueParam) objects and
|
||||
* output them on a given stream, file, pipe, etc.
|
||||
*
|
||||
* They can be called from within an eoCheckPoint, to print different values
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifdef _MSC_VER
|
||||
// to avoid long name warnings
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue