* indentations + whitespace cleanup

This commit is contained in:
Caner Candan 2011-05-05 16:54:00 +02:00
commit 56c6edab04
285 changed files with 6068 additions and 6223 deletions

View file

@ -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:

View file

@ -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

View file

@ -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>

View file

@ -45,4 +45,3 @@
#define eo_is_an_integer false
#endif

View file

@ -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

View file

@ -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

View file

@ -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_

View file

@ -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;
}

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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)
{}
}

View file

@ -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:

View file

@ -85,7 +85,7 @@ public:
}
}
private:
unsigned int objective; // The objective we're storing
unsigned int objective; // The objective we're storing
};
#endif

View file

@ -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

View file

@ -1,7 +1,7 @@
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
#endif
#include <iostream>
#include <fstream>

View file

@ -1,4 +1,3 @@
/*
(c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
@ -22,7 +21,7 @@ Authors:
todos@geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
Johann Dréo <johann.dreo@thalesgroup.com>
Johann Dréo <johann.dreo@thalesgroup.com>
*/
#ifndef _eoOStreamMonitor_h_
@ -45,15 +44,15 @@ Authors:
class eoOStreamMonitor : public eoMonitor
{
public :
eoOStreamMonitor( std::ostream & _out, bool _verbose=true, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true)
eoOStreamMonitor( std::ostream & _out, bool _verbose=true, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true)
{
(void)_verbose;
(void)_verbose;
eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoOStreamMonitor constructor is deprecated and will be removed in the next release" << std::endl;
}
eoOStreamMonitor( std::ostream & _out, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true)
eoOStreamMonitor( std::ostream & _out, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true)
{}
eoMonitor& operator()(void);
@ -69,4 +68,3 @@ private :
};
#endif // _eoOStreamMonitor_h_

View file

@ -45,11 +45,11 @@ eoParallel::~eoParallel()
{
#ifdef _OPENMP
if ( doMeasure() )
{
double _t_end = omp_get_wtime();
eoLogger log;
log << eo::file("measure_" + prefix()) << _t_end - _t_start << std::endl;
}
{
double _t_end = omp_get_wtime();
eoLogger log;
log << eo::file("measure_" + prefix()) << _t_end - _t_start << std::endl;
}
#endif // !_OPENMP
}
@ -63,20 +63,20 @@ std::string eoParallel::prefix() const
std::string value( _prefix.value() );
if ( _isEnabled.value() )
{
if ( _isDynamic.value() )
{
value += "_dynamic.out";
}
else
{
value += "_parallel.out";
}
}
{
if ( _isDynamic.value() )
{
value += "_dynamic.out";
}
else
{
value += "_parallel.out";
}
}
else
{
value += "_sequential.out";
}
{
value += "_sequential.out";
}
return value;
}
@ -98,17 +98,17 @@ void make_parallel(eoParser& parser)
#ifdef _OPENMP
if ( eo::parallel.isEnabled() )
{
if ( eo::parallel.nthreads() > 0 )
{
omp_set_num_threads( eo::parallel.nthreads() );
}
}
{
if ( eo::parallel.nthreads() > 0 )
{
omp_set_num_threads( eo::parallel.nthreads() );
}
}
if ( eo::parallel.doMeasure() )
{
eo::parallel._t_start = omp_get_wtime();
}
{
eo::parallel._t_start = omp_get_wtime();
}
#endif // !_OPENMP
}

View file

@ -135,8 +135,8 @@ private:
/**
eoValueParam<ValueType>: templatized derivation of eoParam. Can be used to contain
any scalar value type. It makes use of std::strstream to get and set values.
any scalar value type. It makes use of std::strstream to get and set values.
@todo This should be changed to std::stringstream when that class is available in g++.
Note also that there is a template specialization for std::pair<double, double> and
@ -186,7 +186,7 @@ public :
/** Change the parameter value
*/
void value( ValueType val )
void value( ValueType val )
{
// convert to string
std::ostringstream os;
@ -431,7 +431,7 @@ public:
// Here, we do have args
_os << "(";
if (narg == 1) // 1 arg only
if (narg == 1) // 1 arg only
{
_os << second[0] << ")" ;
return _os;
@ -453,9 +453,9 @@ public:
void readFrom(std::string & _value)
{
second.resize(0); // just in case
second.resize(0); // just in case
size_t pos = _value.find('(');
if (pos >= _value.size()) // no arguments
if (pos >= _value.size()) // no arguments
{
first = _value;
return;
@ -484,4 +484,3 @@ std::istream & operator>>(std::istream & _is, eoParamParamType & _rate);
/** @} */
#endif

View file

@ -74,19 +74,19 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
unsigned i;
for (i = 1; i < _argc; ++i)
{
if(_argv[i][0] == '@')
if(_argv[i][0] == '@')
{ // read response file
char *pts = _argv[i]+1; // yes a char*, sorry :-)
ifstream ifs (pts);
ifs.peek(); // check if it exists
if (!ifs)
char *pts = _argv[i]+1; // yes a char*, sorry :-)
ifstream ifs (pts);
ifs.peek(); // check if it exists
if (!ifs)
{
string msg = string("Could not open response file: ") + pts;
throw runtime_error(msg);
string msg = string("Could not open response file: ") + pts;
throw runtime_error(msg);
}
// read - will be overwritten by command-line
readFrom(ifs);
break; // stop reading command line args for '@'
// read - will be overwritten by command-line
readFrom(ifs);
break; // stop reading command line args for '@'
}
}
// now read arguments on command-line
@ -188,59 +188,59 @@ void eoParser::readFrom(istream& is)
processing = (str.find(string("Parser"))<str.size());
if (processing) // right \section (or no \section at all)
{
{
if (str[0] == '#')
{ // skip the rest of the line
{ // skip the rest of the line
string tempStr;
getline(is, tempStr);
}
}
if (str[0] == '-')
{
{
if (str.size() < 2)
{
{
eoWarning("Missing parameter");
needHelp.value() = true;
return;
}
}
if (str[1] == '-') // two consecutive dashes
{
{
string::iterator equalLocation = find(str.begin() + 2, str.end(), '=');
string value;
if (equalLocation == str.end())
{ //! @todo it should be the next string
{ //! @todo it should be the next string
value = "";
}
}
else
{
{
value = string(equalLocation + 1, str.end());
}
}
string name(str.begin() + 2, equalLocation);
longNameMap[name] = value;
}
}
else // it should be a char
{
{
string value = "1"; // flags do not need a special
if (str.size() >= 2)
{
{
if (str[2] == '=')
{
{
if (str.size() >= 3)
value = string(str.begin() + 3, str.end());
}
}
else
{
{
value = string(str.begin() + 2, str.end());
}
}
}
}
shortNameMap[str[1]] = value;
}
}
}
}
}
}
}
updateParameters();
@ -268,8 +268,8 @@ void eoParser::printOn(ostream& os) const
eoParam* param = p->second;
if (!isItThere(*param)) // comment out the ones not set by the user
os << "# ";
if (!isItThere(*param)) // comment out the ones not set by the user
os << "# ";
string str = "--" + param->longName() + "=" + param->getValue();
@ -329,12 +329,12 @@ void eoParser::printHelp(ostream& os)
}
if (p->second->shortName())
os << "-" << p->second->shortName() << ", ";
os << "-" << p->second->shortName() << ", ";
os << "--" <<p->second->longName() <<":\t"
<< p->second->description() ;
<< p->second->description() ;
os << "\n" << setw(20) << ( (p->second->required())?"Required":"Optional" );
os << "\n" << setw(20) << ( (p->second->required())?"Required":"Optional" );
os <<". By default: "<<p->second->defValue() << '\n';
} // for p
@ -377,7 +377,7 @@ bool eoParser::userNeedsHelp(void)
// search for unknown short names
for (ShortNameMapType::const_iterator sIt = shortNameMap.begin(); sIt != shortNameMap.end(); ++sIt)
{
{
char entry = sIt->first;
MultiMapType::const_iterator it;
@ -403,7 +403,7 @@ bool eoParser::userNeedsHelp(void)
string msg = "Use -h or --help to get help about available parameters";
messages.push_back( msg );
}
} // if stopOnUnknownParam
return needHelp.value() || !messages.empty();
@ -421,4 +421,3 @@ istream & operator>>(istream & _is, eoParamParamType & _rate)
_rate.readFrom(_is);
return _is;
}

View file

@ -119,7 +119,7 @@ public:
* @param _shortHand Single charachter shorthand for specifying the configuration file
*/
eoParser ( unsigned _argc, char **_argv , std::string _programDescription = "",
std::string _lFileParamName = "param-file", char _shortHand = 'p');
std::string _lFileParamName = "param-file", char _shortHand = 'p');
/**
Processes the parameter and puts it in the appropriate section for readability

View file

@ -25,10 +25,10 @@ Caner Candan <caner.candan@thalesgroup.com>
#include "eoParserLogger.h"
eoParserLogger::eoParserLogger(unsigned _argc, char** _argv,
std::string _programDescription /*= ""*/
,
std::string _lFileParamName /*= "param-file"*/,
char _shortHand /*= 'p'*/)
std::string _programDescription /*= ""*/
,
std::string _lFileParamName /*= "param-file"*/,
char _shortHand /*= 'p'*/)
: eoParser(_argc, _argv, _programDescription, _lFileParamName, _shortHand),
_verbose("quiet", "verbose", "Set the verbose level", 'v'),
_printVerboseLevels(false, "print-verbose-levels", "Print verbose levels", 'l'),
@ -50,9 +50,9 @@ eoParserLogger::eoParserLogger(unsigned _argc, char** _argv,
//------------------------------------------------------------------
if ( ! _output.value().empty() )
{
eo::log << eo::file( _output.value() );
}
{
eo::log << eo::file( _output.value() );
}
//------------------------------------------------------------------
@ -62,9 +62,9 @@ eoParserLogger::eoParserLogger(unsigned _argc, char** _argv,
//------------------------------------------------------------------
if ( _printVerboseLevels.value() )
{
eo::log.printLevels();
}
{
eo::log.printLevels();
}
//------------------------------------------------------------------

View file

@ -17,8 +17,8 @@
Contact: http://eodev.sourceforge.net
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef EO_PARSER_LOGGER_H
@ -37,9 +37,9 @@ class eoParserLogger : public eoParser
{
public:
eoParserLogger(unsigned _argc, char** _argv,
std::string _programDescription = "",
std::string _lFileParamName = "param-file",
char _shortHand = 'p');
std::string _programDescription = "",
std::string _lFileParamName = "param-file",
char _shortHand = 'p');
~eoParserLogger();
private:

View file

@ -59,9 +59,9 @@ public:
/** 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*/
population*/
eoPopStat(unsigned _howMany = 0, std::string _desc ="")
: eoStat<EOT, std::string>("", _desc), combien( _howMany) {}
: 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
@ -119,15 +119,15 @@ public:
*/
void operator()(const std::vector<const EOT*>& _pop)
{
value() = ""; // empty
value() = ""; // empty
unsigned howMany=combien?combien:_pop.size();
for (unsigned i = 0; i < howMany; ++i)
{
std::ostringstream os;
os << *_pop[i] << std::endl;
std::ostringstream os;
os << *_pop[i] << std::endl;
// paranoid:
value() += os.str();
// paranoid:
value() += os.str();
}
}
private:

View file

@ -16,4 +16,3 @@ namespace eo
// global random number generator object
eoRng rng(static_cast<uint32_t>(time(0)));
}

View file

@ -25,7 +25,7 @@ Old contact information: todos@geneura.ugr.es, http://geneura.ugr.es
#ifndef EO_RANDOM_NUMBER_GENERATOR
#define EO_RANDOM_NUMBER_GENERATOR
/** @addtogroup Random
/** @addtogroup Random
* @{
* */

View file

@ -78,7 +78,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
if (ownedBounds.size()>0)
for (unsigned i = 0; i < ownedBounds.size(); ++i)
{
delete ownedBounds[i];
delete ownedBounds[i];
}
ownedBounds.resize(0);
factor.resize(0);
@ -89,29 +89,29 @@ void eoRealVectorBounds::readFrom(std::string _value)
while (_value.size()>0)
{
if (!remove_leading(_value, delim)) // only delimiters were left
break;
break;
// look for opening char
size_t posDeb = _value.find_first_of("[(");
if (posDeb >= _value.size()) // nothing left to read (though probably a syntax error there)
{
break;
}
{
break;
}
// ending char
std::string closeChar = (_value[posDeb] == '(' ? std::string(")") : std::string("]") );
size_t posFin = _value.find_first_of(std::string(closeChar));
if (posFin >= _value.size())
throw std::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
{
std::string sCount = _value.substr(0, posDeb);
count = read_int(sCount);
if (count <= 0)
throw std::runtime_error("Syntax error when reading bounds");
}
{
std::string sCount = _value.substr(0, posDeb);
count = read_int(sCount);
if (count <= 0)
throw std::runtime_error("Syntax error when reading bounds");
}
// the bounds
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
@ -121,7 +121,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
remove_leading(sBounds, delim);
size_t posDelim = sBounds.find_first_of(delim);
if (posDelim >= sBounds.size())
throw std::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;
@ -129,38 +129,38 @@ void eoRealVectorBounds::readFrom(std::string _value)
// min bound
std::string sMinBounds = sBounds.substr(0,posDelim);
if (sMinBounds != std::string("-inf"))
{
minBounded = true;
minBound = read_double(sMinBounds);
}
{
minBounded = true;
minBound = read_double(sMinBounds);
}
// max bound
size_t posEndDelim = sBounds.find_first_not_of(delim,posDelim);
std::string sMaxBounds = sBounds.substr(posEndDelim);
if (sMaxBounds != std::string("+inf"))
{
maxBounded = true;
maxBound = read_double(sMaxBounds);
}
{
maxBounded = true;
maxBound = read_double(sMaxBounds);
}
// now create the eoRealBounds objects
eoRealBounds *ptBounds;
if (minBounded && maxBounded)
ptBounds = new eoRealInterval(minBound, maxBound);
ptBounds = new eoRealInterval(minBound, maxBound);
else if (!minBounded && !maxBounded) // no bound at all
ptBounds = new eoRealNoBounds;
ptBounds = new eoRealNoBounds;
else if (!minBounded && maxBounded)
ptBounds = new eoRealAboveBound(maxBound);
ptBounds = new eoRealAboveBound(maxBound);
else if (minBounded && !maxBounded)
ptBounds = new eoRealBelowBound(minBound);
ptBounds = new eoRealBelowBound(minBound);
// store it for memory management
ownedBounds.push_back(ptBounds);
// push the count
factor.push_back(count);
// and add count of it to the actual bounds
for (unsigned i=0; i<count; i++)
push_back(ptBounds);
push_back(ptBounds);
}
// now adjust the size to the initial value
adjust_size(oldSize);
@ -175,7 +175,7 @@ void eoRealVectorBounds::adjust_size(unsigned _dim)
unsigned missing = _dim-size();
eoRealBounds * ptBounds = back();
for (unsigned i=0; i<missing; i++)
push_back(ptBounds);
push_back(ptBounds);
// update last factor (warning: can be > 1 already!)
factor[factor.size()-1] += missing;
}
@ -221,12 +221,12 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
std::string sMinBounds = sBounds.substr(0,posDelim);
if ( (sMinBounds != std::string("-inf")) &&
(sMinBounds != std::string("-infinity"))
)
{
minBounded = true;
minBound = read_double(sMinBounds);
}
(sMinBounds != std::string("-infinity"))
)
{
minBounded = true;
minBound = read_double(sMinBounds);
}
// max bound
size_t posEndDelim = sBounds.find_first_not_of(delim,posDelim);
@ -234,26 +234,26 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
std::string sMaxBounds = sBounds.substr(posEndDelim);
if ( (sMaxBounds != std::string("+inf")) &&
(sMaxBounds != std::string("+infinity"))
)
{
maxBounded = true;
maxBound = read_double(sMaxBounds);
}
(sMaxBounds != std::string("+infinity"))
)
{
maxBounded = true;
maxBound = read_double(sMaxBounds);
}
// now create the embedded eoRealBounds object
eoRealBounds * locBound;
if (minBounded && maxBounded)
{
if (maxBound <= minBound)
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
locBound = new eoRealInterval(minBound, maxBound);
}
{
if (maxBound <= minBound)
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
locBound = new eoRealInterval(minBound, maxBound);
}
else if (!minBounded && !maxBounded) // no bound at all
locBound = new eoRealNoBounds;
locBound = new eoRealNoBounds;
else if (!minBounded && maxBounded)
locBound = new eoRealAboveBound(maxBound);
locBound = new eoRealAboveBound(maxBound);
else if (minBounded && !maxBounded)
locBound = new eoRealBelowBound(minBound);
locBound = new eoRealBelowBound(minBound);
return locBound;
}

View file

@ -3,7 +3,7 @@
//-----------------------------------------------------------------------------
// eoRealBounds.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 _eoRealBounds_h
#define _eoRealBounds_h
#include <stdexcept> // std::exceptions!
#include <stdexcept> // std::exceptions!
#include <utils/eoRNG.h>
/**
@ -55,24 +55,24 @@ Scalar type:
Basic class is eoRealBounds, a pure virtual.
The following pure virtual methods are to be used in mutations:
- void foldsInBounds(double &) that folds any value that falls out of
- void foldsInBounds(double &) that folds any value that falls out of
the bounds back into the bounds, by bouncing on the limit (if any)
- bool isInBounds(double) that simply says whether or not the argument
- bool isInBounds(double) that simply says whether or not the argument
is in the bounds
- void truncate(double &) 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
eoRealInterval that holds a minimum and maximum value,
Derived class are
eoRealInterval that holds a minimum and maximum value,
eoRealNoBounds the "unbounded bounds" (-infinity, +infinity)
eoRealBelowBound the half-bounded interval [min, +infinity)
eoRealAboveBound the half-bounded interval (-infinity, max]
@ -83,7 +83,7 @@ is the unbounded bound
@ingroup Bounds
*/
class eoRealBounds : public eoPersistent
{
{
public:
virtual ~eoRealBounds(){}
@ -116,17 +116,17 @@ public:
*/
virtual void truncate(double &) const = 0;
/** get minimum value
/** get minimum value
* std::exception if does not exist
*/
*/
virtual double minimum() const = 0 ;
/** get maximum value
* std::exception if does not exist
*/
*/
virtual double maximum() const = 0 ;
/** get range
* std::exception if unbounded
*/
*/
virtual double range() const = 0;
/** random generator of uniform numbers in bounds
@ -159,16 +159,16 @@ public:
{
throw std::logic_error("Trying to get minimum of unbounded eoRealBounds");
}
virtual double maximum() const
virtual double maximum() const
{
throw std::logic_error("Trying to get maximum of unbounded eoRealBounds");
}
virtual double range() const
virtual double range() const
{
throw std::logic_error("Trying to get range of unbounded eoRealBounds");
}
virtual double uniform(eoRng & _rng = eo::rng) const
virtual double uniform(eoRng & _rng = eo::rng) const
{
(void)_rng;
@ -199,7 +199,7 @@ public:
}
/** for memory managements - ugly */
virtual eoRealBounds * dup() const
virtual eoRealBounds * dup() const
{
return new eoRealNoBounds(*this);
}
@ -220,18 +220,18 @@ class eoRealInterval : public eoRealBounds
{
public :
virtual ~eoRealInterval(){}
/**
/**
Simple bounds = minimum and maximum (allowed)
*/
eoRealInterval(double _min=0, double _max=1) :
repMinimum(_min), repMaximum(_max), repRange(_max-_min)
eoRealInterval(double _min=0, double _max=1) :
repMinimum(_min), repMaximum(_max), repRange(_max-_min)
{
if (repRange<=0)
throw std::logic_error("Void range in eoRealBounds");
}
// accessors
// accessors
virtual double minimum() const { return repMinimum; }
virtual double maximum() const { return repMaximum; }
virtual double range() const { return repRange; }
@ -242,13 +242,13 @@ 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);
}
}
// 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;
@ -258,36 +258,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;
@ -320,7 +320,7 @@ public :
}
/** for memory managements - ugly */
virtual eoRealBounds * dup() const
virtual eoRealBounds * dup() const
{
return new eoRealInterval(*this);
}
@ -328,7 +328,7 @@ public :
private :
double repMinimum;
double repMaximum;
double repRange; // to minimize operations ???
double repRange; // to minimize operations ???
};
/**
@ -339,22 +339,22 @@ private :
class eoRealBelowBound : public eoRealBounds
{
public :
virtual ~eoRealBelowBound(){}
/**
virtual ~eoRealBelowBound(){}
/**
Simple bounds = minimum
*/
eoRealBelowBound(double _min=0) :
eoRealBelowBound(double _min=0) :
repMinimum(_min)
{}
// accessors
// accessors
virtual double minimum() const { return repMinimum; }
virtual double maximum() const
virtual double maximum() const
{
throw std::logic_error("Trying to get maximum of eoRealBelowBound");
}
virtual double range() const
virtual double range() const
{
throw std::logic_error("Trying to get range of eoRealBelowBound");
}
@ -374,7 +374,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;
@ -382,16 +382,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;
@ -405,7 +405,7 @@ public :
* but reading should not be done here, because of bound problems
* see eoRealVectorBounds
*/
virtual void readFrom(std::istream& _is)
virtual void readFrom(std::istream& _is)
{
(void)_is;
@ -422,7 +422,7 @@ public :
}
/** for memory managements - ugly */
virtual eoRealBounds * dup() const
virtual eoRealBounds * dup() const
{
return new eoRealBelowBound(*this);
}
@ -438,22 +438,22 @@ class eoRealAboveBound : public eoRealBounds
{
public :
virtual ~eoRealAboveBound(){}
/**
/**
Simple bounds = minimum
*/
eoRealAboveBound(double _max=0) :
eoRealAboveBound(double _max=0) :
repMaximum(_max)
{}
// accessors
// accessors
virtual double maximum() const { return repMaximum; }
virtual double minimum() const
virtual double minimum() const
{
throw std::logic_error("Trying to get minimum of eoRealAboveBound");
}
virtual double range() const
virtual double range() const
{
throw std::logic_error("Trying to get range of eoRealAboveBound");
}
@ -473,7 +473,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;
@ -481,16 +481,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;
@ -521,7 +521,7 @@ public :
}
/** for memory managements - ugly */
virtual eoRealBounds * dup() const
virtual eoRealBounds * dup() const
{
return new eoRealAboveBound(*this);
}
@ -560,13 +560,13 @@ public:
if (maxBounded) maximum = bb.maximum();
if (minBounded && maxBounded)
repBound = new eoRealInterval(minimum, maximum);
repBound = new eoRealInterval(minimum, maximum);
else if (!minBounded && !maxBounded) // no bound at all
repBound = new eoRealNoBounds;
repBound = new eoRealNoBounds;
else if (!minBounded && maxBounded)
repBound = new eoRealAboveBound(maximum);
repBound = new eoRealAboveBound(maximum);
else if (minBounded && !maxBounded)
repBound = new eoRealBelowBound(minimum);
repBound = new eoRealBelowBound(minimum);
}
eoGeneralRealBounds& operator=(const eoGeneralRealBounds& _b)
@ -586,13 +586,13 @@ public:
delete repBound;
// now reallocate
if (minBounded && maxBounded)
repBound = new eoRealInterval(minimum, maximum);
repBound = new eoRealInterval(minimum, maximum);
else if (!minBounded && !maxBounded) // no bound at all
repBound = new eoRealNoBounds;
repBound = new eoRealNoBounds;
else if (!minBounded && maxBounded)
repBound = new eoRealAboveBound(maximum);
repBound = new eoRealAboveBound(maximum);
else if (minBounded && !maxBounded)
repBound = new eoRealBelowBound(minimum);
repBound = new eoRealBelowBound(minimum);
return (*this);
}
@ -633,17 +633,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 double minimum() const {return repBound->minimum();}
/** get maximum value
* std::exception if does not exist
*/
*/
virtual double maximum() const {return repBound->maximum();}
/** get range
* std::exception if unbounded
*/
*/
virtual double range() const {return repBound->range();}
/** random generator of uniform numbers in bounds
@ -655,9 +655,9 @@ public:
virtual eoRealBounds * dup() const {return repBound->dup();}
/** for efficiency, it's better to use the embedded boud directly */
const eoRealBounds & theBounds() const { return *repBound;}
const eoRealBounds & 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
@ -666,7 +666,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;

View file

@ -3,7 +3,7 @@
//-----------------------------------------------------------------------------
// eoRealVectorBounds.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,93 +27,93 @@
#ifndef _eoRealVectorBounds_h
#define _eoRealVectorBounds_h
#include <stdexcept> // std::exceptions!
#include <stdexcept> // std::exceptions!
#include <utils/eoRNG.h>
#include <utils/eoRealBounds.h>
/**
Vector type for bounds (see eoRealBounds.h for scalar types)
------------
Class eoRealVectorBounds implements the std::vectorized version:
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
This file also contains the global variables and eoDummyVectorNoBounds
that are used as defaults in ctors (i.e. when no
bounds are given, it is assumed unbounded values)
THe 2 main classes defined here are
THe 2 main classes defined here are
eoRealBaseVectorBounds, base class that handles all useful functions
eoRealVectorBounds which derives from the preceding *and* eoPersistent
and also has a mechanism for memory handling of the pointers
and also has a mechanism for memory handling of the pointers
it has to allocate
@ingroup Bounds
*/
class eoRealBaseVectorBounds : public std::vector<eoRealBounds *>
{
{
public:
// virtual desctructor (to avoid warning?)
virtual ~eoRealBaseVectorBounds(){}
/** Default Ctor.
/** Default Ctor.
*/
eoRealBaseVectorBounds() : std::vector<eoRealBounds *>(0) {}
/** Ctor: same bounds for everybody, given as an eoRealBounds
*/
eoRealBaseVectorBounds(unsigned _dim, eoRealBounds & _bounds) :
eoRealBaseVectorBounds(unsigned _dim, eoRealBounds & _bounds) :
std::vector<eoRealBounds *>(_dim, &_bounds)
{}
/** Ctor, particular case of dim-2
*/
eoRealBaseVectorBounds(eoRealBounds & _xbounds, eoRealBounds & _ybounds) :
eoRealBaseVectorBounds(eoRealBounds & _xbounds, eoRealBounds & _ybounds) :
std::vector<eoRealBounds *>(0)
{
push_back( &_xbounds);
push_back( &_ybounds);
push_back( &_xbounds);
push_back( &_ybounds);
}
/** test: is i_th component bounded
*/
virtual bool isBounded(unsigned _i)
{
virtual bool isBounded(unsigned _i)
{
return (*this)[_i]->isBounded();
}
/** test: bounded iff all are bounded
*/
virtual bool isBounded(void)
virtual bool isBounded(void)
{
for (unsigned i=0; i<size(); i++)
if (! (*this)[i]->isBounded())
return false;
return false;
return true;
}
/** Self-test: true iff i_th component has no bounds at all
*/
virtual bool hasNoBoundAtAll(unsigned _i)
{
virtual bool hasNoBoundAtAll(unsigned _i)
{
return (*this)[_i]->hasNoBoundAtAll();
}
/** Self-test: true iff all components have no bound at all
*/
virtual bool hasNoBoundAtAll(void)
virtual bool hasNoBoundAtAll(void)
{
for (unsigned i=0; i<size(); i++)
if (! (*this)[i]->hasNoBoundAtAll())
return false;
return false;
return true;
}
virtual bool isMinBounded(unsigned _i)
virtual bool isMinBounded(unsigned _i)
{ return (*this)[_i]->isMinBounded();} ;
virtual bool isMaxBounded(unsigned _i)
virtual bool isMaxBounded(unsigned _i)
{ return (*this)[_i]->isMaxBounded();} ;
/** Folds a real value back into the bounds - i_th component
@ -130,7 +130,7 @@ public:
for (unsigned i=0; i<size(); i++)
{
(*this)[i]->foldsInBounds(_v[i]);
}
}
}
/** Truncates a real value to the bounds - i_th component
@ -147,7 +147,7 @@ public:
for (unsigned i=0; i<size(); i++)
{
(*this)[i]->truncate(_v[i]);
}
}
}
/** test: is i_th component within the bounds?
@ -161,7 +161,7 @@ public:
{
for (unsigned i=0; i<size(); i++)
if (! isInBounds(i, _v[i]))
return false;
return false;
return true;
}
@ -174,7 +174,7 @@ public:
/** Computes the average range
* An std::exception will be raised if one of the component is unbounded
*/
virtual double averageRange()
virtual double averageRange()
{
double r=0.0;
for (unsigned i=0; i<size(); i++)
@ -203,7 +203,7 @@ public:
{
_v[i] = uniform(i, _rng);
}
}
}
/**
* Write object. It's called printOn since it prints the object on a stream.
@ -213,8 +213,8 @@ public:
{
for (unsigned i=0; i<size(); i++)
{
operator[](i)->printOn(_os);
_os << ";";
operator[](i)->printOn(_os);
_os << ";";
}
}
};
@ -234,19 +234,19 @@ public:
/** Ctor: same bounds for everybody, given as an eoRealBounds
*/
eoRealVectorBounds(unsigned _dim, eoRealBounds & _bounds) :
eoRealVectorBounds(unsigned _dim, eoRealBounds & _bounds) :
eoRealBaseVectorBounds(_dim, _bounds), factor(1,_dim), ownedBounds(0)
{}
/** Ctor, particular case of dim-2
*/
eoRealVectorBounds(eoRealBounds & _xbounds, eoRealBounds & _ybounds) :
eoRealVectorBounds(eoRealBounds & _xbounds, eoRealBounds & _ybounds) :
eoRealBaseVectorBounds(_xbounds, _ybounds), factor(2,1), ownedBounds(0)
{}
/** Simple bounds = minimum and maximum (allowed)
*/
eoRealVectorBounds(unsigned _dim, double _min, double _max) :
eoRealVectorBounds(unsigned _dim, double _min, double _max) :
eoRealBaseVectorBounds(), factor(1, _dim), ownedBounds(0)
{
if (_max-_min<=0)
@ -261,7 +261,7 @@ public:
/** Ctor: different bounds for different variables, std::vectors of double
*/
eoRealVectorBounds(std::vector<double> _min, std::vector<double> _max) :
eoRealVectorBounds(std::vector<double> _min, std::vector<double> _max) :
factor(_min.size(), 1), ownedBounds(0)
{
if (_max.size() != _min.size())
@ -270,9 +270,9 @@ public:
eoRealBounds *ptBounds;
for (unsigned i=0; i<_min.size(); i++)
{
ptBounds = new eoRealInterval(_min[i], _max[i]);
ownedBounds.push_back(ptBounds);
push_back(ptBounds);
ptBounds = new eoRealInterval(_min[i], _max[i]);
ownedBounds.push_back(ptBounds);
push_back(ptBounds);
}
}
@ -320,26 +320,26 @@ public:
unsigned int index=factor[0];
if (factor.size()>1)
for (unsigned i=1; i<factor.size(); i++)
{
_os << ";";
if (factor[i] > 1)
_os << factor[i];
operator[](index)->printOn(_os);
index += factor[i];
}
{
_os << ";";
if (factor[i] > 1)
_os << factor[i];
operator[](index)->printOn(_os);
index += factor[i];
}
}
/** Eventually increases the size by duplicating last bound */
void adjust_size(unsigned _dim);
/** need to rewrite copy ctor and assignement operator
/** need to rewrite copy ctor and assignement operator
* because of ownedBounds */
eoRealVectorBounds(const eoRealVectorBounds &);
private:// WARNING: there is no reason for both std::vector below
private:// WARNING: there is no reason for both std::vector below
//to be synchronized in any manner
std::vector<unsigned int> factor; // std::list of nb of "grouped" bounds
std::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&);
};
@ -352,19 +352,19 @@ private:// WARNING: there is no reason for both std::vector below
@ingroup Bounds
*/
class eoRealVectorNoBounds: public eoRealVectorBounds
{
{
public:
// virtual desctructor (to avoid warning?)
virtual ~eoRealVectorNoBounds(){}
/**
/**
* Ctor: nothing to do, but beware of dimension: call base class ctor
*/
eoRealVectorNoBounds(unsigned _dim) :
eoRealVectorNoBounds(unsigned _dim) :
eoRealVectorBounds( (_dim?_dim:1), eoDummyRealNoBounds)
{}
virtual bool isBounded(unsigned) {return false;}
virtual bool isBounded(void) {return false;}
@ -383,7 +383,7 @@ public:
virtual bool isInBounds(unsigned, double) {return true;}
virtual bool isInBounds(std::vector<double>) {return true;}
// accessors
// accessors
virtual double minimum(unsigned)
{
throw std::logic_error("Trying to get minimum of eoRealVectorNoBounds");
@ -397,7 +397,7 @@ public:
throw std::logic_error("Trying to get range of eoRealVectorNoBounds");
}
virtual double averageRange()
virtual double averageRange()
{
throw std::logic_error("Trying to get average range of eoRealVectorNoBounds");
}

View file

@ -52,10 +52,10 @@ public:
{
value().resize(_popPters.size());
for (unsigned i=0; i<_popPters.size(); i++)
{
value()[i] = _popPters[i]->fitness();
range.truncate(value()[i]);
}
{
value()[i] = _popPters[i]->fitness();
range.truncate(value()[i]);
}
}
private :

View file

@ -44,7 +44,7 @@ Contact: http://eodev.sourceforge.net
*
* Compute various statistics on a population.
*
* Objects of those classes are generally called by an eoCheckPoint
* Objects of those classes are generally called by an eoCheckPoint
* to compute statistics about the population at a given generation.
* As they inherit from eoValueParam, they can be printed drectly,
* for instance by an eoMonitor.
@ -433,7 +433,7 @@ public:
eoInterquartileRangeStat( typename EOT::Fitness start, std::string description = "IQR" ) : eoStat<EOT,typename EOT::Fitness>( start, description ) {}
virtual void operator()( const eoPop<EOT> & _pop )
virtual void operator()( const eoPop<EOT> & _pop )
{
if( _pop.size() == 0 ) {
// how to implement value() = 0 ?
@ -444,14 +444,14 @@ public:
unsigned int quartile = pop.size()/4;
std::nth_element( pop.begin(), pop.begin()+quartile*1, pop.end() );
typename EOT::Fitness Q1 = pop[quartile].fitness();
std::nth_element( pop.begin(), pop.begin()+quartile*3, pop.end() );
typename EOT::Fitness Q3 = pop[quartile*3].fitness();
value() = Q1 - Q3;
}
}
virtual std::string className(void) const { return "eoInterquartileRangeStat"; }
};
/** @example t-eoIQRStat.cpp
@ -459,7 +459,7 @@ public:
/** Compute the average size of indivudals over the population
*
* Obviously, will work only on representations that implement the (standard) "size()" method,
* Obviously, will work only on representations that implement the (standard) "size()" method,
* like any STL container.
*/
template<class EOT>
@ -469,10 +469,10 @@ public:
using eoStat<EOT, double>::value;
eoAverageSizeStat( std::string description = "Av.Size" ) :
eoAverageSizeStat( std::string description = "Av.Size" ) :
eoStat<EOT,double>( 0.0, description ) {} // 0 by default
virtual void operator()( const eoPop<EOT> & pop )
virtual void operator()( const eoPop<EOT> & pop )
{
size_t pop_size = pop.size();
@ -487,10 +487,9 @@ public:
value() = static_cast<double>(sum) / static_cast<double>(pop_size);
}
virtual std::string className(void) const { return "eoAverageSizeStat"; }
};
/** @} */
#endif

View file

@ -123,24 +123,24 @@ void eoState::load(std::istream& is)
while (getline(is, str))
{
if (is.eof())
throw runtime_error("No section in load file");
if (is_section(str, name))
break;
if (is.eof())
throw runtime_error("No section in load file");
if (is_section(str, name))
break;
removeComment(str, getCommentString());
fullstring += str + "\n";
}
istringstream the_stream(fullstring);
istringstream the_stream(fullstring);
object->readFrom(the_stream);
}
}
else // if (is_section(str, name)) - what if file empty
{
getline(is, str); // try next line!
// if (is.eof())
// throw runtime_error("No section in load file");
}
else // if (is_section(str, name)) - what if file empty
{
getline(is, str); // try next line!
// if (is.eof())
// throw runtime_error("No section in load file");
}
}
}
@ -172,7 +172,7 @@ string eoState::createObjectName(eoObject* obj)
{
if (obj == 0)
{
ostringstream os;
ostringstream os;
os << objectMap.size();
return os.str();
}
@ -184,7 +184,7 @@ string eoState::createObjectName(eoObject* obj)
unsigned count = 1;
while (it != objectMap.end())
{
ostringstream os;
ostringstream os;
os << obj->className().c_str() << count++;
name = os.str();
it = objectMap.find(name);
@ -192,4 +192,3 @@ string eoState::createObjectName(eoObject* obj)
return name;
}

View file

@ -1,6 +1,6 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
/*
/*
(c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
(c) Thales group, 2010
This library is free software; you can redistribute it and/or
@ -24,7 +24,7 @@ Authors:
todos@geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
Johann Dréo <johann.dreo@thalesgroup.com>
Johann Dréo <johann.dreo@thalesgroup.com>
*/
#ifndef _eoStdoutMonitor_h
@ -43,18 +43,17 @@ Authors:
class eoStdoutMonitor : public eoOStreamMonitor
{
public :
eoStdoutMonitor(bool _verbose, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
eoOStreamMonitor( std::cout, _verbose, _delim, _width, _fill)
{
eoStdoutMonitor(bool _verbose, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
eoOStreamMonitor( std::cout, _verbose, _delim, _width, _fill)
{
eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoStdutMonitor constructor is deprecated and will be removed in the next release" << std::endl;
}
eoStdoutMonitor(std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
eoOStreamMonitor( std::cout, _delim, _width, _fill)
eoStdoutMonitor(std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
eoOStreamMonitor( std::cout, _delim, _width, _fill)
{}
virtual std::string className(void) const { return "eoStdoutMonitor"; }
};
#endif

View file

@ -3,7 +3,7 @@
//-----------------------------------------------------------------------------
// eoTimeCounter.h
// (c) Marc Schoenauer, Maarten Keijzer, and GeNeura Team, 2002
/*
/*
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
@ -40,30 +40,30 @@
class eoTimeCounter : public eoUpdater, public eoValueParam<double>
{
public:
eoTimeCounter() : eoValueParam<double>(0.0, "Time") // : firstTime(true)
eoTimeCounter() : eoValueParam<double>(0.0, "Time") // : firstTime(true)
{
start = time(NULL);
}
/** simply stores the time spent in process in its value() */
/** simply stores the time spent in process in its value() */
virtual void operator()()
{
// ask for system time
utime = clock();
// if (firstTime) /* first generation */
// {
// firstTime=false;
// firstUtime = tmsStruct.tms_utime;
// firstTime=false;
// firstUtime = tmsStruct.tms_utime;
// }
// store elapsed user time
// value(tmsStruct.tms_utime - firstUtime);
// value()=double(utime)/CLOCKS_PER_SEC;
double seconds_elapsed = time(NULL) - start;
value() = (seconds_elapsed > 2140) ? seconds_elapsed : double(utime)/CLOCKS_PER_SEC;
}
private:
// bool firstTime;
// clock_t firstUtime;

View file

@ -51,25 +51,25 @@ public:
eoTimedMonitor(unsigned seconds_) : last_tick(0), seconds(seconds_) {}
eoMonitor& operator()(void) {
bool monitor = false;
if (last_tick == 0) {
monitor = true;
last_tick = clock();
}
bool monitor = false;
if (last_tick == 0) {
monitor = true;
last_tick = clock();
}
clock_t tick = clock();
clock_t tick = clock();
if ( (unsigned)(tick-last_tick) >= seconds * CLOCKS_PER_SEC) {
monitor = true;
}
if ( (unsigned)(tick-last_tick) >= seconds * CLOCKS_PER_SEC) {
monitor = true;
}
if (monitor) {
for (unsigned i = 0; i < monitors.size(); ++i) {
(*monitors[i])();
}
last_tick = clock();
}
return *this;
if (monitor) {
for (unsigned i = 0; i < monitors.size(); ++i) {
(*monitors[i])();
}
last_tick = clock();
}
return *this;
}
void add(eoMonitor& mon) { monitors.push_back(&mon); }

View file

@ -24,8 +24,8 @@
*/
//-----------------------------------------------------------------------------
/** Copied from the eoRndGenerators to have objects deriving from eoInit
* As the whole initialization mechanism in EO is based on eoInit rather than
/** Copied from the eoRndGenerators to have objects deriving from eoInit
* As the whole initialization mechanism in EO is based on eoInit rather than
* eoRndGenerators, we might as well have these directly written without
* overhead
@ -69,14 +69,14 @@ template <class T = double> class eoUniformInit : public eoInit<T>
public :
/** Ctor with only a max bound */
eoUniformInit(T _max = T(1.0), eoRng& _rng = rng) :
minim(T(0.0)), range(_max), uniform(_rng)
minim(T(0.0)), range(_max), uniform(_rng)
{}
/** Ctor with an eoRealBound */
eoUniformInit(eoRealBounds & _bound, eoRng& _rng = rng) :
minim(_bound.minimum()), range(_bound.range()), uniform(_rng)
{}
/** Ctor with explicit min and max */
eoUniformInit(T _min, T _max, eoRng& _rng = rng) :
minim(_min), range(_max-_min), uniform(_rng)
@ -84,14 +84,14 @@ template <class T = double> class eoUniformInit : public eoInit<T>
if (_min>_max)
throw std::logic_error("Min is greater than Max in uniform_generator");
}
/**
Generates the number, uses a static_cast to get the right behaviour
for ints and unsigneds
*/
void operator()(T & _t)
{
_t = minim+static_cast<T>(uniform.uniform(range));
void operator()(T & _t)
{
_t = minim+static_cast<T>(uniform.uniform(range));
}
private :

View file

@ -79,13 +79,13 @@ public :
void operator()(void)
{
time_t now = time(0);
time_t now = time(0);
if (now >= last_time + interval)
{
last_time = now;
eoDynUpdater::operator() ();
}
if (now >= last_time + interval)
{
last_time = now;
eoDynUpdater::operator() ();
}
}
private :
const time_t interval;
@ -106,10 +106,10 @@ public :
void operator()(void)
{
if (++counter % interval == 0)
{
eoDynUpdater::operator() ();
}
if (++counter % interval == 0)
{
eoDynUpdater::operator() ();
}
}
private :
const unsigned interval;

View file

@ -20,7 +20,7 @@ void eoTimedStateSaver::operator()(void)
if (now >= last_time + interval)
{
last_time = now;
ostringstream os;
ostringstream os;
os << prefix << (now - first_time) << '.' << extension;
state.save(os.str());
}
@ -28,7 +28,7 @@ void eoTimedStateSaver::operator()(void)
void eoCountedStateSaver::doItNow(void)
{
ostringstream os;
ostringstream os;
os << prefix << counter << '.' << extension;
state.save(os.str());
}
@ -44,5 +44,3 @@ void eoCountedStateSaver::lastCall(void)
if (saveOnLastCall)
doItNow();
}

View file

@ -45,8 +45,8 @@ class eoUpdater : public eoF<void>
public:
virtual void lastCall() {}
virtual std::string className(void) const { return "eoUpdater"; }
template <class EOT>
template <class EOT>
eoUpdater& addTo(eoCheckPoint<EOT>& cp) { cp.add(*this); return *this; }
};
@ -149,8 +149,8 @@ public :
eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix = "state", std::string _extension = "sav", unsigned _counter = 0)
: state(_state), interval(_interval), counter(_counter),
saveOnLastCall(true),
prefix(_prefix), extension(_extension) {}
saveOnLastCall(true),
prefix(_prefix), extension(_extension) {}
virtual void lastCall(void);
void operator()(void);

View file

@ -95,7 +95,7 @@ bool testDirRes(std::string _dirName, bool _erase=true)
return true;
}
// else
if (_erase) // OK to erase
if (_erase) // OK to erase
{
s = string("/bin/rm ")+ _dirName + "/*";
int res = system(s.c_str());

View file

@ -29,14 +29,14 @@
int Check( PCom *com )
{
if( ! com ) {
fprintf( stderr, "PipeCom: Null pointer.\n" );
fflush( stderr );
return 0;
fprintf( stderr, "PipeCom: Null pointer.\n" );
fflush( stderr );
return 0;
}
if( kill( com->pid, 0 ) != 0 ) {
fprintf( stderr, "PipeCom: process doesn't exists.\n" );
fflush( stderr );
return 0;
fprintf( stderr, "PipeCom: process doesn't exists.\n" );
fflush( stderr );
return 0;
}
return 1;
}
@ -59,46 +59,46 @@ PCom * PipeComOpenArgv( char *prog, char *argv[] )
PCom * ret = NULL;
if( pipe( toFils ) < 0 ) {
perror( "PipeComOpen: Creating pipes" );
return ret;
perror( "PipeComOpen: Creating pipes" );
return ret;
}
if( pipe( toPere ) < 0 ) {
perror( "PipeComOpen: Creating pipes" );
return ret;
perror( "PipeComOpen: Creating pipes" );
return ret;
}
switch( (sonPid = vfork()) ) {
case -1:
perror("PipeComOpen: fork failed" );
return ret;
break;
perror("PipeComOpen: fork failed" );
return ret;
break;
case 0:
/* --- Here's the son --- */
/* --- replace old stdin --- */
if( dup2( toFils[0], fileno(stdin) ) < 0 ) {
perror( "PipeComOpen(son): could not connect" );
exit( -1 );
/* --- AVOIR: kill my father --- */
}
if( dup2( toPere[1], fileno(stdout) ) < 0 ) {
perror( "PipeComOpen(son): could not connect" );
exit( -1 );
}
if( execvp( prog, argv ) < 0 ) {
perror( prog );
perror( "PipeComOpen: can't exec" );
exit(1);
}
break;
/* --- Here's the son --- */
/* --- replace old stdin --- */
if( dup2( toFils[0], fileno(stdin) ) < 0 ) {
perror( "PipeComOpen(son): could not connect" );
exit( -1 );
/* --- AVOIR: kill my father --- */
}
if( dup2( toPere[1], fileno(stdout) ) < 0 ) {
perror( "PipeComOpen(son): could not connect" );
exit( -1 );
}
if( execvp( prog, argv ) < 0 ) {
perror( prog );
perror( "PipeComOpen: can't exec" );
exit(1);
}
break;
default:
ret = (PCom *) malloc( sizeof(PCom) );
if( ! ret )
return NULL;
ret = (PCom *) malloc( sizeof(PCom) );
if( ! ret )
return NULL;
ret->fWrit = (FILE *)fdopen( toFils[1], "w" );
ret->fRead = (FILE *)fdopen( toPere[0], "r" );
ret->pid = sonPid;
ret->fWrit = (FILE *)fdopen( toFils[1], "w" );
ret->fRead = (FILE *)fdopen( toPere[0], "r" );
ret->pid = sonPid;
}
return ret;
}
@ -108,7 +108,7 @@ int PipeComSend( PCom *to, const char *line )
{
int nb = 0;
if( ! Check(to ) )
return nb;
return nb;
nb = fprintf( to->fWrit, line, 0 );
fflush( to->fWrit );
return nb;
@ -119,7 +119,7 @@ int PipeComSendn( PCom *to, const char *data, int n )
{
int nb = 0;
if( ! Check(to) )
return nb;
return nb;
nb = fwrite( data, 1, n, to->fWrit );
fflush( to->fWrit );
@ -130,14 +130,14 @@ int PipeComSendn( PCom *to, const char *data, int n )
int PipeComReceive( PCom *from, char *data, int max )
{
if( ! Check(from) )
return 0;
return 0;
if( ! data ) {
fprintf( stderr, "PipeComReceive: Invalid data pointer\n" );
fflush( stderr );
return 0;
}
if( fgets( data, max, from->fRead ) )
return strlen(data);
return strlen(data);
return 0;
}
@ -146,7 +146,7 @@ int PipeComReceive( PCom *from, char *data, int max )
int PipeComClose( PCom *to )
{
if( ! Check(to) )
return 0;
return 0;
fclose( to->fRead );
fclose( to->fWrit );
free( to );
@ -159,8 +159,8 @@ int PipeComWaitFor( PCom *from, char *what )
{
char buffer[256];
do {
if( ! PipeComReceive( from, buffer, 256 ) )
return 0;
if( ! PipeComReceive( from, buffer, 256 ) )
return 0;
} while( strcmp( buffer, what ) );
return 1;
}

View file

@ -146,14 +146,14 @@ It roulette_wheel(It _begin, It _end, double total, eoRng& _gen = rng)
double roulette = _gen.uniform(total);
if (roulette == 0.0) // covers the case where total==0.0
if (roulette == 0.0) // covers the case where total==0.0
return _begin + _gen.random(_end - _begin); // uniform choice
It i = _begin;
while (roulette > 0.0)
{
roulette -= static_cast<double>(*(i++));
roulette -= static_cast<double>(*(i++));
}
return --i;
@ -164,14 +164,14 @@ const EOT& roulette_wheel(const eoPop<EOT>& _pop, double total, eoRng& _gen = rn
{
double roulette = _gen.uniform(total);
if (roulette == 0.0) // covers the case where total==0.0
if (roulette == 0.0) // covers the case where total==0.0
return _pop[_gen.random(_pop.size())]; // uniform choice
typename eoPop<EOT>::const_iterator i = _pop.begin();
while (roulette > 0.0)
{
roulette -= static_cast<double>((i++)->fitness());
roulette -= static_cast<double>((i++)->fitness());
}
return *--i;
@ -182,14 +182,14 @@ EOT& roulette_wheel(eoPop<EOT>& _pop, double total, eoRng& _gen = rng)
{
float roulette = _gen.uniform(total);
if (roulette == 0.0) // covers the case where total==0.0
if (roulette == 0.0) // covers the case where total==0.0
return _pop[_gen.random(_pop.size())]; // uniform choice
typename eoPop<EOT>::iterator i = _pop.begin();
while (roulette > 0.0)
{
roulette -= static_cast<double>((i++)->fitness());
roulette -= static_cast<double>((i++)->fitness());
}
return *--i;
@ -205,7 +205,7 @@ It deterministic_tournament(It _begin, It _end, unsigned _t_size, eoRng& _gen =
It competitor = _begin + _gen.random(_end - _begin);
if (*best < *competitor)
{
{
best = competitor;
}
}