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

@ -10,6 +10,8 @@
#include <eo> // all usefull eo stuff
#include "mastermind.h" // Chrom eoChromInit eoChromMutation eoChromXover eoChromEvaluator
using namespace std;
//-----------------------------------------------------------------------------
// global variables
//-----------------------------------------------------------------------------

View file

@ -23,7 +23,7 @@ typedef float phenotype;
// genotype
//-----------------------------------------------------------------------------
typedef vector<int> genotype;
typedef std::vector<int> genotype;
//-----------------------------------------------------------------------------
// Chrom
@ -67,12 +67,12 @@ phenotype eoChromEvaluator(const Chrom& chrom)
const unsigned default_length = 8;
const unsigned default_colors = 8;
const string default_solution = "01234567";
const std::string default_solution = "01234567";
unsigned num_colors;
void init_eoChromEvaluator(const unsigned& c, const unsigned& l, string s)
void init_eoChromEvaluator(const unsigned& c, const unsigned& l, std::string s)
{
num_colors = c;
@ -82,14 +82,14 @@ void init_eoChromEvaluator(const unsigned& c, const unsigned& l, string s)
// check length
if (l != default_length && s.size() != l)
{
cerr << "solution length != length" << endl;
std::cerr << "solution length != length" << std::endl;
exit(EXIT_FAILURE);
}
// check number of colors
if (c != default_colors && c < *max_element(s.begin(), s.end()) - '0')
{
cerr << "too high color number found!" << endl;
std::cerr << "too high color number found!" << std::endl;
exit(EXIT_FAILURE);
}
}
@ -160,12 +160,12 @@ class eoChromMutation: public eoMonOp<Chrom>
case 1:
{
// transposition
swap(chrom[position()], chrom[position()]);
std::swap(chrom[position()], chrom[position()]);
break;
}
default:
{
cerr << "unknown operator!" << endl;
std::cerr << "unknown operator!" << std::endl;
exit(EXIT_FAILURE);
break;
}

View file

@ -34,5 +34,5 @@ AC_TYPE_SIZE_T
dnl Checks for library functions.
AC_CHECK_FUNCS(select)
AC_OUTPUT(src/obsolete/Makefile doc/Makefile src/Makefile src/utils/Makefile src/other/Makefile win/Makefile src/gp/Makefile src/es/Makefile src/ga/Makefile src/do/Makefile test/Makefile contrib/Makefile Makefile app/Makefile app/gprop/Makefile app/mastermind/Makefile app/gpsymreg/Makefile)
AC_OUTPUT(src/obsolete/Makefile doc/Makefile src/Makefile src/utils/Makefile src/other/Makefile win/Makefile src/gp/Makefile src/es/Makefile src/ga/Makefile test/Makefile contrib/Makefile Makefile app/Makefile app/gprop/Makefile app/mastermind/Makefile app/gpsymreg/Makefile)

View file

@ -18,7 +18,7 @@
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
CVS Info: $Date: 2001-12-03 16:28:30 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/VirusOp.h,v 1.2 2001-12-03 16:28:30 evomarc Exp $ $Author: evomarc $
CVS Info: $Date: 2003-02-27 19:26:43 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/VirusOp.h,v 1.3 2003-02-27 19:26:43 okoenig Exp $ $Author: okoenig $
*/
#ifndef VirusOp_h
@ -28,7 +28,7 @@ CVS Info: $Date: 2001-12-03 16:28:30 $ $Header: /home/nojhan/dev/eodev/eodev_cvs
#include <iostream> // ostream, istream
#include <functional> // bind2nd
#include <string> // string
#include <string> // std::string
#include <utils/eoRNG.h>
#include "../contrib/MGE/eoVirus.h"
@ -40,7 +40,7 @@ template<class FitT>
class VirusBitFlip: public eoMonOp<eoVirus<FitT> > {
public:
/// The class name.
virtual string className() const { return "VirusBitFlip"; };
virtual std::string className() const { return "VirusBitFlip"; };
/**
* Change one bit.
@ -57,7 +57,7 @@ template<class FitT>
class VirusMutation: public eoMonOp<eoVirus<FitT> > {
public:
/// The class name.
virtual string className() const { return "VirusMutation"; };
virtual std::string className() const { return "VirusMutation"; };
/**
* Change one bit.
@ -65,7 +65,7 @@ class VirusMutation: public eoMonOp<eoVirus<FitT> > {
*/
bool operator()(eoVirus<FitT>& _chrom) {
// Search for virus bits
vector<unsigned> bitsSet;
std::vector<unsigned> bitsSet;
for ( unsigned i = 0; i < _chrom.size(); i ++ ) {
if ( _chrom.virusBit(i) ) {
bitsSet.push_back( i );
@ -90,7 +90,7 @@ class VirusShiftMutation: public eoMonOp<eoVirus<FitT> > {
VirusShiftMutation( ) {};
/// The class name.
virtual string className() const { return "VirusShiftMutation"; };
virtual std::string className() const { return "VirusShiftMutation"; };
/**
* Change one bit.
@ -125,7 +125,7 @@ template<class FitT>
class VirusTransmission: public eoBinOp<eoVirus<FitT> > {
public:
/// The class name.
virtual string className() const { return "VirusTransmission"; };
virtual std::string className() const { return "VirusTransmission"; };
/**
* Change one bit.

View file

@ -18,7 +18,7 @@
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
CVS Info: $Date: 2001-05-17 10:08:25 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/eoVirus.h,v 1.1 2001-05-17 10:08:25 jmerelo Exp $ $Author: jmerelo $
CVS Info: $Date: 2003-02-27 19:26:44 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/eoVirus.h,v 1.2 2003-02-27 19:26:44 okoenig Exp $ $Author: okoenig $
*/
#ifndef eoVirus_h
@ -28,7 +28,7 @@ CVS Info: $Date: 2001-05-17 10:08:25 $ $Header: /home/nojhan/dev/eodev/eodev_cvs
#include <iostream> // ostream, istream
#include <functional> // bind2nd
#include <string> // string
#include <string> // std::string
#include <ga/eoBit.h>
@ -49,13 +49,13 @@ template <class FitT> class eoVirus: public eoBit<FitT>
/**
* (Default) Constructor.
* @param size Size of the binary string.
* @param size Size of the binary std::string.
*/
eoVirus(unsigned _size = 0, bool _value = false, bool _virValue = false):
eoBit<FitT>(_size, _value), virus( _size, _virValue) {}
/// My class name.
virtual string className() const {
virtual std::string className() const {
return "eoVirus";
}
@ -78,33 +78,33 @@ template <class FitT> class eoVirus: public eoBit<FitT>
* To print me on a stream.
* @param os The 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));
cout << endl;
copy(virus.begin(), virus.end(), ostream_iterator<bool>(os));
std::copy(begin(), end(), std::ostream_iterator<bool>(os));
std::cout << std::endl;
std::copy(virus.begin(), virus.end(), std::ostream_iterator<bool>(os));
}
/**
* To read me from a stream.
* @param is The istream.
*/
virtual void readFrom(istream& is){
virtual void readFrom(std::istream& is){
eoBit<FitT>::readFrom(is);
unsigned s;
is >> s;
string bits;
std::string bits;
is >> bits;
if (is) {
virus.resize(bits.size());
transform(bits.begin(), bits.end(), virus.begin(),
bind2nd(equal_to<char>(), '1'));
std::transform(bits.begin(), bits.end(), virus.begin(),
std::bind2nd(std::equal_to<char>(), '1'));
}
}
private:
vector<bool> virus;
std::vector<bool> virus;
};
//-----------------------------------------------------------------------------

View file

@ -29,7 +29,7 @@
//-----------------------------------------------------------------------------
#include <iostream> // istream, ostream
#include <string> // para string
#include <std::string> // para std::string
using namespace std;
@ -71,7 +71,7 @@ class eoAged: public Object
it's got code as an example of implementation. Only "leaf" classes
can be non-virtual.
*/
virtual string className() const { return string("eoAged")+Object::className(); };
virtual std::string className() const { return std::string("eoAged")+Object::className(); };
/**
* Read object.

View file

@ -27,7 +27,7 @@
//-----------------------------------------------------------------------------
#include <stdexcept> // runtime_error
#include <stdexcept> // std::runtime_error
#include <eoObject.h> // eoObject
#include <eoPersistent.h> // eoPersistent
@ -59,7 +59,7 @@ public:
/// Return fitness value.
Fitness fitness() const {
if (invalid())
throw runtime_error("invalid fitness");
throw std::runtime_error("invalid fitness");
return repFitness;
}
@ -90,23 +90,23 @@ public:
//@{
/** Return the class id.
* @return the class name as a string
* @return the class name as a std::string
*/
virtual string className() const { return "EO"; }
virtual std::string className() const { return "EO"; }
/**
* Read object.\\
* Calls base class, just in case that one had something to do.
* The read and print methods should be compatible and have the same format.
* In principle, format is "plain": they just print a number
* @param _is a istream.
* @throw runtime_exception If a valid object can't be read.
* @param _is a std::istream.
* @throw runtime_std::exception If a valid object can't be read.
*/
virtual void readFrom(istream& _is) {
virtual void readFrom(std::istream& _is) {
// the new version of the reafFrom function.
// It can distinguish between valid and invalid fitness values.
string fitness_str;
std::string fitness_str;
int pos = _is.tellg();
_is >> fitness_str;
@ -124,9 +124,9 @@ public:
/**
* Write object. Called printOn since it prints the object _on_ a stream.
* @param _os A ostream.
* @param _os A std::ostream.
*/
virtual void printOn(ostream& _os) const {
virtual void printOn(std::ostream& _os) const {
// the latest version of the code. Very similar to the old code

View file

@ -30,7 +30,7 @@
#include <vector>
/**
Applies a unary function to a vector of things.
Applies a unary function to a std::vector of things.
*/
template <class EOT>
void apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)

View file

@ -77,40 +77,40 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
// the selection
eoValueParam<eoParamParamType>& selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection", "Selection: Roulette, Ranking(p,e), DetTour(T), StochTour(t), Sequential(ordered/unordered) or EliteSequentialSelect", 'S', "Evolution Engine");
eoParamParamType & ppSelect = selectionParam.value(); // pair<string,vector<string> >
eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> >
eoSelectOne<EOT>* select ;
if (ppSelect.first == string("DetTour"))
if (ppSelect.first == std::string("DetTour"))
{
unsigned detSize;
if (!ppSelect.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to DetTour, using 2" << endl;
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
detSize = 2;
// put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(string("2"));
ppSelect.second.push_back(std::string("2"));
}
else // parameter passed by user as DetTour(T)
detSize = atoi(ppSelect.second[0].c_str());
select = new eoDetTournamentSelect<EOT>(detSize);
}
else if (ppSelect.first == string("StochTour"))
else if (ppSelect.first == std::string("StochTour"))
{
double p;
if (!ppSelect.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to StochTour, using 1" << endl;
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
p = 1;
// put back p in parameter for consistency (and status file)
ppSelect.second.push_back(string("1"));
ppSelect.second.push_back(std::string("1"));
}
else // parameter passed by user as DetTour(T)
p = atof(ppSelect.second[0].c_str());
select = new eoStochTournamentSelect<EOT>(p);
}
else if (ppSelect.first == string("Ranking"))
else if (ppSelect.first == std::string("Ranking"))
{
double p,e;
if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent
@ -120,69 +120,69 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
}
else if (ppSelect.second.size()==1) // 1 parameter: pressure
{
cerr << "WARNING, no exponent to Ranking, using 1" << endl;
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
e = 1;
ppSelect.second.push_back(string("1"));
ppSelect.second.push_back(std::string("1"));
p = atof(ppSelect.second[0].c_str());
}
else // no parameters ... or garbage
{
cerr << "WARNING, no parameter to Ranking, using (2,1)" << endl;
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
p=2;
e=1;
// put back in parameter for consistency (and status file)
ppSelect.second.resize(2); // just in case
ppSelect.second[0] = (string("2"));
ppSelect.second[1] = (string("1"));
ppSelect.second[0] = (std::string("2"));
ppSelect.second[1] = (std::string("1"));
}
// check for authorized values
// pressure in (0,1]
if ( (p<=1) || (p>2) )
{
cerr << "WARNING, selective pressure must be in (1,2] in Ranking, using 2\n";
std::cerr << "WARNING, selective pressure must be in (1,2] in Ranking, using 2\n";
p=2;
ppSelect.second[0] = (string("2"));
ppSelect.second[0] = (std::string("2"));
}
// exponent >0
if (e<=0)
{
cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
e=1;
ppSelect.second[1] = (string("1"));
ppSelect.second[1] = (std::string("1"));
}
// now we're OK
eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) );
select = new eoRouletteWorthSelect<EOT>(p2w);
}
else if (ppSelect.first == string("Sequential")) // one after the other
else if (ppSelect.first == std::string("Sequential")) // one after the other
{
bool b;
if (ppSelect.second.size() == 0) // no argument -> default = ordered
{
b=true;
// put back in parameter for consistency (and status file)
ppSelect.second.push_back(string("ordered"));
ppSelect.second.push_back(std::string("ordered"));
}
else
b = !(ppSelect.second[0] == string("unordered"));
b = !(ppSelect.second[0] == std::string("unordered"));
select = new eoSequentialSelect<EOT>(b);
}
else if (ppSelect.first == string("EliteSequential")) // Best first, one after the other in random order afterwards
else if (ppSelect.first == std::string("EliteSequential")) // Best first, one after the other in random order afterwards
{
select = new eoEliteSequentialSelect<EOT>;
}
else if (ppSelect.first == string("Roulette")) // no argument (yet)
else if (ppSelect.first == std::string("Roulette")) // no argument (yet)
{
select = new eoProportionalSelect<EOT>;
}
else if (ppSelect.first == string("Random")) // no argument
else if (ppSelect.first == std::string("Random")) // no argument
{
select = new eoRandomSelect<EOT>;
}
else
{
string stmp = string("Invalid selection: ") + ppSelect.first;
throw runtime_error(stmp.c_str());
std::string stmp = std::string("Invalid selection: ") + ppSelect.first;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(select);
@ -228,7 +228,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
// first, separate G3 and MGG
// maybe one day we have a common class - but is it really necessary???
if (replacementParam.first == string("G3"))
if (replacementParam.first == std::string("G3"))
{
// reduce the parents: by default, survive parents = -2 === 2 parents die
eoHowMany surviveParents = _parser.createParam(eoHowMany(-2,false), "surviveParents", "Nb of surviving parents (percentage or absolute)", '\0', "Evolution Engine / Replacement").value();
@ -236,7 +236,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
ptReplace = new eoG3Replacement<EOT>(-surviveParents); // must receive nb of eliminated parets!
_state.storeFunctor(ptReplace);
}
else if (replacementParam.first == string("MGG"))
else if (replacementParam.first == std::string("MGG"))
{
float t;
unsigned tSize;
@ -245,10 +245,10 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
// the tournament size
if (!replacementParam.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to MGG replacement, using 2" << endl;
std::cerr << "WARNING, no parameter passed to MGG replacement, using 2" << std::endl;
tSize = 2;
// put back 2 in parameter for consistency (and status file)
replacementParam.second.push_back(string("2"));
replacementParam.second.push_back(std::string("2"));
}
else
{
@ -259,7 +259,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
}
else
{
throw runtime_error("Sorry, only deterministic tournament available at the moment");
throw std::runtime_error("Sorry, only deterministic tournament available at the moment");
}
}
ptReplace = new eoMGGReplacement<EOT>(-surviveParents, tSize);
@ -280,58 +280,58 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
double t;
// ---------- General
if (replacementParam.first == string("General"))
if (replacementParam.first == std::string("General"))
{
; // defaults OK
}
// ---------- ESComma
else if (replacementParam.first == string("ESComma"))
else if (replacementParam.first == std::string("ESComma"))
{
; // OK too
}
// ---------- ESPlus
else if (replacementParam.first == string("ESPlus"))
else if (replacementParam.first == std::string("ESPlus"))
{
surviveParents = eoHowMany(1.0);
}
// ---------- Generational
else if (replacementParam.first == string("Generational"))
else if (replacementParam.first == std::string("Generational"))
{
; // OK too (we should check nb of offspring)
}
// ---------- EP
else if (replacementParam.first == string("EP"))
else if (replacementParam.first == std::string("EP"))
{
if (!replacementParam.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to EP replacement, using 6" << endl;
std::cerr << "WARNING, no parameter passed to EP replacement, using 6" << std::endl;
// put back 6 in parameter for consistency (and status file)
replacementParam.second.push_back(string("6"));
replacementParam.second.push_back(std::string("6"));
}
// by coincidence, the syntax for the EP reducer is the same than here:
reduceFinalType = replacementParam;
surviveParents = eoHowMany(1.0);
}
// ---------- SSGA
else if (replacementParam.first == string("SSGA"))
else if (replacementParam.first == std::string("SSGA"))
{
if (!replacementParam.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to SSGA replacement, using 2" << endl;
std::cerr << "WARNING, no parameter passed to SSGA replacement, using 2" << std::endl;
// put back 2 in parameter for consistency (and status file)
replacementParam.second.push_back(string("2"));
reduceParentType = eoParamParamType(string("DetTour(2)"));
replacementParam.second.push_back(std::string("2"));
reduceParentType = eoParamParamType(std::string("DetTour(2)"));
}
else
{
t = atof(replacementParam.second[0].c_str());
if (t>=2)
{ // build the appropriate deafult value
reduceParentType = eoParamParamType(string("DetTour(") + replacementParam.second[0].c_str() + ")");
reduceParentType = eoParamParamType(std::string("DetTour(") + replacementParam.second[0].c_str() + ")");
}
else // check for [0.5,1] will be made in make_general_replacement
{ // build the appropriate deafult value
reduceParentType = eoParamParamType(string("StochTour(") + replacementParam.second[0].c_str() + ")");
reduceParentType = eoParamParamType(std::string("StochTour(") + replacementParam.second[0].c_str() + ")");
}
}
//
@ -340,7 +340,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
}
else // no replacement recognized
{
throw runtime_error("Invalid replacement type " + replacementParam.first);
throw std::runtime_error("Invalid replacement type " + replacementParam.first);
}
ptReplace = & make_general_replacement<EOT>(

View file

@ -47,7 +47,7 @@ class eoNDPlusReplacement : public eoReplacement<EOT>
public:
eoNDPlusReplacement(eoPerf2Worth<EOT, WorthT>& _perf2worth) : perf2worth(_perf2worth) {}
struct WorthPair : public pair<WorthT, const EOT*>
struct WorthPair : public std::pair<WorthT, const EOT*>
{
bool operator<(const WorthPair& other) const { return other.first < first; }
};
@ -96,14 +96,14 @@ template <class EOT>
eoAlgo<EOT> & do_make_algo_pareto(eoParser& _parser, eoState& _state, eoEvalFunc<EOT>& _eval, eoContinue<EOT>& _continue, eoGenOp<EOT>& _op)
{
// the selection
string & selStr = _parser.createParam(string("NSGA-II"), "selCrit", "Pareto Selection Criterion: NSGA, NSGA-II, ParetoRanking", 'S', "Evolution Engine").value();
std::string & selStr = _parser.createParam(std::string("NSGA-II"), "selCrit", "Pareto Selection Criterion: NSGA, NSGA-II, ParetoRanking", 'S', "Evolution Engine").value();
double nicheSize = _parser.createParam(1.0, "nicheSize", "Size of niche for NSGA-I", '\0', "Evolution Engine").value();
eoPerf2Worth<EOT, double> *p2w;
if ( (selStr == string("NSGA")) || (selStr == string("NSGA-I") ) )
if ( (selStr == std::string("NSGA")) || (selStr == std::string("NSGA-I") ) )
p2w = new eoNDSorting_I<EOT>(nicheSize);
else if (selStr == string("NSGA-II"))
else if (selStr == std::string("NSGA-II"))
p2w = new eoNDSorting_II<EOT>();
else if (selStr == string("ParetoRanking"))
else if (selStr == std::string("ParetoRanking"))
{
eoDominanceMap<EOT>& dominance = _state.storeFunctor(new eoDominanceMap<EOT>);
p2w = new eoParetoRanking<EOT>(dominance);
@ -116,64 +116,64 @@ eoAlgo<EOT> & do_make_algo_pareto(eoParser& _parser, eoState& _state, eoEvalFunc
// only the ranking is not re-implemented (yet?)
eoValueParam<eoParamParamType>& selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection", "Selection: Roulette, DetTour(T), StochTour(t) or Random", 'S', "Evolution Engine");
eoParamParamType & ppSelect = selectionParam.value(); // pair<string,vector<string> >
eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> >
eoSelectOne<EOT>* select ;
if (ppSelect.first == string("DetTour"))
if (ppSelect.first == std::string("DetTour"))
{
unsigned detSize;
if (!ppSelect.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to DetTour, using 2" << endl;
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
detSize = 2;
// put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(string("2"));
ppSelect.second.push_back(std::string("2"));
}
else // parameter passed by user as DetTour(T)
detSize = atoi(ppSelect.second[0].c_str());
select = new eoDetTournamentWorthSelect<EOT>(*p2w, detSize);
}
else if (ppSelect.first == string("StochTour"))
else if (ppSelect.first == std::string("StochTour"))
{
double p;
if (!ppSelect.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to StochTour, using 1" << endl;
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
p = 1;
// put back p in parameter for consistency (and status file)
ppSelect.second.push_back(string("1"));
ppSelect.second.push_back(std::string("1"));
}
else // parameter passed by user as DetTour(T)
p = atof(ppSelect.second[0].c_str());
select = new eoStochTournamentWorthSelect<EOT>(*p2w, p);
}
// else if (ppSelect.first == string("Sequential")) // one after the other
// else if (ppSelect.first == std::string("Sequential")) // one after the other
// {
// bool b;
// if (ppSelect.second.size() == 0) // no argument -> default = ordered
// {
// b=true;
// // put back in parameter for consistency (and status file)
// ppSelect.second.push_back(string("ordered"));
// ppSelect.second.push_back(std::string("ordered"));
// }
// else
// b = !(ppSelect.second[0] == string("unordered"));
// b = !(ppSelect.second[0] == std::string("unordered"));
// select = new eoSequentialWorthSelect<EOT>(b);
// }
else if (ppSelect.first == string("Roulette")) // no argument (yet)
else if (ppSelect.first == std::string("Roulette")) // no argument (yet)
{
select = new eoRouletteWorthSelect<EOT>(*p2w);
}
else if (ppSelect.first == string("Random")) // no argument, no perf2Worth
else if (ppSelect.first == std::string("Random")) // no argument, no perf2Worth
{
select = new eoRandomSelect<EOT>;
}
else
{
string stmp = string("Invalid selection: ") + ppSelect.first;
throw runtime_error(stmp.c_str());
std::string stmp = std::string("Invalid selection: ") + ppSelect.first;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(select);

View file

@ -76,40 +76,40 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
// the selection
eoValueParam<eoParamParamType>& selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection", "Selection: Roulette, Ranking(p,e), DetTour(T), StochTour(t) or Sequential(ordered/unordered)", 'S', "Evolution Engine");
eoParamParamType & ppSelect = selectionParam.value(); // pair<string,vector<string> >
eoParamParamType & ppSelect = selectionParam.value(); // std::pair<std::string,std::vector<std::string> >
eoSelectOne<EOT>* select ;
if (ppSelect.first == string("DetTour"))
if (ppSelect.first == std::string("DetTour"))
{
unsigned detSize;
if (!ppSelect.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to DetTour, using 2" << endl;
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
detSize = 2;
// put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(string("2"));
ppSelect.second.push_back(std::string("2"));
}
else // parameter passed by user as DetTour(T)
detSize = atoi(ppSelect.second[0].c_str());
select = new eoDetTournamentSelect<EOT>(detSize);
}
else if (ppSelect.first == string("StochTour"))
else if (ppSelect.first == std::string("StochTour"))
{
double p;
if (!ppSelect.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to StochTour, using 1" << endl;
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
p = 1;
// put back p in parameter for consistency (and status file)
ppSelect.second.push_back(string("1"));
ppSelect.second.push_back(std::string("1"));
}
else // parameter passed by user as DetTour(T)
p = atof(ppSelect.second[0].c_str());
select = new eoStochTournamentSelect<EOT>(p);
}
else if (ppSelect.first == string("Ranking"))
else if (ppSelect.first == std::string("Ranking"))
{
double p,e;
if (ppSelect.second.size()==2) // 2 parameters: pressure and exponent
@ -119,65 +119,65 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
}
else if (ppSelect.second.size()==1) // 1 parameter: pressure
{
cerr << "WARNING, no exponent to Ranking, using 1" << endl;
std::cerr << "WARNING, no exponent to Ranking, using 1" << std::endl;
e = 1;
ppSelect.second.push_back(string("1"));
ppSelect.second.push_back(std::string("1"));
p = atof(ppSelect.second[0].c_str());
}
else // no parameters ... or garbage
{
cerr << "WARNING, no parameter to Ranking, using (2,1)" << endl;
std::cerr << "WARNING, no parameter to Ranking, using (2,1)" << std::endl;
p=2;
e=1;
// put back in parameter for consistency (and status file)
ppSelect.second.resize(2); // just in case
ppSelect.second[0] = (string("2"));
ppSelect.second[1] = (string("1"));
ppSelect.second[0] = (std::string("2"));
ppSelect.second[1] = (std::string("1"));
}
// check for authorized values
// pressure in (0,1]
if ( (p<=1) || (p>2) )
{
cerr << "WARNING, selective pressure must be in (0,1] in Ranking, using 2\n";
std::cerr << "WARNING, selective pressure must be in (0,1] in Ranking, using 2\n";
p=2;
ppSelect.second[0] = (string("2"));
ppSelect.second[0] = (std::string("2"));
}
// exponent >0
if (e<=0)
{
cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
std::cerr << "WARNING, exponent must be positive in Ranking, using 1\n";
e=1;
ppSelect.second[1] = (string("1"));
ppSelect.second[1] = (std::string("1"));
}
// now we're OK
eoPerf2Worth<EOT> & p2w = _state.storeFunctor( new eoRanking<EOT>(p,e) );
select = new eoRouletteWorthSelect<EOT>(p2w);
}
else if (ppSelect.first == string("Sequential")) // one after the other
else if (ppSelect.first == std::string("Sequential")) // one after the other
{
bool b;
if (ppSelect.second.size() == 0) // no argument -> default = ordered
{
b=true;
// put back in parameter for consistency (and status file)
ppSelect.second.push_back(string("ordered"));
ppSelect.second.push_back(std::string("ordered"));
}
else
b = !(ppSelect.second[0] == string("unordered"));
b = !(ppSelect.second[0] == std::string("unordered"));
select = new eoSequentialSelect<EOT>(b);
}
else if (ppSelect.first == string("Roulette")) // no argument (yet)
else if (ppSelect.first == std::string("Roulette")) // no argument (yet)
{
select = new eoProportionalSelect<EOT>;
}
else if (ppSelect.first == string("Random")) // no argument
else if (ppSelect.first == std::string("Random")) // no argument
{
select = new eoRandomSelect<EOT>;
}
else
{
string stmp = string("Invalid selection: ") + ppSelect.first;
throw runtime_error(stmp.c_str());
std::string stmp = std::string("Invalid selection: ") + ppSelect.first;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(select);
@ -188,62 +188,62 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
// the replacement
eoValueParam<eoParamParamType>& replacementParam = _parser.createParam(eoParamParamType("Comma"), "replacement", "Replacement: Comma, Plus or EPTour(T), SSGAWorst, SSGADet(T), SSGAStoch(t)", 'R', "Evolution Engine");
eoParamParamType & ppReplace = replacementParam.value(); // pair<string,vector<string> >
eoParamParamType & ppReplace = replacementParam.value(); // std::pair<std::string,std::vector<std::string> >
eoReplacement<EOT>* replace ;
if (ppReplace.first == string("Comma")) // Comma == generational
if (ppReplace.first == std::string("Comma")) // Comma == generational
{
replace = new eoCommaReplacement<EOT>;
}
else if (ppReplace.first == string("Plus"))
else if (ppReplace.first == std::string("Plus"))
{
replace = new eoPlusReplacement<EOT>;
}
else if (ppReplace.first == string("EPTour"))
else if (ppReplace.first == std::string("EPTour"))
{
unsigned detSize;
if (!ppReplace.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to EPTour, using 6" << endl;
std::cerr << "WARNING, no parameter passed to EPTour, using 6" << std::endl;
detSize = 6;
// put back in parameter for consistency (and status file)
ppReplace.second.push_back(string("6"));
ppReplace.second.push_back(std::string("6"));
}
else // parameter passed by user as EPTour(T)
detSize = atoi(ppSelect.second[0].c_str());
replace = new eoEPReplacement<EOT>(detSize);
}
else if (ppReplace.first == string("SSGAWorst"))
else if (ppReplace.first == std::string("SSGAWorst"))
{
replace = new eoSSGAWorseReplacement<EOT>;
}
else if (ppReplace.first == string("SSGADet"))
else if (ppReplace.first == std::string("SSGADet"))
{
unsigned detSize;
if (!ppReplace.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to SSGADet, using 2" << endl;
std::cerr << "WARNING, no parameter passed to SSGADet, using 2" << std::endl;
detSize = 2;
// put back in parameter for consistency (and status file)
ppReplace.second.push_back(string("2"));
ppReplace.second.push_back(std::string("2"));
}
else // parameter passed by user as SSGADet(T)
detSize = atoi(ppSelect.second[0].c_str());
replace = new eoSSGADetTournamentReplacement<EOT>(detSize);
}
else if (ppReplace.first == string("SSGAStoch"))
else if (ppReplace.first == std::string("SSGAStoch"))
{
double p;
if (!ppReplace.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to SSGAStoch, using 1" << endl;
std::cerr << "WARNING, no parameter passed to SSGAStoch, using 1" << std::endl;
p = 1;
// put back in parameter for consistency (and status file)
ppReplace.second.push_back(string("1"));
ppReplace.second.push_back(std::string("1"));
}
else // parameter passed by user as SSGADet(T)
p = atof(ppSelect.second[0].c_str());
@ -252,8 +252,8 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
}
else
{
string stmp = string("Invalid replacement: ") + ppReplace.first;
throw runtime_error(stmp.c_str());
std::string stmp = std::string("Invalid replacement: ") + ppReplace.first;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(replace);

View file

@ -66,7 +66,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
checkpoint->add(*generationCounter);
// dir for DISK output
eoValueParam<string>& dirNameParam = _parser.createParam(string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk");
eoValueParam<std::string>& dirNameParam = _parser.createParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk");
// shoudl we empty it if exists
eoValueParam<bool>& eraseParam = _parser.createParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk");
bool dirOK = false; // not tested yet
@ -79,9 +79,9 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
*
* eoBestFitnessStat : best value in pop - type EOT::Fitness
* eoAverageStat : average value in pop - type EOT::Fitness
* eoSecondMomentStat: average + stdev - type pair<double, double>
* eoSortedPopStat : whole population - type string (!!)
* eoScalarFitnessStat: the fitnesses - type vector<double>
* eoSecondMomentStat: average + stdev - type std::pair<double, double>
* eoSortedPopStat : whole population - type std::string (!!)
* eoScalarFitnessStat: the fitnesses - type std::vector<double>
*/
// Best fitness in population
@ -188,9 +188,9 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
if (fileBestParam.value()) // A file monitor for best & secondMoment
{
#ifdef _MSVC
string stmp = dirNameParam.value() + "\best.xg";
std::string stmp = dirNameParam.value() + "\best.xg";
#else
string stmp = dirNameParam.value() + "/best.xg";
std::string stmp = dirNameParam.value() + "/best.xg";
#endif
eoFileMonitor *fileMonitor = new eoFileMonitor(stmp);
// save and give to checkpoint
@ -201,7 +201,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
fileMonitor->add(_eval);
if (tCounter) // we want the time as well
{
// cout << "On met timecounter\n";
// std::cout << "On met timecounter\n";
fileMonitor->add(*tCounter);
}
fileMonitor->add(*bestStat);
@ -211,7 +211,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
#if !defined(NO_GNUPLOT)
if (plotBestParam.value()) // an eoGnuplot1DMonitor for best & average
{
string stmp = dirNameParam.value() + "/gnu_best.xg";
std::string stmp = dirNameParam.value() + "/gnu_best.xg";
eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>());
// save and give to checkpoint
_state.storeFunctor(gnuMonitor);
@ -236,7 +236,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
// a gnuplot-based monitor for snapshots: needs a dir name
eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value());
_state.storeFunctor(fitSnapshot);
// add any stat that is a vector<double> to it
// add any stat that is a std::vector<double> to it
fitSnapshot->add(*fitStat);
// and of course add it to the checkpoint
checkpoint->add(*fitSnapshot);
@ -259,9 +259,9 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
#ifdef _MSVC
string stmp = dirNameParam.value() + "\generations";
std::string stmp = dirNameParam.value() + "\generations";
#else
string stmp = dirNameParam.value() + "/generations";
std::string stmp = dirNameParam.value() + "/generations";
#endif
eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
_state.storeFunctor(stateSaver1);
@ -277,9 +277,9 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
#ifdef _MSVC
string stmp = dirNameParam.value() + "\time";
std::string stmp = dirNameParam.value() + "\time";
#else
string stmp = dirNameParam.value() + "/time";
std::string stmp = dirNameParam.value() + "/time";
#endif
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
_state.storeFunctor(stateSaver2);

View file

@ -62,7 +62,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
_state.storeFunctor(increment);
// dir for DISK output
eoValueParam<string>& dirNameParam = _parser.createParam(string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk");
eoValueParam<std::string>& dirNameParam = _parser.createParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk");
// shoudl we empty it if exists
eoValueParam<bool>& eraseParam = _parser.createParam(false, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk");
bool dirOK = false; // not tested yet
@ -75,9 +75,9 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
*
* eoBestFitnessStat : best value in pop - type EOT::Fitness
* eoAverageStat : average value in pop - type EOT::Fitness
* eoSecondMomentStat: average + stdev - type pair<double, double>
* eoSortedPopStat : whole population - type string (!!)
* eoScalarFitnessStat: the fitnesses - type vector<double>
* eoSecondMomentStat: average + stdev - type std::pair<double, double>
* eoSortedPopStat : whole population - type std::string (!!)
* eoScalarFitnessStat: the fitnesses - type std::vector<double>
* eoDFCSTat : FDC wrt best in pop or absolute best - type double
* requires an eoDistance. See eoFDCStat.h
* also computes all elements for the FDC scatter plot
@ -199,7 +199,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
if (fileBestParam.value()) // A file monitor for best & secondMoment
{
string stmp = dirNameParam.value() + "/best.xg";
std::string stmp = dirNameParam.value() + "/best.xg";
eoFileMonitor *fileMonitor = new eoFileMonitor(stmp);
// save and give to checkpoint
_state.storeFunctor(fileMonitor);
@ -213,7 +213,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
if (plotBestParam.value()) // an eoGnuplot1DMonitor for best & average
{
string stmp = dirNameParam.value() + "_gnu_best.xg";
std::string stmp = dirNameParam.value() + "_gnu_best.xg";
eoGnuplot1DMonitor *gnuMonitor = new eoGnuplot1DMonitor(stmp,minimizing_fitness<EOT>());
// save and give to checkpoint
_state.storeFunctor(gnuMonitor);
@ -250,7 +250,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
// a gnuplot-based monitor for snapshots: needs a dir name
eoGnuplot1DSnapshot *fitSnapshot = new eoGnuplot1DSnapshot(dirNameParam.value());
_state.storeFunctor(fitSnapshot);
// add any stat that is a vector<double> to it
// add any stat that is a std::vector<double> to it
fitSnapshot->add(*fitStat);
// and of course add it to the checkpoint
checkpoint->add(*fitSnapshot);
@ -271,7 +271,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
string stmp = dirNameParam.value() + "/generations";
std::string stmp = dirNameParam.value() + "/generations";
eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
_state.storeFunctor(stateSaver1);
checkpoint->add(*stateSaver1);
@ -285,7 +285,7 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
if (! dirOK )
dirOK = testDirRes(dirNameParam.value(), eraseParam.value()); // TRUE
string stmp = dirNameParam.value() + "/time";
std::string stmp = dirNameParam.value() + "/time";
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
_state.storeFunctor(stateSaver2);
checkpoint->add(*stateSaver2);

View file

@ -69,7 +69,7 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
checkpoint.add(increment);
// dir for DISK output
string & dirName = _parser.getORcreateParam(string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk").value();
std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk").value();
// shoudl we empty it if exists
eoValueParam<bool>& eraseParam = _parser.createParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk");
bool dirOK = false; // not tested yet
@ -80,22 +80,22 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
/**
* existing stats for Pareto as of today, Jan. 31. 2002
*
* eoSortedPopStat : whole population - type string (!!)
* eoSortedPopStat : whole population - type std::string (!!)
*/
eoValueParam<eoParamParamType>& fPlotParam = _parser.createParam(eoParamParamType("1(0,1)"), "frontFileFrequency", "File save frequency in objective spaces (pairs of comma-separated objectives in 1 single parentheses pair)", '\0', "Output - Disk");
eoValueParam<eoParamParamType>& fPlotParam = _parser.createParam(eoParamParamType("1(0,1)"), "frontFileFrequency", "File save frequency in objective spaces (std::pairs of comma-separated objectives in 1 single parentheses std::pair)", '\0', "Output - Disk");
#if !defined(NO_GNUPLOT)
bool boolGnuplot = _parser.createParam(false, "plotFront", "Objective plots (requires corresponding files - see frontFileFrequency", '\0', "Output - Graphical").value();
#endif
eoParamParamType & fPlot = fPlotParam.value(); // pair<string,vector<string> >
eoParamParamType & fPlot = fPlotParam.value(); // std::pair<std::string,std::vector<std::string> >
unsigned frequency = atoi(fPlot.first.c_str());
if (frequency) // something to plot
{
unsigned nbPlot = fPlot.second.size();
if ( nbPlot % 2 ) // odd!
throw runtime_error("Odd number of front description in make_checkpoint_pareto");
throw std::runtime_error("Odd number of front description in make_checkpoint_pareto");
// only create the necessary stats
std::vector<bool> bStat(nObj, false); // track of who's already there
@ -110,8 +110,8 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
if (!bStat[obj1]) // not already there: create it
{
char s[1024];
ostrstream os(s, 1022);
os << "Obj. " << obj1 << ends;
std::ostrstream os(s, 1022);
os << "Obj. " << obj1 << std::ends;
fStat = new eoMOFitnessStat<EOT>(obj1, s);
_state.storeFunctor(fStat);
bStat[obj1]=true;
@ -121,8 +121,8 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
if (!bStat[obj2]) // not already there: create it
{
char s2[1024];
ostrstream os2(s2, 1022);
os2 << "Obj. " << obj2 << ends;
std::ostrstream os2(s2, 1022);
os2 << "Obj. " << obj2 << std::ends;
fStat = new eoMOFitnessStat<EOT>(obj2, s2);
_state.storeFunctor(fStat);
bStat[obj2]=true;
@ -132,8 +132,8 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
// then the fileSnapshots
char s3[1024];
ostrstream os3(s3, 1022);
os3 << "Front." << obj1 << "." << obj2 << "." << ends;
std::ostrstream os3(s3, 1022);
os3 << "Front." << obj1 << "." << obj2 << "." << std::ends;
eoFileSnapshot & snapshot = _state.storeFunctor(new
eoFileSnapshot(dirName, frequency, s3 ) );
@ -160,7 +160,7 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
eoSortedPopStat<EOT> * popStat;
if ( printPop ) // we do want pop dump
{
cout << "On cree printpop\n";
std::cout << "On cree printpop\n";
popStat = & _state.storeFunctor(new eoSortedPopStat<EOT>);
// add it to the checkpoint
checkpoint.add(*popStat);
@ -205,9 +205,9 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
#ifdef _MSVC
string stmp = dirName + "\generations";
std::string stmp = dirName + "\generations";
#else
string stmp = dirName + "/generations";
std::string stmp = dirName + "/generations";
#endif
eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
_state.storeFunctor(stateSaver1);
@ -223,9 +223,9 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
#ifdef _MSVC
string stmp = dirName + "\time";
std::string stmp = dirName + "\time";
#else
string stmp = dirName + "/time";
std::string stmp = dirName + "/time";
#endif
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
_state.storeFunctor(stateSaver2);

View file

@ -146,7 +146,7 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
// now check that there is at least one!
if (!continuator)
throw runtime_error("You MUST provide a stopping criterion");
throw std::runtime_error("You MUST provide a stopping criterion");
// OK, it's there: store in the eoState
_state.storeFunctor(continuator);

View file

@ -97,7 +97,7 @@ eoContinue<Indi> & do_make_continue_pareto(eoParser& _parser, eoState& _state, e
// now check that there is at least one!
if (!continuator)
throw runtime_error("You MUST provide a stopping criterion");
throw std::runtime_error("You MUST provide a stopping criterion");
// OK, it's there: store in the eoState
_state.storeFunctor(continuator);

View file

@ -47,64 +47,64 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
eoReduce<EOT> * ptReduce;
// ---------- Deterministic
if (_ppReduce.first == string("Deterministic"))
if (_ppReduce.first == std::string("Deterministic"))
{
ptReduce = new eoTruncate<EOT>;
}
// ---------- EP
else if (_ppReduce.first == string("EP"))
else if (_ppReduce.first == std::string("EP"))
{
if (!_ppReduce.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to EP, using 6" << endl;
std::cerr << "WARNING, no parameter passed to EP, using 6" << std::endl;
detSize = 6;
// put back 6 in parameter for consistency (and status file)
_ppReduce.second.push_back(string("6"));
_ppReduce.second.push_back(std::string("6"));
}
else // parameter passed by user as EP(T)
detSize = atoi(_ppReduce.second[0].c_str());
ptReduce = new eoEPReduce<EOT>(detSize);
}
// ---------- DetTour
else if (_ppReduce.first == string("DetTour"))
else if (_ppReduce.first == std::string("DetTour"))
{
if (!_ppReduce.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to DetTour, using 2" << endl;
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
detSize = 2;
// put back 2 in parameter for consistency (and status file)
_ppReduce.second.push_back(string("2"));
_ppReduce.second.push_back(std::string("2"));
}
else // parameter passed by user as DetTour(T)
detSize = atoi(_ppReduce.second[0].c_str());
ptReduce = new eoDetTournamentTruncate<EOT>(detSize);
}
else if (_ppReduce.first == string("StochTour"))
else if (_ppReduce.first == std::string("StochTour"))
{
double p;
if (!_ppReduce.second.size()) // no parameter added
{
cerr << "WARNING, no parameter passed to StochTour, using 1" << endl;
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
p = 1;
// put back p in parameter for consistency (and status file)
_ppReduce.second.push_back(string("1"));
_ppReduce.second.push_back(std::string("1"));
}
else // parameter passed by user as DetTour(T)
{
p = atof(_ppReduce.second[0].c_str());
if ( (p<=0.5) || (p>1) )
throw runtime_error("Stochastic tournament size should be in [0.5,1]");
throw std::runtime_error("Stochastic tournament size should be in [0.5,1]");
}
ptReduce = new eoStochTournamentTruncate<EOT>(p);
}
else if (_ppReduce.first == string("Uniform"))
else if (_ppReduce.first == std::string("Uniform"))
{
ptReduce = new eoRandomReduce<EOT>;
}
else // no known reduction entered
{
throw runtime_error("Unknown reducer: " + _ppReduce.first);
throw std::runtime_error("Unknown reducer: " + _ppReduce.first);
}
// all done, stores and return a reference
_state.storeFunctor(ptReduce);
@ -117,7 +117,7 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
*
* eoHowMany _elite the number of elite parents (0 = no elitism)
* see below
* bool _strongElitism if elite > 0, string elitism or weak elitism
* bool _strongElitism if elite > 0, std::string elitism or weak elitism
* strong = elite parents survive, whatever the offspring
* weak - elite patents compete AFTER replacement with best offspring
* eoHowMany _surviveParents number of parents after parents recuction

View file

@ -58,7 +58,7 @@ eoPop<EOT>& do_make_pop(eoParser & _parser, eoState& _state, eoInit<EOT> & _ini
// create an empty pop and let the state handle the memory
eoPop<EOT>& pop = _state.takeOwnership(eoPop<EOT>());
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" );
eoValueParam<bool> & recomputeFitnessParam = _parser.createParam(false, "recomputeFitness", "Recompute the fitness after re-loading the pop.?", 'r', "Persistence" );
if (loadNameParam.value() != "") // something to load

View file

@ -18,7 +18,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
CVS Info: $Date: 2001-04-12 16:46:55 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoCloneOps.h,v 1.1 2001-04-12 16:46:55 evomarc Exp $ $Author: evomarc $
CVS Info: $Date: 2003-02-27 19:26:09 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoCloneOps.h,v 1.2 2003-02-27 19:26:09 okoenig Exp $ $Author: okoenig $
*/
//-----------------------------------------------------------------------------
@ -46,7 +46,7 @@ class eoMonCloneOp: public eoMonOp<EOT>
public:
/// Ctor
eoMonCloneOp() : eoMonOp<EOT>() {}
virtual string className() const {return "eoMonCloneOp";}
virtual std::string className() const {return "eoMonCloneOp";}
virtual bool operator()(EOT&){return false;}
};
@ -59,7 +59,7 @@ class eoBinCloneOp: public eoBinOp<EOT>
public:
/// Ctor
eoBinCloneOp() : eoBinOp<EOT>() {}
virtual string className() const {return "eoBinCloneOp";}
virtual std::string className() const {return "eoBinCloneOp";}
virtual bool operator()(EOT&, const EOT&){return false;}
};
@ -71,7 +71,7 @@ class eoQuadCloneOp: public eoQuadOp<EOT>
public:
/// Ctor
eoQuadCloneOp():eoQuadOp<EOT>() {}
virtual string className() const {return "eoQuadCloneOp";}
virtual std::string className() const {return "eoQuadCloneOp";}
virtual bool operator()(EOT& , EOT& ) {return false;}
};

View file

@ -31,7 +31,7 @@
Combined continuators - logical AND:
Continues until one of the embedded continuators says halt!
20/11/00 MS: Changed the 2-continuator construct to a vector<eoContinue<EOT> >
20/11/00 MS: Changed the 2-continuator construct to a std::vector<eoContinue<EOT> >
to be consistent with other Combined constructs
and allow to easily handle more than 2 continuators

View file

@ -51,7 +51,7 @@ public:
{
// First checks that no other eoCtrlCContinue does exist
if (existCtrlCContinue)
throw runtime_error("A signal handler for Ctrl C is already defined!\n");
throw std::runtime_error("A signal handler for Ctrl C is already defined!\n");
signal( SIGINT, signal_handler );
signal( SIGQUIT, signal_handler );
existCtrlCContinue = true;

View file

@ -50,7 +50,7 @@ template <class EOT> class eoDetTournamentSelect: public eoSelectOne<EOT>
eoDetTournamentSelect(unsigned _tSize = 2 ):eoSelectOne<EOT>(), tSize(_tSize) {
// consistency check
if (tSize < 2) {
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
std::cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
tSize = 2;
}
}

View file

@ -31,7 +31,7 @@
#include <eoPop.h>
/**
eoDominanceMap, utility class to calculate and maintain a map (vector<vector<bool> >) of pareto dominance statistics.
eoDominanceMap, utility class to calculate and maintain a map (std::vector<std::vector<bool> >) of pareto dominance statistics.
It is set up such that
@ -115,12 +115,12 @@ class eoDominanceMap : public eoUF<const eoPop<EoType>&, void>, public std::vect
/**
For all elements, returns the no. of elements that dominate the element
Thus: lower is better (and 0 is the front).
It returns a vector<double> cuz that
It returns a std::vector<double> cuz that
makes subsequent manipulation that much easier
*/
vector<double> sum_dominators() const
std::vector<double> sum_dominators() const
{
vector<double> result(size(), 0.0);
std::vector<double> result(size(), 0.0);
for (unsigned i = 0; i < size(); ++i)
{
@ -137,12 +137,12 @@ class eoDominanceMap : public eoUF<const eoPop<EoType>&, void>, public std::vect
/**
For all elements, returns the number of elements that the element dominates
Thus: higher is better
It returns a vector<double> cuz that
It returns a std::vector<double> cuz that
makes subsequent manipulation that much easier
*/
vector<double> sum_dominants() const
std::vector<double> sum_dominants() const
{
vector<double> result(size(), 0.0);
std::vector<double> result(size(), 0.0);
for (unsigned i = 0; i < size(); ++i)
{
@ -159,7 +159,7 @@ class eoDominanceMap : public eoUF<const eoPop<EoType>&, void>, public std::vect
private :
vector<typename EoType::Fitness> fitness;
std::vector<typename EoType::Fitness> fitness;
};
#endif

View file

@ -188,16 +188,16 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
replace(_pop, offspring); // after replace, the new pop. is in _pop
if (pSize > _pop.size())
throw runtime_error("Population shrinking!");
throw std::runtime_error("Population shrinking!");
else if (pSize < _pop.size())
throw runtime_error("Population growing!");
throw std::runtime_error("Population growing!");
}
catch (exception& e)
catch (std::exception& e)
{
string s = e.what();
std::string s = e.what();
s.append( " in eoEasyEA");
throw runtime_error( s );
throw std::runtime_error( s );
}
} while ( continuator( _pop ) );
}

View file

@ -39,7 +39,7 @@ public:
/// Ctor
eoEvalContinue( eoEvalFuncCounter<EOT> & _eval, unsigned long _totalEval)
: eval(_eval), repTotalEvaluations( _totalEval ) {
cout << "Ctor de eoEvalFuncCounter avec total = " << repTotalEvaluations << endl;
std::cout << "Ctor de eoEvalFuncCounter avec total = " << repTotalEvaluations << std::endl;
};
/** Returns false when a certain number of evaluations has been done
@ -47,7 +47,7 @@ public:
virtual bool operator() ( const eoPop<EOT>& _vEO ) {
if (eval.value() >= repTotalEvaluations)
{
cout << "STOP in eoEvalContinue: Reached maximum number of evaluations [" << repTotalEvaluations << "]\n";
std::cout << "STOP in eoEvalContinue: Reached maximum number of evaluations [" << repTotalEvaluations << "]\n";
return false;
}
return true;

View file

@ -52,16 +52,16 @@ public:
virtual ~eoFactory() {}
//@}
/** Another factory methods: 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 methods: 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\\
*/
virtual EOClass* make(istream& _is) = 0;
virtual EOClass* make(std::istream& _is) = 0;
///@name eoObject methods
//@{
/** Return the class id */
virtual string className() const { return "eoFactory"; }
virtual std::string className() const { return "eoFactory"; }
/** Read and print are left without implementation */
//@}

View file

@ -50,7 +50,7 @@ public:
FitnessType bestCurrentFitness = _pop.nth_element_fitness(0);
if (bestCurrentFitness >= maximum)
{
cout << "STOP in eoFitContinue: Best fitness has reached " <<
std::cout << "STOP in eoFitContinue: Best fitness has reached " <<
bestCurrentFitness << "\n";
return false;
}

View file

@ -70,8 +70,8 @@ public:
// minimla check:
if (_offspring.size() != toKeep)
{
cerr << "Les tailles " << _offspring.size() << " " << toKeep << endl;
throw runtime_error("eoG3Replacement: wrong number of remaining offspring");
std::cerr << "Les tailles " << _offspring.size() << " " << toKeep << std::endl;
throw std::runtime_error("eoG3Replacement: wrong number of remaining offspring");
}
// and put back into _parents
plus(_offspring, _parents);

View file

@ -51,10 +51,10 @@ public:
* reached */
virtual bool operator() ( const eoPop<EOT>& _vEO ) {
thisGeneration++;
// cout << " [" << thisGeneration << "] ";
// std::cout << " [" << thisGeneration << "] ";
if (thisGeneration >= repTotalGenerations)
{
cout << "STOP in eoGenContinue: Reached maximum number of generations [" << thisGeneration << "/" << repTotalGenerations << "]\n";
std::cout << "STOP in eoGenContinue: Reached maximum number of generations [" << thisGeneration << "/" << repTotalGenerations << "]\n";
return false;
}
return true;

View file

@ -64,7 +64,7 @@ class eoGenOp : public eoOp<EOT>, public eoUF<eoPopulator<EOT> &, void>
*/
virtual unsigned max_production(void) = 0;
virtual string className() const = 0;
virtual std::string className() const = 0;
void operator()(eoPopulator<EOT>& _pop)
{
_pop.reserve(max_production());
@ -94,7 +94,7 @@ class eoMonGenOp : public eoGenOp<EOT>
(*_it).invalidate(); // look how simple
}
virtual string className() const {return op.className();}
virtual std::string className() const {return op.className();}
private :
eoMonOp<EOT>& op;
};
@ -121,7 +121,7 @@ class eoBinGenOp : public eoGenOp<EOT>
if (op(a, b))
a.invalidate();
}
virtual string className() const {return op.className();}
virtual std::string className() const {return op.className();}
private :
eoBinOp<EOT>& op;
@ -142,7 +142,7 @@ class eoSelBinGenOp : public eoGenOp<EOT>
if (op(*_pop, sel(_pop.source())))
(*_pop).invalidate();
}
virtual string className() const {return op.className();}
virtual std::string className() const {return op.className();}
private :
eoBinOp<EOT>& op;
@ -173,7 +173,7 @@ class eoQuadGenOp : public eoGenOp<EOT>
}
}
virtual string className() const {return op.className();}
virtual std::string className() const {return op.className();}
private :
eoQuadOp<EOT>& op;

View file

@ -94,7 +94,7 @@ class eoGeneralBreeder: public eoBreed<EOT>
}
/// The class name.
virtual string className() const { return "eoGeneralBreeder"; }
virtual std::string className() const { return "eoGeneralBreeder"; }
private:
eoSelectOne<EOT>& select;

View file

@ -47,7 +47,7 @@ class eoInit : public eoUF<EOT&, void>
public:
// virtual void operator()(EOT& chrom)
// {
// throw runtime_error("In the eoInit base class"); // just in case
// throw std::runtime_error("In the eoInit base class"); // just in case
// }
};
@ -115,7 +115,7 @@ typedef typename EOT::AtomType AtomType;
// generator(_generator)
// {
// if (_minSize >= _maxSize)
// throw logic_error("eoInitVariableLength: minSize larger or equal to maxSize");
// throw std::logic_error("eoInitVariableLength: minSize larger or equal to maxSize");
// }
/** Ctor from an eoInit */
@ -123,14 +123,14 @@ typedef typename EOT::AtomType AtomType;
: offset(_minSize), extent(_maxSize - _minSize), init(_init)
{
if (_minSize >= _maxSize)
throw logic_error("eoInitVariableLength: minSize larger or equal to maxSize");
throw std::logic_error("eoInitVariableLength: minSize larger or equal to maxSize");
}
virtual void operator()(EOT& _chrom)
{
_chrom.resize(offset + rng.random(extent));
typename vector<AtomType>::iterator it;
typename std::vector<AtomType>::iterator it;
for (it=_chrom.begin(); it<_chrom.end(); it++)
init(*it);
_chrom.invalidate();

View file

@ -78,7 +78,7 @@ public:
for (i=0; i<pSize; i++) // truncate to 0
{
value()[i] = max(alpha*_pop[i].fitness()+beta, 0.0);
value()[i] = std::max(alpha*_pop[i].fitness()+beta, 0.0);
}
}

View file

@ -58,7 +58,7 @@ public:
{
if (tSize < 2)
{
cout << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2\n";
std::cout << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2\n";
tSize = 2;
}
}
@ -70,7 +70,7 @@ public:
unsigned toKeep = temp.size(); // how many to keep from merged populations
// minimal check
if (toKeep < 2)
throw runtime_error("Not enough parents killed in eoMGGReplacement");
throw std::runtime_error("Not enough parents killed in eoMGGReplacement");
// select best offspring
eoPop<EOT>::iterator it = _offspring.it_best_element();

View file

@ -70,7 +70,7 @@ public :
throw std::logic_error("Negative number of offspring in eoElitism!");
combien = (unsigned int)_rate;
if (combien != _rate)
cout << "Warning: Number of guys to merge in eoElitism was rounded";
std::cout << "Warning: Number of guys to merge in eoElitism was rounded";
}
}
@ -87,7 +87,7 @@ public :
if (combienLocal > _pop.size())
throw std::logic_error("Elite larger than population");
vector<const EOT*> result;
std::vector<const EOT*> result;
_pop.nth_element(combienLocal, result);
for (size_t i = 0; i < result.size(); ++i)

View file

@ -34,7 +34,7 @@
#include <cassert>
/**
Non dominated sorting, it *is a* vector of doubles, the integer part is the rank (to which front it belongs),
Non dominated sorting, it *is a* std::vector of doubles, the integer part is the rank (to which front it belongs),
the fractional part the niching penalty or distance penalty or whatever penalty you want to squeeze into
the bits.
*/
@ -47,10 +47,10 @@ class eoNDSorting : public eoPerf2WorthCached<EOT, double>
{}
/** Pure virtual function that calculates the 'distance' for each element in the current front
Implement to create your own nondominated sorting algorithm. The size of the returned vector
Implement to create your own nondominated sorting algorithm. The size of the returned std::vector
should be equal to the size of the current_front.
*/
virtual vector<double> niche_penalty(const vector<unsigned>& current_front, const eoPop<EOT>& _pop) = 0;
virtual std::vector<double> niche_penalty(const std::vector<unsigned>& current_front, const eoPop<EOT>& _pop) = 0;
void calculate_worths(const eoPop<EOT>& _pop)
{
@ -92,7 +92,7 @@ private :
void one_objective(const eoPop<EOT>& _pop)
{
unsigned i;
vector<DummyEO> tmp_pop;
std::vector<DummyEO> tmp_pop;
tmp_pop.resize(_pop.size());
// copy pop to dummy population (only need the fitnesses)
@ -101,10 +101,6 @@ private :
tmp_pop[i].fitness(_pop[i].fitness());
tmp_pop[i].index = i;
}
// sort it in ascending
sort(tmp_pop.begin(), tmp_pop.end(), greater<DummyEO>() );
for (i = 0; i < _pop.size(); ++i)
{
@ -138,7 +134,7 @@ private :
typedef typename EOT::Fitness::fitness_traits traits;
assert(traits::nObjectives() == 2);
vector<unsigned> sort1(_pop.size()); // index into population sorted on first objective
std::vector<unsigned> sort1(_pop.size()); // index into population sorted on first objective
for (i = 0; i < _pop.size(); ++i)
{
@ -160,10 +156,10 @@ private :
max1 = max1 + 1.0; // add a bit to it so that it is a real upperbound
unsigned prev_front = 0;
vector<double> d;
std::vector<double> d;
d.resize(_pop.size(), max1); // initialize with the value max1 everywhere
vector<vector<unsigned> > fronts(_pop.size()); // to store indices into the front
std::vector<std::vector<unsigned> > fronts(_pop.size()); // to store indices into the front
for (i = 0; i < _pop.size(); ++i)
{
@ -191,7 +187,7 @@ private :
value2 = max1 - value2;
// perform binary search using std::upper_bound, a log n operation for each member
vector<double>::iterator it =
std::vector<double>::iterator it =
std::upper_bound(d.begin(), d.begin() + last_front, value2);
unsigned front = unsigned(it - d.begin());
@ -212,15 +208,15 @@ private :
if (fronts[i].size() == 0) continue;
// Now we have the indices to the current front in current_front, do the niching
vector<double> niche_count = niche_penalty(fronts[i], _pop);
std::vector<double> niche_count = niche_penalty(fronts[i], _pop);
// Check whether the derived class was nice
if (niche_count.size() != fronts[i].size())
{
throw logic_error("eoNDSorting: niche and front should have the same size");
throw std::logic_error("eoNDSorting: niche and front should have the same size");
}
double max_niche = *max_element(niche_count.begin(), niche_count.end());
double max_niche = *std::max_element(niche_count.begin(), niche_count.end());
for (unsigned j = 0; j < fronts[i].size(); ++j)
{
@ -270,8 +266,8 @@ private :
typedef typename EOT::Fitness::fitness_traits traits;
vector<vector<unsigned> > S(_pop.size()); // which individuals does guy i dominate
vector<unsigned> n(_pop.size(), 0); // how many individuals dominate guy i
std::vector<std::vector<unsigned> > S(_pop.size()); // which individuals does guy i dominate
std::vector<unsigned> n(_pop.size(), 0); // how many individuals dominate guy i
unsigned j;
for (i = 0; i < _pop.size(); ++i)
@ -280,12 +276,12 @@ private :
{
if (_pop[i].fitness().dominates(_pop[j].fitness()))
{ // i dominates j
S[i].push_back(j); // add j to i's domination list
S[i].push_back(j); // add j to i's domination std::list
//n[j]++; // as i dominates j
}
else if (_pop[j].fitness().dominates(_pop[i].fitness()))
{ // j dominates i, increment count for i, add i to the domination list of j
{ // j dominates i, increment count for i, add i to the domination std::list of j
n[i]++;
//S[j].push_back(i);
@ -293,7 +289,7 @@ private :
}
}
vector<unsigned> current_front;
std::vector<unsigned> current_front;
current_front.reserve(_pop.size());
// get the first front out
@ -305,22 +301,22 @@ private :
}
}
vector<unsigned> next_front;
std::vector<unsigned> next_front;
next_front.reserve(_pop.size());
unsigned front_index = 0; // which front are we processing
while (!current_front.empty())
{
// Now we have the indices to the current front in current_front, do the niching
vector<double> niche_count = niche_penalty(current_front, _pop);
std::vector<double> niche_count = niche_penalty(current_front, _pop);
// Check whether the derived class was nice
if (niche_count.size() != current_front.size())
{
throw logic_error("eoNDSorting: niche and front should have the same size");
throw std::logic_error("eoNDSorting: niche and front should have the same size");
}
double max_niche = *max_element(niche_count.begin(), niche_count.end());
double max_niche = *std::max_element(niche_count.begin(), niche_count.end());
for (i = 0; i < current_front.size(); ++i)
{
@ -377,9 +373,9 @@ class eoNDSorting_I : public eoNDSorting<EOT>
public :
eoNDSorting_I(double _nicheSize) : eoNDSorting<EOT>(), nicheSize(_nicheSize) {}
vector<double> niche_penalty(const vector<unsigned>& current_front, const eoPop<EOT>& _pop)
std::vector<double> niche_penalty(const std::vector<unsigned>& current_front, const eoPop<EOT>& _pop)
{
vector<double> niche_count(current_front.size(), 0.);
std::vector<double> niche_count(current_front.size(), 0.);
for (unsigned i = 0; i < current_front.size(); ++i)
{ // calculate whether the other points lie within the nice
@ -415,7 +411,7 @@ public :
Adapted from Deb, Agrawal, Pratab and Meyarivan: A Fast Elitist Non-Dominant Sorting Genetic Algorithm for MultiObjective Optimization: NSGA-II
KanGAL Report No. 200001
Note that this class does not do the sorting per se, but the sorting of it worth_vector will give the right order
Note that this class does not do the sorting per se, but the sorting of it worth_std::vector will give the right order
The crowding distance is calculated as the sum of the distances to the nearest neighbours. As we need to return the
penalty value, we have to invert that and invert it again in the base class, but such is life, sigh
@ -437,11 +433,11 @@ class eoNDSorting_II : public eoNDSorting<EOT>
};
/// _cf points into the elements that consist of the current front
vector<double> niche_penalty(const vector<unsigned>& _cf, const eoPop<EOT>& _pop)
std::vector<double> niche_penalty(const std::vector<unsigned>& _cf, const eoPop<EOT>& _pop)
{
typedef typename EOT::Fitness::fitness_traits traits;
unsigned i;
vector<double> niche_count(_cf.size(), 0.);
std::vector<double> niche_count(_cf.size(), 0.);
unsigned nObjectives = traits::nObjectives(); //_pop[_cf[0]].fitness().size();
@ -449,7 +445,7 @@ class eoNDSorting_II : public eoNDSorting<EOT>
for (unsigned o = 0; o < nObjectives; ++o)
{
vector<pair<double, unsigned> > performance(_cf.size());
std::vector<std::pair<double, unsigned> > performance(_cf.size());
for (i =0; i < _cf.size(); ++i)
{
performance[i].first = _pop[_cf[i]].fitness()[o];
@ -458,14 +454,14 @@ class eoNDSorting_II : public eoNDSorting<EOT>
sort(performance.begin(), performance.end(), compare_nodes()); // a lambda operator would've been nice here
vector<double> nc(niche_count.size(), 0.0);
std::vector<double> nc(niche_count.size(), 0.0);
for (i = 1; i < _cf.size()-1; ++i)
{ // and yet another level of indirection
nc[performance[i].second] = performance[i+1].first - performance[i-1].first;
}
double max_dist = *max_element(nc.begin(), nc.end());
double max_dist = *std::max_element(nc.begin(), nc.end());
// set boundary at max_dist + 1 (so it will get chosen over all the others
nc[performance[0].second] = max_dist + 1;

View file

@ -28,13 +28,11 @@
//-----------------------------------------------------------------------------
#include <utils/eoData.h> // For limits definition
#include <iostream> // istream, ostream
#include <string> // string
#include <iostream> // std::istream, std::ostream
#include <string> // std::string
#include <utils/compatibility.h>
using namespace std;
//-----------------------------------------------------------------------------
// eoObject
//-----------------------------------------------------------------------------
@ -69,7 +67,7 @@ class eoObject
their own. Having it pure will force the implementor to provide a
name.
*/
virtual string className() const = 0;
virtual std::string className() const = 0;
};

View file

@ -96,7 +96,7 @@ class eoOneToOneBreeder: public eoBreed<EOT>
// check: only one offspring?
unsigned posEnd = popit.tellp();
if (posEnd != pos)
throw runtime_error("Operator can only generate a SINGLE offspring in eoOneToOneBreeder");
throw std::runtime_error("Operator can only generate a SINGLE offspring in eoOneToOneBreeder");
// do the tournament between parent and offspring
eval(leOffspring); // first need to evaluate the offspring
@ -109,7 +109,7 @@ class eoOneToOneBreeder: public eoBreed<EOT>
}
/// The class name.
virtual string className() const { return "eoOneToOneBreeder"; }
virtual std::string className() const { return "eoOneToOneBreeder"; }
private:
eoGenOp<EOT>& op;

View file

@ -18,7 +18,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
CVS Info: $Date: 2001-03-21 12:10:13 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoOp.h,v 1.27 2001-03-21 12:10:13 jmerelo Exp $ $Author: jmerelo $
CVS Info: $Date: 2003-02-27 19:25:56 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoOp.h,v 1.28 2003-02-27 19:25:56 okoenig Exp $ $Author: okoenig $
*/
//-----------------------------------------------------------------------------
@ -58,9 +58,9 @@ how to build them from a description in a file.
/** Abstract data types for EO operators.
Genetic operators act on chromosomes, changing them.
The type to use them on is problem specific. If your genotype
is a vector<bool>, there are operators that work specifically
on vector<bool>, but you might also find that generic operators
working on vector<T> are what you need.
is a std::vector<bool>, there are operators that work specifically
on std::vector<bool>, but you might also find that generic operators
working on std::vector<T> are what you need.
*/
template<class EOType>
@ -103,7 +103,7 @@ public:
/// Ctor
eoMonOp()
: eoOp<EOType>( eoOp<EOType>::unary ) {};
virtual string className() const {return "eoMonOp";};
virtual std::string className() const {return "eoMonOp";};
};
@ -119,7 +119,7 @@ public:
/// Ctor
eoBinOp()
:eoOp<EOType>( eoOp<EOType>::binary ) {};
virtual string className() const {return "eoBinOp";};
virtual std::string className() const {return "eoBinOp";};
};
/** Quad genetic operator: subclasses eoOp, and defines basically the
@ -133,7 +133,7 @@ public:
/// Ctor
eoQuadOp()
:eoOp<EOType>( eoOp<EOType>::quadratic ) {};
virtual string className() const {return "eoQuadOp";};
virtual std::string className() const {return "eoQuadOp";};
};
/** Turning an eoQuadOp into an eoBinOp: simply don't touch the second arg!

View file

@ -64,15 +64,15 @@ class eoOpContainer : public eoGenOp<EOT>
{
ops.push_back(&wrap_op<EOT>(_op, store));
rates.push_back(_rate);
max_to_produce = max(max_to_produce,ops.back()->max_production());
max_to_produce = std::max(max_to_produce,ops.back()->max_production());
}
virtual string className() const = 0;
virtual std::string className() const = 0;
protected :
vector<double> rates;
vector<eoGenOp<EOT>*> ops;
std::vector<double> rates;
std::vector<eoGenOp<EOT>*> ops;
private :
eoFunctorStore store;
@ -105,13 +105,13 @@ class eoSequentialOp : public eoOpContainer<EOT>
{
// try
// {
// apply it to all the guys in the todo list
// apply it to all the guys in the todo std::list
(*ops[i])(_pop);
// }
// check for out of individuals and do nothing with that...
// catch(eoPopulator<EOT>::OutOfIndividuals&)
// {
// cout << "Warning: not enough individuals to handle\n";
// std::cout << "Warning: not enough individuals to handle\n";
// return ;
// }
}
@ -122,12 +122,12 @@ class eoSequentialOp : public eoOpContainer<EOT>
while (!_pop.exhausted());
}
}
virtual string className() const {return "SequentialOp";}
virtual std::string className() const {return "SequentialOp";}
private :
vector<size_t> to_apply;
vector<size_t> production;
std::vector<size_t> to_apply;
std::vector<size_t> production;
};
@ -149,7 +149,7 @@ class eoProportionalOp : public eoOpContainer<EOT>
catch( typename eoPopulator<EOT>::OutOfIndividuals&)
{}
}
virtual string className() const {return "ProportionalOp";}
virtual std::string className() const {return "ProportionalOp";}
};

View file

@ -39,7 +39,7 @@ template<class eoClass>
class eoOpSelMason: public eoFactory<eoOpSelector<eoClass> > {
public:
typedef vector<eoOp<eoClass>* > vOpP;
typedef std::vector<eoOp<eoClass>* > vOpP;
typedef map<eoOpSelector<eoClass>*, vOpP > MEV;
/// @name ctors and dtors
@ -51,7 +51,7 @@ public:
virtual ~eoOpSelMason() {};
//@}
/** Factory methods: creates an object from an istream, reading from
/** Factory methods: creates an object from an std::istream, reading from
it whatever is needed to create the object. The format is
opSelClassName\\
rate 1 operator1\\
@ -62,9 +62,9 @@ public:
since the built object can´t do it itself. The objects built must be destroyed
from outside, using the #destroy# method
*/
virtual eoOpSelector<eoClass>* make(istream& _is) {
virtual eoOpSelector<eoClass>* make(std::istream& _is) {
string opSelName;
std::string opSelName;
_is >> opSelName;
eoOpSelector<eoClass>* opSelectorP;
// Build the operator selector
@ -72,7 +72,7 @@ public:
opSelectorP = new eoProportionalOpSel<eoClass>();
}
// Temp vector for storing pointers
// Temp std::vector for storing pointers
vOpP tmpPVec;
// read operator rate and name
while ( _is ) {
@ -96,12 +96,12 @@ public:
///@name eoObject methods
//@{
/** Return the class id */
virtual string className() const { return "eoOpSelMason"; }
virtual std::string className() const { return "eoOpSelMason"; }
//@}
private:
map<eoOpSelector<eoClass>*,vector<eoOp<eoClass>* > > allocMap;
map<eoOpSelector<eoClass>*,std::vector<eoOp<eoClass>* > > allocMap;
eoOpFactory<eoClass>& operatorFactory;
};

View file

@ -70,25 +70,25 @@ public :
eoParetoOneConstraintFitness(void) : std::vector<double>(FitnessTraits::nObjectives(),0.0) {}
// Ctr from a vector<double> (size nObjectives+1)
// Ctr from a std::vector<double> (size nObjectives+1)
eoParetoOneConstraintFitness(std::vector<double> & _v) :
std::vector<double>(_v)
{
#ifndef NDEBUG
if (_v.size() != fitness_traits::nObjectives()+1)
throw runtime_error("Size error in Ctor of eoParetoOneConstraintFitness from vector");
throw std::runtime_error("Size error in Ctor of eoParetoOneConstraintFitness from std::vector");
#endif
constraintValue = _v[fitness_traits::nObjectives()];
resize(fitness_traits::nObjectives());
}
// Ctr from a vector<double> and a value
// Ctr from a std::vector<double> and a value
eoParetoOneConstraintFitness(std::vector<double> & _v, double _c) :
std::vector<double>(_v), constraintValue(_c)
{
#ifndef NDEBUG
if (_v.size() != fitness_traits::nObjectives())
throw runtime_error("Size error in Ctor of eoParetoOneConstraintFitness from vector and value");
throw std::runtime_error("Size error in Ctor of eoParetoOneConstraintFitness from std::vector and value");
#endif
}

View file

@ -113,7 +113,7 @@ public :
eoParetoFitness(void) : std::vector<double>(FitnessTraits::nObjectives(),0.0) {}
// Ctr from a vector<double>
// Ctr from a std::vector<double>
eoParetoFitness(std::vector<double> & _v) : std::vector<double>(_v) {}

View file

@ -50,7 +50,7 @@ class eoParetoRanking : public eoPerf2WorthCached<EOT, double>
value() = dominanceMap.sum_dominators(); // get rank: 0 means part of current front
// calculate maximum
double maxim = *max_element(value().begin(), value().end());
double maxim = *std::max_element(value().begin(), value().end());
// higher is better, so invert the value
for (unsigned i = 0; i < value().size(); ++i)

View file

@ -50,7 +50,7 @@ class eoPerf2Worth : public eoUF<const eoPop<EOT>&, void>, public eoValueParam<s
Sort population according to worth, will keep the worths and fitness_cache in sync with the population.
*/
virtual void sort_pop(eoPop<EOT>& _pop)
{ // start with a vector of indices
{ // start with a std::vector of indices
std::vector<unsigned> indices(_pop.size());
unsigned i;
@ -59,7 +59,7 @@ class eoPerf2Worth : public eoUF<const eoPop<EOT>&, void>, public eoValueParam<s
indices[i] = i;
}
sort(indices.begin(), indices.end(), compare_worth(value()));
std::sort(indices.begin(), indices.end(), compare_worth(value()));
eoPop<EOT> tmp_pop;
tmp_pop.resize(_pop.size());
@ -71,8 +71,8 @@ class eoPerf2Worth : public eoUF<const eoPop<EOT>&, void>, public eoValueParam<s
tmp_worths[i] = value()[indices[i]];
}
swap(_pop, tmp_pop);
swap(value(), tmp_worths);
std::swap(_pop, tmp_pop);
std::swap(value(), tmp_worths);
}
/** helper class used to sort indices into populations/worths
@ -155,7 +155,7 @@ class eoPerf2WorthCached : public eoPerf2Worth<EOT, WorthT>
Sort population according to worth, will keep the worths and fitness_cache in sync with the population.
*/
virtual void sort_pop(eoPop<EOT>& _pop)
{ // start with a vector of indices
{ // start with a std::vector of indices
std::vector<unsigned> indices(_pop.size());
unsigned i;
@ -183,9 +183,9 @@ class eoPerf2WorthCached : public eoPerf2Worth<EOT, WorthT>
tmp_cache[i] = fitness_cache[indices[i]];
}
swap(_pop, tmp_pop);
swap(value(), tmp_worths);
swap(fitness_cache, tmp_cache);
std::swap(_pop, tmp_pop);
std::swap(value(), tmp_worths);
std::swap(fitness_cache, tmp_cache);
}
/** helper class used to sort indices into populations/worths

View file

@ -9,7 +9,7 @@
//-----------------------------------------------------------------------------
istream & operator >> ( istream& _is, eoPersistent& _o ) {
std::istream & operator >> ( std::istream& _is, eoPersistent& _o ) {
_o.readFrom(_is);
return _is;
};

View file

@ -36,14 +36,12 @@ const unsigned MAXLINELENGTH=1024;
//-----------------------------------------------------------------------------
#include <iostream> // istream, ostream
#include <string> // para string
#include <iostream> // std::istream, std::ostream
#include <string> // para std::string
//-----------------------------------------------------------------------------
#include "eoPrintable.h"
using namespace std;
//-----------------------------------------------------------------------------
// eoPersistent
//-----------------------------------------------------------------------------
@ -59,16 +57,16 @@ class eoPersistent: public eoPrintable
/**
* Read object.
* @param _is A istream.
* @throw runtime_exception If a valid object can't be read.
* @param _is A std::istream.
* @throw runtime_std::exception If a valid object can't be read.
*/
virtual void readFrom(istream& _is) = 0;
virtual void readFrom(std::istream& _is) = 0;
};
//-----------------------------------------------------------------------------
///Standard input for all objects in the EO hierarchy
istream & operator >> ( istream& _is, eoPersistent& _o );
std::istream & operator >> ( std::istream& _is, eoPersistent& _o );
#endif

View file

@ -36,11 +36,11 @@
#include <eoInit.h>
#include <utils/rnd_generators.h> // for shuffle method
/** A vector of EO object, to be used in all algorithms
/** A std::vector of EO object, to be used in all algorithms
* (selectors, operators, replacements, ...).
*
* We have no idea if a population can be
* some other thing that a vector, but if somebody thinks of it, this concrete
* some other thing that a std::vector, but if somebody thinks of it, this concrete
* implementation can be moved to "generic" and an abstract Population
* interface be provided.
*
@ -51,14 +51,14 @@
*/
template<class EOT>
class eoPop: public vector<EOT>, public eoObject, public eoPersistent
class eoPop: public std::vector<EOT>, public eoObject, public eoPersistent
{
public:
typedef typename EOT::Fitness Fitness;
/** Default ctor. Creates empty pop
*/
eoPop() : vector<EOT>(), eoObject(), eoPersistent() {};
eoPop() : std::vector<EOT>(), eoObject(), eoPersistent() {};
/** Ctor for the initialization of chromosomes
@ -66,7 +66,7 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
@param _chromInit Initialization routine, produces EO's, needs to be an eoInit
*/
eoPop( unsigned _popSize, eoInit<EOT>& _chromInit )
:vector<EOT>()
:std::vector<EOT>()
{
resize(_popSize);
for ( unsigned i = 0; i < _popSize; i++ )
@ -75,7 +75,7 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
}
};
/** appends random guys at end of pop.
/** appstd::ends random guys at end of pop.
Can be used to initialize it pop is empty
@param _popSize total population size
@ -86,7 +86,7 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
unsigned oldSize = size();
if (_newPopSize < oldSize)
{
throw runtime_error("New size smaller than old size in pop.append");
throw std::runtime_error("New size smaller than old size in pop.append");
return;
}
if (_newPopSize == oldSize)
@ -99,11 +99,11 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
};
/** Ctor from an istream; reads the population from a stream,
/** Ctor from an std::istream; reads the population from a stream,
each element should be in different lines
@param _is the stream
*/
eoPop( istream& _is ):vector<EOT>() {
eoPop( std::istream& _is ) :std::vector<EOT>() {
readFrom( _is );
}
@ -125,11 +125,11 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
*/
void sort(void)
{
std::sort(begin(), end(), greater<EOT>());
std::sort(begin(), end(), std::greater<EOT>());
}
/** creates a vector<EOT*> pointing to the individuals in descending order */
void sort(vector<const EOT*>& result) const
/** creates a std::vector<EOT*> pointing to the individuals in descending order */
void sort(std::vector<const EOT*>& result) const
{
result.resize(size());
@ -148,8 +148,8 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
std::random_shuffle(begin(), end(), gen);
}
/** creates a vector<EOT*> pointing to the individuals in random order */
void shuffle(vector<const EOT*>& result) const
/** creates a std::vector<EOT*> pointing to the individuals in random order */
void shuffle(std::vector<const EOT*>& result) const
{
result.resize(size());
@ -162,28 +162,28 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
/** returns an iterator to the best individual DOES NOT MOVE ANYBODY */
typename eoPop<EOT>::iterator it_best_element()
{
typename eoPop<EOT>::iterator it = max_element(begin(), end());
typename eoPop<EOT>::iterator it = std::max_element(begin(), end());
return it;
}
/** returns an iterator to the best individual DOES NOT MOVE ANYBODY */
const EOT & best_element() const
{
typename eoPop<EOT>::const_iterator it = max_element(begin(), end());
typename eoPop<EOT>::const_iterator it = std::max_element(begin(), end());
return (*it);
}
/** returns a const reference to the worse individual DOES NOT MOVE ANYBODY */
const EOT & worse_element() const
{
typename eoPop<EOT>::const_iterator it = min_element(begin(), end());
typename eoPop<EOT>::const_iterator it = std::min_element(begin(), end());
return (*it);
}
/** returns an iterator to the worse individual DOES NOT MOVE ANYBODY */
typename eoPop<EOT>::iterator it_worse_element()
{
typename eoPop<EOT>::iterator it = min_element(begin(), end());
typename eoPop<EOT>::iterator it = std::min_element(begin(), end());
return it;
}
@ -194,7 +194,7 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
typename eoPop<EOT>::iterator nth_element(int nth)
{
typename eoPop<EOT>::iterator it = begin() + nth;
std::nth_element(begin(), it, end(), greater<EOT>());
std::nth_element(begin(), it, end(), std::greater<EOT>());
return it;
}
@ -204,24 +204,24 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
Fitness nth_element_fitness(int which) const
{ // probably not the fastest way to do this, but what the heck
vector<Fitness> fitness(size());
std::vector<Fitness> fitness(size());
std::transform(begin(), end(), fitness.begin(), GetFitness());
typename vector<Fitness>::iterator it = fitness.begin() + which;
std::nth_element(fitness.begin(), it, fitness.end(), greater<Fitness>());
typename std::vector<Fitness>::iterator it = fitness.begin() + which;
std::nth_element(fitness.begin(), it, fitness.end(), std::greater<Fitness>());
return *it;
}
/** const nth_element function, returns pointers to sorted individuals
* up the the nth
*/
void nth_element(int which, vector<const EOT*>& result) const
void nth_element(int which, std::vector<const EOT*>& result) const
{
result.resize(size());
std::transform(begin(), end(), result.begin(), Ref());
typename vector<const EOT*>::iterator it = result.begin() + which;
typename std::vector<const EOT*>::iterator it = result.begin() + which;
std::nth_element(result.begin(), it, result.end(), Cmp());
}
@ -229,30 +229,30 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
/** does STL swap with other pop */
void swap(eoPop<EOT>& other)
{
std::swap(static_cast<vector<EOT>& >(*this), static_cast<vector<EOT>& >(other));
std::swap(static_cast<std::vector<EOT>& >(*this), static_cast<std::vector<EOT>& >(other));
}
/**
* Prints sorted pop but does NOT modify it!
*
* @param _os A ostream.
* @param _os A std::ostream.
*/
virtual void sortedPrintOn(ostream& _os) const
virtual void sortedPrintOn(std::ostream& _os) const
{
vector<const EOT*> result;
std::vector<const EOT*> result;
sort(result);
_os << size() << '\n';
for (unsigned i = 0; i < size(); ++i)
{
_os << *result[i] << endl;
_os << *result[i] << std::endl;
}
}
/**
* Write object. It's called printOn since it prints the object _on_ a stream.
* @param _os A ostream.
* @param _os A std::ostream.
*/
virtual void printOn(ostream& _os) const
virtual void printOn(std::ostream& _os) const
{
_os << size() << '\n';
std::copy( begin(), end(), std::ostream_iterator<EOT>( _os, "\n") );
@ -263,9 +263,9 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
/**
* Read object. The EOT class must have a ctor from a stream;
in this case, a strstream is used.
* @param _is A istream.
* @param _is A std::istream.
*/
virtual void readFrom(istream& _is)
virtual void readFrom(std::istream& _is)
{
size_t sz;
_is >> sz;
@ -280,7 +280,7 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
/** Inherited from eoObject. Returns the class name.
@see eoObject
*/
virtual string className() const {return "eoPop";};
virtual std::string className() const {return "eoPop";};
//@}
virtual void invalidate()

View file

@ -13,7 +13,7 @@
//Implementation of these objects
//-----------------------------------------------------------------------------
ostream & operator << ( ostream& _os, const eoPrintable& _o ) {
std::ostream & operator << ( std::ostream& _os, const eoPrintable& _o ) {
_o.printOn(_os);
return _os;
};

View file

@ -27,10 +27,8 @@
//-----------------------------------------------------------------------------
#include <iostream> // istream, ostream
#include <string> // para string
using namespace std;
#include <iostream> // std::istream, std::ostream
#include <string> // para std::string
//-----------------------------------------------------------------------------
// eoPrintable
@ -50,14 +48,14 @@ class eoPrintable
/**
* Write object. It's called printOn since it prints the object on a stream.
* @param _os A ostream.
* @param _os A std::ostream.
*/
virtual void printOn(ostream& _os) const = 0;
virtual void printOn(std::ostream& _os) const = 0;
};
//-----------------------------------------------------------------------------
///Standard output for all objects in the EO hierarchy
ostream & operator << ( ostream& _os, const eoPrintable& _o );
std::ostream & operator << ( std::ostream& _os, const eoPrintable& _o );
#endif

View file

@ -65,7 +65,7 @@ public:
rates.push_back(_rate);
}
virtual string className() const { return "eoPropCombinedMonOp"; }
virtual std::string className() const { return "eoPropCombinedMonOp"; }
virtual void add(eoMonOp<EOT> & _op, const double _rate, bool _verbose=false)
{
@ -73,11 +73,11 @@ public:
rates.push_back(_rate);
// compute the relative rates in percent - to warn the user!
if (_verbose)
printOn(cout);
printOn(std::cout);
}
// outputs the operators and percentages
virtual void printOn(ostream & _os)
virtual void printOn(std::ostream & _os)
{
double total = 0;
unsigned i;
@ -116,7 +116,7 @@ public:
rates.push_back(_rate);
}
virtual string className() const { return "eoPropCombinedBinOp"; }
virtual std::string className() const { return "eoPropCombinedBinOp"; }
virtual void add(eoBinOp<EOT> & _op, const double _rate, bool _verbose=false)
{
@ -129,9 +129,9 @@ virtual void add(eoBinOp<EOT> & _op, const double _rate, bool _verbose=false)
unsigned i;
for (i=0; i<ops.size(); i++)
total += rates[i];
cout << "In " << className() << "\n" ;
std::cout << "In " << className() << "\n" ;
for (i=0; i<ops.size(); i++)
cout << ops[i]->className() << " with rate " << 100*rates[i]/total << " %\n";
std::cout << ops[i]->className() << " with rate " << 100*rates[i]/total << " %\n";
}
}
@ -170,7 +170,7 @@ public:
rates.push_back(_rate);
}
virtual string className() const { return "eoPropCombinedQuadOp"; }
virtual std::string className() const { return "eoPropCombinedQuadOp"; }
// addition of a true operator
virtual void add(eoQuadOp<EOT> & _op, const double _rate, bool _verbose=false)
@ -179,11 +179,11 @@ virtual void add(eoQuadOp<EOT> & _op, const double _rate, bool _verbose=false)
rates.push_back(_rate);
// compute the relative rates in percent - to warn the user!
if (_verbose)
printOn(cout);
printOn(std::cout);
}
// outputs the operators and percentages
virtual void printOn(ostream & _os)
virtual void printOn(std::ostream & _os)
{
double total = 0;
unsigned i;

View file

@ -48,7 +48,7 @@ public:
total((pop.size() == 0) ? -1.0 : sum_fitness(pop))
{
if (minimizing_fitness<EOT>())
throw logic_error("eoProportionalSelect: minimizing fitness");
throw std::logic_error("eoProportionalSelect: minimizing fitness");
}
void setup(const eoPop<EOT>& _pop)

View file

@ -32,7 +32,7 @@
/** An instance of eoPerfFromWorth
* COmputes the ranked fitness: fitnesses range in [m,M]
* with m=2-pressure/popSize and M=pressure/popSize.
* in between, the progression depends on exponent (linear if 1).
* in between, the progression depstd::ends on exponent (linear if 1).
*/
template <class EOT>
class eoRanking : public eoPerf2Worth<EOT> // false: do not cache fitness
@ -54,24 +54,24 @@ public:
if (_eo == &(*it))
return it-_pop.begin();
}
throw runtime_error("Not found in eoLinearRanking");
throw std::runtime_error("Not found in eoLinearRanking");
}
/* COmputes the ranked fitness: fitnesses range in [m,M]
with m=2-pressure/popSize and M=pressure/popSize.
in between, the progression depends on exponent (linear if 1).
in between, the progression depstd::ends on exponent (linear if 1).
*/
virtual void operator()(const eoPop<EOT>& _pop)
{
vector<const EOT *> rank;
std::vector<const EOT *> rank;
_pop.sort(rank);
unsigned pSize =_pop.size();
unsigned int pSizeMinusOne = pSize-1;
if (pSize <= 1)
throw runtime_error("Cannot do ranking with population of size <= 1");
throw std::runtime_error("Cannot do ranking with population of size <= 1");
// value() refers to the vector of worthes (we're in an eoParamvalue)
// value() refers to the std::vector of worthes (we're in an eoParamvalue)
value().resize(pSize);
double beta = (2-pressure)/pSize;

View file

@ -32,7 +32,7 @@
#include <eoRanking.h>
/** eoRankingSelect: select an individual by roulette wheel on its rank
* is an eoRouletteWorthSelect, i.e. a selector using a vector of worthes
* is an eoRouletteWorthSelect, i.e. a selector using a std::vector of worthes
* rather than the raw fitness (see eoSelectFromWorth.h)
* uses an internal eoRanking object which is an eoPerf2Worth<EOT, double>
*/

View file

@ -90,15 +90,15 @@ typedef typename EOT::Fitness Fitness;
{
if (t_size < 2)
{
cout << "Warning: EP tournament size should be >= 2. Adjusted" << endl;
std::cout << "Warning: EP tournament size should be >= 2. Adjusted" << std::endl;
t_size = 2;
}
}
/// helper struct for comparing on pairs
/// helper struct for comparing on std::pairs
// compares the scores
// uses the fitness if scores are equals ????
typedef pair<float, typename eoPop<EOT>::iterator> EPpair;
typedef std::pair<float, typename eoPop<EOT>::iterator> EPpair;
struct Cmp {
bool operator()(const EPpair a, const EPpair b) const
{
@ -117,7 +117,7 @@ typedef typename EOT::Fitness Fitness;
return;
if (presentSize < _newsize)
throw std::logic_error("eoTruncate: Cannot truncate to a larger size!\n");
vector<EPpair> scores(presentSize);
std::vector<EPpair> scores(presentSize);
for (unsigned i=0; i<presentSize; i++)
{
scores[i].second = _newgen.begin()+i;
@ -133,14 +133,14 @@ typedef typename EOT::Fitness Fitness;
}
// now we have the scores
typename vector<EPpair>::iterator it = scores.begin() + _newsize;
typename std::vector<EPpair>::iterator it = scores.begin() + _newsize;
std::nth_element(scores.begin(), it, scores.end(), Cmp());
// sort(scores.begin(), scores.end(), Cmp());
unsigned j;
// cout << "Les scores apres tri\n";
// std::cout << "Les scores apres tri\n";
// for (j=0; j<scores.size(); j++)
// {
// cout << scores[j].first << " " << *scores[j].second << endl;
// std::cout << scores[j].first << " " << *scores[j].second << std::endl;
// }
eoPop<EOT> tmPop;
for (j=0; j<_newsize; j++)
@ -149,7 +149,7 @@ typedef typename EOT::Fitness Fitness;
}
_newgen.swap(tmPop);
// erase does not work, but I'm sure there is a way in STL to mark
// and later delete all inside a vector ??????
// and later delete all inside a std::vector ??????
// this would avoid all copies here
// it = scores.begin() + _newsize;
@ -193,7 +193,7 @@ public:
{
if (t_size < 2)
{
cout << "Warning, Size for eoDetTournamentTruncate adjusted to 2\n";
std::cout << "Warning, Size for eoDetTournamentTruncate adjusted to 2\n";
t_size = 2;
}
}
@ -241,12 +241,12 @@ public:
{
if (t_rate <= 0.5)
{
cout << "Warning, Rate for eoStochTournamentTruncate adjusted to 0.51\n";
std::cout << "Warning, Rate for eoStochTournamentTruncate adjusted to 0.51\n";
t_rate = 0.51;
}
if (t_rate > 1)
{
cout << "Warning, Rate for eoStochTournamentTruncate adjusted to 1\n";
std::cout << "Warning, Rate for eoStochTournamentTruncate adjusted to 1\n";
t_rate = 1;
}
}

View file

@ -90,7 +90,7 @@ public:
// then the offspring
unsigned reducedOffspringSize = howManyReducedOffspring(offSize);
if (!reducedOffspringSize)
throw runtime_error("No offspring left after reduction!");
throw std::runtime_error("No offspring left after reduction!");
if (reducedOffspringSize != offSize) // need reduction
reduceOffspring(_offspring, reducedOffspringSize);
@ -100,7 +100,7 @@ public:
_parents.begin()+reducedParentSize);
// reduce the resulting population
// size depends on elitism
// size depstd::ends on elitism
if (elite && strongElitism)
{
if (_parents.size() != finalPopSize-elite)
@ -131,9 +131,9 @@ public:
private:
eoHowMany howManyElite; // if 0, no elitism at all
bool strongElitism; // if false -> weak elistism
bool strongElitism; // if false -> weak estd::listism
eoHowMany howManyReducedParents; // if 0, no parent in final replacement
eoHowMany howManyReducedOffspring; // if 0, runtime_error
eoHowMany howManyReducedOffspring; // if 0, std::runtime_error
// the reducers
eoReduce<EOT> & reduceParents;
eoReduce<EOT> & reduceOffspring;

View file

@ -215,7 +215,7 @@ public:
{
if (t_size < 2)
{
cout << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2\n";
std::cout << "Warning, Size for eoDetTournamentTruncateSplit adjusted to 2\n";
t_size = 2;
}
}
@ -265,12 +265,12 @@ public:
{
if (t_rate <= 0.5)
{
cout << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 0.51\n";
std::cout << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 0.51\n";
t_rate = 0.51;
}
if (t_rate > 1)
{
cout << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 1\n";
std::cout << "Warning, Rate for eoStochTournamentTruncateSplit adjusted to 1\n";
t_rate = 1;
}
}

View file

@ -74,7 +74,7 @@ class eoSGAGenOp : public eoGenOp<EOT>
/** inherited from eoGenOp */
virtual unsigned max_production(void) {return 2;}
virtual string className() const {return "eoSGAGenOp";}
virtual std::string className() const {return "eoSGAGenOp";}
private:

View file

@ -33,7 +33,7 @@
///////////////////////////////////////////////////////////////////////////////
// class eoSGATransform
///////////////////////////////////////////////////////////////////////////////
#include <vector> // vector
#include <vector> // std::vector
#include <utils/eoRNG.h>
#include <eoTransform.h>

View file

@ -49,13 +49,13 @@ public:
virtual ~eoSelectFactory() {}
//@}
/** Another factory methods: 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 methods: 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\\
*/
virtual eoSelect<EOT>* make(istream& _is) {
virtual eoSelect<EOT>* make(std::istream& _is) {
eoSelect<EOT> * selectPtr;
string objectTypeStr;
std::string objectTypeStr;
_is >> objectTypeStr;
// All selectors have a rate, the proportion of the original population
float rate;
@ -69,7 +69,7 @@ public:
if ( objectTypeStr == "eoRandomSelect" ) {
selectPtr = new eoRandomSelect<EOT>( rate );
} else {
throw runtime_error( "Incorrect selector type" );
throw std::runtime_error( "Incorrect selector type" );
}
}
return selectPtr;
@ -77,8 +77,8 @@ public:
///@name eoObject methods
//@{
void printOn( ostream& _os ) const {};
void readFrom( istream& _is ){};
void printOn( std::ostream& _os ) const {};
void readFrom( std::istream& _is ){};
/** className is inherited */
//@}

View file

@ -34,14 +34,14 @@
//-----------------------------------------------------------------------------
/** selects one element from a population (is an eoSelectOne)
but the selection is based on a vector of Worth that is different
but the selection is based on a std::vector of Worth that is different
from the fitnesses (e.g. EO fitness is what Koza terms "raw fitness",
Worth is what the selection is based upon).
see class eoPerf2Worth: an eoStat that transforms fitnesses into Worthes
Note: Worthes will not always be doubles - see some multi-objective
techniques where it is a pair of doubles ...
techniques where it is a std::pair of doubles ...
It has to have a < operator it you want to call an existing
selector (see selector.h) - but of course you can write the whole
@ -79,7 +79,7 @@ protected:
{
if (fitness[index] != _eo.fitness())
{
throw runtime_error("eoSelectFromWorth: fitnesses are not in sync");
throw std::runtime_error("eoSelectFromWorth: fitnesses are not in sync");
}
}
@ -95,7 +95,7 @@ template <class EOT, class WorthT = double>
class eoDetTournamentWorthSelect : public eoSelectFromWorth<EOT, WorthT>
{
public:
typedef typename vector<WorthT>::iterator worthIterator;
typedef typename std::vector<WorthT>::iterator worthIterator;
/* Default ctor from an eoPerf2Worth object + tournament size
*/
@ -134,7 +134,7 @@ template <class EOT, class WorthT = double>
class eoStochTournamentWorthSelect : public eoSelectFromWorth<EOT, WorthT>
{
public:
typedef typename vector<WorthT>::iterator worthIterator;
typedef typename std::vector<WorthT>::iterator worthIterator;
/* Default ctor from an eoPerf2Worth object + tournament rate
*/
@ -172,7 +172,7 @@ template <class EOT, class WorthT = double>
class eoRouletteWorthSelect : public eoSelectFromWorth<EOT, WorthT>
{
public:
typedef typename vector<WorthT>::iterator worthIterator;
typedef typename std::vector<WorthT>::iterator worthIterator;
/* Default ctor from an eoPerf2Worth object
*/

View file

@ -53,8 +53,13 @@ template <class EOT> class eoSequentialSelect: public eoSelectOne<EOT>
/** Ctor: sets the current pter to MAXINT so init will take place first time
not very elegant, maybe ...
*/
eoSequentialSelect(bool _ordered = true):
ordered(_ordered), current(MAXINT) {}
#ifdef _MSC_VER
eoSequentialSelect(bool _ordered = true)
: ordered(_ordered), current(std::MAXINT) {}
#else
eoSequentialSelect(bool _ordered = true)
: ordered(_ordered), current(MAXINT) {}
#endif
void setup(const eoPop<EOT>& _pop)
{
@ -78,7 +83,7 @@ template <class EOT> class eoSequentialSelect: public eoSelectOne<EOT>
private:
bool ordered;
unsigned current;
vector<const EOT*> eoPters;
std::vector<const EOT*> eoPters;
};
@ -99,7 +104,11 @@ template <class EOT> class eoEliteSequentialSelect: public eoSelectOne<EOT>
/** Ctor: sets the current pter to MAXINT so init will take place first time
not very elegant, maybe ...
*/
#ifdef _MSC_VER
eoEliteSequentialSelect(): current(std::MAXINT) {}
#else
eoEliteSequentialSelect(): current(MAXINT) {}
#endif
void setup(const eoPop<EOT>& _pop)
{
@ -109,7 +118,7 @@ template <class EOT> class eoEliteSequentialSelect: public eoSelectOne<EOT>
unsigned int ibest = 0;
const EOT * best = eoPters[0];
if (_pop.size() == 1)
throw runtime_error("Trying eoEliteSequentialSelect with only one individual!");
throw std::runtime_error("Trying eoEliteSequentialSelect with only one individual!");
for (unsigned i=1; i<_pop.size(); i++)
if (*eoPters[i]>*best)
{
@ -135,7 +144,7 @@ template <class EOT> class eoEliteSequentialSelect: public eoSelectOne<EOT>
}
private:
unsigned current;
vector<const EOT*> eoPters;
std::vector<const EOT*> eoPters;
};

View file

@ -55,10 +55,10 @@ class eoSharing : public eoPerf2Worth<EOT, double>
unsigned i, j,
pSize=_pop.size();
if (pSize <= 1)
throw runtime_error("Apptempt to do sharing with population of size 1");
throw std::runtime_error("Apptempt to do sharing with population of size 1");
value.resize(pSize);
vector<double> sim(pSize); // to hold the similarities
vector<double> distMatrix(pSize*(pSize-1)/2); // to hold the distances
std::vector<double> sim(pSize); // to hold the similarities
std::vector<double> distMatrix(pSize*(pSize-1)/2); // to hold the distances
// compute the distances
distMatrix(0,0)=0;
@ -86,11 +86,11 @@ class eoSharing : public eoPerf2Worth<EOT, double>
}
// helper class to hold distances
class dMatrix : public vector<double>
class dMatrix : public std::vector<double>
{
public:
// Ctor : sets size
dMatrix(unsigned _s) : vector<double>(_s*(_s-1)), rSize(_s) {}
dMatrix(unsigned _s) : std::vector<double>(_s*(_s-1)), rSize(_s) {}
/** simple accessor */
double operator()(unsigned _i, unsigned _j) const
@ -105,16 +105,16 @@ class eoSharing : public eoPerf2Worth<EOT, double>
}
/** just in case */
void printOn(ostream & _os)
void printOn(std::ostream & _os)
{
unsigned index=0;
for (unsigned i=0; i<rSize; i++)
{
for (unsigned j=0; j<rSize; j++)
_os << this->operator[](index++) << " " ;
_os << endl;
_os << std::endl;
}
_os << endl;
_os << std::endl;
}
private:

View file

@ -80,11 +80,11 @@ template<class EOT> class eoSimpleDEA: public eoDEA<EOT>
update(_distrib, pop); // updates distrib from _pop
}
catch (exception& e)
catch (std::exception& e)
{
string s = e.what();
std::string s = e.what();
s.append( " in eoSimpleDEA");
throw runtime_error( s );
throw std::runtime_error( s );
}
} while ( continuator( pop ) );
}

View file

@ -54,7 +54,7 @@ public:
* reached withtout improvement */
virtual bool operator() ( const eoPop<EOT>& _vEO ) {
thisGeneration++;
// cout << " [" << thisGeneration << "] ";
// std::cout << " [" << thisGeneration << "] ";
Fitness bestCurrentFitness = _vEO.nth_element_fitness(0);
if (steadyState) { // already after MinGenenerations
@ -63,7 +63,7 @@ public:
lastImprovement = thisGeneration;
} else {
if (thisGeneration - lastImprovement > repSteadyGenerations) {
cout << "STOP in eoSteadyFitContinue: Done " << repSteadyGenerations
std::cout << "STOP in eoSteadyFitContinue: Done " << repSteadyGenerations
<< " generations without improvement\n";
return false;
}
@ -73,7 +73,7 @@ public:
steadyState = true;
bestSoFar = bestCurrentFitness;
lastImprovement = thisGeneration;
cout << "eoSteadyFitContinue: Done the minimum number of generations\n";
std::cout << "eoSteadyFitContinue: Done the minimum number of generations\n";
}
}
return true;

View file

@ -48,11 +48,11 @@ template <class EOT> class eoStochTournamentSelect: public eoSelectOne<EOT>
{
// consistency checks
if (Trate < 0.5) {
cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
std::cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
Trate = 0.55;
}
if (Trate > 1) {
cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
std::cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
Trate = 1;
}
}

View file

@ -90,14 +90,14 @@ public:
_pop.nth_element(nbSurvive);
// copy best
_luckyGuys.resize(nbSurvive);
copy(_pop.begin(), _pop.begin()+nbSurvive, _luckyGuys.begin());
std::copy(_pop.begin(), _pop.begin()+nbSurvive, _luckyGuys.begin());
// erase them from pop
_pop.erase(_pop.begin(), _pop.begin()+nbSurvive);
}
unsigned nbRemaining = _pop.size();
// carefull, we can have a rate of 1 if we want to kill all remaining
unsigned nbDie = min(howmanyDie(pSize), pSize-nbSurvive);
unsigned nbDie = std::min(howmanyDie(pSize), pSize-nbSurvive);
if (nbDie > nbRemaining)
throw std::logic_error("eoDeterministicSurviveAndDie: Too many to kill!\n");

View file

@ -26,7 +26,7 @@
#include <eoCellularEasyEA.h>
#include <math.h>
#include <cmath>
template <class EOT> class eoToricCellularEasyEA : public eoCellularEasyEA <EOT> {
@ -71,7 +71,7 @@ public :
virtual eoPop <EOT> neighbours (const eoPop <EOT> & pop, int rank) {
int dim2 = pop.size () ;
int dim = (int) sqrt (dim2) ;
int dim = (int) std::sqrt ( (double) dim2) ;
int j = rank ;
eoPop <EOT> neigh ;

View file

@ -93,7 +93,7 @@ class eoTruncatedSelectMany : public eoSelect<EOT>
else
{
// at the moment, brute force (rush rush, no good)
// what we would need otherwise is a vector<EOT &> class
// what we would need otherwise is a std::vector<EOT &> class
// and selectors that act on such a thing
eoPop<EOT> tmpPop = _source; // hum hum, could be a pain in the ass

View file

@ -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-04 06:51:59 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.7 2001-09-04 06:51:59 evomarc Exp $ $Author: evomarc $
CVS Info: $Date: 2003-02-27 19:25:48 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.8 2003-02-27 19:25:48 okoenig Exp $ $Author: okoenig $
*/
//-----------------------------------------------------------------------------
@ -45,7 +45,7 @@ class eoAtomExchange : public eoBF<unsigned, Atom &, bool>
public:
// a function to initlialize - to be called before every crossover
virtual void randomize(unsigned int, unsigned int){}
virtual string className() const=0;
virtual std::string className() const=0;
};
/** Uniform crossover - well, not really for FixedLength */
@ -70,11 +70,11 @@ public:
return mask[_i];
}
virtual string className() const {return "eoUniformAtomExchange";}
virtual std::string className() const {return "eoUniformAtomExchange";}
private:
double rate;
vector<bool> mask;
std::vector<bool> mask;
};
@ -124,7 +124,7 @@ public :
&& (index<10000) );
if (index >= 10000)
{
cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
std::cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
return false;
}
// here we know we have the right sizes: do the actual exchange
@ -148,12 +148,12 @@ public :
return true; // should we test that? Yes, but no time now
}
virtual string className() const
virtual std::string className() const
{
char s[1024];
ostrstream os(s, 1022);
os << "eoVlAtomExchangeQuadOp(" << atomExchange.className() << ")" << ends;
return string(s);
std::ostrstream os(s, 1022);
os << "eoVlAtomExchangeQuadOp(" << atomExchange.className() << ")" << std::ends;
return std::string(s);
}
private:
@ -188,12 +188,12 @@ public :
return changed; // should we test that? Yes, but no time now
}
virtual string className() const
virtual std::string className() const
{
char s[1024];
ostrstream os(s, 1022);
os << "eoInnerExchangeQuadOp(" << atomExchange.className() << ")" << ends;
return string(s);
std::ostrstream os(s, 1022);
os << "eoInnerExchangeQuadOp(" << atomExchange.className() << ")" << std::ends;
return std::string(s);
}
private:
float rate;
@ -250,7 +250,7 @@ public :
&& (index<10000) );
if (index >= 10000)
{
cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
std::cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
return false;
}
@ -318,7 +318,7 @@ public :
// this while condition is not optimal, as it may take some time
if (index >= 10000)
{
cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
std::cout << "Warning: impossible to generate individual of the right size in 10000 trials\n";
return false;
}

View file

@ -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-04 06:51:59 $ $Version$ $Author: evomarc $
CVS Info: $Date: 2003-02-27 19:25:48 $ $Version$ $Author: okoenig $
*/
//-----------------------------------------------------------------------------
@ -72,7 +72,7 @@ public :
return true;
}
virtual string className() const { return "eoVlAddMutation"; }
virtual std::string className() const { return "eoVlAddMutation"; }
private:
unsigned nMax;
@ -84,7 +84,7 @@ template <class EOT>
class eoGeneDelChooser : public eoUF<EOT &, unsigned int>
{
public:
virtual string className() const =0;
virtual std::string className() const =0;
};
@ -98,7 +98,7 @@ public:
{
return eo::rng.random(_eo.size());
}
virtual string className() const { return "eoUniformGeneChooser"; }
virtual std::string className() const { return "eoUniformGeneChooser"; }
};
/** Deletion of a gene
@ -139,12 +139,12 @@ public :
return true;
}
virtual string className() const
virtual std::string className() const
{
char s[1024];
ostrstream os(s, 1022);
os << "eoVlDelMutation(" << chooser.className() << ")" << ends;
return string(s);
std::ostrstream os(s, 1022);
os << "eoVlDelMutation(" << chooser.className() << ")" << std::ends;
return std::string(s);
}
private:

View file

@ -22,7 +22,7 @@
Marc.Schoenauer@polytechnique.fr
mak@dhi.dk
CVS Info: $Date: 2002-10-18 11:39:05 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVector.h,v 1.13 2002-10-18 11:39:05 jeggermo Exp $ $Author: jeggermo $
CVS Info: $Date: 2003-02-27 19:25:47 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVector.h,v 1.14 2003-02-27 19:25:47 okoenig Exp $ $Author: okoenig $
*/
//-----------------------------------------------------------------------------
@ -36,9 +36,9 @@
/**
Base class for fixed length chromosomes, just derives from EO and vector and
Base class for fixed length chromosomes, just derives from EO and std::vector and
redirects the smaller than operator to EO (fitness based comparison). GeneType
must have the following methods: void ctor (needed for the vector<>), copy ctor,
must have the following methods: void ctor (needed for the std::vector<>), copy ctor,
*/
@ -56,17 +56,17 @@ class eoVector : public EO<FitT>, public std::vector<GeneType>
/// copy ctor abstracting from the FitT
template <class OtherFitnessType>
eoVector(const eoVector<OtherFitnessType, GeneType>& _vec) : vector<GeneType>(_vec)
eoVector(const eoVector<OtherFitnessType, GeneType>& _vec) : std::vector<GeneType>(_vec)
{}
// we can't have a Ctor from a vector, it would create ambiguity
// we can't have a Ctor from a std::vector, it would create ambiguity
// with the copy Ctor
void value(const std::vector<GeneType>& _v)
{
if (_v.size() != size()) // safety check
{
if (size()) // NOT an initial empty vector
cout << "Warning: Changing size in eoVector assignation"<<endl;
if (size()) // NOT an initial empty std::vector
std::cout << "Warning: Changing size in eoVector assignation"<<std::endl;
resize(_v.size());
}
@ -74,14 +74,14 @@ class eoVector : public EO<FitT>, public std::vector<GeneType>
invalidate();
}
/// to avoid conflicts between EO::operator< and vector<GeneType>::operator<
/// to avoid conflicts between EO::operator< and std::vector<GeneType>::operator<
bool operator<(const eoVector<FitT, GeneType>& _eo) const
{
return EO<FitT>::operator<(_eo);
}
/// printing...
virtual void printOn(ostream& os) const
virtual void printOn(std::ostream& os) const
{
EO<FitT>::printOn(os);
os << ' ';
@ -92,7 +92,7 @@ class eoVector : public EO<FitT>, public std::vector<GeneType>
}
/// reading...
virtual void readFrom(istream& is)
virtual void readFrom(std::istream& is)
{
EO<FitT>::readFrom(is);
@ -111,7 +111,7 @@ class eoVector : public EO<FitT>, public std::vector<GeneType>
}
};
/// to avoid conflicts between EO::operator< and vector<double>::operator<
/// to avoid conflicts between EO::operator< and std::vector<double>::operator<
template <class FitT, class GeneType>
bool operator<(const eoVector<FitT, GeneType>& _eo1, const eoVector<FitT, GeneType>& _eo2)
{

View file

@ -35,7 +35,7 @@
// contains the include specific to real representations, i.e. in src/es dir
//-----------------------------------------------------------------------------
// the genotypes - from plain vector<double> to full correlated mutation
// the genotypes - from plain std::vector<double> to full correlated mutation
#include <es/eoReal.h>
#include <es/eoEsSimple.h>
#include <es/eoEsStdev.h>

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -37,7 +37,6 @@
#include <eoInit.h>
using namespace gp_parse_tree;
using namespace std;
/**
\defgroup ParseTree
@ -93,7 +92,7 @@ public :
/**
* To read me from a stream
* @param is The istream
* @param is The std::istream
*/
eoParseTree(std::istream& is) : EO<FType>(), parse_tree<Node>()
@ -102,11 +101,11 @@ public :
}
/// My class name
string className(void) const { return "eoParseTree"; }
std::string className(void) const { return "eoParseTree"; }
/**
* To print me on a stream
* @param os The ostream
* @param os The std::ostream
*/
void printOn(std::ostream& os) const
{
@ -120,7 +119,7 @@ public :
/**
* To read me from a stream
* @param is The istream
* @param is The std::istream
*/
void readFrom(std::istream& is)
{
@ -132,7 +131,7 @@ public :
is >> sz;
vector<Node> v(sz);
std::vector<Node> v(sz);
unsigned i;
@ -158,7 +157,7 @@ public :
fitness(fit);
std::copy(istream_iterator<Node>(is), istream_iterator<Node>(), back_inserter(*this));
std::copy(std::istream_iterator<Node>(is), std::istream_iterator<Node>(), back_inserter(*this));
*/
}
};

Some files were not shown because too many files have changed in this diff Show more