Removed "using namespace std" statements from header files in EO -- "std::" identifier were added where necessary.

This commit is contained in:
okoenig 2003-02-27 19:28:07 +00:00
commit 86fa476c67
263 changed files with 2009 additions and 1976 deletions

View file

@ -46,7 +46,7 @@
eoReal just an eoVector<double>
eoEsSimple + one self-adapting single sigma for all variables
eoEsStdev a whole vector of self-adapting sigmas
eoEsStdev a whole std::vector of self-adapting sigmas
eoEsFull a full self-adapting correlation matrix
@see eoReal eoEsSimple eoEsStdev eoEsFull eoInit
@ -84,7 +84,7 @@ private :
result.stdev = sigma;
}
// Adaptive mutation through a vector of sigmas
// Adaptive mutation through a std::vector of sigmas
void create_self_adapt(eoEsStdev<FitT>& result)
{
unsigned theSize = eoRealInitBounded<EOT>::size();

View file

@ -60,7 +60,7 @@ class eoEsFull : public eoVector<Fit, double>
os << ' ';
}
void readFrom(istream& is)
void readFrom(std::istream& is)
{
eoVector<Fit,double>::readFrom(is);
@ -76,8 +76,8 @@ class eoEsFull : public eoVector<Fit, double>
is >> correlations[i];
}
vector<double> stdevs;
vector<double> correlations;
std::vector<double> stdevs;
std::vector<double> correlations;
};

View file

@ -53,7 +53,7 @@ public:
crossObj(_crossObj), crossMut(_crossMut) {}
/// The class name. Used to display statistics
virtual string className() const { return "eoEsGlobalXover"; }
virtual std::string className() const { return "eoEsGlobalXover"; }
/// The TOTAL number of offspring (here = nb of parents modified in place)
unsigned max_production(void) { return 1; }

View file

@ -84,7 +84,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
virtual string className() const {return "eoESMutate";};
virtual std::string className() const {return "eoESMutate";};
/**
Mutate eoEsSimple
@ -191,7 +191,7 @@ public:
unsigned k, n1, n2;
double d1,d2, S, C;
vector<double> VarStp(_eo.size());
std::vector<double> VarStp(_eo.size());
for (i = 0; i < _eo.size(); i++)
VarStp[i] = _eo.stdevs[i] * rng.normal();
@ -230,7 +230,7 @@ public:
unsigned size = bounds.size();
TauLcl = _init.TauLcl();
TauLcl /= sqrt(2*(double) size);
cout << "Init<eoEsSimple>: tau local " << TauLcl << endl;
std::cout << "Init<eoEsSimple>: tau local " << TauLcl << std::endl;
}
void init(eoEsStdev<FitT>, eoEsMutationInit& _init)
@ -243,14 +243,14 @@ public:
// renormalization
TauLcl /= sqrt( 2.0 * sqrt( (double)size ) );
TauGlb /= sqrt( 2.0 * ( (double) size ) );
cout << "Init<eoStDev>: tau local " << TauLcl << " et global " << TauGlb << endl;
std::cout << "Init<eoStDev>: tau local " << TauLcl << " et global " << TauGlb << std::endl;
}
void init(eoEsFull<FitT>, eoEsMutationInit& _init)
{
init(eoEsStdev<FitT>(), _init);
TauBeta = _init.TauBeta();
cout << "Init<eoEsFull>: tau local " << TauLcl << " et global " << TauGlb << endl;
std::cout << "Init<eoEsFull>: tau local " << TauLcl << " et global " << TauGlb << std::endl;
}
// the data

View file

@ -61,7 +61,7 @@ public :
os << ' ' << stdev << ' ';
}
void readFrom(istream& is)
void readFrom(std::istream& is)
{
eoVector<Fit,double>::readFrom(is);

View file

@ -55,7 +55,7 @@ public:
crossObj(_crossObj), crossMut(_crossMut) {}
/// The class name. Used to display statistics
virtual string className() const { return "eoEsStandardXover"; }
virtual std::string className() const { return "eoEsStandardXover"; }
/**
* modifies one parents in the populator

View file

@ -57,7 +57,7 @@ class eoEsStdev : public eoVector<Fit, double>
os << ' ';
}
void readFrom(istream& is)
void readFrom(std::istream& is)
{
eoVector<Fit,double>::readFrom(is);
stdevs.resize(size());
@ -68,7 +68,7 @@ class eoEsStdev : public eoVector<Fit, double>
}
vector<double> stdevs;
std::vector<double> stdevs;
};
#endif

View file

@ -36,7 +36,7 @@
#include <utils/eoRealBounds.h>
//-----------------------------------------------------------------------------
/** Simple normal mutation of a vector of real values.
/** Simple normal mutation of a std::vector of real values.
* The stDev is fixed - but it is passed ans stored as a reference,
* to enable dynamic mutations (see eoOenFithMutation below).
*
@ -69,7 +69,7 @@ template<class EOT> class eoNormalMutation: public eoMonOp<EOT>
sigma(_sigma), bounds(_bounds), p_change(_p_change) {}
/** The class name */
virtual string className() const { return "eoNormalMutation"; }
virtual std::string className() const { return "eoNormalMutation"; }
/**
* Do it!
@ -129,11 +129,11 @@ public:
{
// minimal check
if (updateFactor>=1)
throw runtime_error("Update factor must be < 1 in eoOneFifthMutation");
throw std::runtime_error("Update factor must be < 1 in eoOneFifthMutation");
}
/** The class name */
virtual string className() const { return "eoOneFifthMutation"; }
virtual std::string className() const { return "eoOneFifthMutation"; }
/**
* Do it!
@ -192,9 +192,9 @@ private:
eoEvalFunc<EOT> & eval;
double threshold; // 1/5 !
double updateFactor ; // the multiplicative factor
vector<unsigned> nbMut; // total number of mutations per gen
vector<unsigned> nbSuccess; // number of successful mutations per gen
unsigned genIndex ; // current index in vectors (circular)
std::vector<unsigned> nbMut; // total number of mutations per gen
std::vector<unsigned> nbSuccess; // number of successful mutations per gen
unsigned genIndex ; // current index in std::vectors (circular)
};

View file

@ -26,8 +26,8 @@
//-----------------------------------------------------------------------------
#include <iostream> // ostream, istream
#include <string> // string
#include <iostream> // std::ostream, std::istream
#include <string> // std::string
#include <eoVector.h>
@ -40,13 +40,13 @@ template <class FitT> class eoReal: public eoVector<FitT, double>
/**
* (Default) Constructor.
* @param size Size of the vector
* @param size Size of the std::vector
*/
eoReal(unsigned size = 0, double value = 0.0):
eoVector<FitT, double>(size, value) {}
/// My class name.
virtual string className() const
virtual std::string className() const
{
return "eoReal";
}

View file

@ -1,7 +1,7 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoRealAtomXover.h : helper classes for vector<real> crossover
// eoRealAtomXover.h : helper classes for std::vector<real> crossover
// (c) Marc Schoenauer 2001
This library is free software; you can redistribute it and/or
@ -47,7 +47,7 @@ public:
eoDoubleExchange() {}
/// The class name. Used to display statistics
virtual string className() const { return "eoDoubleExchange"; }
virtual std::string className() const { return "eoDoubleExchange"; }
/**
Exchanges or not the values
@ -77,7 +77,7 @@ public:
eoDoubleIntermediate() {}
/// The class name. Used to display statistics
virtual string className() const { return "eoDoubleIntermediate"; }
virtual std::string className() const { return "eoDoubleIntermediate"; }
/**
Linear combination of both parents

View file

@ -33,7 +33,7 @@
#include <es/eoReal.h>
#include <utils/eoRealVectorBounds.h>
/** Simple initialization for any EOT that derives from vector<double>
/** Simple initialization for any EOT that derives from std::vector<double>
* uniformly in some bounds
*/
template <class EOT>
@ -44,7 +44,7 @@ class eoRealInitBounded : public eoInit<EOT>
eoRealInitBounded(eoRealVectorBounds & _bounds):bounds(_bounds)
{
if (!bounds.isBounded())
throw runtime_error("Needs bounded bounds to initialize a vector<double>");
throw std::runtime_error("Needs bounded bounds to initialize a std::vector<double>");
}
/** simply passes the argument to the uniform method of the bounds */

View file

@ -35,7 +35,7 @@
//-----------------------------------------------------------------------------
/** eoUniformMutation --> changes all values of the vector
/** eoUniformMutation --> changes all values of the std::vector
by uniform choice with range epsilon
with probability p_change per variable
\class eoUniformMutation eoRealOp.h Tutorial/eoRealOp.h
@ -81,13 +81,13 @@ template<class EOT> class eoUniformMutation: public eoMonOp<EOT>
* @param _p_change the VECTOR of probabilities for each coordinates
*/
eoUniformMutation(eoRealVectorBounds & _bounds,
const vector<double>& _epsilon,
const vector<double>& _p_change):
const std::vector<double>& _epsilon,
const std::vector<double>& _p_change):
homogeneous(false), bounds(_bounds), epsilon(_epsilon),
p_change(_p_change) {}
/// The class name.
virtual string className() const { return "eoUniformMutation"; }
virtual std::string className() const { return "eoUniformMutation"; }
/**
* Do it!
@ -109,7 +109,7 @@ template<class EOT> class eoUniformMutation: public eoMonOp<EOT>
{
// sanity check ?
if (_eo.size() != bounds.size())
throw runtime_error("Invalid size of indi in eoUniformMutation");
throw std::runtime_error("Invalid size of indi in eoUniformMutation");
for (unsigned lieu=0; lieu<_eo.size(); lieu++)
if (rng.flip(p_change[lieu]))
@ -118,9 +118,9 @@ template<class EOT> class eoUniformMutation: public eoMonOp<EOT>
double emin = _eo[lieu]-epsilon[lieu];
double emax = _eo[lieu]+epsilon[lieu];
if (bounds.isMinBounded(lieu))
emin = max(bounds.minimum(lieu), emin);
emin = std::max(bounds.minimum(lieu), emin);
if (bounds.isMaxBounded(lieu))
emax = min(bounds.maximum(lieu), emax);
emax = std::min(bounds.maximum(lieu), emax);
_eo[lieu] = emin + (emax-emin)*rng.uniform();
hasChanged = true;
}
@ -131,11 +131,11 @@ template<class EOT> class eoUniformMutation: public eoMonOp<EOT>
private:
bool homogeneous; // == no bounds passed in the ctor
eoRealVectorBounds & bounds;
vector<double> epsilon; // the ranges for mutation
vector<double> p_change; // the proba that each variable is modified
std::vector<double> epsilon; // the ranges for mutation
std::vector<double> p_change; // the proba that each variable is modified
};
/** eoDetUniformMutation --> changes exactly k values of the vector
/** eoDetUniformMutation --> changes exactly k values of the std::vector
by uniform choice with range epsilon
\class eoDetUniformMutation eoRealOp.h Tutorial/eoRealOp.h
\ingroup parameteric
@ -173,13 +173,13 @@ template<class EOT> class eoDetUniformMutation: public eoMonOp<EOT>
}
/**
* Constructor with bounds and full vector of epsilon
* Constructor with bounds and full std::vector of epsilon
* @param _bounds an eoRealVectorBounds that contains the bounds
* @param _epsilon the VECTOR of ranges for uniform mutation
* @param number of coordinate to modify
*/
eoDetUniformMutation(eoRealVectorBounds & _bounds,
const vector<double>& _epsilon,
const std::vector<double>& _epsilon,
const unsigned& _no = 1):
homogeneous(false), bounds(_bounds), epsilon(_epsilon), no(_no)
{
@ -190,7 +190,7 @@ template<class EOT> class eoDetUniformMutation: public eoMonOp<EOT>
}
/// The class name.
virtual string className() const { return "eoDetUniformMutation"; }
virtual std::string className() const { return "eoDetUniformMutation"; }
/**
* Do it!
@ -209,7 +209,7 @@ template<class EOT> class eoDetUniformMutation: public eoMonOp<EOT>
{
// sanity check ?
if (_eo.size() != bounds.size())
throw runtime_error("Invalid size of indi in eoDetUniformMutation");
throw std::runtime_error("Invalid size of indi in eoDetUniformMutation");
for (unsigned i=0; i<no; i++)
{
unsigned lieu = rng.random(_eo.size());
@ -219,9 +219,9 @@ template<class EOT> class eoDetUniformMutation: public eoMonOp<EOT>
double emin = _eo[lieu]-epsilon[lieu];
double emax = _eo[lieu]+epsilon[lieu];
if (bounds.isMinBounded(lieu))
emin = max(bounds.minimum(lieu), emin);
emin = std::max(bounds.minimum(lieu), emin);
if (bounds.isMaxBounded(lieu))
emax = min(bounds.maximum(lieu), emax);
emax = std::min(bounds.maximum(lieu), emax);
_eo[lieu] = emin + (emax-emin)*rng.uniform();
}
}
@ -231,7 +231,7 @@ template<class EOT> class eoDetUniformMutation: public eoMonOp<EOT>
private:
bool homogeneous; // == no bounds passed in the ctor
eoRealVectorBounds & bounds;
vector<double> epsilon; // the ranges of mutation
std::vector<double> epsilon; // the ranges of mutation
unsigned no;
};
@ -272,7 +272,7 @@ template<class EOT> class eoSegmentCrossover: public eoQuadOp<EOT>
bounds(_bounds), alpha(_alpha), range(1+2*_alpha) {}
/// The class name.
virtual string className() const { return "eoSegmentCrossover"; }
virtual std::string className() const { return "eoSegmentCrossover"; }
/**
* segment crossover - modifies both parents
@ -294,18 +294,18 @@ template<class EOT> class eoSegmentCrossover: public eoQuadOp<EOT>
r1=_eo1[i];
r2=_eo2[i];
if (r1 != r2) { // otherwise you'll get NAN's
double rmin = min(r1, r2);
double rmax = max(r1, r2);
double rmin = std::min(r1, r2);
double rmax = std::max(r1, r2);
double length = rmax - rmin;
if (bounds.isMinBounded(i))
{
alphaMin = max(alphaMin, (bounds.minimum(i)-rmin)/length);
alphaMax = min(alphaMax, (rmax-bounds.minimum(i))/length);
alphaMin = std::max(alphaMin, (bounds.minimum(i)-rmin)/length);
alphaMax = std::min(alphaMax, (rmax-bounds.minimum(i))/length);
}
if (bounds.isMaxBounded(i))
{
alphaMax = min(alphaMax, (bounds.maximum(i)-rmin)/length);
alphaMin = max(alphaMin, (rmax-bounds.maximum(i))/length);
alphaMax = std::min(alphaMax, (bounds.maximum(i)-rmin)/length);
alphaMin = std::max(alphaMin, (rmax-bounds.maximum(i))/length);
}
}
}
@ -350,7 +350,7 @@ template<class EOT> class eoHypercubeCrossover: public eoQuadOp<EOT>
bounds(eoDummyVectorNoBounds), alpha(_alpha), range(1+2*_alpha)
{
if (_alpha < 0)
throw runtime_error("BLX coefficient should be positive");
throw std::runtime_error("BLX coefficient should be positive");
}
/**
@ -366,11 +366,11 @@ template<class EOT> class eoHypercubeCrossover: public eoQuadOp<EOT>
bounds(_bounds), alpha(_alpha), range(1+2*_alpha)
{
if (_alpha < 0)
throw runtime_error("BLX coefficient should be positive");
throw std::runtime_error("BLX coefficient should be positive");
}
/// The class name.
virtual string className() const { return "eoHypercubeCrossover"; }
virtual std::string className() const { return "eoHypercubeCrossover"; }
/**
* hypercube crossover - modifies both parents
@ -402,8 +402,8 @@ template<class EOT> class eoHypercubeCrossover: public eoQuadOp<EOT>
r1=_eo1[i];
r2=_eo2[i];
if (r1 != r2) { // otherwise do nothing
double rmin = min(r1, r2);
double rmax = max(r1, r2);
double rmin = std::min(r1, r2);
double rmax = std::max(r1, r2);
// compute min and max for object variables
double objMin = -alpha * rmax + (1+alpha) * rmin;
@ -412,11 +412,11 @@ template<class EOT> class eoHypercubeCrossover: public eoQuadOp<EOT>
// first find the limits on the alpha's
if (bounds.isMinBounded(i))
{
objMin = max(objMin, bounds.minimum(i));
objMin = std::max(objMin, bounds.minimum(i));
}
if (bounds.isMaxBounded(i))
{
objMax = min(objMax, bounds.maximum(i));
objMax = std::min(objMax, bounds.maximum(i));
}
// then draw variables
double median = (objMin+objMax)/2.0; // uniform within bounds
@ -464,22 +464,22 @@ template<class EOT> class eoRealUXover: public eoQuadOp<EOT>
eoRealUXover(const float& _preference = 0.5): preference(_preference)
{
if ( (_preference <= 0.0) || (_preference >= 1.0) )
runtime_error("UxOver --> invalid preference");
std::runtime_error("UxOver --> invalid preference");
}
/// The class name.
virtual string className() const { return "eoRealUXover"; }
virtual std::string className() const { return "eoRealUXover"; }
/**
* Uniform crossover for real vectors
* Uniform crossover for real std::vectors
* @param _eo1 The first parent
* @param _eo2 The second parent
* @runtime_error if sizes don't match
* @std::runtime_error if sizes don't match
*/
bool operator()(EOT& _eo1, EOT& _eo2)
{
if ( _eo1.size() != _eo2.size())
runtime_error("UxOver --> chromosomes sizes don't match" );
std::runtime_error("UxOver --> chromosomes sizes don't match" );
bool changed = false;
for (unsigned int i=0; i<_eo1.size(); i++)
{

View file

@ -37,7 +37,7 @@
/*
* This fuction does the initialization of what's needed for a particular
* genotype (here, vector<double> == eoReal).
* genotype (here, std::vector<double> == eoReal).
* It could be here tempatied only on the fitness, as it can be used to evolve
* bitstrings with any fitness.
* However, for consistency reasons, it was finally chosen, as in
@ -76,7 +76,7 @@ eoEsChromInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)
// minimum check
if ( (sigmaParam.value() < 0) )
throw runtime_error("Invalid sigma");
throw std::runtime_error("Invalid sigma");
eoEsChromInit<EOT> * init =
new eoEsChromInit<EOT>(boundsParam.value(), sigmaParam.value());

View file

@ -70,11 +70,11 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
// First, decide whether the objective variables are bounded
eoValueParam<eoParamParamType>& boundsParam = _parser.createParam(eoParamParamType("(0,1)"), "objectBounds", "Bounds for variables (unbounded if absent)", 'B', "Genetic Operators");
// get initisalizer size == vector size
// get initisalizer size == std::vector size
// eoRealInitBounded<EOT> * realInit = (eoRealInitBounded<EOT>*)(&_init);
// unsigned vecSize = realInit->theBounds().size();
// get vector size: safer???
// get std::vector size: safer???
EOT eoTmp;
_init(eoTmp);
unsigned vecSize = eoTmp.size();
@ -86,10 +86,10 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
/////Warning: this code should probably be replaced by creating
///// some eoValueParam<eoRealVectorBounds> with specific implementation
//// in eoParser.cpp. At the moemnt, it is there (cf also make_genotype
eoParamParamType & ppBounds = boundsParam.value(); // pair<string,vector<string> >
// transform into a vector<double>
vector<double> v;
vector<string>::iterator it;
eoParamParamType & ppBounds = boundsParam.value(); // std::pair<std::string,std::vector<std::string> >
// transform into a std::vector<double>
std::vector<double> v;
std::vector<std::string>::iterator it;
for (it=ppBounds.second.begin(); it<ppBounds.second.end(); it++)
{
istrstream is(it->c_str());
@ -101,7 +101,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
if (v.size() == 2) // a min and a max for all variables
ptBounds = new eoRealVectorBounds(vecSize, v[0], v[1]);
else // no time now
throw runtime_error("Sorry, only unique bounds for all variables implemented at the moment. Come back later");
throw std::runtime_error("Sorry, only unique bounds for all variables implemented at the moment. Come back later");
// we need to give ownership of this pointer to somebody
/////////// end of temporary code
}
@ -113,10 +113,10 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
// while Maarten codes the full tree-structured general operator input
// BTW we must leave that simple version available somehow, as it is the one
// that 90% people use!
eoValueParam<string>& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Genetic Operators");
eoValueParam<std::string>& operatorParam = _parser.createParam(std::string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Genetic Operators");
if (operatorParam.value() != string("SGA"))
throw runtime_error("Sorry, only SGA-like operator available right now\n");
if (operatorParam.value() != std::string("SGA"))
throw std::runtime_error("Sorry, only SGA-like operator available right now\n");
// now we read Pcross and Pmut,
// the relative weights for all crossovers -> proportional choice
@ -127,12 +127,12 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Genetic Operators" );
// minimum check
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
throw runtime_error("Invalid pCross");
throw std::runtime_error("Invalid pCross");
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Genetic Operators" );
// minimum check
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
throw runtime_error("Invalid pMut");
throw std::runtime_error("Invalid pMut");
// the crossovers
/////////////////
@ -140,18 +140,18 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
eoValueParam<double>& segmentRateParam = _parser.createParam(double(1.0), "segmentRate", "Relative rate for segment crossover", 's', "Genetic Operators" );
// minimum check
if ( (segmentRateParam.value() < 0) )
throw runtime_error("Invalid segmentRate");
throw std::runtime_error("Invalid segmentRate");
eoValueParam<double>& arithmeticRateParam = _parser.createParam(double(2.0), "arithmeticRate", "Relative rate for arithmetic crossover", 'A', "Genetic Operators" );
// minimum check
if ( (arithmeticRateParam.value() < 0) )
throw runtime_error("Invalid arithmeticRate");
throw std::runtime_error("Invalid arithmeticRate");
// minimum check
bool bCross = true;
if (segmentRateParam.value()+arithmeticRateParam.value()==0)
{
cerr << "Warning: no crossover" << endl;
std::cerr << "Warning: no crossover" << std::endl;
bCross = false;
}
@ -181,37 +181,37 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
eoValueParam<double> & epsilonParam = _parser.createParam(0.01, "epsilon", "Half-size of interval for Uniform Mutation", 'e', "Genetic Operators" );
// minimum check
if ( (epsilonParam.value() < 0) )
throw runtime_error("Invalid epsilon");
throw std::runtime_error("Invalid epsilon");
eoValueParam<double> & uniformMutRateParam = _parser.createParam(1.0, "uniformMutRate", "Relative rate for uniform mutation", 'u', "Genetic Operators" );
// minimum check
if ( (uniformMutRateParam.value() < 0) )
throw runtime_error("Invalid uniformMutRate");
throw std::runtime_error("Invalid uniformMutRate");
eoValueParam<double> & detMutRateParam = _parser.createParam(1.0, "detMutRate", "Relative rate for deterministic uniform mutation", 'd', "Genetic Operators" );
// minimum check
if ( (detMutRateParam.value() < 0) )
throw runtime_error("Invalid detMutRate");
throw std::runtime_error("Invalid detMutRate");
eoValueParam<double> & normalMutRateParam = _parser.createParam(1.0, "normalMutRate", "Relative rate for Gaussian mutation", 'd', "Genetic Operators" );
// minimum check
if ( (normalMutRateParam.value() < 0) )
throw runtime_error("Invalid normalMutRate");
throw std::runtime_error("Invalid normalMutRate");
// and the sigma
eoValueParam<double> & sigmaParam = _parser.createParam(1.0, "sigma", "Sigma (fixed) for Gaussian mutation", 'S', "Genetic Operators" );
// minimum check
if ( (sigmaParam.value() < 0) )
throw runtime_error("Invalid sigma");
throw std::runtime_error("Invalid sigma");
// minimum check
bool bMut = true;
if (uniformMutRateParam.value()+detMutRateParam.value()+normalMutRateParam.value()==0)
{
cerr << "Warning: no mutation" << endl;
std::cerr << "Warning: no mutation" << std::endl;
bMut = false;
}
if (!bCross && !bMut)
throw runtime_error("No operator called in SGA operator definition!!!");
throw std::runtime_error("No operator called in SGA operator definition!!!");
// Create the CombinedMonOp
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;

View file

@ -70,17 +70,17 @@
template <class EOT>
eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<EOT>& _init)
{
// get vector size
// get std::vector size
unsigned vecSize = _init.size();
// First, decide whether the objective variables are bounded
eoValueParam<eoRealVectorBounds>& boundsParam = _parser.createParam(eoRealVectorBounds(vecSize,eoDummyRealNoBounds), "objectBounds", "Bounds for variables", 'B', "Variation Operators");
// now we read Pcross and Pmut,
eoValueParam<string>& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
eoValueParam<std::string>& operatorParam = _parser.createParam(std::string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
if (operatorParam.value() != string("SGA"))
throw runtime_error("Sorry, only SGA-like operator available right now\n");
if (operatorParam.value() != std::string("SGA"))
throw std::runtime_error("Sorry, only SGA-like operator available right now\n");
// now we read Pcross and Pmut,
// and create the eoGenOp that is exactly
@ -89,21 +89,21 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
eoValueParam<double>& pCrossParam = _parser.createParam(1.0, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
// minimum check
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
throw runtime_error("Invalid pCross");
throw std::runtime_error("Invalid pCross");
eoValueParam<double>& pMutParam = _parser.createParam(1.0, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
// minimum check
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
throw runtime_error("Invalid pMut");
throw std::runtime_error("Invalid pMut");
// crossover
/////////////
// ES crossover
eoValueParam<string>& crossTypeParam = _parser.createParam(string("global"), "crossType", "Type of ES recombination (global or standard)", 'C', "Variation Operators");
eoValueParam<std::string>& crossTypeParam = _parser.createParam(std::string("global"), "crossType", "Type of ES recombination (global or standard)", 'C', "Variation Operators");
eoValueParam<string>& crossObjParam = _parser.createParam(string("discrete"), "crossObj", "Recombination of object variables (discrete, intermediate or none)", 'O', "Variation Operators");
eoValueParam<string>& crossStdevParam = _parser.createParam(string("intermediate"), "crossStdev", "Recombination of mutation strategy parameters (intermediate, discrete or none)", 'S', "Variation Operators");
eoValueParam<std::string>& crossObjParam = _parser.createParam(std::string("discrete"), "crossObj", "Recombination of object variables (discrete, intermediate or none)", 'O', "Variation Operators");
eoValueParam<std::string>& crossStdevParam = _parser.createParam(std::string("intermediate"), "crossStdev", "Recombination of mutation strategy parameters (intermediate, discrete or none)", 'S', "Variation Operators");
// The pointers: first the atom Xover
eoBinOp<double> *ptObjAtomCross = NULL;
@ -112,33 +112,33 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
eoGenOp<EOT> *ptCross;
// check for the atom Xovers
if (crossObjParam.value() == string("discrete"))
if (crossObjParam.value() == std::string("discrete"))
ptObjAtomCross = new eoDoubleExchange;
else if (crossObjParam.value() == string("intermediate"))
else if (crossObjParam.value() == std::string("intermediate"))
ptObjAtomCross = new eoDoubleIntermediate;
else if (crossObjParam.value() == string("none"))
else if (crossObjParam.value() == std::string("none"))
ptObjAtomCross = new eoBinCloneOp<double>;
else throw runtime_error("Invalid Object variable crossover type");
else throw std::runtime_error("Invalid Object variable crossover type");
if (crossStdevParam.value() == string("discrete"))
if (crossStdevParam.value() == std::string("discrete"))
ptStdevAtomCross = new eoDoubleExchange;
else if (crossStdevParam.value() == string("intermediate"))
else if (crossStdevParam.value() == std::string("intermediate"))
ptStdevAtomCross = new eoDoubleIntermediate;
else if (crossStdevParam.value() == string("none"))
else if (crossStdevParam.value() == std::string("none"))
ptStdevAtomCross = new eoBinCloneOp<double>;
else throw runtime_error("Invalid mutation strategy parameter crossover type");
else throw std::runtime_error("Invalid mutation strategy parameter crossover type");
// and build the indi Xover
if (crossTypeParam.value() == string("global"))
if (crossTypeParam.value() == std::string("global"))
ptCross = new eoEsGlobalXover<EOT>(*ptObjAtomCross, *ptStdevAtomCross);
else if (crossTypeParam.value() == string("standard"))
else if (crossTypeParam.value() == std::string("standard"))
{ // using a standard eoBinOp, but wrap it into an eoGenOp
eoBinOp<EOT> & crossTmp = _state.storeFunctor(
new eoEsStandardXover<EOT>(*ptObjAtomCross, *ptStdevAtomCross)
);
ptCross = new eoBinGenOp<EOT>(crossTmp);
}
else throw runtime_error("Invalide Object variable crossover type");
else throw std::runtime_error("Invalide Object variable crossover type");
// now that everything is OK, DON'T FORGET TO STORE MEMORY
_state.storeFunctor(ptObjAtomCross);

View file

@ -67,7 +67,7 @@
template <class EOT>
eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<EOT>& _init)
{
// get vector size
// get std::vector size
unsigned vecSize = _init.size();
// First, decide whether the objective variables are bounded
@ -77,10 +77,10 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
// while Maarten codes the full tree-structured general operator input
// BTW we must leave that simple version available somehow, as it is the one
// that 90% people use!
eoValueParam<string>& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
eoValueParam<std::string>& operatorParam = _parser.createParam(std::string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
if (operatorParam.value() != string("SGA"))
throw runtime_error("Sorry, only SGA-like operator available right now\n");
if (operatorParam.value() != std::string("SGA"))
throw std::runtime_error("Sorry, only SGA-like operator available right now\n");
// now we read Pcross and Pmut,
// the relative weights for all crossovers -> proportional choice
@ -91,12 +91,12 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
// minimum check
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
throw runtime_error("Invalid pCross");
throw std::runtime_error("Invalid pCross");
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
// minimum check
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
throw runtime_error("Invalid pMut");
throw std::runtime_error("Invalid pMut");
// the crossovers
/////////////////
@ -104,29 +104,29 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
eoValueParam<double>& alphaParam = _parser.createParam(double(0.0), "alpha", "Bound for factor of linear recombinations", 'a', "Variation Operators" );
// minimum check
if ( (alphaParam.value() < 0) )
throw runtime_error("Invalid BLX coefficient alpha");
throw std::runtime_error("Invalid BLX coefficient alpha");
eoValueParam<double>& segmentRateParam = _parser.createParam(double(1.0), "segmentRate", "Relative rate for segment crossover", 's', "Variation Operators" );
// minimum check
if ( (segmentRateParam.value() < 0) )
throw runtime_error("Invalid segmentRate");
throw std::runtime_error("Invalid segmentRate");
eoValueParam<double>& hypercubeRateParam = _parser.createParam(double(1.0), "hypercubeRate", "Relative rate for hypercube crossover", 'A', "Variation Operators" );
// minimum check
if ( (hypercubeRateParam.value() < 0) )
throw runtime_error("Invalid hypercubeRate");
throw std::runtime_error("Invalid hypercubeRate");
eoValueParam<double>& uxoverRateParam = _parser.createParam(double(1.0), "uxoverRate", "Relative rate for uniform crossover", 'A', "Variation Operators" );
// minimum check
if ( (uxoverRateParam.value() < 0) )
throw runtime_error("Invalid uxoverRate");
throw std::runtime_error("Invalid uxoverRate");
// minimum check
bool bCross = true;
if (segmentRateParam.value()+hypercubeRateParam.value()+uxoverRateParam.value()==0)
{
cerr << "Warning: no crossover" << endl;
std::cerr << "Warning: no crossover" << std::endl;
bCross = false;
}
@ -161,22 +161,22 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
eoValueParam<double> & epsilonParam = _parser.createParam(0.01, "epsilon", "Half-size of interval for Uniform Mutation", 'e', "Variation Operators" );
// minimum check
if ( (epsilonParam.value() < 0) )
throw runtime_error("Invalid epsilon");
throw std::runtime_error("Invalid epsilon");
eoValueParam<double> & uniformMutRateParam = _parser.createParam(1.0, "uniformMutRate", "Relative rate for uniform mutation", 'u', "Variation Operators" );
// minimum check
if ( (uniformMutRateParam.value() < 0) )
throw runtime_error("Invalid uniformMutRate");
throw std::runtime_error("Invalid uniformMutRate");
eoValueParam<double> & detMutRateParam = _parser.createParam(1.0, "detMutRate", "Relative rate for deterministic uniform mutation", 'd', "Variation Operators" );
// minimum check
if ( (detMutRateParam.value() < 0) )
throw runtime_error("Invalid detMutRate");
throw std::runtime_error("Invalid detMutRate");
eoValueParam<double> & normalMutRateParam = _parser.createParam(1.0, "normalMutRate", "Relative rate for Gaussian mutation", 'd', "Variation Operators" );
// minimum check
if ( (normalMutRateParam.value() < 0) )
throw runtime_error("Invalid normalMutRate");
throw std::runtime_error("Invalid normalMutRate");
eoValueParam<double> & sigmaParam = _parser.createParam(0.3, "sigma", "Sigma (fixed) for Gaussian mutation", 's', "Variation Operators" );
@ -184,11 +184,11 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
bool bMut = true;
if (uniformMutRateParam.value()+detMutRateParam.value()+normalMutRateParam.value()==0)
{
cerr << "Warning: no mutation" << endl;
std::cerr << "Warning: no mutation" << std::endl;
bMut = false;
}
if (!bCross && !bMut)
throw runtime_error("No operator called in SGA operator definition!!!");
throw std::runtime_error("No operator called in SGA operator definition!!!");
// Create the CombinedMonOp
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;

View file

@ -25,7 +25,7 @@
//-----------------------------------------------------------------------------
/** This file contains all ***INSTANCIATED*** declarations of all components
* of the library for ***vector<RealValues>*** evolution inside EO.
* of the library for ***std::vector<RealValues>*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
*
* The corresponding ***INSTANCIATED*** definitions are contained in