Removed "using namespace std" statements from header files in EO -- "std::" identifier were added where necessary.
This commit is contained in:
parent
6441ea1ec3
commit
86fa476c67
263 changed files with 2009 additions and 1976 deletions
|
|
@ -35,9 +35,9 @@
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // ostream, istream
|
||||
#include <iostream> // std::ostream, std::istream
|
||||
#include <functional> // bind2nd
|
||||
#include <string> // string
|
||||
#include <string> // std::string
|
||||
|
||||
#include <eoVector.h>
|
||||
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
/** eoBit: implementation of bitstring chromosome.
|
||||
\class eoBit eoBit.h ga/eoBit.h
|
||||
\ingroup bitstring
|
||||
* based on STL's vector<bool> specialization.
|
||||
* based on STL's std::vector<bool> specialization.
|
||||
*/
|
||||
template <class FitT> class eoBit: public eoVector<FitT, bool>
|
||||
{
|
||||
|
|
@ -58,45 +58,45 @@ template <class FitT> class eoBit: public eoVector<FitT, bool>
|
|||
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
* @param size Size of the binary string.
|
||||
* @param size Size of the binary std::string.
|
||||
*/
|
||||
eoBit(unsigned size = 0, bool value = false):
|
||||
eoVector<FitT, bool>(size, value) {}
|
||||
|
||||
/// My class name.
|
||||
virtual string className() const
|
||||
virtual std::string className() const
|
||||
{
|
||||
return "eoBit";
|
||||
}
|
||||
|
||||
/**
|
||||
* To print me on a stream.
|
||||
* @param os The ostream.
|
||||
* @param os The std::ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& os) const
|
||||
virtual void printOn(std::ostream& os) const
|
||||
{
|
||||
EO<FitT>::printOn(os);
|
||||
os << ' ';
|
||||
os << size() << ' ';
|
||||
copy(begin(), end(), ostream_iterator<bool>(os));
|
||||
std::copy(begin(), end(), std::ostream_iterator<bool>(os));
|
||||
}
|
||||
|
||||
/**
|
||||
* To read me from a stream.
|
||||
* @param is The istream.
|
||||
* @param is The std::istream.
|
||||
*/
|
||||
virtual void readFrom(istream& is)
|
||||
virtual void readFrom(std::istream& is)
|
||||
{
|
||||
EO<FitT>::readFrom(is);
|
||||
unsigned s;
|
||||
is >> s;
|
||||
string bits;
|
||||
std::string bits;
|
||||
is >> bits;
|
||||
if (is)
|
||||
{
|
||||
resize(bits.size());
|
||||
transform(bits.begin(), bits.end(), begin(),
|
||||
bind2nd(equal_to<char>(), '1'));
|
||||
std::transform(bits.begin(), bits.end(), begin(),
|
||||
std::bind2nd(std::equal_to<char>(), '1'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
CVS Info: $Date: 2001-09-08 05:59:17 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/ga/eoBitOp.h,v 1.14 2001-09-08 05:59:17 evomarc Exp $ $Author: evomarc $
|
||||
CVS Info: $Date: 2003-02-27 19:24:47 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/ga/eoBitOp.h,v 1.15 2003-02-27 19:24:47 okoenig Exp $ $Author: okoenig $
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ template<class Chrom> class eoOneBitFlip: public eoMonOp<Chrom>
|
|||
{
|
||||
public:
|
||||
/// The class name.
|
||||
virtual string className() const { return "eoOneBitFlip"; }
|
||||
virtual std::string className() const { return "eoOneBitFlip"; }
|
||||
|
||||
/**
|
||||
* Change one bit.
|
||||
|
|
@ -75,7 +75,7 @@ template<class Chrom> class eoDetBitFlip: public eoMonOp<Chrom>
|
|||
eoDetBitFlip(const unsigned& _num_bit = 1): num_bit(_num_bit) {}
|
||||
|
||||
/// The class name.
|
||||
virtual string className() const { return "eoDetBitFlip"; }
|
||||
virtual std::string className() const { return "eoDetBitFlip"; }
|
||||
|
||||
/**
|
||||
* Change num_bit bits.
|
||||
|
|
@ -112,7 +112,7 @@ template<class Chrom> class eoBitMutation: public eoMonOp<Chrom>
|
|||
rate(_rate), normalize(_normalize) {}
|
||||
|
||||
/// The class name.
|
||||
virtual string className() const { return "eoBitMutation"; }
|
||||
virtual std::string className() const { return "eoBitMutation"; }
|
||||
|
||||
/**
|
||||
* Mutate a chromosome.
|
||||
|
|
@ -147,7 +147,7 @@ template<class Chrom> class eoBitInversion: public eoMonOp<Chrom>
|
|||
{
|
||||
public:
|
||||
/// The class name.
|
||||
virtual string className() const { return "eoBitInversion"; }
|
||||
virtual std::string className() const { return "eoBitInversion"; }
|
||||
|
||||
/**
|
||||
* Inverts a range of bits in a binary chromosome.
|
||||
|
|
@ -158,9 +158,9 @@ template<class Chrom> class eoBitInversion: public eoMonOp<Chrom>
|
|||
|
||||
unsigned u1 = eo::rng.random(chrom.size() + 1) , u2;
|
||||
do u2 = eo::rng.random(chrom.size() + 1); while (u1 == u2);
|
||||
unsigned r1 = min(u1, u2), r2 = max(u1, u2);
|
||||
unsigned r1 = std::min(u1, u2), r2 = std::max(u1, u2);
|
||||
|
||||
reverse(chrom.begin() + r1, chrom.begin() + r2);
|
||||
std::reverse(chrom.begin() + r1, chrom.begin() + r2);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
@ -175,10 +175,10 @@ template<class Chrom> class eoBitNext: public eoMonOp<Chrom>
|
|||
{
|
||||
public:
|
||||
/// The class name.
|
||||
virtual string className() const { return "eoBitNext"; }
|
||||
virtual std::string className() const { return "eoBitNext"; }
|
||||
|
||||
/**
|
||||
* Change the bit string x to be x+1.
|
||||
* Change the bit std::string x to be x+1.
|
||||
* @param chrom The chromosome to be added one.
|
||||
*/
|
||||
bool operator()(Chrom& chrom)
|
||||
|
|
@ -209,10 +209,10 @@ template<class Chrom> class eoBitPrev: public eoMonOp<Chrom>
|
|||
{
|
||||
public:
|
||||
/// The class name.
|
||||
virtual string className() const { return "eoBitPrev"; }
|
||||
virtual std::string className() const { return "eoBitPrev"; }
|
||||
|
||||
/**
|
||||
* Change the bit string x to be x-1.
|
||||
* Change the bit std::string x to be x-1.
|
||||
* @param chrom The chromosome to be substracted one.
|
||||
*/
|
||||
bool operator()(Chrom& chrom)
|
||||
|
|
@ -243,7 +243,7 @@ template<class Chrom> class eo1PtBitXover: public eoQuadOp<Chrom>
|
|||
{
|
||||
public:
|
||||
/// The class name.
|
||||
virtual string className() const { return "eo1PtBitXover"; }
|
||||
virtual std::string className() const { return "eo1PtBitXover"; }
|
||||
|
||||
/**
|
||||
* 1-point crossover for binary chromosomes.
|
||||
|
|
@ -252,12 +252,12 @@ template<class Chrom> class eo1PtBitXover: public eoQuadOp<Chrom>
|
|||
*/
|
||||
bool operator()(Chrom& chrom1, Chrom& chrom2)
|
||||
{
|
||||
unsigned site = eo::rng.random(min(chrom1.size(), chrom2.size()));
|
||||
unsigned site = eo::rng.random(std::min(chrom1.size(), chrom2.size()));
|
||||
|
||||
if (!std::equal(chrom1.begin(), chrom1.begin()+site, chrom2.begin()))
|
||||
{
|
||||
|
||||
swap_ranges(chrom1.begin(), chrom1.begin() + site, chrom2.begin());
|
||||
std::swap_ranges(chrom1.begin(), chrom1.begin() + site, chrom2.begin());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -278,21 +278,21 @@ template<class Chrom> class eoUBitXover: public eoQuadOp<Chrom>
|
|||
eoUBitXover(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 "eoUBitXover"; }
|
||||
virtual std::string className() const { return "eoUBitXover"; }
|
||||
|
||||
/**
|
||||
* Uniform crossover for binary chromosomes.
|
||||
* @param chrom1 The first chromosome.
|
||||
* @param chrom2 The first chromosome.
|
||||
* @runtime_error if sizes don't match
|
||||
* @std::runtime_error if sizes don't match
|
||||
*/
|
||||
bool operator()(Chrom& chrom1, Chrom& chrom2)
|
||||
{
|
||||
if ( chrom1.size() != chrom2.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<chrom1.size(); i++)
|
||||
{
|
||||
|
|
@ -323,11 +323,11 @@ template<class Chrom> class eoNPtsBitXover: public eoQuadOp<Chrom>
|
|||
eoNPtsBitXover(const unsigned& _num_points = 2): num_points(_num_points)
|
||||
{
|
||||
if (num_points < 1)
|
||||
runtime_error("NxOver --> invalid number of points");
|
||||
std::runtime_error("NxOver --> invalid number of points");
|
||||
}
|
||||
|
||||
/// The class name.
|
||||
virtual string className() const { return "eoNPtsBitXover"; }
|
||||
virtual std::string className() const { return "eoNPtsBitXover"; }
|
||||
|
||||
/**
|
||||
* n-point crossover for binary chromosomes.
|
||||
|
|
@ -336,10 +336,10 @@ template<class Chrom> class eoNPtsBitXover: public eoQuadOp<Chrom>
|
|||
*/
|
||||
bool operator()(Chrom& chrom1, Chrom& chrom2)
|
||||
{
|
||||
unsigned max_size = min(chrom1.size(), chrom2.size());
|
||||
unsigned max_points = min(max_size - 1, num_points);
|
||||
unsigned max_size = std::min(chrom1.size(), chrom2.size());
|
||||
unsigned max_points = std::min(max_size - 1, num_points);
|
||||
|
||||
vector<bool> points(max_size, false);
|
||||
std::vector<bool> points(max_size, false);
|
||||
|
||||
// select ranges of bits to swap
|
||||
do {
|
||||
|
|
@ -362,7 +362,7 @@ template<class Chrom> class eoNPtsBitXover: public eoQuadOp<Chrom>
|
|||
change = !change;
|
||||
|
||||
if (change)
|
||||
swap(chrom1[bit], chrom2[bit]);
|
||||
std::swap(chrom1[bit], chrom2[bit]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -374,8 +374,8 @@ template<class Chrom> class eoNPtsBitXover: public eoQuadOp<Chrom>
|
|||
|
||||
|
||||
|
||||
/** eoBitGxOver --> Npts crossover when bistring considered
|
||||
as a string of binary-encoded genes (exchanges genes)
|
||||
/** eoBitGxOver --> Npts crossover when bistd::string considered
|
||||
as a std::string of binary-encoded genes (exchanges genes)
|
||||
Is anybody still using it apart from historians ??? :-)
|
||||
\class eoBitGxOver eoBitOp.h ga/eoBitOp.h
|
||||
\ingroup bitstring
|
||||
|
|
@ -389,13 +389,13 @@ template<class Chrom> class eoBitGxOver: public eoQuadOp<Chrom>
|
|||
gene_size(_gene_size), num_points(_num_points)
|
||||
{
|
||||
if (gene_size < 1)
|
||||
runtime_error("GxOver --> invalid gene size");
|
||||
std::runtime_error("GxOver --> invalid gene size");
|
||||
if (num_points < 1)
|
||||
runtime_error("GxOver --> invalid number of points");
|
||||
std::runtime_error("GxOver --> invalid number of points");
|
||||
}
|
||||
|
||||
/// The class name
|
||||
virtual string className() const { return "eoBitGxOver"; }
|
||||
virtual std::string className() const { return "eoBitGxOver"; }
|
||||
|
||||
/**
|
||||
* Gene crossover for binary chromosomes.
|
||||
|
|
@ -404,10 +404,10 @@ template<class Chrom> class eoBitGxOver: public eoQuadOp<Chrom>
|
|||
*/
|
||||
bool operator()(Chrom& chrom1, Chrom& chrom2)
|
||||
{
|
||||
unsigned max_genes = min(chrom1.size(), chrom2.size()) / gene_size;
|
||||
unsigned cut_genes = min(max_genes, num_points);
|
||||
unsigned max_genes = std::min(chrom1.size(), chrom2.size()) / gene_size;
|
||||
unsigned cut_genes = std::min(max_genes, num_points);
|
||||
|
||||
vector<bool> points(max_genes, false);
|
||||
std::vector<bool> points(max_genes, false);
|
||||
|
||||
// selects genes to swap
|
||||
do {
|
||||
|
|
@ -424,7 +424,7 @@ template<class Chrom> class eoBitGxOver: public eoQuadOp<Chrom>
|
|||
// swaps genes
|
||||
for (unsigned i = 0; i < points.size(); i++)
|
||||
if (points[i])
|
||||
swap_ranges(chrom1.begin() + i * gene_size,
|
||||
std::swap_ranges(chrom1.begin() + i * gene_size,
|
||||
chrom1.begin() + i * gene_size + gene_size,
|
||||
chrom2.begin() + i * gene_size);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,22 +50,22 @@ public:
|
|||
virtual ~eoBitOpFactory() {};
|
||||
//@}
|
||||
|
||||
/** Another factory method: creates an object from an istream, reading from
|
||||
it whatever is needed to create the object. Usually, the format for the istream will be\\
|
||||
/** Another factory method: creates an object from an std::istream, reading from
|
||||
it whatever is needed to create the object. Usually, the format for the std::istream will be\\
|
||||
objectType parameter1 parameter2 ... parametern\\
|
||||
If there are problems, an exception is raised; it should be caught at the
|
||||
If there are problems, an std::exception is raised; it should be caught at the
|
||||
upper level, because it might be something for that level\\
|
||||
At the same time, it catches exceptions thrown at a lower level, which will
|
||||
At the same time, it catches std::exceptions thrown at a lower level, which will
|
||||
indicate that whatever is in the stream is for this method to process
|
||||
@param _is an stream from where a single line will be read
|
||||
@throw runtime_exception if the object type is not known
|
||||
@throw runtime_std::exception if the object type is not known
|
||||
*/
|
||||
virtual eoOp<EOT>* make(istream& _is)
|
||||
virtual eoOp<EOT>* make(std::istream& _is)
|
||||
{
|
||||
eoOp<EOT> * opPtr = NULL;
|
||||
try {
|
||||
opPtr = eoFactory<EOT>::make( _is );
|
||||
} catch ( const string& objectTypeStr ) {
|
||||
} catch ( const std::string& objectTypeStr ) {
|
||||
if ( objectTypeStr == "eoBinBitFlip" ) {
|
||||
opPtr = new eoOneBitFlip<EOT>( );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
LR(0.0), nbBest(_nbBest), nbWorst(_nbWorst)
|
||||
{
|
||||
if (nbBest+nbWorst == 0)
|
||||
throw runtime_error("Must update either from best or from worst in eoPBILAdditive");
|
||||
throw std::runtime_error("Must update either from best or from worst in eoPBILAdditive");
|
||||
|
||||
if (_nbBest)
|
||||
{
|
||||
|
|
@ -79,10 +79,10 @@ public:
|
|||
{
|
||||
eoPBILDistrib<EOT>& distrib = dynamic_cast<eoPBILDistrib<EOT>&>(_distrib);
|
||||
|
||||
vector<double> & p = distrib.value();
|
||||
std::vector<double> & p = distrib.value();
|
||||
|
||||
unsigned i, popSize=_pop.size();
|
||||
vector<const EOT*> result;
|
||||
std::vector<const EOT*> result;
|
||||
_pop.sort(result); // is it necessary to sort the whole population?
|
||||
// but I'm soooooooo lazy !!!
|
||||
|
||||
|
|
|
|||
|
|
@ -34,21 +34,21 @@
|
|||
* It encodes a univariate distribution on the space of bitstrings,
|
||||
* i.e. one probability for each bit to be one
|
||||
*
|
||||
* It is an eoValueParam<vector<double> > :
|
||||
* the vector<double> stores the probabilities that each bit is 1
|
||||
* It is an eoValueParam<std::vector<double> > :
|
||||
* the std::vector<double> stores the probabilities that each bit is 1
|
||||
*
|
||||
* It is still pure virtual, as the update method needs to be specified
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoPBILDistrib : public eoDistribution<EOT>,
|
||||
public eoValueParam<vector<double> >
|
||||
public eoValueParam<std::vector<double> >
|
||||
{
|
||||
public:
|
||||
/** Ctor with size of genomes, and update parameters */
|
||||
eoPBILDistrib(unsigned _genomeSize) :
|
||||
eoDistribution<EOT>(),
|
||||
eoValueParam<vector<double> >(vector<double>(_genomeSize, 0.5), "Distribution"),
|
||||
eoValueParam<std::vector<double> >(std::vector<double>(_genomeSize, 0.5), "Distribution"),
|
||||
genomeSize(_genomeSize)
|
||||
{}
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ public:
|
|||
unsigned Size() {return genomeSize;}
|
||||
|
||||
/** printing... */
|
||||
virtual void printOn(ostream& os) const
|
||||
virtual void printOn(std::ostream& os) const
|
||||
{
|
||||
os << value().size() << ' ';
|
||||
for (unsigned i=0; i<value().size(); i++)
|
||||
|
|
@ -73,7 +73,7 @@ public:
|
|||
}
|
||||
|
||||
/** reading...*/
|
||||
virtual void readFrom(istream& is)
|
||||
virtual void readFrom(std::istream& is)
|
||||
{
|
||||
unsigned sz;
|
||||
is >> sz;
|
||||
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
unsigned int size() {return genomeSize;}
|
||||
|
||||
virtual string className() const {return "eoPBILDistrib";};
|
||||
virtual std::string className() const {return "eoPBILDistrib";};
|
||||
|
||||
private:
|
||||
unsigned genomeSize; // size of indis
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public:
|
|||
const EOT & best = _pop.best_element();
|
||||
eoPBILDistrib<EOT>& distrib = dynamic_cast<eoPBILDistrib<EOT>&>(_distrib);
|
||||
|
||||
vector<double> & p = distrib.value();
|
||||
std::vector<double> & p = distrib.value();
|
||||
|
||||
for (unsigned g=0; g<distrib.size(); g++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ eoPBILDistrib<EOT> & do_make_PBILdistrib(eoParser & _parser, eoState& _state, E
|
|||
// chromosome size:
|
||||
unsigned theSize;
|
||||
// but it might have been already read in the definition fo the performance
|
||||
eoParam* ptParam = _parser.getParamWithLongName(string("chromSize"));
|
||||
eoParam* ptParam = _parser.getParamWithLongName(std::string("chromSize"));
|
||||
|
||||
if (!ptParam) // not already defined: read it here
|
||||
{
|
||||
|
|
@ -72,7 +72,7 @@ eoPBILDistrib<EOT> & do_make_PBILdistrib(eoParser & _parser, eoState& _state, E
|
|||
_state.storeFunctor(ptDistrib);
|
||||
|
||||
// now the initialization: read a previously saved distribution, or random
|
||||
eoValueParam<string>& loadNameParam = _parser.createParam(string(""), "Load","A save file to restart from",'L', "Persistence" );
|
||||
eoValueParam<std::string>& loadNameParam = _parser.createParam(std::string(""), "Load","A save file to restart from",'L', "Persistence" );
|
||||
if (loadNameParam.value() != "") // something to load
|
||||
{
|
||||
// create another state for reading
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ eoDistribUpdater<EOT> & do_make_PBILupdate(eoParser & _parser, eoState& _state,
|
|||
// ast the moment, a single update rule is available
|
||||
// but at some point we'll have to choose among different rules
|
||||
|
||||
string UType = _parser.createParam(string("PBIL"), "updateRule", "Type of update rule (only PBIL additive at the moment)", 'U', "Algorithm").value();
|
||||
std::string UType = _parser.createParam(std::string("PBIL"), "updateRule", "Type of update rule (only PBIL additive at the moment)", 'U', "Algorithm").value();
|
||||
|
||||
unsigned nbBest = _parser.createParam(unsigned(1), "nbBest", "Number of good guys to update from", 'B', "Algorithm").value();
|
||||
double LRBest = _parser.createParam(0.1, "LRBest", "Learning Rate (from best guys)", 'L', "Algorithm").value();
|
||||
|
|
@ -61,7 +61,7 @@ eoDistribUpdater<EOT> & do_make_PBILupdate(eoParser & _parser, eoState& _state,
|
|||
// a pointer to choose among several possible types
|
||||
eoDistribUpdater<EOT> * ptUpdate;
|
||||
|
||||
if (UType == string("PBIL"))
|
||||
if (UType == std::string("PBIL"))
|
||||
{
|
||||
if ( (nbWorst == 0) && (nbBest == 1) )
|
||||
ptUpdate = new eoPBILOrg<EOT>(LRBest, tolerance);
|
||||
|
|
@ -69,7 +69,7 @@ eoDistribUpdater<EOT> & do_make_PBILupdate(eoParser & _parser, eoState& _state,
|
|||
ptUpdate = new eoPBILAdditive<EOT>(LRBest, nbBest, tolerance, LRWorst, nbWorst);
|
||||
}
|
||||
else
|
||||
throw runtime_error("Only PBIL additive update rule available at the moment");
|
||||
throw std::runtime_error("Only PBIL additive update rule available at the moment");
|
||||
|
||||
// done: don't forget to store the allocated pointers
|
||||
_state.storeFunctor(ptUpdate);
|
||||
|
|
|
|||
|
|
@ -72,10 +72,10 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
|
|||
// 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("Only SGA-like operator available right now\n");
|
||||
if (operatorParam.value() != std::string("SGA"))
|
||||
throw std::runtime_error("Only SGA-like operator available right now\n");
|
||||
|
||||
// now we read Pcross and Pmut,
|
||||
// the relative weights for all crossovers -> proportional choice
|
||||
|
|
@ -86,12 +86,12 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
|
|||
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
|
||||
/////////////////
|
||||
|
|
@ -99,23 +99,23 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
|
|||
eoValueParam<double>& onePointRateParam = _parser.createParam(double(1.0), "onePointRate", "Relative rate for one point crossover", '1', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (onePointRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid onePointRate");
|
||||
throw std::runtime_error("Invalid onePointRate");
|
||||
|
||||
eoValueParam<double>& twoPointsRateParam = _parser.createParam(double(1.0), "twoPointRate", "Relative rate for two point crossover", '2', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (twoPointsRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid twoPointsRate");
|
||||
throw std::runtime_error("Invalid twoPointsRate");
|
||||
|
||||
eoValueParam<double>& uRateParam = _parser.createParam(double(2.0), "uRate", "Relative rate for uniform crossover", 'U', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (uRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid uRate");
|
||||
throw std::runtime_error("Invalid uRate");
|
||||
|
||||
// minimum check
|
||||
bool bCross = true;
|
||||
if (onePointRateParam.value()+twoPointsRateParam.value()+uRateParam.value()==0)
|
||||
{
|
||||
cerr << "Warning: no crossover" << endl;
|
||||
std::cerr << "Warning: no crossover" << std::endl;
|
||||
bCross = false;
|
||||
}
|
||||
|
||||
|
|
@ -146,23 +146,23 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
|
|||
eoValueParam<double> & pMutPerBitParam = _parser.createParam(0.01, "pMutPerBit", "Probability of flipping 1 bit in bit-flip mutation", 'b', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (pMutPerBitParam.value() < 0) || (pMutPerBitParam.value() > 0.5) )
|
||||
throw runtime_error("Invalid pMutPerBit");
|
||||
throw std::runtime_error("Invalid pMutPerBit");
|
||||
|
||||
eoValueParam<double> & bitFlipRateParam = _parser.createParam(0.01, "bitFlipRate", "Relative rate for bit-flip mutation", 's', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (bitFlipRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid bitFlipRate");
|
||||
throw std::runtime_error("Invalid bitFlipRate");
|
||||
|
||||
eoValueParam<double> & oneBitRateParam = _parser.createParam(0.01, "oneBitRate", "Relative rate for deterministic bit-flip mutation", 'd', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (oneBitRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid oneBitRate");
|
||||
throw std::runtime_error("Invalid oneBitRate");
|
||||
|
||||
// minimum check
|
||||
bool bMut = true;
|
||||
if (bitFlipRateParam.value()+oneBitRateParam.value()==0)
|
||||
{
|
||||
cerr << "Warning: no mutation" << endl;
|
||||
std::cerr << "Warning: no mutation" << std::endl;
|
||||
bMut = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue