Removed "using namespace std" statements from header files in EO -- "std::" identifier were added where necessary.
This commit is contained in:
parent
6441ea1ec3
commit
86fa476c67
263 changed files with 2009 additions and 1976 deletions
|
|
@ -52,7 +52,7 @@ Olivier: this has been removed in .NET :) One step more standard...
|
|||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#undef max // as they come in pairs
|
||||
#undef max // as they come in std::pairs
|
||||
#endif
|
||||
|
||||
// add min and max to std...
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <utils/eoStat.h>
|
||||
|
||||
/** eoCheckPoint is a container class.
|
||||
It contains 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 -
|
||||
|
|
@ -76,7 +76,7 @@ bool eoCheckPoint<EOT>::operator()(const eoPop<EOT>& _pop)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
vector<const EOT*> sorted_pop;
|
||||
std::vector<const EOT*> sorted_pop;
|
||||
if (!sorted.empty())
|
||||
{
|
||||
_pop.sort(sorted_pop);
|
||||
|
|
|
|||
|
|
@ -27,11 +27,9 @@
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <vector> // vector
|
||||
#include <vector> // std::vector
|
||||
#include <set> // set
|
||||
#include <string> // string
|
||||
|
||||
using namespace std;
|
||||
#include <string> // std::string
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class eoDistance : public eoBF<const EOT &, const EOT &, double>
|
|||
|
||||
/**
|
||||
This is a generic class for Euclidain distance computation:
|
||||
assumes the 2 things are vectors of something that is double-castable
|
||||
assumes the 2 things are std::vectors of something that is double-castable
|
||||
*/
|
||||
|
||||
template< class EOT >
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ public :
|
|||
value() = num/(sqrt(sumDist)*sqrt(sumFit));
|
||||
}
|
||||
|
||||
/** accessors to the private eoValueParam<vector<double> >
|
||||
/** accessors to the private eoValueParam<std::vector<double> >
|
||||
*/
|
||||
const eoValueParam<vector<double> > & theDist()
|
||||
const eoValueParam<std::vector<double> > & theDist()
|
||||
{ return distToBest; }
|
||||
const eoValueParam<vector<double> > & theFit()
|
||||
const eoValueParam<std::vector<double> > & theFit()
|
||||
{ return fitnesses; }
|
||||
|
||||
|
||||
|
|
@ -96,13 +96,13 @@ private:
|
|||
eoDistance<EOT> & dist;
|
||||
EOT theBest;
|
||||
bool boolOpt; // whether the best is known or not
|
||||
eoValueParam<vector<double> > distToBest;
|
||||
eoValueParam<vector<double> > fitnesses;
|
||||
eoValueParam<std::vector<double> > distToBest;
|
||||
eoValueParam<std::vector<double> > fitnesses;
|
||||
};
|
||||
|
||||
/** Specific class for FDCStat monitoring:
|
||||
* As I failed to have FDC stat as an eoStat, this is the trick
|
||||
* to put the 2 eoParam<vector<double> > into a monitor
|
||||
* to put the 2 eoParam<std::vector<double> > into a monitor
|
||||
* This class does nothing else.
|
||||
*/
|
||||
template <class EOT>
|
||||
|
|
@ -110,7 +110,7 @@ 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 vectors (distances to optimum
|
||||
we need here an eoFDCStat. The 2 std::vectors (distances to optimum
|
||||
and fitnesses) are added to the monitor so they can be processed
|
||||
later to a file - and eventually by gnuplot
|
||||
*/
|
||||
|
|
@ -127,7 +127,7 @@ public:
|
|||
/** just to be sure the add method is not called further
|
||||
*/
|
||||
virtual void add(const eoParam& _param)
|
||||
{ throw runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); }
|
||||
{ throw std::runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); }
|
||||
|
||||
private:
|
||||
eoFDCStat<EOT> & FDCstat;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
CVS Info: $Date: 2002-12-09 21:04:47 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoFileMonitor.h,v 1.10 2002-12-09 21:04:47 evomarc Exp $ $Author: evomarc $
|
||||
CVS Info: $Date: 2003-02-27 19:21:19 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoFileMonitor.h,v 1.11 2003-02-27 19:21:19 okoenig Exp $ $Author: okoenig $
|
||||
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -51,11 +51,11 @@ public :
|
|||
{
|
||||
if (! _keep)
|
||||
{
|
||||
ofstream os(filename.c_str());
|
||||
std::ofstream os(filename.c_str());
|
||||
if (!os)
|
||||
{
|
||||
string str = "eoFileMonitor: Could not open " + filename;
|
||||
throw runtime_error(str);
|
||||
std::string str = "eoFileMonitor: Could not open " + filename;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ public :
|
|||
|
||||
void printHeader(void);
|
||||
virtual void printHeader(std::ostream& os);
|
||||
virtual string getFileName() // for eoGnuPlot
|
||||
virtual std::string getFileName() // for eoGnuPlot
|
||||
{ return filename;}
|
||||
private :
|
||||
std::string filename;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
Prints snapshots of fitnesses to a (new) file every N generations
|
||||
|
||||
Assumes that the parameters that are passed to the monitor
|
||||
(method add in eoMonitor.h) are eoValueParam<vector<double> > of same size.
|
||||
(method add in eoMonitor.h) are eoValueParam<std::vector<double> > of same size.
|
||||
|
||||
A dir is created and one file per snapshot is created there -
|
||||
so you can later generate a movie!
|
||||
|
|
@ -46,34 +46,34 @@ so you can later generate a movie!
|
|||
TODO: The counter is handled internally, but this should be changed
|
||||
so that you can pass e.g. an evalcounter (minor)
|
||||
|
||||
I failed to templatize everything so that it can handle eoParam<vector<T> >
|
||||
I failed to templatize everything so that it can handle eoParam<std::vector<T> >
|
||||
for any type T, simply calling their getValue method ...
|
||||
*/
|
||||
|
||||
class eoFileSnapshot : public eoMonitor
|
||||
{
|
||||
public :
|
||||
typedef vector<double> vDouble;
|
||||
typedef eoValueParam<vector<double> > vDoubleParam;
|
||||
typedef std::vector<double> vDouble;
|
||||
typedef eoValueParam<std::vector<double> > vDoubleParam;
|
||||
|
||||
eoFileSnapshot(std::string _dirname, unsigned _frequency = 1,
|
||||
std::string _filename = "gen", std::string _delim = " "):
|
||||
dirname(_dirname), frequency(_frequency),
|
||||
filename(_filename), delim(_delim), counter(0), boolChanged(true)
|
||||
{
|
||||
string s = "test -d " + dirname;
|
||||
std::string s = "test -d " + dirname;
|
||||
int res = system(s.c_str());
|
||||
// test for (unlikely) errors
|
||||
if ( (res==-1) || (res==127) )
|
||||
throw runtime_error("Problem executing test of dir in eoFileSnapshot");
|
||||
throw std::runtime_error("Problem executing test of dir in eoFileSnapshot");
|
||||
// now make sure there is a dir without any genXXX file in it
|
||||
if (res) // no dir present
|
||||
{
|
||||
s = string("mkdir ")+dirname;
|
||||
s = std::string("mkdir ")+dirname;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = string("/bin/rm ")+dirname+ "/" + filename + "*";
|
||||
s = std::string("/bin/rm ")+dirname+ "/" + filename + "*";
|
||||
}
|
||||
system(s.c_str());
|
||||
// all done
|
||||
|
|
@ -89,20 +89,20 @@ public :
|
|||
|
||||
/** accessor to the current filename: needed by the gnuplot subclass
|
||||
*/
|
||||
string getFileName() {return currentFileName;}
|
||||
std::string getFileName() {return currentFileName;}
|
||||
|
||||
/** sets the current filename depending on the counter
|
||||
*/
|
||||
void setCurrentFileName()
|
||||
{
|
||||
char buff[255];
|
||||
ostrstream oscount(buff, 254);
|
||||
std::ostrstream oscount(buff, 254);
|
||||
oscount << counter;
|
||||
oscount << std::ends;
|
||||
currentFileName = dirname + "/" + filename + oscount.str();
|
||||
}
|
||||
|
||||
/** The operator(void): opens the ostream and calls the write method
|
||||
/** The operator(void): opens the std::ostream and calls the write method
|
||||
*/
|
||||
eoMonitor& operator()(void)
|
||||
{
|
||||
|
|
@ -115,40 +115,40 @@ public :
|
|||
counter++;
|
||||
boolChanged = true;
|
||||
setCurrentFileName();
|
||||
ofstream os(currentFileName.c_str());
|
||||
std::ofstream os(currentFileName.c_str());
|
||||
|
||||
if (!os)
|
||||
{
|
||||
string str = "eoFileSnapshot: Could not open " + currentFileName;
|
||||
throw runtime_error(str);
|
||||
std::string str = "eoFileSnapshot: Could not open " + currentFileName;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
return operator()(os);
|
||||
}
|
||||
|
||||
/** The operator(): write on an ostream
|
||||
/** The operator(): write on an std::ostream
|
||||
*/
|
||||
eoMonitor& operator()(std::ostream& _os)
|
||||
{
|
||||
const eoValueParam<vector<double> > * ptParam =
|
||||
static_cast<const eoValueParam<vector<double> >* >(vec[0]);
|
||||
const eoValueParam<std::vector<double> > * ptParam =
|
||||
static_cast<const eoValueParam<std::vector<double> >* >(vec[0]);
|
||||
|
||||
const vector<double> v = ptParam->value();
|
||||
if (vec.size() == 1) // only one vector: -> add number in front
|
||||
const std::vector<double> v = ptParam->value();
|
||||
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" ;
|
||||
}
|
||||
else // need to get all other vectors
|
||||
else // need to get all other std::vectors
|
||||
{
|
||||
vector<vector<double> > vv(vec.size());
|
||||
std::vector<std::vector<double> > vv(vec.size());
|
||||
vv[0]=v;
|
||||
for (unsigned i=1; i<vec.size(); i++)
|
||||
{
|
||||
ptParam = static_cast<const eoValueParam<vector<double> >* >(vec[1]);
|
||||
ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
|
||||
vv[i] = ptParam->value();
|
||||
if (vv[i].size() != v.size())
|
||||
throw runtime_error("Dimension error in eoSnapshotMonitor");
|
||||
throw std::runtime_error("Dimension error in eoSnapshotMonitor");
|
||||
}
|
||||
for (unsigned k=0; k<v.size(); k++)
|
||||
{
|
||||
|
|
@ -160,17 +160,17 @@ public :
|
|||
return *this;
|
||||
}
|
||||
|
||||
virtual const string getDirName() // for eoGnuPlot
|
||||
virtual const std::string getDirName() // for eoGnuPlot
|
||||
{ return dirname;}
|
||||
virtual const string baseFileName() // the title for eoGnuPlot
|
||||
virtual const std::string baseFileName() // the title for eoGnuPlot
|
||||
{ return filename;}
|
||||
|
||||
/// add checks whether it is a vector of doubles
|
||||
/// add checks whether it is a std::vector of doubles
|
||||
void add(const eoParam& _param)
|
||||
{
|
||||
if (!dynamic_cast<const eoValueParam<vector<double> >*>(&_param))
|
||||
if (!dynamic_cast<const eoValueParam<std::vector<double> >*>(&_param))
|
||||
{
|
||||
throw logic_error(string("eoFileSnapshot: I can only monitor vectors of doubles, sorry. The offending parameter name = ") + _param.longName());
|
||||
throw std::logic_error(std::string("eoFileSnapshot: I can only monitor std::vectors of doubles, sorry. The offending parameter name = ") + _param.longName());
|
||||
}
|
||||
eoMonitor::add(_param);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class eoGnuplot
|
|||
{
|
||||
public:
|
||||
// Ctor
|
||||
eoGnuplot(std::string _title, std::string _extra = string("")) :
|
||||
eoGnuplot(std::string _title, std::string _extra = std::string("")) :
|
||||
firstTime(true)
|
||||
{
|
||||
// opens pipe with Gnuplot
|
||||
|
|
@ -65,7 +65,7 @@ class eoGnuplot
|
|||
}
|
||||
|
||||
/// Class name.
|
||||
virtual string className() const { return "eoGnuplot"; }
|
||||
virtual std::string className() const { return "eoGnuplot"; }
|
||||
|
||||
/** send a command to gnuplot directly
|
||||
*/
|
||||
|
|
@ -105,8 +105,8 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
|||
/////////////////////////////////////////////////////////
|
||||
{
|
||||
char snum[255];
|
||||
ostrstream os(snum, 254);
|
||||
os << "300x200-0+" << numWindow*220 << ends;
|
||||
std::ostrstream os(snum, 254);
|
||||
os << "300x200-0+" << numWindow*220 << std::ends;
|
||||
numWindow++;
|
||||
char *args[6];
|
||||
args[0] = strdup( "gnuplot" );
|
||||
|
|
@ -117,7 +117,7 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
|||
args[5] = 0;
|
||||
gpCom = PipeComOpenArgv( "gnuplot", args );
|
||||
if( ! gpCom )
|
||||
throw runtime_error("Impossible to spawn gnuplot\n");
|
||||
throw std::runtime_error("Impossible to spawn gnuplot\n");
|
||||
else {
|
||||
PipeComSend( gpCom, "set grid\n" );
|
||||
PipeComSend( gpCom, _extra.c_str() );
|
||||
|
|
@ -139,7 +139,7 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
|||
* Created......: Mon Mar 13 13:50:11 1995
|
||||
* Description..: Communication par pipe bidirectionnel avec un autre process
|
||||
*
|
||||
* Ident........: $Id: eoGnuplot.h,v 1.5 2002-08-23 15:40:59 evomarc Exp $
|
||||
* Ident........: $Id: eoGnuplot.h,v 1.6 2003-02-27 19:21:18 okoenig Exp $
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class eoGnuplot1DMonitor: public eoFileMonitor, public eoGnuplot
|
|||
virtual void FirstPlot();
|
||||
|
||||
/// Class name.
|
||||
virtual string className() const { return "eoGnuplot1DMonitor"; }
|
||||
virtual std::string className() const { return "eoGnuplot1DMonitor"; }
|
||||
|
||||
private:
|
||||
};
|
||||
|
|
@ -103,10 +103,10 @@ inline void eoGnuplot1DMonitor::FirstPlot()
|
|||
{
|
||||
if (vec.size() < 2)
|
||||
{
|
||||
throw runtime_error("Must have some stats to plot!\n");
|
||||
throw std::runtime_error("Must have some stats to plot!\n");
|
||||
}
|
||||
char buff[1024];
|
||||
ostrstream os(buff, 1024);
|
||||
std::ostrstream os(buff, 1024);
|
||||
os << "plot";
|
||||
for (unsigned i=1; i<vec.size(); i++) {
|
||||
os << " '" << getFileName().c_str() <<
|
||||
|
|
|
|||
|
|
@ -96,14 +96,14 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
|||
virtual eoMonitor& operator() (void) ;
|
||||
|
||||
/// Class name.
|
||||
virtual string className() const { return "eoGnuplot1DSnapshot"; }
|
||||
virtual std::string className() const { return "eoGnuplot1DSnapshot"; }
|
||||
|
||||
virtual void handleBounds(eoRealVectorBounds & _bounds)
|
||||
{
|
||||
// use strstream and not stringstream until strstream is in all distributions
|
||||
// use strstream and not std::stringstream until strstream is in all distributions
|
||||
char buf[1024];
|
||||
std::ostrstream os(buf, 1023);
|
||||
// ostrstream os;
|
||||
// std::ostrstream os;
|
||||
os << "set autoscale\nset yrange [" ;
|
||||
if (_bounds.isMinBounded(0))
|
||||
os << _bounds.minimum(0);
|
||||
|
|
@ -130,7 +130,7 @@ inline eoMonitor& eoGnuplot1DSnapshot::operator() (void)
|
|||
|
||||
// sends plot order to gnuplot
|
||||
char buff[1024];
|
||||
ostrstream os(buff, 1024);
|
||||
std::ostrstream os(buff, 1024);
|
||||
os << "set title 'Gen. " << getCounter() << "'; plot '"
|
||||
<< getFileName() << "' notitle with points ps " << pointSize << "\n";
|
||||
os << '\0';
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public:
|
|||
rate = 0.0; // just in case, but shoud be unused
|
||||
combien = int(_rate); // negative values are allowed here
|
||||
if (combien != _rate)
|
||||
cerr << "Warning: Number was rounded in eoHowMany";
|
||||
std::cerr << "Warning: Number was rounded in eoHowMany";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,13 +118,13 @@ public:
|
|||
if (combien < 0)
|
||||
{
|
||||
if (_size+combien<0)
|
||||
throw runtime_error("Negative result in eoHowMany");
|
||||
throw std::runtime_error("Negative result in eoHowMany");
|
||||
return _size+combien;
|
||||
}
|
||||
return unsigned(combien);
|
||||
}
|
||||
|
||||
virtual void printOn(ostream& _os) const
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
{
|
||||
if (combien == 0)
|
||||
_os << 100*rate << "% " << std::ends;
|
||||
|
|
@ -134,9 +134,9 @@ public:
|
|||
|
||||
}
|
||||
|
||||
virtual void readFrom(istream& _is)
|
||||
virtual void readFrom(std::istream& _is)
|
||||
{
|
||||
string value;
|
||||
std::string value;
|
||||
_is >> value;
|
||||
readFrom(value);
|
||||
return;
|
||||
|
|
@ -165,7 +165,7 @@ public:
|
|||
|
||||
// minimal check
|
||||
if ( rate < 0.0 )
|
||||
throw runtime_error("Negative rate read in eoHowMany::readFrom");
|
||||
throw std::runtime_error("Negative rate read in eoHowMany::readFrom");
|
||||
}
|
||||
|
||||
/** The unary - operator: reverses the computation */
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@
|
|||
The fitnesses of a whole population, as a vector
|
||||
*/
|
||||
template <class EOT, class FitT = typename EOT::Fitness>
|
||||
class eoFitnessStat : public eoSortedStat<EOT, vector<FitT> >
|
||||
class eoFitnessStat : public eoSortedStat<EOT, std::vector<FitT> >
|
||||
{
|
||||
public :
|
||||
eoFitnessStat(std::string _description = "AllFitnesses") :
|
||||
eoSortedStat<EOT, vector<FitT> >(vector<FitT>(0), _description) {}
|
||||
eoSortedStat<EOT,std::vector<FitT> >(std::vector<FitT>(0), _description) {}
|
||||
|
||||
virtual void operator()(const vector<const EOT*>& _popPters)
|
||||
virtual void operator()(const std::vector<const EOT*>& _popPters)
|
||||
{
|
||||
value().resize(_popPters.size());
|
||||
for (unsigned i=0; i<_popPters.size(); i++)
|
||||
|
|
@ -51,17 +51,25 @@ public :
|
|||
/** For multi-objective fitness, we need to translate a stat<vector<double> >
|
||||
into a vector<stat>, so each objective gets a seperate stat
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
// The follownig is needed to avoid some bug in Visual Studio 6.0
|
||||
typedef double PartFitDefault;
|
||||
template <class EOT, class PartFitT = PartFitDefault>
|
||||
class eoMOFitnessStat : public eoSortedStat<EOT, std::vector<PartFitT> >
|
||||
#else
|
||||
template <class EOT, class PartFitT = double>
|
||||
class eoMOFitnessStat : public eoSortedStat<EOT, vector<PartFitT> >
|
||||
class eoMOFitnessStat : public eoSortedStat<EOT, std::vector<PartFitT> >
|
||||
#endif
|
||||
|
||||
{
|
||||
public :
|
||||
/** Ctor: say what component you want
|
||||
*/
|
||||
eoMOFitnessStat(unsigned _objective, std::string _description = "MO-Fitness") :
|
||||
eoSortedStat<EOT, vector<PartFitT> >(vector<PartFitT>(0), _description),
|
||||
eoSortedStat<EOT, std::vector<PartFitT> >(std::vector<PartFitT>(0), _description),
|
||||
objective(_objective) {}
|
||||
|
||||
virtual void operator()(const vector<const EOT*>& _popPters)
|
||||
virtual void operator()(const std::vector<const EOT*>& _popPters)
|
||||
{
|
||||
value().resize(_popPters.size());
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
CVS Info: $Date: 2001-04-03 10:08:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoMonitor.h,v 1.9 2001-04-03 10:08:07 jmerelo Exp $ $Author: jmerelo $
|
||||
CVS Info: $Date: 2003-02-27 19:21:18 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoMonitor.h,v 1.10 2003-02-27 19:21:18 okoenig Exp $ $Author: okoenig $
|
||||
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -37,7 +37,7 @@ CVS Info: $Date: 2001-04-03 10:08:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs
|
|||
class eoParam;
|
||||
|
||||
/**
|
||||
The abstract monitor class is a vector of parameter pointers. Use
|
||||
The abstract monitor class is a std::vector of parameter pointers. Use
|
||||
either push_back a pointer or add a reference to a parameter.
|
||||
Derived classes will then implement the operator()(void) which
|
||||
will stream or pipe the current values of the parameters to wherever you
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public:
|
|||
void defValue ( std::string str ) { repDefault = str; };
|
||||
|
||||
/**
|
||||
* Returns the value of the param as a string
|
||||
* Returns the value of the param as a std::string
|
||||
*/
|
||||
/**
|
||||
* Returns if required or not.
|
||||
|
|
@ -123,8 +123,8 @@ private:
|
|||
any scalar value type. It makes use of std::strstream to get and set values. This
|
||||
should be changed to std::stringstream when that class is available in g++.
|
||||
|
||||
Note also that there is a template specialization for pair<double, double> and
|
||||
for vector<double>. These stream their contents delimited with whitespace.
|
||||
Note also that there is a template specialization for std::pair<double, double> and
|
||||
for std::vector<double>. These stream their contents delimited with whitespace.
|
||||
*/
|
||||
|
||||
template <class ValueType>
|
||||
|
|
@ -174,7 +174,7 @@ public :
|
|||
};
|
||||
|
||||
/*
|
||||
Specialization for string
|
||||
Specialization for std::string
|
||||
*/
|
||||
template <>
|
||||
std::string eoValueParam<std::string>::getValue(void) const
|
||||
|
|
@ -197,7 +197,7 @@ void eoValueParam<bool>::setValue(std::string _value)
|
|||
}
|
||||
|
||||
|
||||
/// Because MSVC does not support partial specialization, the pair is a double, not a T
|
||||
/// Because MSVC does not support partial specialization, the std::pair is a double, not a T
|
||||
template <>
|
||||
std::string eoValueParam<std::pair<double, double> >::getValue(void) const
|
||||
{
|
||||
|
|
@ -208,7 +208,7 @@ std::string eoValueParam<std::pair<double, double> >::getValue(void) const
|
|||
return os.str();
|
||||
}
|
||||
|
||||
/// Because MSVC does not support partial specialization, the pair is a double, not a T
|
||||
/// Because MSVC does not support partial specialization, the std::pair is a double, not a T
|
||||
template <>
|
||||
void eoValueParam<std::pair<double, double> >::setValue(std::string _value)
|
||||
{
|
||||
|
|
@ -217,9 +217,9 @@ void eoValueParam<std::pair<double, double> >::setValue(std::string _value)
|
|||
is >> repValue.second;
|
||||
}
|
||||
|
||||
// The vector<vector<double> >
|
||||
// The std::vector<std::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 std::vector is a std::vector of doubles, not a T
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<std::vector<double> > >::getValue(void) const
|
||||
{
|
||||
|
|
@ -235,7 +235,7 @@ std::string eoValueParam<std::vector<std::vector<double> > >::getValue(void) con
|
|||
return os.str();
|
||||
}
|
||||
|
||||
/// 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 std::vector is a std::vector of doubles, not a T
|
||||
template <>
|
||||
void eoValueParam<std::vector<std::vector<double> > >::setValue(std::string _value)
|
||||
{
|
||||
|
|
@ -256,9 +256,9 @@ void eoValueParam<std::vector<std::vector<double> > >::setValue(std::string _val
|
|||
}
|
||||
}
|
||||
|
||||
// The vector<double>
|
||||
// The std::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 std::vector is a double, not a T
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<double> >::getValue(void) const
|
||||
{
|
||||
|
|
@ -269,7 +269,7 @@ std::string eoValueParam<std::vector<double> >::getValue(void) const
|
|||
return os.str();
|
||||
}
|
||||
|
||||
/// Because MSVC does not support partial specialization, the vector is a double, not a T
|
||||
/// Because MSVC does not support partial specialization, the std::vector is a double, not a T
|
||||
template <>
|
||||
void eoValueParam<std::vector<double> >::setValue(std::string _value)
|
||||
{
|
||||
|
|
@ -280,9 +280,9 @@ void eoValueParam<std::vector<double> >::setValue(std::string _value)
|
|||
std::copy(std::istream_iterator<double>(is), std::istream_iterator<double>(), repValue.begin());
|
||||
}
|
||||
|
||||
// The vector<eoMinimizingFitness>
|
||||
// The std::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 std::vector is a eoMinimizingFitness, not a T
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<eoMinimizingFitness> >::getValue(void) const
|
||||
{
|
||||
|
|
@ -293,7 +293,7 @@ std::string eoValueParam<std::vector<eoMinimizingFitness> >::getValue(void) cons
|
|||
return os.str();
|
||||
}
|
||||
|
||||
/// Because MSVC does not support partial specialization, the vector is a eoMinimizingFitness, not a T
|
||||
/// Because MSVC does not support partial specialization, the std::vector is a eoMinimizingFitness, not a T
|
||||
// NOTE: g++ doesn support it either!!!
|
||||
template <>
|
||||
void eoValueParam<std::vector<eoMinimizingFitness> >::setValue(std::string _value)
|
||||
|
|
@ -305,19 +305,19 @@ void eoValueParam<std::vector<eoMinimizingFitness> >::setValue(std::string _valu
|
|||
std::copy(std::istream_iterator<eoMinimizingFitness>(is), std::istream_iterator<eoMinimizingFitness>(), repValue.begin());
|
||||
}
|
||||
|
||||
// The vector<const EOT*>
|
||||
// The std::vector<const EOT*>
|
||||
//////////////////////////////////
|
||||
template <>
|
||||
std::string eoValueParam<std::vector<void*> >::getValue(void) const
|
||||
{
|
||||
throw std::runtime_error("I cannot getValue for a vector<EOT*>");
|
||||
throw std::runtime_error("I cannot getValue for a std::vector<EOT*>");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
template <>
|
||||
void eoValueParam<std::vector<void*> >::setValue(std::string)
|
||||
{
|
||||
throw std::runtime_error("I cannot setValue for a vector<EOT*>");
|
||||
throw std::runtime_error("I cannot setValue for a std::vector<EOT*>");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -325,19 +325,19 @@ void eoValueParam<std::vector<void*> >::setValue(std::string)
|
|||
class eoContainerParam : public eoParam
|
||||
{
|
||||
public :
|
||||
eoContainerParam (ContainerType& value, string _shortName, string _longName,
|
||||
string _default,
|
||||
string _description,
|
||||
eoContainerParam (ContainerType& value, std::string _shortName, std::string _longName,
|
||||
std::string _default,
|
||||
std::string _description,
|
||||
bool _required,
|
||||
bool _change )
|
||||
: value(_value), eoParam(_shortName, _longName, _description, _default, _required, _change)
|
||||
{}
|
||||
|
||||
|
||||
// void setValue(const string & _value)
|
||||
// void setValue(const std::string & _value)
|
||||
// {
|
||||
// std::istringstream is(_value);
|
||||
// copy(istream_iterator<Container::value_type>(is), istream_iterator<Container::value_type>(), back_inserter(value));
|
||||
// std::istd::stringstream is(_value);
|
||||
// copy(std::istream_iterator<Container::value_type>(is), std::istream_iterator<Container::value_type>(), back_inserter(value));
|
||||
// }
|
||||
|
||||
private :
|
||||
|
|
@ -348,9 +348,9 @@ private :
|
|||
* Another helper class for parsing parameters like
|
||||
* Keyword(arg1, arg2, ...)
|
||||
*
|
||||
* It is basically a pair<string,vector<string> >
|
||||
* first string is keyword
|
||||
* the vector<string> contains all arguments (as strings)
|
||||
* It is basically a std::pair<std::string,std::vector<std::string> >
|
||||
* first std::string is keyword
|
||||
* the std::vector<std::string> contains all arguments (as std::strings)
|
||||
* See make_algo.h
|
||||
*/
|
||||
|
||||
|
|
@ -403,7 +403,7 @@ public:
|
|||
// so here we do have arguments
|
||||
std::string t = _value.substr(pos+1);// the arguments
|
||||
_value.resize(pos);
|
||||
first = _value; // done for the keyword (NOTE: may be empty string!)
|
||||
first = _value; // done for the keyword (NOTE: may be empty std::string!)
|
||||
|
||||
// now all arguments
|
||||
std::string delim(" (),");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
/**
|
||||
CVS Info: $Date: 2002-09-18 15:36:41 $ $Version$ $Author: evomarc $
|
||||
CVS Info: $Date: 2003-02-27 19:21:17 $ $Version$ $Author: okoenig $
|
||||
*/
|
||||
#ifndef eoParser_h
|
||||
#define eoParser_h
|
||||
|
|
@ -118,17 +118,17 @@ public:
|
|||
* @param _lFileParamName Name of the parameter specifying the configuration file (--param-file)
|
||||
* @param _shortHand Single charachter shorthand for specifying the configuration file
|
||||
*/
|
||||
eoParser ( unsigned _argc, char **_argv , string _programDescription = "",
|
||||
string _lFileParamName = "param-file", char _shortHand = 'p');
|
||||
eoParser ( unsigned _argc, char **_argv , std::string _programDescription = "",
|
||||
std::string _lFileParamName = "param-file", char _shortHand = 'p');
|
||||
|
||||
/**
|
||||
Processes the parameter and puts it in the appropriate section for readability
|
||||
*/
|
||||
void processParam(eoParam& param, std::string section = "");
|
||||
|
||||
void readFrom(istream& is);
|
||||
void readFrom(std::istream& is);
|
||||
|
||||
void printOn(ostream& os) const;
|
||||
void printOn(std::ostream& os) const;
|
||||
|
||||
/// className for readibility
|
||||
std::string className(void) const { return "Parser"; }
|
||||
|
|
@ -139,9 +139,9 @@ public:
|
|||
* Prints an automatic help in the specified output using the information
|
||||
* provided by parameters
|
||||
*/
|
||||
void printHelp(ostream& os);
|
||||
void printHelp(std::ostream& os);
|
||||
|
||||
string ProgramName() { return programName; }
|
||||
std::string ProgramName() { return programName; }
|
||||
|
||||
/**
|
||||
* checks if _param has been actually entered by the user
|
||||
|
|
@ -194,7 +194,7 @@ private:
|
|||
|
||||
void doRegisterParam(eoParam& param) const;
|
||||
|
||||
std::pair<bool, string> getValue(eoParam& _param) const;
|
||||
std::pair<bool, std::string> getValue(eoParam& _param) const;
|
||||
|
||||
void updateParameters() const;
|
||||
|
||||
|
|
@ -203,13 +203,13 @@ private:
|
|||
// used to store all parameters that are processed
|
||||
MultiMapType params;
|
||||
|
||||
string programName;
|
||||
string programDescription;
|
||||
std::string programName;
|
||||
std::string programDescription;
|
||||
|
||||
typedef map<char, string> ShortNameMapType;
|
||||
typedef std::map<char, std::string> ShortNameMapType;
|
||||
ShortNameMapType shortNameMap;
|
||||
|
||||
typedef map<string, string> LongNameMapType;
|
||||
typedef std::map<std::string, std::string> LongNameMapType;
|
||||
LongNameMapType longNameMap;
|
||||
|
||||
eoValueParam<bool> needHelp;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
eoPopString and eoSortedPopString
|
||||
|
||||
that transform the population into a string
|
||||
that transform the population into a std::string
|
||||
that can be used to dump to the screen
|
||||
*/
|
||||
|
||||
|
|
@ -38,9 +38,9 @@ that can be used to dump to the screen
|
|||
#include <utils/eoStat.h>
|
||||
|
||||
|
||||
/** Thanks to MS/VC++, eoParam mechanism is unable to handle vectors of stats.
|
||||
/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats.
|
||||
This snippet is a workaround:
|
||||
This class will "print" a whole population into a string - that you can later
|
||||
This class will "print" a whole population into a std::string - that you can later
|
||||
send to any stream
|
||||
This is the plain version - see eoPopString for the Sorted version
|
||||
|
||||
|
|
@ -48,15 +48,15 @@ Note: this Stat should probably be used only within eoStdOutMonitor, and not
|
|||
inside an eoFileMonitor, as the eoState construct will work much better there.
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoPopStat : public eoStat<EOT, string>
|
||||
class eoPopStat : public eoStat<EOT, std::string>
|
||||
{
|
||||
public :
|
||||
/** default Ctor, void string by default, as it appears
|
||||
/** default Ctor, void std::string by default, as it appears
|
||||
on the description line once at beginning of evolution. and
|
||||
is meaningless there. _howMany defaults to 0, that is, the whole
|
||||
population*/
|
||||
eoPopStat(unsigned _howMany = 0, string _desc ="")
|
||||
: eoStat<EOT, string>("", _desc), combien( _howMany) {}
|
||||
eoPopStat(unsigned _howMany = 0, std::string _desc ="")
|
||||
: eoStat<EOT, std::string>("", _desc), combien( _howMany) {}
|
||||
|
||||
/** 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
|
||||
|
|
@ -70,7 +70,7 @@ void operator()(const eoPop<EOT>& _pop)
|
|||
for (unsigned i = 0; i < howMany; ++i)
|
||||
{
|
||||
std::ostrstream os(buffer, 1022); // leave space for emergency terminate
|
||||
os << _pop[i] << endl << ends;
|
||||
os << _pop[i] << std::endl << std::ends;
|
||||
|
||||
// paranoid:
|
||||
buffer[1022] = '\0';
|
||||
|
|
@ -81,9 +81,9 @@ private:
|
|||
unsigned combien;
|
||||
};
|
||||
|
||||
/** Thanks to MS/VC++, eoParam mechanism is unable to handle vectors of stats.
|
||||
/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats.
|
||||
This snippet is a workaround:
|
||||
This class will "print" a whole population into a string - that you can later
|
||||
This class will "print" a whole population into a std::string - that you can later
|
||||
send to any stream
|
||||
This is the Sorted version - see eoPopString for the plain version
|
||||
|
||||
|
|
@ -91,22 +91,22 @@ Note: this Stat should probably be used only within eoStdOutMonitor, and not
|
|||
inside an eoFileMonitor, as the eoState construct will work much better there.
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoSortedPopStat : public eoSortedStat<EOT, string>
|
||||
class eoSortedPopStat : public eoSortedStat<EOT, std::string>
|
||||
{
|
||||
public :
|
||||
/** default Ctor, void string by default, as it appears
|
||||
/** default Ctor, void std::string by default, as it appears
|
||||
* on the description line once at beginning of evolution. and
|
||||
* is meaningless there _howMany defaults to 0, that is, the whole
|
||||
* population
|
||||
*/
|
||||
eoSortedPopStat(unsigned _howMany = 0, string _desc ="") :
|
||||
eoSortedStat<EOT, string>("", _desc) , combien( _howMany) {}
|
||||
eoSortedPopStat(unsigned _howMany = 0, std::string _desc ="") :
|
||||
eoSortedStat<EOT, std::string>("", _desc) , combien( _howMany) {}
|
||||
|
||||
/** 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
|
||||
that are written by the monitor it is probably used from.
|
||||
*/
|
||||
void operator()(const vector<const EOT*>& _pop)
|
||||
void operator()(const std::vector<const EOT*>& _pop)
|
||||
{
|
||||
char buffer[1023]; // about one K of space per member
|
||||
value() = ""; // empty
|
||||
|
|
@ -114,7 +114,7 @@ public :
|
|||
for (unsigned i = 0; i < howMany; ++i)
|
||||
{
|
||||
std::ostrstream os(buffer, 1022); // leave space for emergency terminate
|
||||
os << *_pop[i] << endl << ends;
|
||||
os << *_pop[i] << std::endl << std::ends;
|
||||
|
||||
// paranoid:
|
||||
buffer[1022] = '\0';
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
// (and paraphrasing a bit in places), the Mersenne Twister is ``designed
|
||||
// with consideration of the flaws of various existing generators,'' has
|
||||
// a period of 2^19937 - 1, gives a sequence that is 623-dimensionally
|
||||
// equidistributed, and ``has passed many stringent tests, including the
|
||||
// equidistributed, and ``has passed many std::stringent tests, including the
|
||||
// die-hard test of G. Marsaglia and the load test of P. Hellekalek and
|
||||
// S. Wegenkittl.'' It is efficient in memory usage (typically using 2506
|
||||
// to 5012 bytes of static data, depending on data type sizes, and the code
|
||||
|
|
@ -212,7 +212,7 @@ public :
|
|||
|
||||
/**
|
||||
roulette_wheel(vec, total = 0) does a roulette wheel selection
|
||||
on the input vector vec. If the total is not supplied, it is
|
||||
on the input std::vector vec. If the total is not supplied, it is
|
||||
calculated. It returns an integer denoting the selected argument.
|
||||
*/
|
||||
template <class T>
|
||||
|
|
@ -237,7 +237,7 @@ public :
|
|||
}
|
||||
|
||||
///
|
||||
void printOn(ostream& _os) const
|
||||
void printOn(std::ostream& _os) const
|
||||
{
|
||||
for (int i = 0; i < N; ++i)
|
||||
{
|
||||
|
|
@ -248,7 +248,7 @@ public :
|
|||
}
|
||||
|
||||
///
|
||||
void readFrom(istream& _is)
|
||||
void readFrom(std::istream& _is)
|
||||
{
|
||||
for (int i = 0; i < N; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ eoRealVectorNoBounds eoDummyVectorNoBounds(0);
|
|||
///////////// helper read functions - could be somewhere else
|
||||
|
||||
// removes leading delimiters - return false if nothing else left
|
||||
bool remove_leading(std::string & _s, const string _delim)
|
||||
bool remove_leading(std::string & _s, const std::string _delim)
|
||||
{
|
||||
size_t posDebToken = _s.find_first_not_of(_delim);
|
||||
if (posDebToken >= _s.size())
|
||||
|
|
@ -27,7 +27,7 @@ bool remove_leading(std::string & _s, const string _delim)
|
|||
|
||||
double read_double(std::string _s)
|
||||
{
|
||||
istrstream is(_s.c_str());
|
||||
std::istrstream is(_s.c_str());
|
||||
double r;
|
||||
is >> r;
|
||||
return r;
|
||||
|
|
@ -35,7 +35,7 @@ double read_double(std::string _s)
|
|||
|
||||
int read_int(std::string _s)
|
||||
{
|
||||
istrstream is(_s.c_str());
|
||||
std::istrstream is(_s.c_str());
|
||||
int i;
|
||||
is >> i;
|
||||
return i;
|
||||
|
|
@ -56,9 +56,9 @@ eoRealVectorBounds::eoRealVectorBounds(const eoRealVectorBounds & _b):
|
|||
|
||||
// the readFrom method of eoRealVectorNoBounds:
|
||||
// only calls the readFrom(string) - for param reading
|
||||
void eoRealVectorBounds::readFrom(istream& _is)
|
||||
void eoRealVectorBounds::readFrom(std::istream& _is)
|
||||
{
|
||||
string value;
|
||||
std::string value;
|
||||
_is >> value;
|
||||
readFrom(value);
|
||||
return;
|
||||
|
|
@ -79,7 +79,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
|
|||
resize(0);
|
||||
|
||||
// now read
|
||||
string delim(",; ");
|
||||
std::string delim(",; ");
|
||||
while (_value.size()>0)
|
||||
{
|
||||
if (!remove_leading(_value, delim)) // only delimiters were left
|
||||
|
|
@ -91,38 +91,38 @@ void eoRealVectorBounds::readFrom(std::string _value)
|
|||
break;
|
||||
}
|
||||
// ending char
|
||||
string closeChar = (_value[posDeb] == '(' ? string(")") : string("]") );
|
||||
std::string closeChar = (_value[posDeb] == '(' ? std::string(")") : std::string("]") );
|
||||
|
||||
size_t posFin = _value.find_first_of(string(closeChar));
|
||||
size_t posFin = _value.find_first_of(std::string(closeChar));
|
||||
if (posFin >= _value.size())
|
||||
throw runtime_error("Syntax error when reading bounds");
|
||||
throw std::runtime_error("Syntax error when reading bounds");
|
||||
|
||||
// y a-t-il un nbre devant
|
||||
unsigned count = 1;
|
||||
if (posDeb > 0) // something before opening
|
||||
{
|
||||
string sCount = _value.substr(0, posDeb);
|
||||
std::string sCount = _value.substr(0, posDeb);
|
||||
count = read_int(sCount);
|
||||
if (count <= 0)
|
||||
throw runtime_error("Syntax error when reading bounds");
|
||||
throw std::runtime_error("Syntax error when reading bounds");
|
||||
}
|
||||
|
||||
// the bounds
|
||||
string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
|
||||
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
|
||||
// and remove from original string
|
||||
_value = _value.substr(posFin+1);
|
||||
|
||||
remove_leading(sBounds, delim);
|
||||
size_t posDelim = sBounds.find_first_of(delim);
|
||||
if (posDelim >= sBounds.size())
|
||||
throw runtime_error("Syntax error when reading bounds");
|
||||
throw std::runtime_error("Syntax error when reading bounds");
|
||||
|
||||
bool minBounded=false, maxBounded=false;
|
||||
double minBound=0, maxBound=0;
|
||||
|
||||
// min bound
|
||||
string sMinBounds = sBounds.substr(0,posDelim);
|
||||
if (sMinBounds != string("-inf"))
|
||||
std::string sMinBounds = sBounds.substr(0,posDelim);
|
||||
if (sMinBounds != std::string("-inf"))
|
||||
{
|
||||
minBounded = true;
|
||||
minBound = read_double(sMinBounds);
|
||||
|
|
@ -131,8 +131,8 @@ void eoRealVectorBounds::readFrom(std::string _value)
|
|||
// max bound
|
||||
size_t posEndDelim = sBounds.find_first_not_of(delim,posDelim);
|
||||
|
||||
string sMaxBounds = sBounds.substr(posEndDelim);
|
||||
if (sMaxBounds != string("+inf"))
|
||||
std::string sMaxBounds = sBounds.substr(posEndDelim);
|
||||
if (sMaxBounds != std::string("+inf"))
|
||||
{
|
||||
maxBounded = true;
|
||||
maxBound = read_double(sMaxBounds);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef _eoRealBounds_h
|
||||
#define _eoRealBounds_h
|
||||
|
||||
#include <stdexcept> // exceptions!
|
||||
#include <stdexcept> // std::exceptions!
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
|
|
@ -56,8 +56,8 @@ it exceeds it
|
|||
|
||||
So mutation can choose
|
||||
- iterate trying until they fall in bounds,
|
||||
- only try once and "repair" by using the foldsInBounds method
|
||||
- only try once and repair using the truncate method (will create a
|
||||
- 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
|
||||
|
|
@ -107,20 +107,20 @@ public:
|
|||
virtual void truncate(double &) = 0;
|
||||
|
||||
/** get minimum value
|
||||
* @exception if does not exist
|
||||
* @std::exception if does not exist
|
||||
*/
|
||||
virtual double minimum() = 0;
|
||||
/** get maximum value
|
||||
* @exception if does not exist
|
||||
* @std::exception if does not exist
|
||||
*/
|
||||
virtual double maximum() = 0;
|
||||
/** get range
|
||||
* @exception if unbounded
|
||||
* @std::exception if unbounded
|
||||
*/
|
||||
virtual double range() = 0;
|
||||
|
||||
/** random generator of uniform numbers in bounds
|
||||
* @exception if unbounded
|
||||
* @std::exception if unbounded
|
||||
*/
|
||||
virtual double uniform(eoRng & _rng = eo::rng) = 0;
|
||||
|
||||
|
|
@ -145,39 +145,39 @@ public:
|
|||
|
||||
virtual double minimum()
|
||||
{
|
||||
throw logic_error("Trying to get minimum of unbounded eoRealBounds");
|
||||
throw std::logic_error("Trying to get minimum of unbounded eoRealBounds");
|
||||
}
|
||||
virtual double maximum()
|
||||
{
|
||||
throw logic_error("Trying to get maximum of unbounded eoRealBounds");
|
||||
throw std::logic_error("Trying to get maximum of unbounded eoRealBounds");
|
||||
}
|
||||
virtual double range()
|
||||
{
|
||||
throw logic_error("Trying to get range of unbounded eoRealBounds");
|
||||
throw std::logic_error("Trying to get range of unbounded eoRealBounds");
|
||||
}
|
||||
|
||||
virtual double uniform(eoRng & _rng = eo::rng)
|
||||
{
|
||||
throw logic_error("Trying to generate uniform values in unbounded eoRealBounds");
|
||||
throw std::logic_error("Trying to generate uniform values in unbounded eoRealBounds");
|
||||
}
|
||||
|
||||
// methods from eoPersistent
|
||||
/**
|
||||
* Read object.
|
||||
* @param _is A istream.
|
||||
* @param _is A std::istream.
|
||||
* but reading should not be done here, because of bound problems
|
||||
* see eoRealVectorBounds
|
||||
*/
|
||||
virtual void readFrom(istream& _is)
|
||||
virtual void readFrom(std::istream& _is)
|
||||
{
|
||||
throw runtime_error("Should not use eoRealBounds::readFrom");
|
||||
throw std::runtime_error("Should not use eoRealBounds::readFrom");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object on a stream.
|
||||
* @param _os A ostream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
{
|
||||
_os << "[-inf,+inf]";
|
||||
}
|
||||
|
|
@ -279,20 +279,20 @@ public :
|
|||
// methods from eoPersistent
|
||||
/**
|
||||
* Read object.
|
||||
* @param _is A istream.
|
||||
* @param _is A std::istream.
|
||||
* but reading should not be done here, because of bound problems
|
||||
* see eoRealVectorBounds
|
||||
*/
|
||||
virtual void readFrom(istream& _is)
|
||||
virtual void readFrom(std::istream& _is)
|
||||
{
|
||||
throw runtime_error("Should not use eoRealInterval::readFrom");
|
||||
throw std::runtime_error("Should not use eoRealInterval::readFrom");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object on a stream.
|
||||
* @param _os A ostream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
{
|
||||
_os << "[" << repMinimum << "," << repMaximum << "]";
|
||||
}
|
||||
|
|
@ -328,17 +328,17 @@ public :
|
|||
|
||||
virtual double maximum()
|
||||
{
|
||||
throw logic_error("Trying to get maximum of eoRealBelowBound");
|
||||
throw std::logic_error("Trying to get maximum of eoRealBelowBound");
|
||||
}
|
||||
virtual double range()
|
||||
{
|
||||
throw logic_error("Trying to get range of eoRealBelowBound");
|
||||
throw std::logic_error("Trying to get range of eoRealBelowBound");
|
||||
}
|
||||
|
||||
// random generators
|
||||
virtual double uniform(eoRng & _rng = eo::rng)
|
||||
{
|
||||
throw logic_error("Trying to generate uniform values in eoRealBelowBound");
|
||||
throw std::logic_error("Trying to generate uniform values in eoRealBelowBound");
|
||||
}
|
||||
|
||||
// description
|
||||
|
|
@ -375,20 +375,20 @@ public :
|
|||
// methods from eoPersistent
|
||||
/**
|
||||
* Read object.
|
||||
* @param _is A istream.
|
||||
* @param _is A std::istream.
|
||||
* but reading should not be done here, because of bound problems
|
||||
* see eoRealVectorBounds
|
||||
*/
|
||||
virtual void readFrom(istream& _is)
|
||||
virtual void readFrom(std::istream& _is)
|
||||
{
|
||||
throw runtime_error("Should not use eoRealBelowBound::readFrom");
|
||||
throw std::runtime_error("Should not use eoRealBelowBound::readFrom");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object on a stream.
|
||||
* @param _os A ostream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
{
|
||||
_os << "[" << repMinimum << ",+inf]";
|
||||
}
|
||||
|
|
@ -423,17 +423,17 @@ public :
|
|||
|
||||
virtual double minimum()
|
||||
{
|
||||
throw logic_error("Trying to get minimum of eoRealAboveBound");
|
||||
throw std::logic_error("Trying to get minimum of eoRealAboveBound");
|
||||
}
|
||||
virtual double range()
|
||||
{
|
||||
throw logic_error("Trying to get range of eoRealAboveBound");
|
||||
throw std::logic_error("Trying to get range of eoRealAboveBound");
|
||||
}
|
||||
|
||||
// random generators
|
||||
virtual double uniform(eoRng & _rng = eo::rng)
|
||||
{
|
||||
throw logic_error("Trying to generate uniform values in eoRealAboveBound");
|
||||
throw std::logic_error("Trying to generate uniform values in eoRealAboveBound");
|
||||
}
|
||||
|
||||
// description
|
||||
|
|
@ -470,20 +470,20 @@ public :
|
|||
// methods from eoPersistent
|
||||
/**
|
||||
* Read object.
|
||||
* @param _is A istream.
|
||||
* @param _is A std::istream.
|
||||
* but reading should not be done here, because of bound problems
|
||||
* see eoRealVectorBounds
|
||||
*/
|
||||
virtual void readFrom(istream& _is)
|
||||
virtual void readFrom(std::istream& _is)
|
||||
{
|
||||
throw runtime_error("Should not use eoRealAboveBound::readFrom");
|
||||
throw std::runtime_error("Should not use eoRealAboveBound::readFrom");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object on a stream.
|
||||
* @param _os A ostream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
{
|
||||
_os << "[-inf," << repMaximum << "]";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef _eoRealVectorBounds_h
|
||||
#define _eoRealVectorBounds_h
|
||||
|
||||
#include <stdexcept> // exceptions!
|
||||
#include <stdexcept> // std::exceptions!
|
||||
#include <utils/eoRNG.h>
|
||||
#include <utils/eoRealBounds.h>
|
||||
|
||||
|
|
@ -40,9 +40,9 @@
|
|||
/**
|
||||
Vector type for bounds (see eoRealBounds.h for scalar types)
|
||||
------------
|
||||
Class eoRealVectorBounds implements the vectorized version:
|
||||
it is basically a vector of eoRealBounds * and forwards all request
|
||||
to the elements of the vector.
|
||||
Class eoRealVectorBounds implements the std::vectorized version:
|
||||
it is basically a std::vector of eoRealBounds * and forwards all request
|
||||
to the elements of the std::vector.
|
||||
|
||||
This file also contains the global variables and eoDummyVectorNoBounds
|
||||
that are used as defaults in ctors (i.e. when no
|
||||
|
|
@ -55,7 +55,7 @@ eoRealVectorBounds which derives from the preceding *and* eoPersistent
|
|||
and also has a mechanism for memory handling of the pointers
|
||||
it has to allocate
|
||||
*/
|
||||
class eoRealBaseVectorBounds : public vector<eoRealBounds *>
|
||||
class eoRealBaseVectorBounds : public std::vector<eoRealBounds *>
|
||||
{
|
||||
public:
|
||||
// virtual desctructor (to avoid warning?)
|
||||
|
|
@ -63,18 +63,18 @@ public:
|
|||
|
||||
/** Default Ctor.
|
||||
*/
|
||||
eoRealBaseVectorBounds() : vector<eoRealBounds *>(0) {}
|
||||
eoRealBaseVectorBounds() : std::vector<eoRealBounds *>(0) {}
|
||||
|
||||
/** Ctor: same bounds for everybody, given as an eoRealBounds
|
||||
*/
|
||||
eoRealBaseVectorBounds(unsigned _dim, eoRealBounds & _bounds) :
|
||||
vector<eoRealBounds *>(_dim, &_bounds)
|
||||
std::vector<eoRealBounds *>(_dim, &_bounds)
|
||||
{}
|
||||
|
||||
/** Ctor, particular case of dim-2
|
||||
*/
|
||||
eoRealBaseVectorBounds(eoRealBounds & _xbounds, eoRealBounds & _ybounds) :
|
||||
vector<eoRealBounds *>(0)
|
||||
std::vector<eoRealBounds *>(0)
|
||||
{
|
||||
push_back( &_xbounds);
|
||||
push_back( &_ybounds);
|
||||
|
|
@ -127,9 +127,9 @@ public:
|
|||
(*this)[_i]->foldsInBounds(_r);
|
||||
}
|
||||
|
||||
/** Folds all variables of a vector of real values into the bounds
|
||||
/** Folds all variables of a std::vector of real values into the bounds
|
||||
*/
|
||||
virtual void foldsInBounds(vector<double> & _v)
|
||||
virtual void foldsInBounds(std::vector<double> & _v)
|
||||
{
|
||||
for (unsigned i=0; i<size(); i++)
|
||||
{
|
||||
|
|
@ -144,9 +144,9 @@ public:
|
|||
(*this)[_i]->truncate(_r);
|
||||
}
|
||||
|
||||
/** truncates all variables of a vector of real values to the bounds
|
||||
/** truncates all variables of a std::vector of real values to the bounds
|
||||
*/
|
||||
virtual void truncate(vector<double> & _v)
|
||||
virtual void truncate(std::vector<double> & _v)
|
||||
{
|
||||
for (unsigned i=0; i<size(); i++)
|
||||
{
|
||||
|
|
@ -161,7 +161,7 @@ public:
|
|||
|
||||
/** test: are ALL components within the bounds?
|
||||
*/
|
||||
virtual bool isInBounds(vector<double> _v)
|
||||
virtual bool isInBounds(std::vector<double> _v)
|
||||
{
|
||||
for (unsigned i=0; i<size(); i++)
|
||||
if (! isInBounds(i, _v[i]))
|
||||
|
|
@ -169,14 +169,14 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
/** Accessors: will raise an exception if these do not exist
|
||||
/** Accessors: will raise an std::exception if these do not exist
|
||||
*/
|
||||
virtual double minimum(unsigned _i) {return (*this)[_i]->minimum();}
|
||||
virtual double maximum(unsigned _i) {return (*this)[_i]->maximum();}
|
||||
virtual double range(unsigned _i) {return (*this)[_i]->range();}
|
||||
|
||||
/** Computes the average range
|
||||
* An exception will be raised if one of the component is unbounded
|
||||
* An std::exception will be raised if one of the component is unbounded
|
||||
*/
|
||||
virtual double averageRange()
|
||||
{
|
||||
|
|
@ -187,7 +187,7 @@ public:
|
|||
}
|
||||
|
||||
/** Generates a random number in i_th range
|
||||
* An exception will be raised if one of the component is unbounded
|
||||
* An std::exception will be raised if one of the component is unbounded
|
||||
*/
|
||||
virtual double uniform(unsigned _i, eoRng & _rng = eo::rng)
|
||||
{
|
||||
|
|
@ -195,10 +195,10 @@ public:
|
|||
return r;
|
||||
}
|
||||
|
||||
/** fills a vector with uniformly chosen variables in bounds
|
||||
* An exception will be raised if one of the component is unbounded
|
||||
/** fills a std::vector with uniformly chosen variables in bounds
|
||||
* An std::exception will be raised if one of the component is unbounded
|
||||
*/
|
||||
void uniform(vector<double> & _v, eoRng & _rng = eo::rng)
|
||||
void uniform(std::vector<double> & _v, eoRng & _rng = eo::rng)
|
||||
{
|
||||
_v.resize(size());
|
||||
for (unsigned i=0; i<size(); i++)
|
||||
|
|
@ -209,9 +209,9 @@ public:
|
|||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object on a stream.
|
||||
* @param _os A ostream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
{
|
||||
for (unsigned i=0; i<size(); i++)
|
||||
{
|
||||
|
|
@ -259,9 +259,9 @@ public:
|
|||
push_back(ptBounds);
|
||||
}
|
||||
|
||||
/** Ctor: different bounds for different variables, vectors of double
|
||||
/** Ctor: different bounds for different variables, std::vectors of double
|
||||
*/
|
||||
eoRealVectorBounds(vector<double> _min, vector<double> _max) :
|
||||
eoRealVectorBounds(std::vector<double> _min, std::vector<double> _max) :
|
||||
factor(_min.size(), 1), ownedBounds(0)
|
||||
{
|
||||
if (_max.size() != _min.size())
|
||||
|
|
@ -276,10 +276,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/** Ctor from a string
|
||||
* and don't worry, the readFrom(string) starts by setting everything to 0!
|
||||
/** Ctor from a std::string
|
||||
* and don't worry, the readFrom(std::string) starts by setting everything to 0!
|
||||
*/
|
||||
eoRealVectorBounds(string _s) : eoRealBaseVectorBounds()
|
||||
eoRealVectorBounds(std::string _s) : eoRealBaseVectorBounds()
|
||||
{
|
||||
readFrom(_s);
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ public:
|
|||
/** Dtor: destroy all ownedBounds - BUG ???*/
|
||||
virtual ~eoRealVectorBounds()
|
||||
{
|
||||
// cout << "Dtor, avec size = " << ownedBounds.size() << endl;
|
||||
// std::cout << "Dtor, avec size = " << ownedBounds.size() << std::endl;
|
||||
// for (unsigned i = 0; i < ownedBounds.size(); ++i)
|
||||
// {
|
||||
// delete ownedBounds[i];
|
||||
|
|
@ -298,19 +298,19 @@ public:
|
|||
// methods from eoPersistent
|
||||
/**
|
||||
* Read object from a stream
|
||||
* only calls the readFrom(string) - for param reading
|
||||
* @param _is A istream.
|
||||
* only calls the readFrom(std::string) - for param reading
|
||||
* @param _is A std::istream.
|
||||
*/
|
||||
virtual void readFrom(istream& _is) ;
|
||||
virtual void readFrom(std::istream& _is) ;
|
||||
|
||||
/**
|
||||
* Read object from a string
|
||||
* @param _is A istream.
|
||||
* Read object from a std::string
|
||||
* @param _is A std::istream.
|
||||
*/
|
||||
virtual void readFrom(string _s) ;
|
||||
virtual void readFrom(std::string _s) ;
|
||||
|
||||
/** overload printOn method to save space */
|
||||
virtual void printOn(ostream& _os) const
|
||||
virtual void printOn(std::ostream& _os) const
|
||||
{
|
||||
if (factor[0]>1)
|
||||
_os << factor[0] ;
|
||||
|
|
@ -336,10 +336,10 @@ public:
|
|||
* because of ownedBounds */
|
||||
eoRealVectorBounds(const eoRealVectorBounds &);
|
||||
|
||||
private:// WARNING: there is no reason for both vector below
|
||||
private:// WARNING: there is no reason for both std::vector below
|
||||
//to be synchronized in any manner
|
||||
vector<unsigned int> factor; // list of nb of "grouped" bounds
|
||||
vector<eoRealBounds *> ownedBounds;
|
||||
std::vector<unsigned int> factor; // std::list of nb of "grouped" bounds
|
||||
std::vector<eoRealBounds *> ownedBounds;
|
||||
// keep this one private
|
||||
eoRealVectorBounds& operator=(const eoRealVectorBounds&);
|
||||
};
|
||||
|
|
@ -347,7 +347,7 @@ private:// WARNING: there is no reason for both vector below
|
|||
//////////////////////////////////////////////////////////////
|
||||
/** the dummy unbounded eoRealVectorBounds: usefull if you don't need bounds!
|
||||
* everything is inlined.
|
||||
* Warning: we do need this class, and not only a vector<eoRealNoBounds *>
|
||||
* Warning: we do need this class, and not only a std::vector<eoRealNoBounds *>
|
||||
*/
|
||||
class eoRealVectorNoBounds: public eoRealVectorBounds
|
||||
{
|
||||
|
|
@ -373,43 +373,43 @@ public:
|
|||
virtual bool isMaxBounded(unsigned) {return false;}
|
||||
|
||||
virtual void foldsInBounds(unsigned, double &) {return;}
|
||||
virtual void foldsInBounds(vector<double> &) {return;}
|
||||
virtual void foldsInBounds(std::vector<double> &) {return;}
|
||||
|
||||
virtual void truncate(unsigned, double &) {return;}
|
||||
virtual void truncate(vector<double> &) {return;}
|
||||
virtual void truncate(std::vector<double> &) {return;}
|
||||
|
||||
virtual bool isInBounds(unsigned, double) {return true;}
|
||||
virtual bool isInBounds(vector<double>) {return true;}
|
||||
virtual bool isInBounds(std::vector<double>) {return true;}
|
||||
|
||||
// accessors
|
||||
virtual double minimum(unsigned)
|
||||
{
|
||||
throw logic_error("Trying to get minimum of eoRealVectorNoBounds");
|
||||
throw std::logic_error("Trying to get minimum of eoRealVectorNoBounds");
|
||||
}
|
||||
virtual double maximum(unsigned)
|
||||
{
|
||||
throw logic_error("Trying to get maximum of eoRealVectorNoBounds");
|
||||
throw std::logic_error("Trying to get maximum of eoRealVectorNoBounds");
|
||||
}
|
||||
virtual double range(unsigned)
|
||||
{
|
||||
throw logic_error("Trying to get range of eoRealVectorNoBounds");
|
||||
throw std::logic_error("Trying to get range of eoRealVectorNoBounds");
|
||||
}
|
||||
|
||||
virtual double averageRange()
|
||||
{
|
||||
throw logic_error("Trying to get average range of eoRealVectorNoBounds");
|
||||
throw std::logic_error("Trying to get average range of eoRealVectorNoBounds");
|
||||
}
|
||||
|
||||
// random generators
|
||||
virtual double uniform(unsigned, eoRng & _rng = eo::rng)
|
||||
{
|
||||
throw logic_error("No uniform distribution on eoRealVectorNoBounds");
|
||||
throw std::logic_error("No uniform distribution on eoRealVectorNoBounds");
|
||||
}
|
||||
|
||||
// fills a vector with uniformly chosen variables in bounds
|
||||
void uniform(vector<double> &, eoRng & _rng = eo::rng)
|
||||
// fills a std::vector with uniformly chosen variables in bounds
|
||||
void uniform(std::vector<double> &, eoRng & _rng = eo::rng)
|
||||
{
|
||||
throw logic_error("No uniform distribution on eoRealVectorNoBounds");
|
||||
throw std::logic_error("No uniform distribution on eoRealVectorNoBounds");
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ template <class T = double> class eoUniformGenerator : public eoRndGenerator<T>
|
|||
minim(_min), range(_max-_min), uniform(_rng)
|
||||
{
|
||||
if (_min>_max)
|
||||
throw logic_error("Min is greater than Max in uniform_generator");
|
||||
throw std::logic_error("Min is greater than Max in uniform_generator");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,19 +31,19 @@
|
|||
#include <utils/eoStat.h>
|
||||
|
||||
/**
|
||||
The fitnesses of a whole population, as a vector
|
||||
The fitnesses of a whole population, as a std::vector
|
||||
*/
|
||||
template <class EOT, class FitT = typename EOT::Fitness>
|
||||
class eoScalarFitnessStat : public eoSortedStat<EOT, vector<double> >
|
||||
class eoScalarFitnessStat : public eoSortedStat<EOT, std::vector<double> >
|
||||
{
|
||||
public :
|
||||
eoScalarFitnessStat(std::string _description = "FitnessES",
|
||||
eoRealVectorBounds & _bounds = eoDummyVectorNoBounds) :
|
||||
eoSortedStat<EOT, vector<double> >(vector<double>(0), _description) ,
|
||||
eoSortedStat<EOT, std::vector<double> >(std::vector<double>(0), _description) ,
|
||||
range(*_bounds[0])
|
||||
{}
|
||||
|
||||
virtual void operator()(const vector<const EOT*>& _popPters)
|
||||
virtual void operator()(const std::vector<const EOT*>& _popPters)
|
||||
{
|
||||
value().resize(_popPters.size());
|
||||
for (unsigned i=0; i<_popPters.size(); i++)
|
||||
|
|
|
|||
|
|
@ -27,17 +27,18 @@
|
|||
#ifndef _eoStat_h
|
||||
#define _eoStat_h
|
||||
|
||||
#include <numeric> // accumulate
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <utils/eoParam.h>
|
||||
#include <eoPop.h>
|
||||
#include <numeric> // accumulate
|
||||
#include <eoParetoFitness.h>
|
||||
|
||||
/**
|
||||
Base class for all statistics that need to be calculated
|
||||
over the (unsorted) population
|
||||
(I guess it is not really necessary? MS.
|
||||
Depends, there might be reasons to have a stat that is not an eoValueParam,
|
||||
Depstd::ends, there might be reasons to have a stat that is not an eoValueParam,
|
||||
but maybe I'm just kidding myself, MK)
|
||||
*/
|
||||
template <class EOT>
|
||||
|
|
@ -63,10 +64,10 @@ public :
|
|||
Base class for statistics calculated over a sorted snapshot of the population
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoSortedStatBase : public eoUF<const vector<const EOT*>&, void>
|
||||
class eoSortedStatBase : public eoUF<const std::vector<const EOT*>&, void>
|
||||
{
|
||||
public:
|
||||
virtual void lastCall(const vector<const EOT*>&) {}
|
||||
virtual void lastCall(const std::vector<const EOT*>&) {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -111,9 +112,9 @@ public :
|
|||
virtual void operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
doit(_pop, EOT::Fitness()); // specializations for scalar and vector
|
||||
doit(_pop, EOT::Fitness()); // specializations for scalar and std::vector
|
||||
#else
|
||||
doit(_pop, typename EOT::Fitness()); // specializations for scalar and vector
|
||||
doit(_pop, typename EOT::Fitness()); // specializations for scalar and std::vector
|
||||
#endif
|
||||
}
|
||||
private :
|
||||
|
|
@ -192,10 +193,10 @@ public :
|
|||
|
||||
eoNthElementFitnessStat(int _which, std::string _description = "nth element fitness") : eoSortedStat<EOT, Fitness>(Fitness(), _description), which(_which) {}
|
||||
|
||||
virtual void operator()(const vector<const EOT*>& _pop)
|
||||
virtual void operator()(const std::vector<const EOT*>& _pop)
|
||||
{
|
||||
if (which > _pop.size())
|
||||
throw logic_error("fitness requested of element outside of pop");
|
||||
throw std::logic_error("fitness requested of element outside of pop");
|
||||
|
||||
doit(_pop, Fitness());
|
||||
}
|
||||
|
|
@ -226,11 +227,11 @@ private :
|
|||
value().resize(traits::nObjectives());
|
||||
|
||||
// copy of pointers, what the heck
|
||||
vector<const EOT*> tmp_pop = _pop;
|
||||
std::vector<const EOT*> tmp_pop = _pop;
|
||||
|
||||
for (unsigned o = 0; o < value().size(); ++o)
|
||||
{
|
||||
typename vector<const EOT*>::iterator nth = tmp_pop.begin() + which;
|
||||
typename std::vector<const EOT*>::iterator nth = tmp_pop.begin() + which;
|
||||
std::nth_element(tmp_pop.begin(), nth, tmp_pop.end(), CmpFitness(o, traits::maximizing(o)));
|
||||
value()[o] = (*nth)->fitness()[o];
|
||||
}
|
||||
|
|
@ -238,7 +239,7 @@ private :
|
|||
|
||||
// for everything else
|
||||
template <class T>
|
||||
void doit(const vector<const EOT*>& _pop, T)
|
||||
void doit(const std::vector<const EOT*>& _pop, T)
|
||||
{
|
||||
value() = _pop[which]->fitness();
|
||||
}
|
||||
|
|
@ -319,7 +320,7 @@ private :
|
|||
|
||||
for (unsigned o = 0; o < traits::nObjectives(); ++o)
|
||||
{
|
||||
typename eoPop<EOT>::const_iterator it = max_element(_pop.begin(), _pop.end(), CmpFitness(o, traits::maximizing(o)));
|
||||
typename eoPop<EOT>::const_iterator it = std::max_element(_pop.begin(), _pop.end(), CmpFitness(o, traits::maximizing(o)));
|
||||
value()[o] = it->fitness()[o];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ template <class T = double> class eoUniformInit : public eoInit<T>
|
|||
minim(_min), range(_max-_min), uniform(_rng)
|
||||
{
|
||||
if (_min>_max)
|
||||
throw logic_error("Min is greater than Max in uniform_generator");
|
||||
throw std::logic_error("Min is greater than Max in uniform_generator");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ template <class T = double> class uniform_generator
|
|||
minim(_min), range(_max-_min), uniform(_rng)
|
||||
{
|
||||
if (_min>_max)
|
||||
throw logic_error("Min is greater than Max in uniform_generator");
|
||||
throw std::logic_error("Min is greater than Max in uniform_generator");
|
||||
}
|
||||
|
||||
T operator()(void) { return minim+static_cast<T>(uniform.uniform(range)); }
|
||||
|
|
@ -94,7 +94,7 @@ template <class T = uint32> class random_generator
|
|||
minim(_min), range(_max-_min), random(_rng)
|
||||
{
|
||||
if (_min>_max)
|
||||
throw logic_error("Min is greater than Max in random_generator");
|
||||
throw std::logic_error("Min is greater than Max in random_generator");
|
||||
}
|
||||
|
||||
T operator()(void) { return (T) (minim + random.random(range)); }
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ double sum_fitness(const eoPop<EOT>& _pop, std::pair<double, double>& _minmax)
|
|||
double v = static_cast<double>(it->fitness());
|
||||
|
||||
_minmax.first = std::min(_minmax.first, v);
|
||||
_minmax.second = std::max(_minmax.second, v);
|
||||
_minmax.second = max(_minmax.second, v);
|
||||
|
||||
rawTotal += v;
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue