diff --git a/eo/app/mastermind/mastermind.cpp b/eo/app/mastermind/mastermind.cpp index 0db39120..25ee725b 100644 --- a/eo/app/mastermind/mastermind.cpp +++ b/eo/app/mastermind/mastermind.cpp @@ -10,6 +10,8 @@ #include // all usefull eo stuff #include "mastermind.h" // Chrom eoChromInit eoChromMutation eoChromXover eoChromEvaluator +using namespace std; + //----------------------------------------------------------------------------- // global variables //----------------------------------------------------------------------------- diff --git a/eo/app/mastermind/mastermind.h b/eo/app/mastermind/mastermind.h index 82495a3d..59d2cd74 100644 --- a/eo/app/mastermind/mastermind.h +++ b/eo/app/mastermind/mastermind.h @@ -23,7 +23,7 @@ typedef float phenotype; // genotype //----------------------------------------------------------------------------- -typedef vector genotype; +typedef std::vector 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 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; } diff --git a/eo/configure.in b/eo/configure.in index 1fcca74b..90de6124 100644 --- a/eo/configure.in +++ b/eo/configure.in @@ -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) diff --git a/eo/contrib/MGE/VirusOp.h b/eo/contrib/MGE/VirusOp.h index b0ee6cba..5d8459c4 100644 --- a/eo/contrib/MGE/VirusOp.h +++ b/eo/contrib/MGE/VirusOp.h @@ -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 // ostream, istream #include // bind2nd -#include // string +#include // std::string #include #include "../contrib/MGE/eoVirus.h" @@ -40,7 +40,7 @@ template class VirusBitFlip: public eoMonOp > { 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 VirusMutation: public eoMonOp > { 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 > { */ bool operator()(eoVirus& _chrom) { // Search for virus bits - vector bitsSet; + std::vector 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 > { 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 VirusTransmission: public eoBinOp > { public: /// The class name. - virtual string className() const { return "VirusTransmission"; }; + virtual std::string className() const { return "VirusTransmission"; }; /** * Change one bit. diff --git a/eo/contrib/MGE/eoVirus.h b/eo/contrib/MGE/eoVirus.h index d49af26c..720e2eda 100644 --- a/eo/contrib/MGE/eoVirus.h +++ b/eo/contrib/MGE/eoVirus.h @@ -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 // ostream, istream #include // bind2nd -#include // string +#include // std::string #include @@ -49,13 +49,13 @@ template class eoVirus: public eoBit /** * (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(_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 eoVirus: public eoBit * To print me on a stream. * @param os The ostream. */ - virtual void printOn(ostream& os) const { + virtual void printOn(std::ostream& os) const { EO::printOn(os); os << ' '; os << size() << ' '; - copy(begin(), end(), ostream_iterator(os)); - cout << endl; - copy(virus.begin(), virus.end(), ostream_iterator(os)); + std::copy(begin(), end(), std::ostream_iterator(os)); + std::cout << std::endl; + std::copy(virus.begin(), virus.end(), std::ostream_iterator(os)); } /** * To read me from a stream. * @param is The istream. */ - virtual void readFrom(istream& is){ + virtual void readFrom(std::istream& is){ eoBit::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(), '1')); + std::transform(bits.begin(), bits.end(), virus.begin(), + std::bind2nd(std::equal_to(), '1')); } } private: - vector virus; + std::vector virus; }; //----------------------------------------------------------------------------- diff --git a/eo/contrib/eoAged.h b/eo/contrib/eoAged.h index 3211791d..c4c02fc3 100644 --- a/eo/contrib/eoAged.h +++ b/eo/contrib/eoAged.h @@ -29,7 +29,7 @@ //----------------------------------------------------------------------------- #include // istream, ostream -#include // para string +#include // 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. diff --git a/eo/src/EO.h b/eo/src/EO.h index 7613d91c..fae793ae 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -27,7 +27,7 @@ //----------------------------------------------------------------------------- -#include // runtime_error +#include // std::runtime_error #include // eoObject #include // 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 diff --git a/eo/src/apply.h b/eo/src/apply.h index f376a91e..54cf162e 100644 --- a/eo/src/apply.h +++ b/eo/src/apply.h @@ -30,7 +30,7 @@ #include /** - Applies a unary function to a vector of things. + Applies a unary function to a std::vector of things. */ template void apply(eoUF& _proc, std::vector& _pop) diff --git a/eo/src/do/make_algo_easea.h b/eo/src/do/make_algo_easea.h index 605264b9..cbcb9960 100644 --- a/eo/src/do/make_algo_easea.h +++ b/eo/src/do/make_algo_easea.h @@ -77,40 +77,40 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc // the selection eoValueParam& 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 > + eoParamParamType & ppSelect = selectionParam.value(); // std::pair > eoSelectOne* 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(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(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 & 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 & p2w = _state.storeFunctor( new eoRanking(p,e) ); select = new eoRouletteWorthSelect(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(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; } - else if (ppSelect.first == string("Roulette")) // no argument (yet) + else if (ppSelect.first == std::string("Roulette")) // no argument (yet) { select = new eoProportionalSelect; } - else if (ppSelect.first == string("Random")) // no argument + else if (ppSelect.first == std::string("Random")) // no argument { select = new eoRandomSelect; } 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 & 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 & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc ptReplace = new eoG3Replacement(-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 & 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 & 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(-surviveParents, tSize); @@ -280,58 +280,58 @@ eoAlgo & 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 & 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( diff --git a/eo/src/do/make_algo_pareto.h b/eo/src/do/make_algo_pareto.h index 223aed6c..726fa834 100644 --- a/eo/src/do/make_algo_pareto.h +++ b/eo/src/do/make_algo_pareto.h @@ -47,7 +47,7 @@ class eoNDPlusReplacement : public eoReplacement public: eoNDPlusReplacement(eoPerf2Worth& _perf2worth) : perf2worth(_perf2worth) {} - struct WorthPair : public pair + struct WorthPair : public std::pair { bool operator<(const WorthPair& other) const { return other.first < first; } }; @@ -96,14 +96,14 @@ template eoAlgo & do_make_algo_pareto(eoParser& _parser, eoState& _state, eoEvalFunc& _eval, eoContinue& _continue, eoGenOp& _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 *p2w; - if ( (selStr == string("NSGA")) || (selStr == string("NSGA-I") ) ) + if ( (selStr == std::string("NSGA")) || (selStr == std::string("NSGA-I") ) ) p2w = new eoNDSorting_I(nicheSize); - else if (selStr == string("NSGA-II")) + else if (selStr == std::string("NSGA-II")) p2w = new eoNDSorting_II(); - else if (selStr == string("ParetoRanking")) + else if (selStr == std::string("ParetoRanking")) { eoDominanceMap& dominance = _state.storeFunctor(new eoDominanceMap); p2w = new eoParetoRanking(dominance); @@ -116,64 +116,64 @@ eoAlgo & do_make_algo_pareto(eoParser& _parser, eoState& _state, eoEvalFunc // only the ranking is not re-implemented (yet?) eoValueParam& selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection", "Selection: Roulette, DetTour(T), StochTour(t) or Random", 'S', "Evolution Engine"); - eoParamParamType & ppSelect = selectionParam.value(); // pair > + eoParamParamType & ppSelect = selectionParam.value(); // std::pair > eoSelectOne* 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(*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(*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(b); // } - else if (ppSelect.first == string("Roulette")) // no argument (yet) + else if (ppSelect.first == std::string("Roulette")) // no argument (yet) { select = new eoRouletteWorthSelect(*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; } 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); diff --git a/eo/src/do/make_algo_scalar.h b/eo/src/do/make_algo_scalar.h index 7ec834bf..6500492e 100644 --- a/eo/src/do/make_algo_scalar.h +++ b/eo/src/do/make_algo_scalar.h @@ -76,40 +76,40 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc // the selection eoValueParam& 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 > + eoParamParamType & ppSelect = selectionParam.value(); // std::pair > eoSelectOne* 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(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(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 & 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 & p2w = _state.storeFunctor( new eoRanking(p,e) ); select = new eoRouletteWorthSelect(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(b); } - else if (ppSelect.first == string("Roulette")) // no argument (yet) + else if (ppSelect.first == std::string("Roulette")) // no argument (yet) { select = new eoProportionalSelect; } - else if (ppSelect.first == string("Random")) // no argument + else if (ppSelect.first == std::string("Random")) // no argument { select = new eoRandomSelect; } 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 & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc // the replacement eoValueParam& 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 > + eoParamParamType & ppReplace = replacementParam.value(); // std::pair > eoReplacement* replace ; - if (ppReplace.first == string("Comma")) // Comma == generational + if (ppReplace.first == std::string("Comma")) // Comma == generational { replace = new eoCommaReplacement; } - else if (ppReplace.first == string("Plus")) + else if (ppReplace.first == std::string("Plus")) { replace = new eoPlusReplacement; } - 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(detSize); } - else if (ppReplace.first == string("SSGAWorst")) + else if (ppReplace.first == std::string("SSGAWorst")) { replace = new eoSSGAWorseReplacement; } - 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(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 & 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); diff --git a/eo/src/do/make_checkpoint.h b/eo/src/do/make_checkpoint.h index 176c476b..0ee6f129 100644 --- a/eo/src/do/make_checkpoint.h +++ b/eo/src/do/make_checkpoint.h @@ -66,7 +66,7 @@ eoCheckPoint& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval checkpoint->add(*generationCounter); // dir for DISK output - eoValueParam& dirNameParam = _parser.createParam(string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk"); + eoValueParam& dirNameParam = _parser.createParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk"); // shoudl we empty it if exists eoValueParam& 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& 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 - * eoSortedPopStat : whole population - type string (!!) - * eoScalarFitnessStat: the fitnesses - type vector + * eoSecondMomentStat: average + stdev - type std::pair + * eoSortedPopStat : whole population - type std::string (!!) + * eoScalarFitnessStat: the fitnesses - type std::vector */ // Best fitness in population @@ -188,9 +188,9 @@ eoCheckPoint& 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& 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& 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()); // save and give to checkpoint _state.storeFunctor(gnuMonitor); @@ -236,7 +236,7 @@ eoCheckPoint& 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 to it + // add any stat that is a std::vector to it fitSnapshot->add(*fitStat); // and of course add it to the checkpoint checkpoint->add(*fitSnapshot); @@ -259,9 +259,9 @@ eoCheckPoint& 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& 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); diff --git a/eo/src/do/make_checkpoint_FDC.h b/eo/src/do/make_checkpoint_FDC.h index fc8792f2..d198c9dd 100644 --- a/eo/src/do/make_checkpoint_FDC.h +++ b/eo/src/do/make_checkpoint_FDC.h @@ -62,7 +62,7 @@ eoCheckPoint& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval _state.storeFunctor(increment); // dir for DISK output - eoValueParam& dirNameParam = _parser.createParam(string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk"); + eoValueParam& dirNameParam = _parser.createParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk"); // shoudl we empty it if exists eoValueParam& 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& 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 - * eoSortedPopStat : whole population - type string (!!) - * eoScalarFitnessStat: the fitnesses - type vector + * eoSecondMomentStat: average + stdev - type std::pair + * eoSortedPopStat : whole population - type std::string (!!) + * eoScalarFitnessStat: the fitnesses - type std::vector * 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& 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& 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()); // save and give to checkpoint _state.storeFunctor(gnuMonitor); @@ -250,7 +250,7 @@ eoCheckPoint& 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 to it + // add any stat that is a std::vector to it fitSnapshot->add(*fitStat); // and of course add it to the checkpoint checkpoint->add(*fitSnapshot); @@ -271,7 +271,7 @@ eoCheckPoint& 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& 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); diff --git a/eo/src/do/make_checkpoint_pareto.h b/eo/src/do/make_checkpoint_pareto.h index 4acd0295..37ab768f 100644 --- a/eo/src/do/make_checkpoint_pareto.h +++ b/eo/src/do/make_checkpoint_pareto.h @@ -69,7 +69,7 @@ eoCheckPoint& 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& 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& 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& 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& 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 > + eoParamParamType & fPlot = fPlotParam.value(); // std::pair > 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 bStat(nObj, false); // track of who's already there @@ -110,8 +110,8 @@ eoCheckPoint& 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(obj1, s); _state.storeFunctor(fStat); bStat[obj1]=true; @@ -121,8 +121,8 @@ eoCheckPoint& 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(obj2, s2); _state.storeFunctor(fStat); bStat[obj2]=true; @@ -132,8 +132,8 @@ eoCheckPoint& 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& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state, eoSortedPopStat * popStat; if ( printPop ) // we do want pop dump { - cout << "On cree printpop\n"; + std::cout << "On cree printpop\n"; popStat = & _state.storeFunctor(new eoSortedPopStat); // add it to the checkpoint checkpoint.add(*popStat); @@ -205,9 +205,9 @@ eoCheckPoint& 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& 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); diff --git a/eo/src/do/make_continue.h b/eo/src/do/make_continue.h index 750df285..0ae6a907 100644 --- a/eo/src/do/make_continue.h +++ b/eo/src/do/make_continue.h @@ -146,7 +146,7 @@ eoContinue & 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); diff --git a/eo/src/do/make_continue_pareto.h b/eo/src/do/make_continue_pareto.h index d5b4400d..364f6057 100644 --- a/eo/src/do/make_continue_pareto.h +++ b/eo/src/do/make_continue_pareto.h @@ -97,7 +97,7 @@ eoContinue & 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); diff --git a/eo/src/do/make_general_replacement.h b/eo/src/do/make_general_replacement.h index 1ae8424e..9f9aba44 100644 --- a/eo/src/do/make_general_replacement.h +++ b/eo/src/do/make_general_replacement.h @@ -47,64 +47,64 @@ eoReduce & decode_reduce(eoParamParamType & _ppReduce, eoState & _state) eoReduce * ptReduce; // ---------- Deterministic - if (_ppReduce.first == string("Deterministic")) + if (_ppReduce.first == std::string("Deterministic")) { ptReduce = new eoTruncate; } // ---------- 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(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(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(p); } - else if (_ppReduce.first == string("Uniform")) + else if (_ppReduce.first == std::string("Uniform")) { ptReduce = new eoRandomReduce; } 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 & 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 diff --git a/eo/src/do/make_pop.h b/eo/src/do/make_pop.h index 52892be1..244485df 100644 --- a/eo/src/do/make_pop.h +++ b/eo/src/do/make_pop.h @@ -58,7 +58,7 @@ eoPop& do_make_pop(eoParser & _parser, eoState& _state, eoInit & _ini // create an empty pop and let the state handle the memory eoPop& pop = _state.takeOwnership(eoPop()); - eoValueParam& loadNameParam = _parser.createParam(string(""), "Load","A save file to restart from",'L', "Persistence" ); + eoValueParam& loadNameParam = _parser.createParam(std::string(""), "Load","A save file to restart from",'L', "Persistence" ); eoValueParam & recomputeFitnessParam = _parser.createParam(false, "recomputeFitness", "Recompute the fitness after re-loading the pop.?", 'r', "Persistence" ); if (loadNameParam.value() != "") // something to load diff --git a/eo/src/eoCloneOps.h b/eo/src/eoCloneOps.h index 89a91db4..4af49c62 100644 --- a/eo/src/eoCloneOps.h +++ b/eo/src/eoCloneOps.h @@ -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 public: /// Ctor eoMonCloneOp() : eoMonOp() {} - 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 public: /// Ctor eoBinCloneOp() : eoBinOp() {} - 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 public: /// Ctor eoQuadCloneOp():eoQuadOp() {} - virtual string className() const {return "eoQuadCloneOp";} + virtual std::string className() const {return "eoQuadCloneOp";} virtual bool operator()(EOT& , EOT& ) {return false;} }; diff --git a/eo/src/eoCombinedContinue.h b/eo/src/eoCombinedContinue.h index b6035ffe..35932ea2 100644 --- a/eo/src/eoCombinedContinue.h +++ b/eo/src/eoCombinedContinue.h @@ -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 > +20/11/00 MS: Changed the 2-continuator construct to a std::vector > to be consistent with other Combined constructs and allow to easily handle more than 2 continuators diff --git a/eo/src/eoCtrlCContinue.h b/eo/src/eoCtrlCContinue.h index edff201d..5997d992 100644 --- a/eo/src/eoCtrlCContinue.h +++ b/eo/src/eoCtrlCContinue.h @@ -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; diff --git a/eo/src/eoDetTournamentSelect.h b/eo/src/eoDetTournamentSelect.h index 5c72031c..4a197b3a 100755 --- a/eo/src/eoDetTournamentSelect.h +++ b/eo/src/eoDetTournamentSelect.h @@ -50,7 +50,7 @@ template class eoDetTournamentSelect: public eoSelectOne eoDetTournamentSelect(unsigned _tSize = 2 ):eoSelectOne(), 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; } } diff --git a/eo/src/eoDominanceMap.h b/eo/src/eoDominanceMap.h index 01b76e2d..fab752b7 100644 --- a/eo/src/eoDominanceMap.h +++ b/eo/src/eoDominanceMap.h @@ -31,7 +31,7 @@ #include /** - eoDominanceMap, utility class to calculate and maintain a map (vector >) of pareto dominance statistics. + eoDominanceMap, utility class to calculate and maintain a map (std::vector >) of pareto dominance statistics. It is set up such that @@ -115,12 +115,12 @@ class eoDominanceMap : public eoUF&, 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 cuz that + It returns a std::vector cuz that makes subsequent manipulation that much easier */ - vector sum_dominators() const + std::vector sum_dominators() const { - vector result(size(), 0.0); + std::vector result(size(), 0.0); for (unsigned i = 0; i < size(); ++i) { @@ -137,12 +137,12 @@ class eoDominanceMap : public eoUF&, void>, public std::vect /** For all elements, returns the number of elements that the element dominates Thus: higher is better - It returns a vector cuz that + It returns a std::vector cuz that makes subsequent manipulation that much easier */ - vector sum_dominants() const + std::vector sum_dominants() const { - vector result(size(), 0.0); + std::vector result(size(), 0.0); for (unsigned i = 0; i < size(); ++i) { @@ -159,7 +159,7 @@ class eoDominanceMap : public eoUF&, void>, public std::vect private : - vector fitness; + std::vector fitness; }; #endif diff --git a/eo/src/eoEasyEA.h b/eo/src/eoEasyEA.h index e4cba578..eddced4c 100644 --- a/eo/src/eoEasyEA.h +++ b/eo/src/eoEasyEA.h @@ -188,16 +188,16 @@ template class eoEasyEA: public eoAlgo 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 ) ); } diff --git a/eo/src/eoEvalContinue.h b/eo/src/eoEvalContinue.h index a2245247..34bd6c3f 100644 --- a/eo/src/eoEvalContinue.h +++ b/eo/src/eoEvalContinue.h @@ -39,7 +39,7 @@ public: /// Ctor eoEvalContinue( eoEvalFuncCounter & _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& _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; diff --git a/eo/src/eoFactory.h b/eo/src/eoFactory.h index f755036e..13864f03 100644 --- a/eo/src/eoFactory.h +++ b/eo/src/eoFactory.h @@ -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 */ //@} diff --git a/eo/src/eoFitContinue.h b/eo/src/eoFitContinue.h index 276e0b7c..dc823c53 100644 --- a/eo/src/eoFitContinue.h +++ b/eo/src/eoFitContinue.h @@ -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; } diff --git a/eo/src/eoG3Replacement.h b/eo/src/eoG3Replacement.h index 28928edf..7e7950f7 100644 --- a/eo/src/eoG3Replacement.h +++ b/eo/src/eoG3Replacement.h @@ -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); diff --git a/eo/src/eoGenContinue.h b/eo/src/eoGenContinue.h index 201d15ac..0f97e99a 100644 --- a/eo/src/eoGenContinue.h +++ b/eo/src/eoGenContinue.h @@ -51,10 +51,10 @@ public: * reached */ virtual bool operator() ( const eoPop& _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; diff --git a/eo/src/eoGenOp.h b/eo/src/eoGenOp.h index 9dcf6126..077bfcad 100644 --- a/eo/src/eoGenOp.h +++ b/eo/src/eoGenOp.h @@ -64,7 +64,7 @@ class eoGenOp : public eoOp, public eoUF &, void> */ virtual unsigned max_production(void) = 0; - virtual string className() const = 0; + virtual std::string className() const = 0; void operator()(eoPopulator& _pop) { _pop.reserve(max_production()); @@ -94,7 +94,7 @@ class eoMonGenOp : public eoGenOp (*_it).invalidate(); // look how simple } - virtual string className() const {return op.className();} + virtual std::string className() const {return op.className();} private : eoMonOp& op; }; @@ -121,7 +121,7 @@ class eoBinGenOp : public eoGenOp if (op(a, b)) a.invalidate(); } - virtual string className() const {return op.className();} + virtual std::string className() const {return op.className();} private : eoBinOp& op; @@ -142,7 +142,7 @@ class eoSelBinGenOp : public eoGenOp 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& op; @@ -173,7 +173,7 @@ class eoQuadGenOp : public eoGenOp } } - virtual string className() const {return op.className();} + virtual std::string className() const {return op.className();} private : eoQuadOp& op; diff --git a/eo/src/eoGeneralBreeder.h b/eo/src/eoGeneralBreeder.h index 878955a8..db46ab90 100644 --- a/eo/src/eoGeneralBreeder.h +++ b/eo/src/eoGeneralBreeder.h @@ -94,7 +94,7 @@ class eoGeneralBreeder: public eoBreed } /// The class name. - virtual string className() const { return "eoGeneralBreeder"; } + virtual std::string className() const { return "eoGeneralBreeder"; } private: eoSelectOne& select; diff --git a/eo/src/eoInit.h b/eo/src/eoInit.h index 08580aac..8383e7d2 100644 --- a/eo/src/eoInit.h +++ b/eo/src/eoInit.h @@ -47,7 +47,7 @@ class eoInit : public eoUF 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::iterator it; + typename std::vector::iterator it; for (it=_chrom.begin(); it<_chrom.end(); it++) init(*it); _chrom.invalidate(); diff --git a/eo/src/eoLinearFitScaling.h b/eo/src/eoLinearFitScaling.h index 998728a9..ead16039 100644 --- a/eo/src/eoLinearFitScaling.h +++ b/eo/src/eoLinearFitScaling.h @@ -78,7 +78,7 @@ public: for (i=0; i::iterator it = _offspring.it_best_element(); diff --git a/eo/src/eoMerge.h b/eo/src/eoMerge.h index 27e6e49b..defd1fc5 100644 --- a/eo/src/eoMerge.h +++ b/eo/src/eoMerge.h @@ -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 result; + std::vector result; _pop.nth_element(combienLocal, result); for (size_t i = 0; i < result.size(); ++i) diff --git a/eo/src/eoNDSorting.h b/eo/src/eoNDSorting.h index 44b18b33..fedbf868 100644 --- a/eo/src/eoNDSorting.h +++ b/eo/src/eoNDSorting.h @@ -34,7 +34,7 @@ #include /** - 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 {} /** 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 niche_penalty(const vector& current_front, const eoPop& _pop) = 0; + virtual std::vector niche_penalty(const std::vector& current_front, const eoPop& _pop) = 0; void calculate_worths(const eoPop& _pop) { @@ -92,7 +92,7 @@ private : void one_objective(const eoPop& _pop) { unsigned i; - vector tmp_pop; + std::vector 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() ); - for (i = 0; i < _pop.size(); ++i) { @@ -138,7 +134,7 @@ private : typedef typename EOT::Fitness::fitness_traits traits; assert(traits::nObjectives() == 2); - vector sort1(_pop.size()); // index into population sorted on first objective + std::vector 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 d; + std::vector d; d.resize(_pop.size(), max1); // initialize with the value max1 everywhere - vector > fronts(_pop.size()); // to store indices into the front + std::vector > 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::iterator it = + std::vector::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 niche_count = niche_penalty(fronts[i], _pop); + std::vector 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 > S(_pop.size()); // which individuals does guy i dominate - vector n(_pop.size(), 0); // how many individuals dominate guy i + std::vector > S(_pop.size()); // which individuals does guy i dominate + std::vector 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 current_front; + std::vector current_front; current_front.reserve(_pop.size()); // get the first front out @@ -305,22 +301,22 @@ private : } } - vector next_front; + std::vector 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 niche_count = niche_penalty(current_front, _pop); + std::vector 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 public : eoNDSorting_I(double _nicheSize) : eoNDSorting(), nicheSize(_nicheSize) {} - vector niche_penalty(const vector& current_front, const eoPop& _pop) + std::vector niche_penalty(const std::vector& current_front, const eoPop& _pop) { - vector niche_count(current_front.size(), 0.); + std::vector 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 }; /// _cf points into the elements that consist of the current front - vector niche_penalty(const vector& _cf, const eoPop& _pop) + std::vector niche_penalty(const std::vector& _cf, const eoPop& _pop) { typedef typename EOT::Fitness::fitness_traits traits; unsigned i; - vector niche_count(_cf.size(), 0.); + std::vector niche_count(_cf.size(), 0.); unsigned nObjectives = traits::nObjectives(); //_pop[_cf[0]].fitness().size(); @@ -449,7 +445,7 @@ class eoNDSorting_II : public eoNDSorting for (unsigned o = 0; o < nObjectives; ++o) { - vector > performance(_cf.size()); + std::vector > 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 sort(performance.begin(), performance.end(), compare_nodes()); // a lambda operator would've been nice here - vector nc(niche_count.size(), 0.0); + std::vector 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; diff --git a/eo/src/eoObject.h b/eo/src/eoObject.h index 69a6b388..7f603905 100644 --- a/eo/src/eoObject.h +++ b/eo/src/eoObject.h @@ -28,13 +28,11 @@ //----------------------------------------------------------------------------- #include // For limits definition -#include // istream, ostream -#include // string +#include // std::istream, std::ostream +#include // std::string #include -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; }; diff --git a/eo/src/eoOneToOneBreeder.h b/eo/src/eoOneToOneBreeder.h index 09891a71..cd18edd1 100644 --- a/eo/src/eoOneToOneBreeder.h +++ b/eo/src/eoOneToOneBreeder.h @@ -96,7 +96,7 @@ class eoOneToOneBreeder: public eoBreed // 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 } /// The class name. - virtual string className() const { return "eoOneToOneBreeder"; } + virtual std::string className() const { return "eoOneToOneBreeder"; } private: eoGenOp& op; diff --git a/eo/src/eoOp.h b/eo/src/eoOp.h index e1986759..e2143619 100644 --- a/eo/src/eoOp.h +++ b/eo/src/eoOp.h @@ -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, there are operators that work specifically - on vector, but you might also find that generic operators - working on vector are what you need. + is a std::vector, there are operators that work specifically + on std::vector, but you might also find that generic operators + working on std::vector are what you need. */ template @@ -103,7 +103,7 @@ public: /// Ctor eoMonOp() : eoOp( eoOp::unary ) {}; - virtual string className() const {return "eoMonOp";}; + virtual std::string className() const {return "eoMonOp";}; }; @@ -119,7 +119,7 @@ public: /// Ctor eoBinOp() :eoOp( eoOp::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( eoOp::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! diff --git a/eo/src/eoOpContainer.h b/eo/src/eoOpContainer.h index b68665df..00a3addf 100644 --- a/eo/src/eoOpContainer.h +++ b/eo/src/eoOpContainer.h @@ -64,15 +64,15 @@ class eoOpContainer : public eoGenOp { ops.push_back(&wrap_op(_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 rates; - vector*> ops; + std::vector rates; + std::vector*> ops; private : eoFunctorStore store; @@ -105,13 +105,13 @@ class eoSequentialOp : public eoOpContainer { // 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::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 while (!_pop.exhausted()); } } - virtual string className() const {return "SequentialOp";} + virtual std::string className() const {return "SequentialOp";} private : - vector to_apply; - vector production; + std::vector to_apply; + std::vector production; }; @@ -149,7 +149,7 @@ class eoProportionalOp : public eoOpContainer catch( typename eoPopulator::OutOfIndividuals&) {} } - virtual string className() const {return "ProportionalOp";} + virtual std::string className() const {return "ProportionalOp";} }; diff --git a/eo/src/eoOpSelMason.h b/eo/src/eoOpSelMason.h index 44089827..6c1d8092 100644 --- a/eo/src/eoOpSelMason.h +++ b/eo/src/eoOpSelMason.h @@ -39,7 +39,7 @@ template class eoOpSelMason: public eoFactory > { public: - typedef vector* > vOpP; + typedef std::vector* > vOpP; typedef map*, 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* make(istream& _is) { + virtual eoOpSelector* make(std::istream& _is) { - string opSelName; + std::string opSelName; _is >> opSelName; eoOpSelector* opSelectorP; // Build the operator selector @@ -72,7 +72,7 @@ public: opSelectorP = new eoProportionalOpSel(); } - // 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*,vector* > > allocMap; + map*,std::vector* > > allocMap; eoOpFactory& operatorFactory; }; diff --git a/eo/src/eoParetoConstraintFitness.h b/eo/src/eoParetoConstraintFitness.h index c6c0446d..9e2b2942 100644 --- a/eo/src/eoParetoConstraintFitness.h +++ b/eo/src/eoParetoConstraintFitness.h @@ -70,25 +70,25 @@ public : eoParetoOneConstraintFitness(void) : std::vector(FitnessTraits::nObjectives(),0.0) {} - // Ctr from a vector (size nObjectives+1) + // Ctr from a std::vector (size nObjectives+1) eoParetoOneConstraintFitness(std::vector & _v) : std::vector(_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 and a value + // Ctr from a std::vector and a value eoParetoOneConstraintFitness(std::vector & _v, double _c) : std::vector(_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 } diff --git a/eo/src/eoParetoFitness.h b/eo/src/eoParetoFitness.h index 6ebaea70..4634c9f4 100644 --- a/eo/src/eoParetoFitness.h +++ b/eo/src/eoParetoFitness.h @@ -113,7 +113,7 @@ public : eoParetoFitness(void) : std::vector(FitnessTraits::nObjectives(),0.0) {} - // Ctr from a vector + // Ctr from a std::vector eoParetoFitness(std::vector & _v) : std::vector(_v) {} diff --git a/eo/src/eoParetoRanking.h b/eo/src/eoParetoRanking.h index 322c97ba..60063fab 100644 --- a/eo/src/eoParetoRanking.h +++ b/eo/src/eoParetoRanking.h @@ -50,7 +50,7 @@ class eoParetoRanking : public eoPerf2WorthCached 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) diff --git a/eo/src/eoPerf2Worth.h b/eo/src/eoPerf2Worth.h index 0807fb03..4138817a 100644 --- a/eo/src/eoPerf2Worth.h +++ b/eo/src/eoPerf2Worth.h @@ -50,7 +50,7 @@ class eoPerf2Worth : public eoUF&, void>, public eoValueParam& _pop) - { // start with a vector of indices + { // start with a std::vector of indices std::vector indices(_pop.size()); unsigned i; @@ -59,7 +59,7 @@ class eoPerf2Worth : public eoUF&, void>, public eoValueParam tmp_pop; tmp_pop.resize(_pop.size()); @@ -71,8 +71,8 @@ class eoPerf2Worth : public eoUF&, void>, public eoValueParam Sort population according to worth, will keep the worths and fitness_cache in sync with the population. */ virtual void sort_pop(eoPop& _pop) - { // start with a vector of indices + { // start with a std::vector of indices std::vector indices(_pop.size()); unsigned i; @@ -183,9 +183,9 @@ class eoPerf2WorthCached : public eoPerf2Worth 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 diff --git a/eo/src/eoPersistent.cpp b/eo/src/eoPersistent.cpp index 9e61c48d..1c0c52ea 100644 --- a/eo/src/eoPersistent.cpp +++ b/eo/src/eoPersistent.cpp @@ -9,7 +9,7 @@ //----------------------------------------------------------------------------- -istream & operator >> ( istream& _is, eoPersistent& _o ) { +std::istream & operator >> ( std::istream& _is, eoPersistent& _o ) { _o.readFrom(_is); return _is; }; diff --git a/eo/src/eoPersistent.h b/eo/src/eoPersistent.h index c6f83838..2d4c3eb1 100644 --- a/eo/src/eoPersistent.h +++ b/eo/src/eoPersistent.h @@ -36,14 +36,12 @@ const unsigned MAXLINELENGTH=1024; //----------------------------------------------------------------------------- -#include // istream, ostream -#include // para string +#include // std::istream, std::ostream +#include // 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 diff --git a/eo/src/eoPop.h b/eo/src/eoPop.h index 7c3f8184..46cc2ab9 100644 --- a/eo/src/eoPop.h +++ b/eo/src/eoPop.h @@ -36,11 +36,11 @@ #include #include // 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 eoPop: public vector, public eoObject, public eoPersistent +class eoPop: public std::vector, public eoObject, public eoPersistent { public: typedef typename EOT::Fitness Fitness; /** Default ctor. Creates empty pop */ - eoPop() : vector(), eoObject(), eoPersistent() {}; + eoPop() : std::vector(), eoObject(), eoPersistent() {}; /** Ctor for the initialization of chromosomes @@ -66,7 +66,7 @@ class eoPop: public vector, public eoObject, public eoPersistent @param _chromInit Initialization routine, produces EO's, needs to be an eoInit */ eoPop( unsigned _popSize, eoInit& _chromInit ) - :vector() + :std::vector() { resize(_popSize); for ( unsigned i = 0; i < _popSize; i++ ) @@ -75,7 +75,7 @@ class eoPop: public vector, 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, 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, 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() { + eoPop( std::istream& _is ) :std::vector() { readFrom( _is ); } @@ -125,11 +125,11 @@ class eoPop: public vector, public eoObject, public eoPersistent */ void sort(void) { - std::sort(begin(), end(), greater()); + std::sort(begin(), end(), std::greater()); } - /** creates a vector pointing to the individuals in descending order */ - void sort(vector& result) const + /** creates a std::vector pointing to the individuals in descending order */ + void sort(std::vector& result) const { result.resize(size()); @@ -148,8 +148,8 @@ class eoPop: public vector, public eoObject, public eoPersistent std::random_shuffle(begin(), end(), gen); } - /** creates a vector pointing to the individuals in random order */ - void shuffle(vector& result) const + /** creates a std::vector pointing to the individuals in random order */ + void shuffle(std::vector& result) const { result.resize(size()); @@ -162,28 +162,28 @@ class eoPop: public vector, public eoObject, public eoPersistent /** returns an iterator to the best individual DOES NOT MOVE ANYBODY */ typename eoPop::iterator it_best_element() { - typename eoPop::iterator it = max_element(begin(), end()); + typename eoPop::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::const_iterator it = max_element(begin(), end()); + typename eoPop::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::const_iterator it = min_element(begin(), end()); + typename eoPop::const_iterator it = std::min_element(begin(), end()); return (*it); } /** returns an iterator to the worse individual DOES NOT MOVE ANYBODY */ typename eoPop::iterator it_worse_element() { - typename eoPop::iterator it = min_element(begin(), end()); + typename eoPop::iterator it = std::min_element(begin(), end()); return it; } @@ -194,7 +194,7 @@ class eoPop: public vector, public eoObject, public eoPersistent typename eoPop::iterator nth_element(int nth) { typename eoPop::iterator it = begin() + nth; - std::nth_element(begin(), it, end(), greater()); + std::nth_element(begin(), it, end(), std::greater()); return it; } @@ -204,24 +204,24 @@ class eoPop: public vector, 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(size()); + std::vector fitness(size()); std::transform(begin(), end(), fitness.begin(), GetFitness()); - typename vector::iterator it = fitness.begin() + which; - std::nth_element(fitness.begin(), it, fitness.end(), greater()); + typename std::vector::iterator it = fitness.begin() + which; + std::nth_element(fitness.begin(), it, fitness.end(), std::greater()); return *it; } /** const nth_element function, returns pointers to sorted individuals * up the the nth */ - void nth_element(int which, vector& result) const + void nth_element(int which, std::vector& result) const { result.resize(size()); std::transform(begin(), end(), result.begin(), Ref()); - typename vector::iterator it = result.begin() + which; + typename std::vector::iterator it = result.begin() + which; std::nth_element(result.begin(), it, result.end(), Cmp()); } @@ -229,30 +229,30 @@ class eoPop: public vector, public eoObject, public eoPersistent /** does STL swap with other pop */ void swap(eoPop& other) { - std::swap(static_cast& >(*this), static_cast& >(other)); + std::swap(static_cast& >(*this), static_cast& >(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 result; + std::vector 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( _os, "\n") ); @@ -263,9 +263,9 @@ class eoPop: public vector, 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, 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() diff --git a/eo/src/eoPrintable.cpp b/eo/src/eoPrintable.cpp index b5649599..c90e6424 100644 --- a/eo/src/eoPrintable.cpp +++ b/eo/src/eoPrintable.cpp @@ -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; }; diff --git a/eo/src/eoPrintable.h b/eo/src/eoPrintable.h index e416175d..256383dc 100644 --- a/eo/src/eoPrintable.h +++ b/eo/src/eoPrintable.h @@ -27,10 +27,8 @@ //----------------------------------------------------------------------------- -#include // istream, ostream -#include // para string - -using namespace std; +#include // std::istream, std::ostream +#include // 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 diff --git a/eo/src/eoProportionalCombinedOp.h b/eo/src/eoProportionalCombinedOp.h index 5fba7fe5..7fa8a895 100644 --- a/eo/src/eoProportionalCombinedOp.h +++ b/eo/src/eoProportionalCombinedOp.h @@ -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 & _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 & _op, const double _rate, bool _verbose=false) { @@ -129,9 +129,9 @@ virtual void add(eoBinOp & _op, const double _rate, bool _verbose=false) unsigned i; for (i=0; iclassName() << " 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 & _op, const double _rate, bool _verbose=false) @@ -179,11 +179,11 @@ virtual void add(eoQuadOp & _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; diff --git a/eo/src/eoProportionalSelect.h b/eo/src/eoProportionalSelect.h index d870dcaf..f85321f4 100755 --- a/eo/src/eoProportionalSelect.h +++ b/eo/src/eoProportionalSelect.h @@ -48,7 +48,7 @@ public: total((pop.size() == 0) ? -1.0 : sum_fitness(pop)) { if (minimizing_fitness()) - throw logic_error("eoProportionalSelect: minimizing fitness"); + throw std::logic_error("eoProportionalSelect: minimizing fitness"); } void setup(const eoPop& _pop) diff --git a/eo/src/eoRanking.h b/eo/src/eoRanking.h index 49bae600..5b7421be 100644 --- a/eo/src/eoRanking.h +++ b/eo/src/eoRanking.h @@ -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 eoRanking : public eoPerf2Worth // 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& _pop) { - vector rank; + std::vector 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; diff --git a/eo/src/eoRankingSelect.h b/eo/src/eoRankingSelect.h index 6f070cb9..fd5619a9 100644 --- a/eo/src/eoRankingSelect.h +++ b/eo/src/eoRankingSelect.h @@ -32,7 +32,7 @@ #include /** 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 */ diff --git a/eo/src/eoReduce.h b/eo/src/eoReduce.h index f07615f5..53d8e427 100644 --- a/eo/src/eoReduce.h +++ b/eo/src/eoReduce.h @@ -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::iterator> EPpair; + typedef std::pair::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 scores(presentSize); + std::vector scores(presentSize); for (unsigned i=0; i::iterator it = scores.begin() + _newsize; + typename std::vector::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 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; } } diff --git a/eo/src/eoReduceMergeReduce.h b/eo/src/eoReduceMergeReduce.h index 0cde81ea..05854ea7 100644 --- a/eo/src/eoReduceMergeReduce.h +++ b/eo/src/eoReduceMergeReduce.h @@ -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 & reduceParents; eoReduce & reduceOffspring; diff --git a/eo/src/eoReduceSplit.h b/eo/src/eoReduceSplit.h index 9db344ed..fcc4cc7e 100644 --- a/eo/src/eoReduceSplit.h +++ b/eo/src/eoReduceSplit.h @@ -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; } } diff --git a/eo/src/eoSGAGenOp.h b/eo/src/eoSGAGenOp.h index 35c31cd6..a6533f07 100644 --- a/eo/src/eoSGAGenOp.h +++ b/eo/src/eoSGAGenOp.h @@ -74,7 +74,7 @@ class eoSGAGenOp : public eoGenOp /** inherited from eoGenOp */ virtual unsigned max_production(void) {return 2;} - virtual string className() const {return "eoSGAGenOp";} + virtual std::string className() const {return "eoSGAGenOp";} private: diff --git a/eo/src/eoSGATransform.h b/eo/src/eoSGATransform.h index 47e2747a..4eebbe37 100644 --- a/eo/src/eoSGATransform.h +++ b/eo/src/eoSGATransform.h @@ -33,7 +33,7 @@ /////////////////////////////////////////////////////////////////////////////// // class eoSGATransform /////////////////////////////////////////////////////////////////////////////// -#include // vector +#include // std::vector #include #include diff --git a/eo/src/eoSelectFactory.h b/eo/src/eoSelectFactory.h index aafb01a7..d94a0fa0 100644 --- a/eo/src/eoSelectFactory.h +++ b/eo/src/eoSelectFactory.h @@ -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* make(istream& _is) { + virtual eoSelect* make(std::istream& _is) { eoSelect * 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( 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 */ //@} diff --git a/eo/src/eoSelectFromWorth.h b/eo/src/eoSelectFromWorth.h index 516abf22..d2c993dc 100644 --- a/eo/src/eoSelectFromWorth.h +++ b/eo/src/eoSelectFromWorth.h @@ -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 eoDetTournamentWorthSelect : public eoSelectFromWorth { public: - typedef typename vector::iterator worthIterator; + typedef typename std::vector::iterator worthIterator; /* Default ctor from an eoPerf2Worth object + tournament size */ @@ -134,7 +134,7 @@ template class eoStochTournamentWorthSelect : public eoSelectFromWorth { public: - typedef typename vector::iterator worthIterator; + typedef typename std::vector::iterator worthIterator; /* Default ctor from an eoPerf2Worth object + tournament rate */ @@ -172,7 +172,7 @@ template class eoRouletteWorthSelect : public eoSelectFromWorth { public: - typedef typename vector::iterator worthIterator; + typedef typename std::vector::iterator worthIterator; /* Default ctor from an eoPerf2Worth object */ diff --git a/eo/src/eoSequentialSelect.h b/eo/src/eoSequentialSelect.h index 523928a1..adb65327 100644 --- a/eo/src/eoSequentialSelect.h +++ b/eo/src/eoSequentialSelect.h @@ -53,8 +53,13 @@ template class eoSequentialSelect: public eoSelectOne /** 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& _pop) { @@ -78,7 +83,7 @@ template class eoSequentialSelect: public eoSelectOne private: bool ordered; unsigned current; - vector eoPters; + std::vector eoPters; }; @@ -99,7 +104,11 @@ template class eoEliteSequentialSelect: public eoSelectOne /** 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& _pop) { @@ -109,7 +118,7 @@ template class eoEliteSequentialSelect: public eoSelectOne 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 eoEliteSequentialSelect: public eoSelectOne } private: unsigned current; - vector eoPters; + std::vector eoPters; }; diff --git a/eo/src/eoSharing.h b/eo/src/eoSharing.h index f2178adf..037dfcce 100644 --- a/eo/src/eoSharing.h +++ b/eo/src/eoSharing.h @@ -55,10 +55,10 @@ class eoSharing : public eoPerf2Worth 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 sim(pSize); // to hold the similarities - vector distMatrix(pSize*(pSize-1)/2); // to hold the distances + std::vector sim(pSize); // to hold the similarities + std::vector distMatrix(pSize*(pSize-1)/2); // to hold the distances // compute the distances distMatrix(0,0)=0; @@ -86,11 +86,11 @@ class eoSharing : public eoPerf2Worth } // helper class to hold distances - class dMatrix : public vector + class dMatrix : public std::vector { public: // Ctor : sets size - dMatrix(unsigned _s) : vector(_s*(_s-1)), rSize(_s) {} + dMatrix(unsigned _s) : std::vector(_s*(_s-1)), rSize(_s) {} /** simple accessor */ double operator()(unsigned _i, unsigned _j) const @@ -105,16 +105,16 @@ class eoSharing : public eoPerf2Worth } /** just in case */ - void printOn(ostream & _os) + void printOn(std::ostream & _os) { unsigned index=0; for (unsigned i=0; ioperator[](index++) << " " ; - _os << endl; + _os << std::endl; } - _os << endl; + _os << std::endl; } private: diff --git a/eo/src/eoSimpleDEA.h b/eo/src/eoSimpleDEA.h index ea785250..3eef44c7 100644 --- a/eo/src/eoSimpleDEA.h +++ b/eo/src/eoSimpleDEA.h @@ -80,11 +80,11 @@ template class eoSimpleDEA: public eoDEA 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 ) ); } diff --git a/eo/src/eoSteadyFitContinue.h b/eo/src/eoSteadyFitContinue.h index 7b3e0ef1..62b3e6fe 100755 --- a/eo/src/eoSteadyFitContinue.h +++ b/eo/src/eoSteadyFitContinue.h @@ -54,7 +54,7 @@ public: * reached withtout improvement */ virtual bool operator() ( const eoPop& _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; diff --git a/eo/src/eoStochTournamentSelect.h b/eo/src/eoStochTournamentSelect.h index a2928a52..69f0376e 100755 --- a/eo/src/eoStochTournamentSelect.h +++ b/eo/src/eoStochTournamentSelect.h @@ -48,11 +48,11 @@ template class eoStochTournamentSelect: public eoSelectOne { // 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; } } diff --git a/eo/src/eoSurviveAndDie.h b/eo/src/eoSurviveAndDie.h index eb582cb1..1c4f766f 100644 --- a/eo/src/eoSurviveAndDie.h +++ b/eo/src/eoSurviveAndDie.h @@ -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"); diff --git a/eo/src/eoToricCellularEasyEA.h b/eo/src/eoToricCellularEasyEA.h index bd4149ab..1710cec6 100644 --- a/eo/src/eoToricCellularEasyEA.h +++ b/eo/src/eoToricCellularEasyEA.h @@ -26,7 +26,7 @@ #include -#include +#include template class eoToricCellularEasyEA : public eoCellularEasyEA { @@ -71,7 +71,7 @@ public : virtual eoPop neighbours (const eoPop & pop, int rank) { int dim2 = pop.size () ; - int dim = (int) sqrt (dim2) ; + int dim = (int) std::sqrt ( (double) dim2) ; int j = rank ; eoPop neigh ; diff --git a/eo/src/eoTruncatedSelectMany.h b/eo/src/eoTruncatedSelectMany.h index 24dbc47a..9cad8dbc 100644 --- a/eo/src/eoTruncatedSelectMany.h +++ b/eo/src/eoTruncatedSelectMany.h @@ -93,7 +93,7 @@ class eoTruncatedSelectMany : public eoSelect else { // at the moment, brute force (rush rush, no good) - // what we would need otherwise is a vector class + // what we would need otherwise is a std::vector class // and selectors that act on such a thing eoPop tmpPop = _source; // hum hum, could be a pain in the ass diff --git a/eo/src/eoVariableLengthCrossover.h b/eo/src/eoVariableLengthCrossover.h index 9f3af205..1d1eaf82 100644 --- a/eo/src/eoVariableLengthCrossover.h +++ b/eo/src/eoVariableLengthCrossover.h @@ -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 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 mask; + std::vector 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; } diff --git a/eo/src/eoVariableLengthMutation.h b/eo/src/eoVariableLengthMutation.h index 6e4d37ba..949b5d9a 100644 --- a/eo/src/eoVariableLengthMutation.h +++ b/eo/src/eoVariableLengthMutation.h @@ -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 eoGeneDelChooser : public eoUF { 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: diff --git a/eo/src/eoVector.h b/eo/src/eoVector.h index d888a7fe..bc95bf79 100644 --- a/eo/src/eoVector.h +++ b/eo/src/eoVector.h @@ -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, public std::vector /// copy ctor abstracting from the FitT template - eoVector(const eoVector& _vec) : vector(_vec) + eoVector(const eoVector& _vec) : std::vector(_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& _v) { if (_v.size() != size()) // safety check { - if (size()) // NOT an initial empty vector - cout << "Warning: Changing size in eoVector assignation"<, public std::vector invalidate(); } - /// to avoid conflicts between EO::operator< and vector::operator< + /// to avoid conflicts between EO::operator< and std::vector::operator< bool operator<(const eoVector& _eo) const { return EO::operator<(_eo); } /// printing... - virtual void printOn(ostream& os) const + virtual void printOn(std::ostream& os) const { EO::printOn(os); os << ' '; @@ -92,7 +92,7 @@ class eoVector : public EO, public std::vector } /// reading... - virtual void readFrom(istream& is) + virtual void readFrom(std::istream& is) { EO::readFrom(is); @@ -111,7 +111,7 @@ class eoVector : public EO, public std::vector } }; -/// to avoid conflicts between EO::operator< and vector::operator< +/// to avoid conflicts between EO::operator< and std::vector::operator< template bool operator<(const eoVector& _eo1, const eoVector& _eo2) { diff --git a/eo/src/es.h b/eo/src/es.h index 84fd2c73..c3d307ae 100644 --- a/eo/src/es.h +++ b/eo/src/es.h @@ -35,7 +35,7 @@ // contains the include specific to real representations, i.e. in src/es dir //----------------------------------------------------------------------------- -// the genotypes - from plain vector to full correlated mutation +// the genotypes - from plain std::vector to full correlated mutation #include #include #include diff --git a/eo/src/es/eoEsChromInit.h b/eo/src/es/eoEsChromInit.h index 9e80679a..a9b40e41 100644 --- a/eo/src/es/eoEsChromInit.h +++ b/eo/src/es/eoEsChromInit.h @@ -46,7 +46,7 @@ eoReal just an eoVector 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& result) { unsigned theSize = eoRealInitBounded::size(); diff --git a/eo/src/es/eoEsFull.h b/eo/src/es/eoEsFull.h index 1f6eb734..7c5b5faf 100644 --- a/eo/src/es/eoEsFull.h +++ b/eo/src/es/eoEsFull.h @@ -60,7 +60,7 @@ class eoEsFull : public eoVector os << ' '; } - void readFrom(istream& is) + void readFrom(std::istream& is) { eoVector::readFrom(is); @@ -76,8 +76,8 @@ class eoEsFull : public eoVector is >> correlations[i]; } - vector stdevs; - vector correlations; + std::vector stdevs; + std::vector correlations; }; diff --git a/eo/src/es/eoEsGlobalXover.h b/eo/src/es/eoEsGlobalXover.h index ce016b56..1743e170 100644 --- a/eo/src/es/eoEsGlobalXover.h +++ b/eo/src/es/eoEsGlobalXover.h @@ -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; } diff --git a/eo/src/es/eoEsMutate.h b/eo/src/es/eoEsMutate.h index d6568a90..e86feb05 100644 --- a/eo/src/es/eoEsMutate.h +++ b/eo/src/es/eoEsMutate.h @@ -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 VarStp(_eo.size()); + std::vector 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: tau local " << TauLcl << endl; + std::cout << "Init: tau local " << TauLcl << std::endl; } void init(eoEsStdev, eoEsMutationInit& _init) @@ -243,14 +243,14 @@ public: // renormalization TauLcl /= sqrt( 2.0 * sqrt( (double)size ) ); TauGlb /= sqrt( 2.0 * ( (double) size ) ); - cout << "Init: tau local " << TauLcl << " et global " << TauGlb << endl; + std::cout << "Init: tau local " << TauLcl << " et global " << TauGlb << std::endl; } void init(eoEsFull, eoEsMutationInit& _init) { init(eoEsStdev(), _init); TauBeta = _init.TauBeta(); - cout << "Init: tau local " << TauLcl << " et global " << TauGlb << endl; + std::cout << "Init: tau local " << TauLcl << " et global " << TauGlb << std::endl; } // the data diff --git a/eo/src/es/eoEsSimple.h b/eo/src/es/eoEsSimple.h index 9ec29040..3a38faa3 100644 --- a/eo/src/es/eoEsSimple.h +++ b/eo/src/es/eoEsSimple.h @@ -61,7 +61,7 @@ public : os << ' ' << stdev << ' '; } - void readFrom(istream& is) + void readFrom(std::istream& is) { eoVector::readFrom(is); diff --git a/eo/src/es/eoEsStandardXover.h b/eo/src/es/eoEsStandardXover.h index d360d953..b4cc1153 100644 --- a/eo/src/es/eoEsStandardXover.h +++ b/eo/src/es/eoEsStandardXover.h @@ -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 diff --git a/eo/src/es/eoEsStdev.h b/eo/src/es/eoEsStdev.h index fd43476d..277b2d90 100644 --- a/eo/src/es/eoEsStdev.h +++ b/eo/src/es/eoEsStdev.h @@ -57,7 +57,7 @@ class eoEsStdev : public eoVector os << ' '; } - void readFrom(istream& is) + void readFrom(std::istream& is) { eoVector::readFrom(is); stdevs.resize(size()); @@ -68,7 +68,7 @@ class eoEsStdev : public eoVector } - vector stdevs; + std::vector stdevs; }; #endif diff --git a/eo/src/es/eoNormalMutation.h b/eo/src/es/eoNormalMutation.h index 6dd12dc8..cb4ef551 100644 --- a/eo/src/es/eoNormalMutation.h +++ b/eo/src/es/eoNormalMutation.h @@ -36,7 +36,7 @@ #include //----------------------------------------------------------------------------- -/** 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 eoNormalMutation: public eoMonOp 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 & eval; double threshold; // 1/5 ! double updateFactor ; // the multiplicative factor - vector nbMut; // total number of mutations per gen - vector nbSuccess; // number of successful mutations per gen - unsigned genIndex ; // current index in vectors (circular) + std::vector nbMut; // total number of mutations per gen + std::vector nbSuccess; // number of successful mutations per gen + unsigned genIndex ; // current index in std::vectors (circular) }; diff --git a/eo/src/es/eoReal.h b/eo/src/es/eoReal.h index e1429e52..516395f1 100644 --- a/eo/src/es/eoReal.h +++ b/eo/src/es/eoReal.h @@ -26,8 +26,8 @@ //----------------------------------------------------------------------------- -#include // ostream, istream -#include // string +#include // std::ostream, std::istream +#include // std::string #include @@ -40,13 +40,13 @@ template class eoReal: public eoVector /** * (Default) Constructor. - * @param size Size of the vector + * @param size Size of the std::vector */ eoReal(unsigned size = 0, double value = 0.0): eoVector(size, value) {} /// My class name. - virtual string className() const + virtual std::string className() const { return "eoReal"; } diff --git a/eo/src/es/eoRealAtomXover.h b/eo/src/es/eoRealAtomXover.h index 91d7520e..9380b443 100644 --- a/eo/src/es/eoRealAtomXover.h +++ b/eo/src/es/eoRealAtomXover.h @@ -1,7 +1,7 @@ /** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- //----------------------------------------------------------------------------- -// eoRealAtomXover.h : helper classes for vector crossover +// eoRealAtomXover.h : helper classes for std::vector 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 diff --git a/eo/src/es/eoRealInitBounded.h b/eo/src/es/eoRealInitBounded.h index 8d8fb05b..b0f98ba6 100644 --- a/eo/src/es/eoRealInitBounded.h +++ b/eo/src/es/eoRealInitBounded.h @@ -33,7 +33,7 @@ #include #include -/** Simple initialization for any EOT that derives from vector +/** Simple initialization for any EOT that derives from std::vector * uniformly in some bounds */ template @@ -44,7 +44,7 @@ class eoRealInitBounded : public eoInit eoRealInitBounded(eoRealVectorBounds & _bounds):bounds(_bounds) { if (!bounds.isBounded()) - throw runtime_error("Needs bounded bounds to initialize a vector"); + throw std::runtime_error("Needs bounded bounds to initialize a std::vector"); } /** simply passes the argument to the uniform method of the bounds */ diff --git a/eo/src/es/eoRealOp.h b/eo/src/es/eoRealOp.h index 01d7d6e8..405f9692 100644 --- a/eo/src/es/eoRealOp.h +++ b/eo/src/es/eoRealOp.h @@ -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 eoUniformMutation: public eoMonOp * @param _p_change the VECTOR of probabilities for each coordinates */ eoUniformMutation(eoRealVectorBounds & _bounds, - const vector& _epsilon, - const vector& _p_change): + const std::vector& _epsilon, + const std::vector& _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 eoUniformMutation: public eoMonOp { // 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 eoUniformMutation: public eoMonOp 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 eoUniformMutation: public eoMonOp private: bool homogeneous; // == no bounds passed in the ctor eoRealVectorBounds & bounds; - vector epsilon; // the ranges for mutation - vector p_change; // the proba that each variable is modified + std::vector epsilon; // the ranges for mutation + std::vector 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 eoDetUniformMutation: public eoMonOp } /** - * 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& _epsilon, + const std::vector& _epsilon, const unsigned& _no = 1): homogeneous(false), bounds(_bounds), epsilon(_epsilon), no(_no) { @@ -190,7 +190,7 @@ template class eoDetUniformMutation: public eoMonOp } /// The class name. - virtual string className() const { return "eoDetUniformMutation"; } + virtual std::string className() const { return "eoDetUniformMutation"; } /** * Do it! @@ -209,7 +209,7 @@ template class eoDetUniformMutation: public eoMonOp { // 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 class eoDetUniformMutation: public eoMonOp 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 eoDetUniformMutation: public eoMonOp private: bool homogeneous; // == no bounds passed in the ctor eoRealVectorBounds & bounds; - vector epsilon; // the ranges of mutation + std::vector epsilon; // the ranges of mutation unsigned no; }; @@ -272,7 +272,7 @@ template class eoSegmentCrossover: public eoQuadOp 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 eoSegmentCrossover: public eoQuadOp 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 eoHypercubeCrossover: public eoQuadOp 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 eoHypercubeCrossover: public eoQuadOp 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 eoHypercubeCrossover: public eoQuadOp 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 eoHypercubeCrossover: public eoQuadOp // 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 eoRealUXover: public eoQuadOp 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++) { diff --git a/eo/src/es/make_genotype_real.h b/eo/src/es/make_genotype_real.h index eb9128ac..948e6962 100644 --- a/eo/src/es/make_genotype_real.h +++ b/eo/src/es/make_genotype_real.h @@ -37,7 +37,7 @@ /* * This fuction does the initialization of what's needed for a particular - * genotype (here, vector == eoReal). + * genotype (here, std::vector == 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 & 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 * init = new eoEsChromInit(boundsParam.value(), sigmaParam.value()); diff --git a/eo/src/es/make_op.h b/eo/src/es/make_op.h index fb2c4bf8..846c9908 100644 --- a/eo/src/es/make_op.h +++ b/eo/src/es/make_op.h @@ -70,11 +70,11 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit& 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 * realInit = (eoRealInitBounded*)(&_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 & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit with specific implementation //// in eoParser.cpp. At the moemnt, it is there (cf also make_genotype - eoParamParamType & ppBounds = boundsParam.value(); // pair > - // transform into a vector - vector v; - vector::iterator it; + eoParamParamType & ppBounds = boundsParam.value(); // std::pair > + // transform into a std::vector + std::vector v; + std::vector::iterator it; for (it=ppBounds.second.begin(); itc_str()); @@ -101,7 +101,7 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Genetic Operators"); + eoValueParam& 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 & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit& 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& 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 & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit& 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& 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 & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & 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 & 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 & 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 & 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 & 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 *ptCombinedMonOp = NULL; diff --git a/eo/src/es/make_op_es.h b/eo/src/es/make_op_es.h index 0a5bc8d0..5f2d938a 100644 --- a/eo/src/es/make_op_es.h +++ b/eo/src/es/make_op_es.h @@ -70,17 +70,17 @@ template eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded& _init) { - // get vector size + // get std::vector size unsigned vecSize = _init.size(); // First, decide whether the objective variables are bounded eoValueParam& boundsParam = _parser.createParam(eoRealVectorBounds(vecSize,eoDummyRealNoBounds), "objectBounds", "Bounds for variables", 'B', "Variation Operators"); // now we read Pcross and Pmut, - eoValueParam& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators"); + eoValueParam& 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 & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< eoValueParam& 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& 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& crossTypeParam = _parser.createParam(string("global"), "crossType", "Type of ES recombination (global or standard)", 'C', "Variation Operators"); + eoValueParam& crossTypeParam = _parser.createParam(std::string("global"), "crossType", "Type of ES recombination (global or standard)", 'C', "Variation Operators"); - eoValueParam& crossObjParam = _parser.createParam(string("discrete"), "crossObj", "Recombination of object variables (discrete, intermediate or none)", 'O', "Variation Operators"); - eoValueParam& crossStdevParam = _parser.createParam(string("intermediate"), "crossStdev", "Recombination of mutation strategy parameters (intermediate, discrete or none)", 'S', "Variation Operators"); + eoValueParam& crossObjParam = _parser.createParam(std::string("discrete"), "crossObj", "Recombination of object variables (discrete, intermediate or none)", 'O', "Variation Operators"); + eoValueParam& 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 *ptObjAtomCross = NULL; @@ -112,33 +112,33 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< eoGenOp *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; - 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; - 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(*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 & crossTmp = _state.storeFunctor( new eoEsStandardXover(*ptObjAtomCross, *ptStdevAtomCross) ); ptCross = new eoBinGenOp(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); diff --git a/eo/src/es/make_op_real.h b/eo/src/es/make_op_real.h index 6e3e377a..80fc42e4 100644 --- a/eo/src/es/make_op_real.h +++ b/eo/src/es/make_op_real.h @@ -67,7 +67,7 @@ template eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded& _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 & 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& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators"); + eoValueParam& 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 & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< eoValueParam& 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& 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 & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< eoValueParam& 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& 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& 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& 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 & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< eoValueParam & 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 & 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 & 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 & 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 & sigmaParam = _parser.createParam(0.3, "sigma", "Sigma (fixed) for Gaussian mutation", 's', "Variation Operators" ); @@ -184,11 +184,11 @@ eoGenOp & 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 *ptCombinedMonOp = NULL; diff --git a/eo/src/es/make_real.h b/eo/src/es/make_real.h index 5c776ff4..8c227f26 100644 --- a/eo/src/es/make_real.h +++ b/eo/src/es/make_real.h @@ -25,7 +25,7 @@ //----------------------------------------------------------------------------- /** This file contains all ***INSTANCIATED*** declarations of all components - * of the library for ***vector*** evolution inside EO. + * of the library for ***std::vector*** evolution inside EO. * It should be included in the file that calls any of the corresponding fns * * The corresponding ***INSTANCIATED*** definitions are contained in diff --git a/eo/src/ga/eoBit.h b/eo/src/ga/eoBit.h index 558903b1..96383c02 100644 --- a/eo/src/ga/eoBit.h +++ b/eo/src/ga/eoBit.h @@ -35,9 +35,9 @@ //----------------------------------------------------------------------------- -#include // ostream, istream +#include // std::ostream, std::istream #include // bind2nd -#include // string +#include // std::string #include @@ -50,7 +50,7 @@ /** eoBit: implementation of bitstring chromosome. \class eoBit eoBit.h ga/eoBit.h \ingroup bitstring - * based on STL's vector specialization. + * based on STL's std::vector specialization. */ template class eoBit: public eoVector { @@ -58,45 +58,45 @@ template class eoBit: public eoVector /** * (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(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::printOn(os); os << ' '; os << size() << ' '; - copy(begin(), end(), ostream_iterator(os)); + std::copy(begin(), end(), std::ostream_iterator(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::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(), '1')); + std::transform(bits.begin(), bits.end(), begin(), + std::bind2nd(std::equal_to(), '1')); } } }; diff --git a/eo/src/ga/eoBitOp.h b/eo/src/ga/eoBitOp.h index 8ab78652..3c1ff1b2 100644 --- a/eo/src/ga/eoBitOp.h +++ b/eo/src/ga/eoBitOp.h @@ -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 eoOneBitFlip: public eoMonOp { 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 eoDetBitFlip: public eoMonOp 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 eoBitMutation: public eoMonOp 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 eoBitInversion: public eoMonOp { 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 eoBitInversion: public eoMonOp 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 eoBitNext: public eoMonOp { 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 eoBitPrev: public eoMonOp { 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 eo1PtBitXover: public eoQuadOp { 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 eo1PtBitXover: public eoQuadOp */ 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 eoUBitXover: public eoQuadOp 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 class eoNPtsBitXover: public eoQuadOp 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 eoNPtsBitXover: public eoQuadOp */ 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 points(max_size, false); + std::vector points(max_size, false); // select ranges of bits to swap do { @@ -362,7 +362,7 @@ template class eoNPtsBitXover: public eoQuadOp change = !change; if (change) - swap(chrom1[bit], chrom2[bit]); + std::swap(chrom1[bit], chrom2[bit]); } return true; @@ -374,8 +374,8 @@ template class eoNPtsBitXover: public eoQuadOp -/** 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 eoBitGxOver: public eoQuadOp 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 eoBitGxOver: public eoQuadOp */ 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 points(max_genes, false); + std::vector points(max_genes, false); // selects genes to swap do { @@ -424,7 +424,7 @@ template class eoBitGxOver: public eoQuadOp // 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); diff --git a/eo/src/ga/eoBitOpFactory.h b/eo/src/ga/eoBitOpFactory.h index 9ec142bd..27394aef 100644 --- a/eo/src/ga/eoBitOpFactory.h +++ b/eo/src/ga/eoBitOpFactory.h @@ -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* make(istream& _is) + virtual eoOp* make(std::istream& _is) { eoOp * opPtr = NULL; try { opPtr = eoFactory::make( _is ); - } catch ( const string& objectTypeStr ) { + } catch ( const std::string& objectTypeStr ) { if ( objectTypeStr == "eoBinBitFlip" ) { opPtr = new eoOneBitFlip( ); } diff --git a/eo/src/ga/eoPBILAdditive.h b/eo/src/ga/eoPBILAdditive.h index 9f32859b..29b3fdd6 100644 --- a/eo/src/ga/eoPBILAdditive.h +++ b/eo/src/ga/eoPBILAdditive.h @@ -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& distrib = dynamic_cast&>(_distrib); - vector & p = distrib.value(); + std::vector & p = distrib.value(); unsigned i, popSize=_pop.size(); - vector result; + std::vector result; _pop.sort(result); // is it necessary to sort the whole population? // but I'm soooooooo lazy !!! diff --git a/eo/src/ga/eoPBILDistrib.h b/eo/src/ga/eoPBILDistrib.h index 96a781bc..91720acb 100644 --- a/eo/src/ga/eoPBILDistrib.h +++ b/eo/src/ga/eoPBILDistrib.h @@ -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 > : - * the vector stores the probabilities that each bit is 1 + * It is an eoValueParam > : + * the std::vector stores the probabilities that each bit is 1 * * It is still pure virtual, as the update method needs to be specified */ template class eoPBILDistrib : public eoDistribution, - public eoValueParam > + public eoValueParam > { public: /** Ctor with size of genomes, and update parameters */ eoPBILDistrib(unsigned _genomeSize) : eoDistribution(), - eoValueParam >(vector(_genomeSize, 0.5), "Distribution"), + eoValueParam >(std::vector(_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> 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 diff --git a/eo/src/ga/eoPBILOrg.h b/eo/src/ga/eoPBILOrg.h index da949064..b236412a 100644 --- a/eo/src/ga/eoPBILOrg.h +++ b/eo/src/ga/eoPBILOrg.h @@ -54,7 +54,7 @@ public: const EOT & best = _pop.best_element(); eoPBILDistrib& distrib = dynamic_cast&>(_distrib); - vector & p = distrib.value(); + std::vector & p = distrib.value(); for (unsigned g=0; g & 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 & do_make_PBILdistrib(eoParser & _parser, eoState& _state, E _state.storeFunctor(ptDistrib); // now the initialization: read a previously saved distribution, or random - eoValueParam& loadNameParam = _parser.createParam(string(""), "Load","A save file to restart from",'L', "Persistence" ); + eoValueParam& 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 diff --git a/eo/src/ga/make_PBILupdate.h b/eo/src/ga/make_PBILupdate.h index db9241ea..9b4ffd83 100644 --- a/eo/src/ga/make_PBILupdate.h +++ b/eo/src/ga/make_PBILupdate.h @@ -50,7 +50,7 @@ eoDistribUpdater & 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 & do_make_PBILupdate(eoParser & _parser, eoState& _state, // a pointer to choose among several possible types eoDistribUpdater * ptUpdate; - if (UType == string("PBIL")) + if (UType == std::string("PBIL")) { if ( (nbWorst == 0) && (nbBest == 1) ) ptUpdate = new eoPBILOrg(LRBest, tolerance); @@ -69,7 +69,7 @@ eoDistribUpdater & do_make_PBILupdate(eoParser & _parser, eoState& _state, ptUpdate = new eoPBILAdditive(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); diff --git a/eo/src/ga/make_op.h b/eo/src/ga/make_op.h index bf8d27d0..85af41ff 100644 --- a/eo/src/ga/make_op.h +++ b/eo/src/ga/make_op.h @@ -72,10 +72,10 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init // general operator input // BTW we must leave that simple version available somehow, as it is the one // that 90% people use! - eoValueParam& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators"); + eoValueParam& 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 & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init eoValueParam& 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& 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 & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init eoValueParam& 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& 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& 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 & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init eoValueParam & 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 & 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 & 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; } diff --git a/eo/src/gp/eoParseTree.h b/eo/src/gp/eoParseTree.h index 5a36a5dc..2f92d593 100644 --- a/eo/src/gp/eoParseTree.h +++ b/eo/src/gp/eoParseTree.h @@ -37,7 +37,6 @@ #include 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(), parse_tree() @@ -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 v(sz); + std::vector v(sz); unsigned i; @@ -158,7 +157,7 @@ public : fitness(fit); - std::copy(istream_iterator(is), istream_iterator(), back_inserter(*this)); + std::copy(std::istream_iterator(is), std::istream_iterator(), back_inserter(*this)); */ } }; diff --git a/eo/src/gp/eoParseTreeDepthInit.h b/eo/src/gp/eoParseTreeDepthInit.h index d77c2d48..3cd95b04 100644 --- a/eo/src/gp/eoParseTreeDepthInit.h +++ b/eo/src/gp/eoParseTreeDepthInit.h @@ -35,7 +35,6 @@ #include using namespace gp_parse_tree; -using namespace std; /** eoParseTreeDepthInit : the initializer class for eoParseTree \class eoParseTreeDepthInit eoParseTreeDepthInit.h gp/eoParseTreeDepthInit.h @@ -51,7 +50,7 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > protected: // a binary predicate for sorting // hopefully this will work with M$VC++ 6.0 - struct lt_arity:public binary_function + struct lt_arity:public std::binary_function { bool operator()(const Node &_node1, const Node &_node2) { return (_node1.arity() < _node2.arity());}; }; @@ -63,13 +62,13 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > /** * Constructor * @parm _max_depth The maximum depth of a tree - * @param _initializor A vector containing the possible nodes + * @param _initializor A std::vector containing the possible nodes * @param _grow False results in a full tree, True result is a randomly grown tree * @param _ramped_half_and_half True results in Ramped Half and Half Initialization */ eoParseTreeDepthInit( unsigned _max_depth, - const vector& _initializor, + const std::vector& _initializor, bool _grow = true, bool _ramped_half_and_half = false) : @@ -82,21 +81,21 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > { if(initializor.empty()) { - throw logic_error("eoParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); + throw std::logic_error("eoParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); } - // lets sort the initializor vector according to arity (so we can be sure the terminals are in front) + // lets sort the initializor std::vector according to arity (so we can be sure the terminals are in front) // we use stable_sort so that if element i was in front of element j and they have the same arity i remains in front of j stable_sort(initializor.begin(), initializor.end(), lt_arity()); } /// My class name - virtual string className() const { return "eoParseTreeDepthInit"; }; + virtual std::string className() const { return "eoParseTreeDepthInit"; }; /**initialize a tree * @param _tree : the tree to be initialized */ void operator()(EoType& _tree) { - list sequence; + std::list sequence; generate(sequence, current_depth); parse_tree tmp(sequence.begin(), sequence.end()); @@ -117,11 +116,11 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > } private : - void generate(list& sequence, int the_max, int last_terminal = -1) + void generate(std::list& sequence, int the_max, int last_terminal = -1) { if (last_terminal == -1) { // check where the last terminal in the sequence resides - typename vector::iterator it; + typename std::vector::iterator it; for (it = initializor.begin(); it != initializor.end(); ++it) { if (it->arity() > 0) @@ -133,12 +132,12 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > if (the_max == 1) { // generate terminals only - typename vector::iterator it = initializor.begin() + rng.random(last_terminal); + typename std::vector::iterator it = initializor.begin() + rng.random(last_terminal); sequence.push_front(*it); return; } - typename vector::iterator what_it; + typename std::vector::iterator what_it; if (grow) { @@ -171,12 +170,12 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > * @param pop the population to be created * @param population_size the size of the population to be created * @param init_max_depth the initial maximum tree depth - * @param initializor A vector containing the possible nodes + * @param initializor A std::vector containing the possible nodes \ingroup ParseTree */ template -void eoInitRampedHalfAndHalf(eoPop< eoParseTree > &pop, unsigned int population_size, unsigned int init_max_depth, vector &initializor) +void eoInitRampedHalfAndHalf(eoPop< eoParseTree > &pop, unsigned int population_size, unsigned int init_max_depth, std::vector &initializor) { typedef eoParseTree EoType; typedef eoPop< EoType > Pop; @@ -185,10 +184,10 @@ void eoInitRampedHalfAndHalf(eoPop< eoParseTree > &pop, unsigned in unsigned int part_pop_size = population_size / (2*M); unsigned int m=0; - cerr << "EO WARNING: Ramped Half and Half Initialization is now supported by eoParseTreeDepthInit." << endl; - cerr << " This function is now obsolete and might be removed in the future so you should"<< endl; - cerr << " update your code to use: " << endl << endl; - cerr << " eoParseTreeDepthInit( _max_depth, _initializer, bool _grow, bool _ramped_half_and_half)" << endl << endl; + std::cerr << "EO WARNING: Ramped Half and Half Initialization is now supported by eoParseTreeDepthInit." << std::endl; + std::cerr << " This function is now obsolete and might be removed in the future so you should"<< std::endl; + std::cerr << " update your code to use: " << std::endl << std::endl; + std::cerr << " eoParseTreeDepthInit( _max_depth, _initializer, bool _grow, bool _ramped_half_and_half)" << std::endl << std::endl; pop.clear(); diff --git a/eo/src/gp/eoParseTreeOp.h b/eo/src/gp/eoParseTreeOp.h index 649b1926..1cc91a73 100644 --- a/eo/src/gp/eoParseTreeOp.h +++ b/eo/src/gp/eoParseTreeOp.h @@ -51,7 +51,7 @@ public: : eoQuadOp(), max_length(_max_length) {}; /// the ckassname - virtual string className() const { return "eoSubtreeXOver"; }; + virtual std::string className() const { return "eoSubtreeXOver"; }; /// Dtor virtual ~eoSubtreeXOver () {}; @@ -99,7 +99,7 @@ public: {}; /// the class name - virtual string className() const { return "eoBranchMutation"; }; + virtual std::string className() const { return "eoBranchMutation"; }; /// Dtor virtual ~eoBranchMutation() {}; @@ -152,14 +152,14 @@ public: /** * Constructor - * @param _initializor The vector of Nodes given to the eoGpDepthInitializer + * @param _initializor The std::vector of Nodes given to the eoGpDepthInitializer */ - eoPointMutation( vector& _initializor) + eoPointMutation( std::vector& _initializor) : eoMonOp(), initializor(_initializor) {}; /// the class name - virtual string className() const { return "eoPointMutation"; }; + virtual std::string className() const { return "eoPointMutation"; }; /// Dtor virtual ~eoPointMutation() {}; @@ -191,7 +191,7 @@ public: } private : - vector& initializor; + std::vector& initializor; }; @@ -217,7 +217,7 @@ public: {}; /// The class name - virtual string className() const { return "eoExpansionMutation"; }; + virtual std::string className() const { return "eoExpansionMutation"; }; /// Dtor virtual ~eoExpansionMutation() {}; @@ -284,7 +284,7 @@ public: {}; /// The class name - virtual string className() const { return "eoCollapseSubtreeMutation"; }; + virtual std::string className() const { return "eoCollapseSubtreeMutation"; }; /// Dtor virtual ~eoCollapseSubtreeMutation() {}; @@ -347,7 +347,7 @@ public: {}; /// The class name - virtual string className() const { return "eoHoistMutation"; }; + virtual std::string className() const { return "eoHoistMutation"; }; /// Dtor virtual ~eoHoistMutation() {}; diff --git a/eo/src/gp/eoStParseTreeDepthInit.h b/eo/src/gp/eoStParseTreeDepthInit.h index e16d6bd0..3dac6f13 100644 --- a/eo/src/gp/eoStParseTreeDepthInit.h +++ b/eo/src/gp/eoStParseTreeDepthInit.h @@ -34,7 +34,6 @@ using namespace gp_parse_tree; -using namespace std; #define TERMINAL 0 @@ -68,12 +67,12 @@ class eoStParseTreeDepthInit : public eoInit< eoParseTree > /** * Constructor * @parm _max_depth The maximum depth of a tree - * @param _initializor A vector containing the possible nodes + * @param _initializor A std::vector containing the possible nodes * @param _grow False results in a full tree, True result is a randomly grown tree */ eoStParseTreeDepthInit( unsigned _max_depth, - const vector& _node, + const std::vector& _node, const int& _return_type, bool _grow = true) : @@ -84,48 +83,48 @@ class eoStParseTreeDepthInit : public eoInit< eoParseTree > { if(_node.empty()) { - throw logic_error("eoStParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); + throw std::logic_error("eoStParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); } unsigned int i=0; int arity=0; int type=0; - vector node_vector; + std::vector node_std::vector; for(i=0; i < _node.size(); i++) { arity = _node[i].arity(); type = _node[i].type(); if(arity==0) { - node_vector = node[type][TERMINAL]; - node_vector.push_back(_node[i]); - node[type][TERMINAL]= node_vector; + node_std::vector = node[type][TERMINAL]; + node_std::vector.push_back(_node[i]); + node[type][TERMINAL]= node_std::vector; } else //if (arity != 0) // non-terminal { - node_vector = node[type][NONTERMINAL]; - node_vector.push_back(_node[i]); - node[type][NONTERMINAL] = node_vector; + node_std::vector = node[type][NONTERMINAL]; + node_std::vector.push_back(_node[i]); + node[type][NONTERMINAL] = node_std::vector; } - node_vector = node[type][ALL]; - node_vector.push_back(_node[i]); - node[type][ALL] = node_vector; + node_std::vector = node[type][ALL]; + node_std::vector.push_back(_node[i]); + node[type][ALL] = node_std::vector; } } /// My class name - virtual string className() const { return "eoStParseTreeDepthInit"; }; + virtual std::string className() const { return "eoStParseTreeDepthInit"; }; /**initialize a tree * @param _tree : the tree to be initialized */ void operator()(EoType& _tree) { - list sequence; + std::list sequence; bool good_tree = false; do { @@ -137,7 +136,7 @@ class eoStParseTreeDepthInit : public eoInit< eoParseTree > _tree.swap(tmp); } private : - bool generate(list& sequence, int the_max, int request_type) + bool generate(std::list& sequence, int the_max, int request_type) { int selected=0; @@ -182,7 +181,7 @@ class eoStParseTreeDepthInit : public eoInit< eoParseTree > unsigned max_depth; - map < int, map < int, vector > > node; + map < int, map < int, std::vector > > node; int return_type; bool grow; diff --git a/eo/src/gp/eoStParseTreeOp.h b/eo/src/gp/eoStParseTreeOp.h index c2e97521..28bd3ff8 100644 --- a/eo/src/gp/eoStParseTreeOp.h +++ b/eo/src/gp/eoStParseTreeOp.h @@ -37,7 +37,7 @@ // a help function template -void get_possible_nodes(const EOT &_eo, vector &possible_nodes, const int type) +void get_possible_nodes(const EOT &_eo, std::vector &possible_nodes, const int type) { int n=0; possible_nodes.clear(); @@ -65,7 +65,7 @@ public: : eoQuadOp(), max_length(_max_length) {}; /// the ckassname - virtual string className() const { return "eoStSubtreeXOver"; }; + virtual std::string className() const { return "eoStSubtreeXOver"; }; /// Dtor virtual ~eoStSubtreeXOver () {}; @@ -78,7 +78,7 @@ public: bool operator()(EoType & _eo1, EoType & _eo2 ) { int i = 0; - vector nodes; + std::vector nodes; int n = 0; int type = 0; int j = 0; @@ -142,7 +142,7 @@ public: {}; /// the class name - virtual string className() const { return "eoStBranchMutation"; }; + virtual std::string className() const { return "eoStBranchMutation"; }; /// Dtor virtual ~eoStBranchMutation() {}; @@ -154,7 +154,7 @@ public: bool operator()(EoType& _eo1 ) { int i = rng.random(_eo1.size()); - vector nodes; + std::vector nodes; int type = _eo1[i]->type(); int j=0; int n=0; @@ -200,29 +200,29 @@ public: /** * Constructor - * @param _initializor The vector of Nodes given to the eoGpDepthInitializer + * @param _initializor The std::vector of Nodes given to the eoGpDepthInitializer */ - eoStPointMutation( vector& _node) + eoStPointMutation( std::vector& _node) : eoMonOp() { unsigned int i=0; int arity=0; int type=0; - vector node_vector; + std::vector node_std::vector; for(i=0; i < _node.size(); i++) { arity = _node[i].arity(); type = _node[i].type(); - node_vector = node[type][arity]; - node_vector.push_back(_node[i]); - node[type][arity]= node_vector; + node_std::vector = node[type][arity]; + node_std::vector.push_back(_node[i]); + node[type][arity]= node_std::vector; }; }; /// the class name - virtual string className() const { return "eoStPointMutation"; }; + virtual std::string className() const { return "eoStPointMutation"; }; /// Dtor virtual ~eoStPointMutation() {}; @@ -246,7 +246,7 @@ public: private : - map < int, map < int, vector > > node; + map < int, map < int, std::vector > > node; }; @@ -270,7 +270,7 @@ public: {}; /// the class name - virtual string className() const { return "eoStHoistMutation"; }; + virtual std::string className() const { return "eoStHoistMutation"; }; /// Dtor virtual ~eoStHoistMutation() {}; @@ -282,7 +282,7 @@ public: bool operator()(EoType& _eo1 ) { - vector nodes; + std::vector nodes; // get the type of the current tree int type = _eo1[ _eo1.size() - 1 ]->type(); diff --git a/eo/src/gp/parse_tree.h b/eo/src/gp/parse_tree.h index ca9892dc..032606ee 100644 --- a/eo/src/gp/parse_tree.h +++ b/eo/src/gp/parse_tree.h @@ -53,7 +53,7 @@ RetVal Node::operator()(RetVal, subtree<... , It values) where It is whatever type you desire (most of the time - this will be a vector containing the values of your + this will be a std::vector containing the values of your variables); 3) parse_tree::apply(RetVal, It values, It2 moreValues) @@ -129,22 +129,22 @@ tree[2] points at the root node4 Embedded iterators are implemented to iterate over nodes rather - than subtrees. So an easy way to copy your tree to a vector is: + than subtrees. So an easy way to copy your tree to a std::vector is: - vector vec(tree.size()); + std::vector vec(tree.size()); copy(tree.ebegin(), tree.eend(), vec.begin()); - You can also copy it to an ostream_iterator with this + You can also copy it to an std::ostream_iterator with this technique, given that your Node implements an appropriate - operator<<. Reinitializing a tree with the vector is also + operator<<. Reinitializing a tree with the std::vector is also simple: tree.clear(); copy(vec.begin(), vec.end(), back_inserter(tree)); - or from an istream: + or from an std::istream: - copy(istream_iterator(my_stream), istream_iterator(), back_inserter(tree)); + copy(std::istream_iterator(my_stream), std::istream_iterator(), back_inserter(tree)); Note that the back_inserter must be used as there is no resize member in the parse_tree. back_inserter will use @@ -972,7 +972,7 @@ void swap(gp_parse_tree::parse_tree& a, gp_parse_tree::parse_tree& b) } template inline -void iter_swap(vector >::iterator a, vector > b) +void iter_swap(std::vector >::iterator a, std::vector > b) { a->swap(*b); }*/ diff --git a/eo/src/obsolete/eo1d.h b/eo/src/obsolete/eo1d.h index 7642692f..73e83ea0 100644 --- a/eo/src/obsolete/eo1d.h +++ b/eo/src/obsolete/eo1d.h @@ -27,7 +27,7 @@ #ifndef _EO1D_H #define _EO1D_H -#include // for ostream +#include // for std::ostream // EO Includes #include @@ -59,7 +59,7 @@ least, a copy ctor, assignment operators, \deprecated As eo1d provides a so-called 'fat' interface, it might be wiser to use eoFixedLength or eoVariableLength instead, that derive from - vector and list respectively and (important) redirect the less than + std::vector and std::list respectively and (important) redirect the less than comparison operator to EO rather than the STL variants. @see eoFixedLength eoVariableLength @@ -80,15 +80,15 @@ public: /** Ctor using a random number generator and with an specified size @param _rndGen Random number generator @param _size lineal dimension of the eo1d - @param _ID An ID string, preferably unique + @param _ID An ID std::string, preferably unique */ - eo1d( unsigned _size, eoRnd& _rndGen, const string& _ID = ""); + eo1d( unsigned _size, eoRnd& _rndGen, const std::string& _ID = ""); - /** Ctor from a istream. It just passes the stream to EO, subclasses should + /** Ctor from a std::istream. It just passes the stream to EO, subclasses should have to implement this. @param _is the input stream */ - eo1d( istream& _is): EO(){ readFrom(is); } + eo1d( std::istream& _is): EO(){ readFrom(is); } /// Copy ctor eo1d( const eo1d& _eo ) @@ -108,7 +108,7 @@ public: @param _i index of the gene, which is the minimal unit. Must be an unsigned less than #length()# @return what's inside the gene, with the correct type - @exception out_of_range if _i > size() + @std::exception out_of_range if _i > size() */ virtual T getGene( unsigned _i ) const = 0; @@ -117,7 +117,7 @@ public: * for T must be defined . @param _i index @return what's inside the gene, with the correct type - @exception out_of_range if _i > size() + @std::exception out_of_range if _i > size() */ virtual void setGene( unsigned _i, const T& _value ) = 0; @@ -143,10 +143,10 @@ public: /** * Read object. Theoretically, the length is known in advance. All objects * Should call base class - * @param _s A istream. - * @throw runtime_exception If a valid object can't be read. + * @param _s A std::istream. + * @throw runtime_std::exception If a valid object can't be read. */ - virtual void readFrom(istream& _s) { + virtual void readFrom(std::istream& _s) { for ( unsigned i = 0; i < length(); i ++ ) { T tmp; @@ -160,8 +160,8 @@ public: /** Print itself: inherited from eoObject implementation. Instance from base classes are processed in base classes, so you don´t have to worry about, for instance, fitness. - @param _s the ostream in which things are written*/ - virtual void printOn( ostream& _s ) const{ + @param _s the std::ostream in which things are written*/ + virtual void printOn( std::ostream& _s ) const{ for ( unsigned i = 0; i < length(); i ++ ) { _s << getGene( i ) << " "; } @@ -170,7 +170,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eo1d";}; + std::string className() const {return "eo1d";}; //@} @@ -184,11 +184,11 @@ public: /* Ctor using a random number generator and with an specified size @param _rndGen Random number generator @param _size lineal dimension of the eo1d - @param _ID An ID string, preferably unique + @param _ID An ID std::string, preferably unique */ template< class T, class fitnessT> eo1d::eo1d( unsigned _size, eoRnd& _rndGen, - const string& _ID ) + const std::string& _ID ) :EO ( _ID ) { for ( unsigned i = 0; i < _size; i ++ ) { insertGene( i, _rndGen() ); diff --git a/eo/src/obsolete/eo1dWDistance.h b/eo/src/obsolete/eo1dWDistance.h index 0cd94049..2019e95c 100644 --- a/eo/src/obsolete/eo1dWDistance.h +++ b/eo/src/obsolete/eo1dWDistance.h @@ -27,7 +27,7 @@ #ifndef _EO1DWDISTANCE_H #define _EO1DWDISTANCE_H -#include // for ostream +#include // for std::ostream // EO Includes #include @@ -58,7 +58,7 @@ public: @param _i index of the gene, which is the minimal unit. Must be an unsigned less than #length()# @return what's inside the gene, with the correct type - @exception out_of_range if _i > size() + @std::exception out_of_range if _i > size() */ virtual T getGene( unsigned _i ) const { return innereo1d.getGene( _i ); @@ -69,7 +69,7 @@ public: * for T must be defined . @param _i index @return what's inside the gene, with the correct type - @exception out_of_range if _i > size() + @std::exception out_of_range if _i > size() */ virtual void setGene( unsigned _i, const T& _value ) { innereo1d.setGene( _i, _value); @@ -118,7 +118,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eo1dWDistance";}; + std::string className() const {return "eo1dWDistance";}; //@} diff --git a/eo/src/obsolete/eo2d.h b/eo/src/obsolete/eo2d.h index e02d5f15..c8d08219 100644 --- a/eo/src/obsolete/eo2d.h +++ b/eo/src/obsolete/eo2d.h @@ -39,7 +39,7 @@ Description.....: Implementation of a 2-dimensional chromosome. #ifndef _EO2D_H #define _EO2D_H -#include // for ostream +#include // for std::ostream #include // EO Includes @@ -81,18 +81,18 @@ public: @param _rows Initial number of rows @param _columns Initial number of columns @param _rndGen Random "T-type" generator - @param _ID An ID string, preferably unique + @param _ID An ID std::string, preferably unique */ eo2d( const unsigned _rows, const unsigned _columns, eoRnd& _rndGen, - const string& _ID = ""); + const std::string& _ID = ""); - /** Ctor from an istream. It just passes the stream to EO, subclasses should + /** Ctor from an std::istream. It just passes the stream to EO, subclasses should have to implement this. @param _is the input stream */ - eo2d( istream& _is): EO( _is ){}; + eo2d( std::istream& _is): EO( _is ){}; /// Copy ctor eo2d( const eo2d& _eo ) @@ -112,8 +112,8 @@ public: @param _r Index for rows. Must be an unsigned less than #numOfRows()# @param _c Index for columns. Must be an unsigned less than #numOfCols()# @return what's inside the gene, with the correct type - @exception out_of_range if _r >=numOfRows() - @exception out_of_range if _c >=numOfCols() + @std::exception out_of_range if _r >=numOfRows() + @std::exception out_of_range if _c >=numOfCols() */ virtual T getGene( const unsigned _r, const unsigned _j ) const = 0; @@ -124,8 +124,8 @@ public: @param _r Index for rows. Must be an unsigned less than #numOfRows()# @param _c Index for columns. Must be an unsigned less than #numOfCols()# @return what's inside the gene, with the correct type - @exception out_of_range if _r >=numOfRows() - @exception out_of_range if _c >=numOfCols() + @std::exception out_of_range if _r >=numOfRows() + @std::exception out_of_range if _c >=numOfCols() */ virtual void setGene( const unsigned _r, const unsigned _c, @@ -136,16 +136,16 @@ public: * Obviously, changes number of rows. @param _r Position where the new row will be inserted. @param _val Vector containing the new values to be inserted. - @exception invalid_argument If _val has not numOfCols() components. - @exception out_of_range If _r is greater than numOfRows() + @std::exception invalid_argument If _val has not numOfCols() components. + @std::exception out_of_range If _r is greater than numOfRows() */ virtual void insertRow( const unsigned _r, - const vector& _val ) = 0; + const std::vector& _val ) = 0; /** Eliminates the row at position _r; all the other genes will be shifted up. @param _r Number of he row to be deleted. - @exception out_of_range if _r >=numOfRows() + @std::exception out_of_range if _r >=numOfRows() */ virtual void deleteRow( const unsigned _r ) = 0; @@ -154,15 +154,15 @@ public: * Obviously, changes number of cols. @param _r Position where the new column will be inserted. @param _val Vector containing the new values to be inserted. - @exception invalid_argument if _val has not numOfRows() components. + @std::exception invalid_argument if _val has not numOfRows() components. */ virtual void insertCol( const unsigned _c, - const vector& _val ) = 0; + const std::vector& _val ) = 0; /** Eliminates the column at position _c; all the other columns will be shifted left. @param _c Number of he column to be deleted. - @exception out_of_range if _c >=numOfCols() + @std::exception out_of_range if _c >=numOfCols() */ virtual void deleteCol( const unsigned _c ) = 0; @@ -177,10 +177,10 @@ public: /** * Read object. Theoretically, the length is known in advance. All objects * Should call base class - * @param _s A istream. - * @throw runtime_exception If a valid object can't be read. + * @param _s A std::istream. + * @throw runtime_std::exception If a valid object can't be read. */ - virtual void readFrom(istream& _s) { + virtual void readFrom(std::istream& _s) { for ( unsigned r = 0; r < numOfRows(); ++r ) { for ( unsigned c = 0; c < numOfCols(); ++c ) { @@ -196,8 +196,8 @@ public: /** Print itself: inherited from eoObject implementation. Instance from base classes are processed in base classes, so you don´t have to worry about, for instance, fitness. - @param _s the ostream in which things are written*/ - virtual void printOn( ostream& _s ) const{ + @param _s the std::ostream in which things are written*/ + virtual void printOn( std::ostream& _s ) const{ for ( unsigned r = 0; r < numOfRows(); ++r ) { for ( unsigned c = 0; c < numOfCols(); ++c ) { _s << getGene( r,c ) << " "; @@ -208,7 +208,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eo2d";}; + std::string className() const {return "eo2d";}; //@} @@ -223,13 +223,13 @@ public: @param _rows Initial number of rows @param _columns Initial number of columns @param _rndGen Random "T-type" generator - @param _ID An ID string, preferably unique + @param _ID An ID std::string, preferably unique */ template< class T, class fitnessT> eo2d::eo2d( const unsigned _rows, const unsigned _columns, eoRnd& _rndGen, - const string& _ID = "") + const std::string& _ID = "") :EO ( _ID ) { for ( unsigned r = 0; r < _rows; ++r ) { for ( unsigned c = 0; c < _cols; ++c ) { diff --git a/eo/src/obsolete/eo2dVector.h b/eo/src/obsolete/eo2dVector.h index febbca36..ec583368 100644 --- a/eo/src/obsolete/eo2dVector.h +++ b/eo/src/obsolete/eo2dVector.h @@ -5,14 +5,14 @@ File............: eo2dVector.h Author..........: Geneura Team (this file: Victor Rivas, vrivas@ujaen.es) Date............: 29-Sep-1999, at Fac. of Sciences, Univ. of Granada (Spain) Description.....: Implementation of a 2-dimensional chromosome usign STL - vectors. + std::vectors. ================ Modif. 1 ================ Author........: Date..........: Description...: -QUEDA: Operador de asignación, lectura desde istream, escritura a ostream +QUEDA: Operador de asignación, lectura desde std::istream, escritura a std::ostream ----------------------------------------------------------------------------- */ //----------------------------------------------------------------------------- @@ -42,20 +42,20 @@ QUEDA: Operador de asignaci #define _eo2dVector_H // STL libraries -#include // For vector +#include // For std::vector #include #include -#include +#include #include #include -/** Adaptor that turns an STL vector of vectror into an EO +/** Adaptor that turns an STL std::vector of vectror into an EO with the same gene type as the type with which - the vector of vector has been instantiated. + the std::vector of std::vector has been instantiated. */ template -class eo2dVector: public eo2d, public vector< vector > { +class eo2dVector: public eo2d, public std::vector< std::vector > { public: typedef T Type ; @@ -72,7 +72,7 @@ public: eo2dVector( const unsigned _rows = 0, const unsigned _cols = 0, T _val = T() ) - : eo2d(), vector< vector >( _rows, vector( _cols, _val ) ){}; + : eo2d(), std::vector< std::vector >( _rows, std::vector( _cols, _val ) ){}; /** Ctor using a random number generator. @param _rows Number of rows. @@ -83,23 +83,23 @@ public: const unsigned _cols, eoRnd& _rnd ); - /** Ctor from a istream. The T class should accept reading from a istream. It doesn't read fitness, + /** Ctor from a std::istream. The T class should accept reading from a std::istream. It doesn't read fitness, which is supposed to be dynamic and dependent on environment. @param _is the input stream; should have all values in a single line, separated by whitespace */ - //eo2dVector( istream& _is); + //eo2dVector( std::istream& _is); /// copy ctor eo2dVector( const eo2dVector & _eo ) - : eo2d( _eo ), vector< vector >( _eo ){ }; + : eo2d( _eo ), std::vector< std::vector >( _eo ){ }; /// Assignment operator /* const eo2dVector& operator =( const eo2dVector & _eo ) { if ( this != &_eo ){ eo2d::operator=( _eo ); - vector< >::operator=( _eo ); + std::vector< >::operator=( _eo ); } return *this; } @@ -113,21 +113,21 @@ public: @param _r Index for rows. Must be an unsigned less than #numOfRows()# @param _c Index for columns. Must be an unsigned less than #numOfCols()# @return what's inside the gene, with the correct type - @exception out_of_range if _r >=numOfRows() - @exception out_of_range if _c >=numOfCols() + @std::exception out_of_range if _r >=numOfRows() + @std::exception out_of_range if _c >=numOfCols() */ virtual T getGene( const unsigned _r, const unsigned _c ) const { if ( _r >= numOfRows() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::getGene: row out of range. " - << "It should be <" << numOfRows() << '\0' << endl; + << "It should be <" << numOfRows() << '\0' << std::endl; throw out_of_range( msg.str() ); } if ( _c >= numOfCols() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::getGene: column out of range. " - << "It should be <" << numOfCols() << '\0' << endl; + << "It should be <" << numOfCols() << '\0' << std::endl; throw out_of_range( msg.str() ); } return (*this)[_r][_c]; @@ -138,22 +138,22 @@ public: @param _r Index for rows. Must be an unsigned less than #numOfRows()# @param _c Index for columns. Must be an unsigned less than #numOfCols()# @return what's inside the gene, with the correct type - @exception out_of_range if _r >=numOfRows() - @exception out_of_range if _c >=numOfCols() + @std::exception out_of_range if _r >=numOfRows() + @std::exception out_of_range if _c >=numOfCols() */ virtual void setGene( const unsigned _r, const unsigned _c, const T& _value ) { if ( _r >= numOfRows() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::setGene: row out of range. " - << "It should be <" << numOfRows() << '\0' << endl; + << "It should be <" << numOfRows() << '\0' << std::endl; throw out_of_range( msg.str() ); } if ( _c >= numOfCols() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::setGene: column out of range. " - << "It should be <" << numOfCols() << '\0' << endl; + << "It should be <" << numOfCols() << '\0' << std::endl; throw out_of_range( msg.str() ); } (*this)[_r][_c]=_value; @@ -166,47 +166,47 @@ public: * Obviously, changes number of rows. @param _r Position where the new row will be inserted. @param _val Vector containing the new values to be inserted. - @exception invalid_argument If _val has not numOfCols() components. - @exception out_of_range If _r is greater than numOfRows() + @std::exception invalid_argument If _val has not numOfCols() components. + @std::exception out_of_range If _r is greater than numOfRows() */ virtual void insertRow( const unsigned _r, - const vector& _val ) { + const std::vector& _val ) { // Test errors. if ( _r > numOfRows() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::insertRow: row out of range. " - << "It should be <=" << numOfRows() << '\0' << endl; + << "It should be <=" << numOfRows() << '\0' << std::endl; throw out_of_range( msg.str() ); } if ( _val.size() != numOfCols() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::insertRow: " << "Incorrect number of values to be added. " - << "It should be ==" << numOfCols() << '\0' << endl; + << "It should be ==" << numOfCols() << '\0' << std::endl; throw invalid_argument( msg.str() ); } // Insert the row. - vector< vector >::iterator ite = begin()+_r; + std::vector< std::vector >::iterator ite = begin()+_r; insert( ite, _val ); }; /** Eliminates the row at position _r; all the other genes will be shifted up. @param _r Number of he row to be deleted. - @exception out_of_range if _r >=numOfRows() + @std::exception out_of_range if _r >=numOfRows() */ virtual void deleteRow( const unsigned _r ) { // Test error. if ( _r >= numOfRows() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::deleteRow: " << "Row out of range. " - << "It should be <" << numOfRows() << '\0' << endl; + << "It should be <" << numOfRows() << '\0' << std::endl; throw out_of_range( msg.str() ); } // Delete row. - vector< vector >::iterator ite = this->begin()+_r; + std::vector< std::vector >::iterator ite = this->begin()+_r; this->erase( ite ); }; @@ -215,30 +215,30 @@ public: * Obviously, changes number of cols. @param _r Position where the new column will be inserted. @param _val Vector containing the new values to be inserted. - @exception invalid_argument if _val has not numOfRows() components. + @std::exception invalid_argument if _val has not numOfRows() components. */ virtual void insertCol( const unsigned _c, - const vector& _val ) { + const std::vector& _val ) { // Test errors. if ( _c > numOfCols() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::insertCol: " << "Column out of range. " - << "It should be >=" << numOfCols() << '\0' << endl; + << "It should be >=" << numOfCols() << '\0' << std::endl; throw out_of_range( msg.str() ); } if ( _val.size() != numOfRows() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::insertCol: " << "Incorrect number of values to be added. " - << "It should be ==" << numOfRows() << '\0' << endl; + << "It should be ==" << numOfRows() << '\0' << std::endl; throw invalid_argument( msg.str() ); } // Insert column. for( unsigned r=0; r >::iterator it1 = begin()+r; - vector::iterator it2 = (*it1).begin()+_c; + std::vector >::iterator it1 = begin()+r; + std::vector::iterator it2 = (*it1).begin()+_c; (*it1).insert( it2, _val[r] ); }; } @@ -246,21 +246,21 @@ public: /** Eliminates the column at position _c; all the other columns will be shifted left. @param _c Number of he column to be deleted. - @exception out_of_range if _c >=numOfCols() + @std::exception out_of_range if _c >=numOfCols() */ virtual void deleteCol( const unsigned _c ) { // Test error. if ( _c >= numOfCols() ) { - ostrstream msg; + std::ostrstream msg; msg << "ERROR in eo2dVector::deleteCol: " << "Column out of range. " - << "It should be <" << numOfCols() << '\0' << endl; + << "It should be <" << numOfCols() << '\0' << std::endl; throw out_of_range( msg.str() ); } // Delete columns. for( unsigned r=0; r >::iterator it1 = begin()+r; - vector::iterator it2 = (*it1).begin()+_c; + std::vector >::iterator it1 = begin()+r; + std::vector::iterator it2 = (*it1).begin()+_c; (*it1).erase( it2 ); } }; @@ -283,7 +283,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eo2dVector";}; + std::string className() const {return "eo2dVector";}; //@} }; @@ -297,9 +297,9 @@ template eo2dVector::eo2dVector( const unsigned _rows, const unsigned _cols, eoRnd& _rnd ) - : eo2d(), vector< vector >( _rows, vector( _cols, T() ) ){ - for ( vector< vector >::iterator i = begin(); i != end(); ++i ) { - for( vector::iterator j=(*i).begin(); j!= (*i).end(); ++j ) { + : eo2d(), std::vector< std::vector >( _rows, std::vector( _cols, T() ) ){ + for ( std::vector< std::vector >::iterator i = begin(); i != end(); ++i ) { + for( std::vector::iterator j=(*i).begin(); j!= (*i).end(); ++j ) { *j = _rnd(); } } @@ -307,8 +307,8 @@ eo2dVector::eo2dVector( const unsigned _rows, //_____________________________________________________________________________ /*template -eoVector::eoVector( istream& _is) - : eo1d(), vector( ){ +eoVector::eoVector( std::istream& _is) + : eo1d(), std::vector( ){ while (_is ) { T tmp; _is >> tmp; @@ -320,12 +320,12 @@ eoVector::eoVector( istream& _is) //_____________________________________________________________________________ template -ostream& operator<<( ostream& _os, const eo2dVector& _eo) { +std::ostream& operator<<( std::ostream& _os, const eo2dVector& _eo) { for( unsigned i=0; i<_eo.numOfRows(); ++i ) { for( unsigned j=0; j<_eo.numOfCols(); ++j ) { _os << _eo.getGene( i,j ) << " "; } - _os << endl; + _os << std::endl; } return _os; }; diff --git a/eo/src/obsolete/eoAtomBitFlip.h b/eo/src/obsolete/eoAtomBitFlip.h index 99bf4acb..be1a1be5 100644 --- a/eo/src/obsolete/eoAtomBitFlip.h +++ b/eo/src/obsolete/eoAtomBitFlip.h @@ -48,7 +48,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eoAtomBitFlip";}; + std::string className() const {return "eoAtomBitFlip";}; //@} }; diff --git a/eo/src/obsolete/eoAtomCreep.h b/eo/src/obsolete/eoAtomCreep.h index 05fda764..8c293208 100644 --- a/eo/src/obsolete/eoAtomCreep.h +++ b/eo/src/obsolete/eoAtomCreep.h @@ -56,7 +56,7 @@ public: /** Inherited from eoObject @see eoObject */ - virtual string className() const {return "eoAtomCreep";}; + virtual std::string className() const {return "eoAtomCreep";}; //@} }; diff --git a/eo/src/obsolete/eoAtomRandom.h b/eo/src/obsolete/eoAtomRandom.h index 18ca49a8..1cc846ee 100644 --- a/eo/src/obsolete/eoAtomRandom.h +++ b/eo/src/obsolete/eoAtomRandom.h @@ -52,7 +52,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eoAtomRandom";}; + std::string className() const {return "eoAtomRandom";}; //@} private: diff --git a/eo/src/obsolete/eoBackInserter.h b/eo/src/obsolete/eoBackInserter.h index 79727870..24bdad38 100644 --- a/eo/src/obsolete/eoBackInserter.h +++ b/eo/src/obsolete/eoBackInserter.h @@ -5,7 +5,7 @@ Abstract population insertion operator, which is used by the eoGeneralOps to insert the results in the (intermediate) population. This file also contains the definitions of a derived classes that implements a back inserter, - probably the only efficient inserter for populations of type vector. + probably the only efficient inserter for populations of type std::vector. (c) Maarten Keijzer (mkeijzer@mad.scientist.com) and GeNeura Team, 1999, 2000 @@ -49,7 +49,7 @@ class eoBackInserter : public eoPopInserter return *this; } - string className(void) const { return "eoBackInserter"; } + std::string className(void) const { return "eoBackInserter"; } }; diff --git a/eo/src/obsolete/eoBin.h b/eo/src/obsolete/eoBin.h index 544c3bb3..86dc8e7a 100644 --- a/eo/src/obsolete/eoBin.h +++ b/eo/src/obsolete/eoBin.h @@ -24,9 +24,9 @@ //----------------------------------------------------------------------------- -#include // ostream, istream +#include // std::ostream, std::istream #include // bind2nd -#include // string +#include // std::string #include @@ -39,7 +39,7 @@ /** eoBin: implementation of binary chromosome. \class eoBin eoBin.h ga/eoBin.h \ingroup bitstring - * based on STL's bit_vector (vector). + * based on STL's bit_std::vector (std::vector). */ template class eoBin: public eoFixedLength { @@ -47,33 +47,33 @@ template class eoBin: public eoFixedLength /** * (Default) Constructor. - * @param size Size of the binary string. + * @param size Size of the binary std::string. */ eoBin(unsigned size = 0, bool value = false): eoVector(size, value) {} /// My class name. - string className() const + std::string className() const { return "eoBin"; } /** * To print me on a stream. - * @param os The ostream. + * @param os The std::ostream. */ - void printOn(ostream& os) const + void printOn(std::ostream& os) const { - copy(begin(), end(), ostream_iterator(os)); + copy(begin(), end(), std::ostream_iterator(os)); } /** * To read me from a stream. - * @param is The istream. + * @param is The std::istream. */ - void readFrom(istream& is) + void readFrom(std::istream& is) { - string bits; + std::string bits; is >> bits; if (is) { diff --git a/eo/src/obsolete/eoBreeder.h b/eo/src/obsolete/eoBreeder.h index 1cacd7e6..7d8dd9bc 100644 --- a/eo/src/obsolete/eoBreeder.h +++ b/eo/src/obsolete/eoBreeder.h @@ -28,7 +28,7 @@ //----------------------------------------------------------------------------- -#include // vector +#include // std::vector #include #include // eoOp, eoMonOp, eoBinOp #include // eoPop @@ -103,7 +103,7 @@ template class eoBreeder: public eoTransform }; /// The class name. - string className() const { return "eoBreeder"; } + std::string className() const { return "eoBreeder"; } private: eoOpSelector& opSel; diff --git a/eo/src/obsolete/eoCopyElite.h b/eo/src/obsolete/eoCopyElite.h index cb27500b..19dafcff 100644 --- a/eo/src/obsolete/eoCopyElite.h +++ b/eo/src/obsolete/eoCopyElite.h @@ -63,7 +63,7 @@ template class eoElitism : public eoCopyElite if (howmany > _pop.size()) throw logical_error("Elite larger than population"); - vector result; + std::vector result; _pop.nth_element(howmany, result); for (int i = 0; i < result.size(); ++i) diff --git a/eo/src/obsolete/eoDetTournament.h b/eo/src/obsolete/eoDetTournament.h index e4697b7c..2bd15b9d 100644 --- a/eo/src/obsolete/eoDetTournament.h +++ b/eo/src/obsolete/eoDetTournament.h @@ -48,7 +48,7 @@ template class eoDetTournament: public eoSelectOne eoDetTournament(unsigned _Tsize = 2 ):eoSelectOne(), Tsize(_Tsize) { // consistency check if (Tsize < 2) { - cout << "Warning, Tournament size should be >= 2\nAdjusted\n"; + std::cout << "Warning, Tournament size should be >= 2\nAdjusted\n"; Tsize = 2; } } diff --git a/eo/src/obsolete/eoDetTournamentInserter.h b/eo/src/obsolete/eoDetTournamentInserter.h index 95bd0b34..9077aece 100644 --- a/eo/src/obsolete/eoDetTournamentInserter.h +++ b/eo/src/obsolete/eoDetTournamentInserter.h @@ -61,7 +61,7 @@ public : return *this; } - string className(void) const { return "eoDetTournamentInserter"; } + std::string className(void) const { return "eoDetTournamentInserter"; } private : unsigned t_size; diff --git a/eo/src/obsolete/eoDistance.h b/eo/src/obsolete/eoDistance.h index 13ca197e..5f3c333e 100644 --- a/eo/src/obsolete/eoDistance.h +++ b/eo/src/obsolete/eoDistance.h @@ -56,7 +56,7 @@ class eoDistance { virtual double distance( const EOT& ) const = 0; /// Returns classname - virtual string className() const { return "eoDistance"; } + virtual std::string className() const { return "eoDistance"; } }; diff --git a/eo/src/obsolete/eoDup.h b/eo/src/obsolete/eoDup.h index b41cb7a5..67e4a863 100644 --- a/eo/src/obsolete/eoDup.h +++ b/eo/src/obsolete/eoDup.h @@ -62,7 +62,7 @@ public: /** Inherited from eoObject @see eoObject */ - virtual string className() const {return "eoDup";}; + virtual std::string className() const {return "eoDup";}; //@} }; diff --git a/eo/src/obsolete/eoES.h b/eo/src/obsolete/eoES.h index fdc258c3..9f4051f8 100644 --- a/eo/src/obsolete/eoES.h +++ b/eo/src/obsolete/eoES.h @@ -27,17 +27,17 @@ #define _eoESCHROM_H // STL libraries -#include // For vector<> +#include // For std::vector<> #include #include -#include // for ostream +#include // for std::ostream // EO includes #include /**@name Chromosomes for evolution strategies -Each chromosome in an evolution strategies is composed of a vector of floating point -values plus a vector of sigmas, that are added to them during mutation +Each chromosome in an evolution strategies is composed of a std::vector of floating point +values plus a std::vector of sigmas, that are added to them during mutation */ //@{ @@ -97,13 +97,13 @@ bool operator == ( eoESGene _e1, eoESGene _e2 ) { } /// -ostream & operator << ( ostream& _s, const eoESGene& _e ) { +std::ostream & operator << ( std::ostream& _s, const eoESGene& _e ) { _s << _e.val << ", " << _e.sigma << " | "; return _s; } /// Dummy >> -istream & operator >> ( istream& _s, const eoESGene& _e ) { +std::istream & operator >> ( std::istream& _s, const eoESGene& _e ) { _s >> _e.val; _s >> _e.sigma; return _s; @@ -154,7 +154,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eoESChrom";}; + std::string className() const {return "eoESChrom";}; //@} }; diff --git a/eo/src/obsolete/eoESChrom.h b/eo/src/obsolete/eoESChrom.h index dc51db0d..1ad0bcf4 100644 --- a/eo/src/obsolete/eoESChrom.h +++ b/eo/src/obsolete/eoESChrom.h @@ -27,17 +27,17 @@ #define _eoESCHROM_H // STL libraries -#include // For vector<> +#include // For std::vector<> #include #include -#include // for ostream +#include // for std::ostream // EO includes #include /**@name Chromosomes for evolution strategies -Each chromosome in an evolution strategies is composed of a vector of floating point -values plus a vector of sigmas, that are added to them during mutation +Each chromosome in an evolution strategies is composed of a std::vector of floating point +values plus a std::vector of sigmas, that are added to them during mutation */ //@{ @@ -97,13 +97,13 @@ bool operator == ( eoESGene _e1, eoESGene _e2 ) { } /// -ostream & operator << ( ostream& _s, const eoESGene& _e ) { +std::ostream & operator << ( std::ostream& _s, const eoESGene& _e ) { _s << _e.val << ", " << _e.sigma << " | "; return _s; } /// Dummy >> -istream & operator >> ( istream& _s, const eoESGene& _e ) { +std::istream & operator >> ( std::istream& _s, const eoESGene& _e ) { _s >> _e.val; _s >> _e.sigma; return _s; @@ -154,7 +154,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eoESChrom";}; + std::string className() const {return "eoESChrom";}; //@} }; diff --git a/eo/src/obsolete/eoESFullChrom.h b/eo/src/obsolete/eoESFullChrom.h index e8e67457..e00914b5 100644 --- a/eo/src/obsolete/eoESFullChrom.h +++ b/eo/src/obsolete/eoESFullChrom.h @@ -27,28 +27,28 @@ #define _EOESFULLCHROM_H // STL libraries -#include // For vector<> +#include // For std::vector<> #include #include -#include // for ostream +#include // for std::ostream // EO includes #include #include /**@name Chromosomes for evolution strategies -Each chromosome in an evolution strategies is composed of a vector of floating point -values plus a vector of sigmas, that are added to them during mutation and a vector of correlations +Each chromosome in an evolution strategies is composed of a std::vector of floating point +values plus a std::vector of sigmas, that are added to them during mutation and a std::vector of correlations */ //@{ /**@name individuals for evolution strategies -MS- 22/10/99 Each individual in an evolution strategy is composed of - a vector of floating point values - a vector of std deviations - a vector of rotation angles (for correlated mutations) + a std::vector of floating point values + a std::vector of std deviations + a std::vector of rotation angles (for correlated mutations) -These individuals CANNOT BE IMPLEMENTED as vectors of anything +These individuals CANNOT BE IMPLEMENTED as std::vectors of anything at least in the case of correlated mutations */ //@{ @@ -95,11 +95,11 @@ class eoESFullChrom : public eoVector { StdDevInit = parser.getFloat("-II", "--SigmaInit", "0.3", "Initial value for std. dev. (scaled by range)" ); verbose = parser.getBool("-Iv", "--verbose", - "Verbose listing of ES individuals (mutation parameters"); + "Verbose std::listing of ES individuals (mutation parameters"); } - catch (exception & e) + catch (std::exception & e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; parser.printHelp(); exit(1); } @@ -109,10 +109,10 @@ class eoESFullChrom : public eoVector { throw invalid_argument( "No standard deviation: choose another representation please" ); } if (num_sigma > num_genes) { - cout << "WARNING, Number of Standard Deviations > Number of Object Variables\nAdjusted!\n"; + std::cout << "WARNING, Number of Standard Deviations > Number of Object Variables\nAdjusted!\n"; num_sigma = num_genes; // modify the Param value - so .status is OK - ostrstream sloc; + std::ostrstream sloc; sloc << num_genes; parser.setParamValue("--NbSigma", sloc.str()); } @@ -122,8 +122,8 @@ class eoESFullChrom : public eoVector { StdDev.resize(num_sigma); if (correlated_mutations) { if (num_sigma < num_genes) { - cout << "WARNING less Std Dev. than number of variables + Correlated mutations\n"; - cout << "Though possible, this is a strange setting" << endl; + std::cout << "WARNING less Std Dev. than number of variables + Correlated mutations\n"; + std::cout << "Though possible, this is a strange setting" << std::endl; } // nb of rotation angles: N*(N-1)/2 (in general!) CorCff.resize ( (2*num_genes - num_sigma)*(num_sigma - 1) / 2 ); @@ -201,32 +201,32 @@ class eoESFullChrom : public eoVector { /** Print itself: inherited from eoObject implementation. Instance from base classes are processed in base classes, so you don´t have to worry about, for instance, fitness. - @param _s the ostream in which things are written*/ - virtual void printOn( ostream& _s ) const{ - copy( begin(), end(), ostream_iterator( _s, " ") ); + @param _s the std::ostream in which things are written*/ + virtual void printOn( std::ostream& _s ) const{ + copy( begin(), end(), std::ostream_iterator( _s, " ") ); // The formatting instructinos shoudl be left to the caller // _s << "\n"; if (verbose) { _s << "\n\tStd Dev. " ; - copy( StdDev.begin(), StdDev.end(), ostream_iterator( _s, " ") ); + copy( StdDev.begin(), StdDev.end(), std::ostream_iterator( _s, " ") ); if (CorCff.size()) { _s << "\n\t"; - copy( CorCff.begin(), CorCff.end(), ostream_iterator( _s, " ") ); + copy( CorCff.begin(), CorCff.end(), std::ostream_iterator( _s, " ") ); } } }; - /** This exception should be thrown when trying to insert or delete a gene + /** This std::exception should be thrown when trying to insert or delete a gene in a fixed length chromosome */ - class FixedLengthChromosome : public exception { + class FixedLengthChromosome : public std::exception { public: /** * Constructor */ FixedLengthChromosome() - : exception() { }; + : std::exception() { }; ~FixedLengthChromosome() {}; }; @@ -239,14 +239,14 @@ class eoESFullChrom : public eoVector { /** Inherited from eoObject @see eoObject */ - virtual string className() const {return "eoESFullChrom";}; + virtual std::string className() const {return "eoESFullChrom";}; private: - // vector ObjVar; /* object variable vector */ + // std::vector ObjVar; /* object variable std::vector */ // or shoudl the class be subclass of EOVector ??? - vector StdDev; /* standard deviation vector */ - vector CorCff; /* correlation coefficient vector */ + std::vector StdDev; /* standard deviation std::vector */ + std::vector CorCff; /* correlation coefficient std::vector */ bool verbose; /* Print std deviations or not */ diff --git a/eo/src/obsolete/eoESFullMut.h b/eo/src/obsolete/eoESFullMut.h index 5d2d2fa7..9d967c7a 100644 --- a/eo/src/obsolete/eoESFullMut.h +++ b/eo/src/obsolete/eoESFullMut.h @@ -95,7 +95,7 @@ public: /** Inherited from eoObject @see eoObject */ - virtual string className() const {return "eoESMutate";}; + virtual std::string className() const {return "eoESMutate";}; /** Mutate eoEsSimple @@ -197,7 +197,7 @@ public: */ unsigned i,k; - vector VarStp(_eo.size()); + std::vector VarStp(_eo.size()); for (i = 0; i < _eo.size(); i++) VarStp[i] = _eo.stdevs[i] * rng.normal(); diff --git a/eo/src/obsolete/eoEsObjectiveBounds.h b/eo/src/obsolete/eoEsObjectiveBounds.h index f6e2fdda..4a25aa30 100644 --- a/eo/src/obsolete/eoEsObjectiveBounds.h +++ b/eo/src/obsolete/eoEsObjectiveBounds.h @@ -30,7 +30,7 @@ /** \defgroup EvolutionStrategies - Various classes for the initialization and mutation of real valued vectors. + Various classes for the initialization and mutation of real valued std::vectors. Supports simple mutations and various more adaptable mutations, including correlated mutations. diff --git a/eo/src/obsolete/eoGOpBreeder.h b/eo/src/obsolete/eoGOpBreeder.h index 13c8a717..0b8c76f6 100644 --- a/eo/src/obsolete/eoGOpBreeder.h +++ b/eo/src/obsolete/eoGOpBreeder.h @@ -48,7 +48,7 @@ class eoGOpBreeder: public eoUF&, void> } /// The class name. - string className() const { return "eoGOpBreeder"; } + std::string className() const { return "eoGOpBreeder"; } private: eoGOpSelector& opSel; diff --git a/eo/src/obsolete/eoGOpSelector.h b/eo/src/obsolete/eoGOpSelector.h index ae207b9c..279d709b 100644 --- a/eo/src/obsolete/eoGOpSelector.h +++ b/eo/src/obsolete/eoGOpSelector.h @@ -41,7 +41,7 @@ using namespace std; /** Base class for alternative selectors, which use the generalized operator interface. eoGOpBreeders expects this class */ template -class eoGOpSelector: public eoOpSelector, public vector*> +class eoGOpSelector: public eoOpSelector, public std::vector*> { public: @@ -49,7 +49,7 @@ public: /// Dtor virtual ~eoGOpSelector() { - for ( list< eoGeneralOp* >::iterator i= ownOpList.begin(); + for ( std::list< eoGeneralOp* >::iterator i= ownOpList.begin(); i != ownOpList.end(); i++ ) { delete *i; } @@ -65,7 +65,7 @@ public: // implementation can be found below /** Retrieve the operator using its integer handle - @param _id The id number. Should be a valid id, or an exception + @param _id The id number. Should be a valid id, or an std::exception will be thrown @return a reference of the operator corresponding to that id. */ @@ -88,22 +88,22 @@ public: virtual eoGeneralOp& selectOp() = 0; /// - virtual string className() const { return "eoGOpSelector"; }; + virtual std::string className() const { return "eoGOpSelector"; }; /// - void printOn(ostream& _os) const {} - // _os << className().c_str() << endl; + void printOn(std::ostream& _os) const {} + // _os << className().c_str() << std::endl; // for ( unsigned i=0; i!= rates.size(); i++ ) { - // _os << *(operator[](i)) << "\t" << rates[i] << endl; + // _os << *(operator[](i)) << "\t" << rates[i] << std::endl; // } //} - const vector& getRates(void) const { return rates; } + const std::vector& getRates(void) const { return rates; } private : - vector rates; - list< eoGeneralOp* > ownOpList; + std::vector rates; + std::list< eoGeneralOp* > ownOpList; }; /* Implementation of longish functions defined above */ @@ -121,7 +121,7 @@ inline eoOpSelector::ID eoGOpSelector::addOp( eoOp& _op, else { // if it's not a general op, it's a "old" op; create a wrapped op from it - // and keep it on a list to delete them afterwards + // and keep it on a std::list to delete them afterwards // will use auto_ptr when they're readily available switch(_op.getType()) @@ -167,9 +167,9 @@ inline void eoGOpSelector::deleteOp( ID _id ) operator[](_id) = 0; rates[_id] = 0.0; - // check oplist and clear it there too. + // check opstd::list and clear it there too. - list< eoGeneralOp* >::iterator it = find(ownOpList.begin(), ownOpList.end(), op); + std::list< eoGeneralOp* >::iterator it = find(ownOpList.begin(), ownOpList.end(), op); if(it != ownOpList.end()) { diff --git a/eo/src/obsolete/eoGenTerm.h b/eo/src/obsolete/eoGenTerm.h index 6a52cdb8..615ab90b 100644 --- a/eo/src/obsolete/eoGenTerm.h +++ b/eo/src/obsolete/eoGenTerm.h @@ -42,7 +42,7 @@ public: * reached */ virtual bool operator() ( const eoPop& _vEO ) { thisGeneration++; - // cout << " [" << thisGeneration << "] "; + // std::cout << " [" << thisGeneration << "] "; return (thisGeneration < repTotalGenerations) ; // for the postincrement } diff --git a/eo/src/obsolete/eoGeneration.h b/eo/src/obsolete/eoGeneration.h index 93cdfd3b..282de928 100644 --- a/eo/src/obsolete/eoGeneration.h +++ b/eo/src/obsolete/eoGeneration.h @@ -65,13 +65,13 @@ template class eoGeneration: public eoAlgo for ( i = breeders.begin(); i != breeders.end(); i++) evaluator(*i); replace(breeders, pop); - } catch ( exception& e ) { - throw runtime_error( e.what() ); + } catch ( std::exception& e ) { + throw std::runtime_error( e.what() ); } } /// Class name. - string className() const { return "eoGeneration"; } + std::string className() const { return "eoGeneration"; } private: eoBinPopOp& select; diff --git a/eo/src/obsolete/eoGenericBinOp.h b/eo/src/obsolete/eoGenericBinOp.h index dbf909f8..7c06546a 100644 --- a/eo/src/obsolete/eoGenericBinOp.h +++ b/eo/src/obsolete/eoGenericBinOp.h @@ -46,7 +46,7 @@ public: /// Ctor eoGenericBinOp() : eoOp( eoOp::binary ) {}; - virtual string className() const {return "eoGenericBinOp";}; + virtual std::string className() const {return "eoGenericBinOp";}; }; /** Converter from eoGenericBinOp to eoBinOp @@ -60,7 +60,7 @@ public: /// Ctor eoGeneric2TrueBinOp(eoGenericBinOp & _binOp) : binOp( _binOp ) {}; - virtual string className() const {return "eoGeneric2TrueBinOp";} + virtual std::string className() const {return "eoGeneric2TrueBinOp";} virtual void operator()(EOT & _eo1, const EOT & _eo2) { diff --git a/eo/src/obsolete/eoGenericMonOp.h b/eo/src/obsolete/eoGenericMonOp.h index d6d833c9..f090d1fa 100644 --- a/eo/src/obsolete/eoGenericMonOp.h +++ b/eo/src/obsolete/eoGenericMonOp.h @@ -46,7 +46,7 @@ public: /// Ctor eoGenericMonOp() : eoOp( eoOp::unary ) {}; - virtual string className() const {return "eoGenericMonOp";}; + virtual std::string className() const {return "eoGenericMonOp";}; }; /** COnverter from eoGenericMonOp to eoMonOp @@ -60,7 +60,7 @@ public: /// Ctor eoGeneric2TrueMonOp(eoGenericMonOp & _monOp) : monOp( _monOp ) {}; - virtual string className() const {return "eoGeneric2trueMonOp";} + virtual std::string className() const {return "eoGeneric2trueMonOp";} virtual void operator()(EOT & _eo) { diff --git a/eo/src/obsolete/eoGenericQuadOp.h b/eo/src/obsolete/eoGenericQuadOp.h index 95b3667d..35455cfb 100644 --- a/eo/src/obsolete/eoGenericQuadOp.h +++ b/eo/src/obsolete/eoGenericQuadOp.h @@ -51,7 +51,7 @@ public: /// Ctor eoGenericQuadOp() : eoOp( eoOp::quadratic ) {}; - virtual string className() const {return "eoGenericQuadOp";}; + virtual std::string className() const {return "eoGenericQuadOp";}; }; /** Converter from eoGenericQuadOp to eoQuadOp @@ -65,7 +65,7 @@ public: /// Ctor eoGeneric2TrueQuadOp(eoGenericQuadOp & _quadOp) : quadOp( _quadOp ) {}; - virtual string className() const {return "eoGeneric2TrueQuadOp";} + virtual std::string className() const {return "eoGeneric2TrueQuadOp";} virtual void operator()(EOT & _eo1, EOT & _eo2) { diff --git a/eo/src/obsolete/eoID.h b/eo/src/obsolete/eoID.h index f7d65ec7..5763b11b 100644 --- a/eo/src/obsolete/eoID.h +++ b/eo/src/obsolete/eoID.h @@ -27,8 +27,8 @@ //----------------------------------------------------------------------------- -#include // istream, ostream -#include // for string +#include // std::istream, std::ostream +#include // for std::string using namespace std; @@ -68,14 +68,14 @@ class eoID: public Object it's got code as an example of implementation. Only "leaf" classes can be non-virtual. */ - virtual string className() const { return string("[eoID]")+Object::className(); }; + virtual std::string className() const { return std::string("[eoID]")+Object::className(); }; /** * 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) { + virtual void readFrom(std::istream& _is) { Object::readFrom( _is ); _is >> thisID; } @@ -83,9 +83,9 @@ class eoID: public Object /** * 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{ Object::printOn( _os ); _os << thisID; } diff --git a/eo/src/obsolete/eoInclusion.h b/eo/src/obsolete/eoInclusion.h index cc84cdaf..5e752a15 100644 --- a/eo/src/obsolete/eoInclusion.h +++ b/eo/src/obsolete/eoInclusion.h @@ -25,8 +25,8 @@ template class eoInclusion: public eoMerge /// (Default) Constructor. eoInclusion(const float& _rate = 1.0): eoMerge( _rate ) {} - /// Ctor from istream - eoInclusion( istream& _is): eoBinPopOp( _is ) {}; + /// Ctor from std::istream + eoInclusion( std::istream& _is): eoBinPopOp( _is ) {}; /// Dtor virtual ~eoInclusion() {}; @@ -55,7 +55,7 @@ template class eoInclusion: public eoMerge /** Inherited from eoObject. Returns the class name. @see eoObject */ - virtual string className() const {return "eoInclusion";}; + virtual std::string className() const {return "eoInclusion";}; //@} }; diff --git a/eo/src/obsolete/eoInplaceTransform.h b/eo/src/obsolete/eoInplaceTransform.h index 17a358cc..a2785506 100644 --- a/eo/src/obsolete/eoInplaceTransform.h +++ b/eo/src/obsolete/eoInplaceTransform.h @@ -27,7 +27,7 @@ //----------------------------------------------------------------------------- -#include // vector +#include // std::vector #include #include // eoOp, eoMonOp, eoBinOp #include // eoPop diff --git a/eo/src/obsolete/eoInsertion.h b/eo/src/obsolete/eoInsertion.h index 39c65b1a..26774f67 100644 --- a/eo/src/obsolete/eoInsertion.h +++ b/eo/src/obsolete/eoInsertion.h @@ -46,8 +46,8 @@ template class eoInsertion: public eoBinaryFunctor&, c /// (Default) Constructor. eoInsertion(const float& _rate = 1.0): eoMerge( _rate ) {} - /// Ctor from istream - eoInsertion( istream& _is): eoBinPopOp( _is ) {}; + /// Ctor from std::istream + eoInsertion( std::istream& _is): eoBinPopOp( _is ) {}; /// Dtor virtual ~eoInsertion() {}; @@ -86,7 +86,7 @@ template class eoInsertion: public eoBinaryFunctor&, c /** Inherited from eoObject. Returns the class name. @see eoObject */ - virtual string className() const {return "eoInsertion";}; + virtual std::string className() const {return "eoInsertion";}; //@} }; diff --git a/eo/src/obsolete/eoKill.h b/eo/src/obsolete/eoKill.h index e32eed28..e7ec85a5 100644 --- a/eo/src/obsolete/eoKill.h +++ b/eo/src/obsolete/eoKill.h @@ -54,7 +54,7 @@ public: /** Inherited from eoObject @see eoObject */ - virtual string className() const {return "eoKill";}; + virtual std::string className() const {return "eoKill";}; //@} }; diff --git a/eo/src/obsolete/eoLottery.h b/eo/src/obsolete/eoLottery.h index a96c54e4..39ca8723 100644 --- a/eo/src/obsolete/eoLottery.h +++ b/eo/src/obsolete/eoLottery.h @@ -28,7 +28,7 @@ //----------------------------------------------------------------------------- -#include // logic_error +#include // std::logic_error #include // sum_fitness #include @@ -53,7 +53,7 @@ template class eoLottery: public eoBinaryFunctor()) { - throw logic_error("eoLottery: minimizing fitness"); + throw std::logic_error("eoLottery: minimizing fitness"); } } diff --git a/eo/src/obsolete/eoMutation.h b/eo/src/obsolete/eoMutation.h index ecca1826..f3225fff 100644 --- a/eo/src/obsolete/eoMutation.h +++ b/eo/src/obsolete/eoMutation.h @@ -51,14 +51,14 @@ public: } /// To print me on a stream. - /// @param os The ostream. - void printOn(ostream& os) const { + /// @param os The std::ostream. + void printOn(std::ostream& os) const { os << rate ; } /// To read me from a stream. - /// @param is The istream. - void readFrom(istream& is) { + /// @param is The std::istream. + void readFrom(std::istream& is) { is >> rate ; } @@ -68,7 +68,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eoMutation";}; + std::string className() const {return "eoMutation";}; //@} protected: diff --git a/eo/src/obsolete/eoOpFactory.h b/eo/src/obsolete/eoOpFactory.h index f4182acd..2d835d99 100644 --- a/eo/src/obsolete/eoOpFactory.h +++ b/eo/src/obsolete/eoOpFactory.h @@ -50,17 +50,17 @@ public: virtual ~eoOpFactory() {} //@} - /** 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 @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* make(istream& _is) { + virtual eoOp* make(std::istream& _is) { eoOp * opPtr = NULL; - string objectTypeStr; + std::string objectTypeStr; _is >> objectTypeStr; if ( objectTypeStr == "eoDup") { opPtr = new eoDup(); diff --git a/eo/src/obsolete/eoOpSelector.h b/eo/src/obsolete/eoOpSelector.h index 82be4732..d15f620c 100644 --- a/eo/src/obsolete/eoOpSelector.h +++ b/eo/src/obsolete/eoOpSelector.h @@ -31,7 +31,7 @@ //----------------------------------------------------------------------------- -#include // runtime_error +#include // std::runtime_error #include #include @@ -63,12 +63,12 @@ public: /** Gets a non-const reference to an operator, so that it can be changed, modified or whatever @param _id a previously assigned ID - @throw runtime_exception if the ID does not exist*/ + @throw runtime_std::exception if the ID does not exist*/ virtual eoOp& getOp( ID _id ) = 0; /** Remove an operator from the operator set @param _id a previously assigned ID - @throw runtime_exception if the ID does not exist + @throw runtime_std::exception if the ID does not exist */ virtual void deleteOp( ID _id ) = 0; @@ -79,9 +79,9 @@ 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 "eoOpSelector"; }; + virtual std::string className() const { return "eoOpSelector"; }; /** * Read object and print objects are left for subclasses to define. diff --git a/eo/src/obsolete/eoParser.h b/eo/src/obsolete/eoParser.h index 01369913..fb837370 100644 --- a/eo/src/obsolete/eoParser.h +++ b/eo/src/obsolete/eoParser.h @@ -29,8 +29,8 @@ #include // for strcasecmp ... maybe there's a c++ way of doing it? // Yep there is, but needs either a simple functor for the equal function - // or a hand-rolled string template class (this isn't that horrible as - // it sounds, it just means a new string_traits class with two changed + // or a hand-rolled std::string template class (this isn't that horrible as + // it sounds, it just means a new std::string_traits class with two changed // function definitions. (Maarten) #ifdef _MSC_VER #define strcasecmp(a,b) _strnicmp(a,b,strlen(a)) @@ -44,8 +44,8 @@ #include #include -// include for exceptions -#include // logic_error +// include for std::exceptions +#include // std::logic_error //----------------------------------------------------------------------------- // Class Param @@ -71,9 +71,9 @@ public: * @param _description Description of the parameter. What is useful for. * @param _required If it is a necessary parameter or not */ - Param (string _shortName="-h", string _longName="--help", - string _default = "", valueType _valType= STRING, - string _description="Shows this help", + Param (std::string _shortName="-h", std::string _longName="--help", + std::string _default = "", valueType _valType= STRING, + std::string _description="Shows this help", bool _required=false ) : repShortName(_shortName), repLongName(_longName), repDescription(_description ), repEnv(""), repDefault(_default), @@ -108,38 +108,38 @@ public: /** * Returns the short name. */ - const string& shortName ( void ) const { return repShortName; }; + const std::string& shortName ( void ) const { return repShortName; }; /** * Returns the long name. */ - const string& longName ( void ) const { return repLongName; }; + const std::string& longName ( void ) const { return repLongName; }; /** * Returns the description of the argument */ - const string& description ( void ) const { return repDescription; }; + const std::string& description ( void ) const { return repDescription; }; /** * Returns the environment variable of the argument */ - const string& environment ( void ) const { return repEnv; }; + const std::string& environment ( void ) const { return repEnv; }; /** * Returns the default value of the argument */ - const string& defValue ( void ) const { return repDefault; }; + const std::string& defValue ( void ) const { return repDefault; }; /** * Sets a value for the param. * @param _value The new value. */ - void value ( const string& _value ) { repValue = _value; repChanged = true; }; + void value ( const std::string& _value ) { repValue = _value; repChanged = true; }; /** * Returns the value of the param. */ - const string& value ( void ) const { return repValue; }; + const std::string& value ( void ) const { return repValue; }; /** * Returns if required or not. @@ -157,13 +157,13 @@ public: bool changed( void ) const { return repChanged; }; private: - string repShortName; - string repLongName; - string repDescription; - string repEnv; - string repDefault; + std::string repShortName; + std::string repLongName; + std::string repDescription; + std::string repEnv; + std::string repDefault; - string repValue; + std::string repValue; Param::valueType repValType; bool repRequired; bool repChanged; @@ -194,15 +194,15 @@ public: * @param _argc, _ argv command line arguments * @param _programDescription Description of the work the program does */ - Parser ( int _argc, char **_argv , string _programDescription, - string _sFileParamName = "-P", - string _lFileParamName = "--Param") : + Parser ( int _argc, char **_argv , std::string _programDescription, + std::string _sFileParamName = "-P", + std::string _lFileParamName = "--Param") : params(), programName( _argv[0]), programDescription( _programDescription), parse_argc(_argc), parse_argv(_argv), InputFileName("") { // the input file name has to be read immediately - from command-line or environement (not input0file :-) - string _default = _argv[0]; + std::string _default = _argv[0]; _default += ".param"; Param param (_sFileParamName, _lFileParamName, _default, Param::STRING, "Name of the input file", 0); @@ -249,7 +249,7 @@ public: * Adds a fake parameter == title in the output file * @param the title */ - void AddTitle (const string& _title) + void AddTitle (const std::string& _title) { Param param ( "", "", "", Param::TITLE, _title, false ); params.push_back( param ); @@ -266,12 +266,12 @@ public: */ /** - * Gets the string value of a param from the full parameter description + * Gets the std::string value of a param from the full parameter description * @param see above */ - string getString (const string& _shortName, const string& _longName, - const string& _default = "", - const string& _description="", bool _required=false) { + std::string getString (const std::string& _shortName, const std::string& _longName, + const std::string& _default = "", + const std::string& _description="", bool _required=false) { Param param ( _shortName, _longName, _default, Param::STRING, _description, _required ); parse( param ); params.push_back( param ); @@ -284,8 +284,8 @@ public: * @param see above */ - bool getBool (const string& _shortName, const string& _longName, - const string& _description="") { + bool getBool (const std::string& _shortName, const std::string& _longName, + const std::string& _description="") { Param param ( _shortName, _longName, "false", Param::BOOL, _description, false ); parse( param ); params.push_back( param ); @@ -299,19 +299,19 @@ public: }; /** - * Gets the "array" (vector of strings) value of a param from the full parameter description + * Gets the "array" (std::vector of std::strings) value of a param from the full parameter description * @param see above */ - vector getArray (const string& _shortName, const string& _longName, - const string& _default = "", - const string& _description="", bool _required=false) { + std::vector getArray (const std::string& _shortName, const std::string& _longName, + const std::string& _default = "", + const std::string& _description="", bool _required=false) { Param param ( _shortName, _longName, _default, Param::ARRAY, _description, _required ); parse( param ); params.push_back( param ); istrstream is(param.value().c_str()); - vector retValue; - string tmpStr; + std::vector retValue; + std::string tmpStr; is >> tmpStr; while(is){ @@ -324,12 +324,12 @@ public: /** * Gets the int value of a param given the full description of the parameter * @param see above - * @exception BadType if the param's value isn't a correct int + * @std::exception BadType if the param's value isn't a correct int */ - int getInt (const string& _shortName, const string& _longName, - const string& _default = "", - const string& _description="", bool _required=false) { + int getInt (const std::string& _shortName, const std::string& _longName, + const std::string& _default = "", + const std::string& _description="", bool _required=false) { Param param ( _shortName, _longName, _default, Param::INT, _description, _required ); parse( param ); params.push_back( param ); @@ -350,12 +350,12 @@ public: /** * Gets the unsigned lon value of a param given ... * @param see above - * @exception BadType if the param's value isn't a correct unsigned long + * @std::exception BadType if the param's value isn't a correct unsigned long */ - int getUnsignedLong (const string& _shortName, const string& _longName, - const string& _default = "", - const string& _description="", bool _required=false) { + int getUnsignedLong (const std::string& _shortName, const std::string& _longName, + const std::string& _default = "", + const std::string& _description="", bool _required=false) { Param param ( _shortName, _longName, _default, Param::UL, _description, _required ); parse( param ); params.push_back( param ); @@ -376,12 +376,12 @@ public: /** * Gets the float value of a param given the description of the parameter * @param see above - * @exception BadType if the param's value isn't a correct int + * @std::exception BadType if the param's value isn't a correct int */ - float getFloat (const string& _shortName, const string& _longName, - const string& _default = "", - const string& _description="", bool _required=false) { + float getFloat (const std::string& _shortName, const std::string& _longName, + const std::string& _default = "", + const std::string& _description="", bool _required=false) { Param param ( _shortName, _longName, _default, Param::FLOAT, _description, _required ); parse( param ); params.push_back( param ); @@ -400,19 +400,19 @@ public: }; - string parse_string (istream & _is) { - string paramValue; + std::string parse_std::string (std::istream & _is) { + std::string paramValue; _is >> paramValue; - //if the first character of the string or array is not a " => just one word or array-element. + //if the first character of the std::string or array is not a " => just one word or array-element. if( paramValue[0] != '\"' ) return paramValue; - if( paramValue[1] == '\"' ) // the empty string + if( paramValue[1] == '\"' ) // the empty std::string return "" ; - //else => read until the next " (the end of the string). + //else => read until the next " (the end of the std::string). const char *c = paramValue.c_str(); - string tmpStr = c+1;// skip the " + std::string tmpStr = c+1;// skip the " if (tmpStr[tmpStr.length()-1] == '\"') { // one word only //tmpStr[tmpStr.length()-1] = '\0'; tmpStr.erase( &tmpStr[tmpStr.length()-1] ); @@ -436,11 +436,11 @@ public: void parse (Param & param) { int i; - string tmpStr, ReadStr, FirstWord; + std::string tmpStr, ReadStr, FirstWord; // FIRST: look if the associated environment variables have any value, to use them. if( getenv( param.environment().c_str() ) ) { - //cout <<"\t\t ENV param: ,"<shortName()<<", ,"<environment().c_str())<shortName()<<", ,"<environment().c_str())<" --> a single string in the array + ReadStr = parse_std::string(is); + if ( ReadStr != "<" ) { // no "<" ">" --> a single std::string in the array param.value(ReadStr); break; } // read next word - and keep it in case of <> mismatch - FirstWord = parse_string(is); + FirstWord = parse_std::string(is); // test for empty array if (FirstWord == ">") { param.value(""); @@ -491,15 +491,15 @@ public: } // else, read all words until ">" tmpStr = FirstWord; - ReadStr = parse_string(is); + ReadStr = parse_std::string(is); while ( is && (ReadStr != ">") ) { tmpStr = tmpStr + " " + ReadStr; - ReadStr = parse_string(is); + ReadStr = parse_std::string(is); } if (!is) { // there was a "<" without the corresponding ">" throw Parser::BadArrayParam( param.longName(), FirstWord ); - param.value(FirstWord); // assume unique string + param.value(FirstWord); // assume unique std::string } else param.value(tmpStr); @@ -516,18 +516,18 @@ public: ( ! strcmp(param.shortName().c_str(), parse_argv[i]) ) ) { // found the parameter name if (param.valType() == Param::BOOL) { - //cout <<"BOOL: "<" --> a single string in the array + if ( ReadStr != "<" ) { // no "<" ">" --> a single std::string in the array param.value(ReadStr); }else{ // read next word - and keep it in case of <> mismatch @@ -544,11 +544,11 @@ public: tmpStr = tmpStr + " " + ReadStr; ReadStr = parse_argv[i++]; } - //cout <<"tmpStr ;"<=parse_argc) && (ReadStr != ">") ) { // there was a "<" without the corresponding ">" throw Parser::BadArrayParam( param.longName(), FirstWord ); - param.value(FirstWord); // assume unique string + param.value(FirstWord); // assume unique std::string }else{ param.value(tmpStr); } @@ -570,11 +570,11 @@ public: * Sets a new value for a param given its short name or its long name. * @param _name One of the names of the param. * @param _value Value to be assigned. - * @exception UnknownArg if the param doesn't exist - * @exception MissingVal if the param hasn't got a value + * @std::exception UnknownArg if the param doesn't exist + * @std::exception MissingVal if the param hasn't got a value */ - Param::valueType setParamValue (const string& _name, const char* _value){ - vector::iterator pos; + Param::valueType setParamValue (const std::string& _name, const char* _value){ + std::vector::iterator pos; for (pos=params.begin() ; pos!=params.end() ; pos++) if (pos->shortName()==_name || pos->longName()==_name) @@ -584,7 +584,7 @@ public: if (pos!=params.end()) { switch ( pos->valType() ) { case Param::TITLE: - cerr << "Error, we should not be there" << endl; + std::cerr << "Error, we should not be there" << std::endl; exit(1); break; case Param::BOOL : @@ -613,14 +613,14 @@ public: }; /// the output method - generate the .status file (unless other name is given) - friend ostream & operator<< ( ostream & os, Parser & _parser ) + friend std::ostream & operator<< ( std::ostream & os, Parser & _parser ) { - vector::iterator p; + std::vector::iterator p; //print every param with its value for ( p=_parser.params.begin(); p!=_parser.params.end(); p++ ) { switch ( p->valType() ) { case Param::BOOL : - if( p->value() == (string) "true") + if( p->value() == (std::string) "true") os << p->longName(); else os << "#" << p->longName() ; // so the name of the bool is commented out @@ -639,30 +639,30 @@ public: os << p->longName()<<" \""<value().c_str()<<"\" "; break; case Param::TITLE: - os << endl; // Title is in the description below + os << std::endl; // Title is in the description below break; } // switch os << "\t #" << p->shortName() << " : " << p->description(); if (p->valType() != Param::TITLE) os << " [" << p->defValue() << "]" ; - os << endl; + os << std::endl; } return os; }; /** - * Prints out the list of parameters in the output file (if specified) + * Prints out the std::list of parameters in the output file (if specified) */ - void outputParam(string _OutputFile="") + void outputParam(std::string _OutputFile="") { if (_OutputFile == "") { _OutputFile = parse_argv[0]; _OutputFile += ".status"; } - ofstream os(_OutputFile.c_str()); + std::ofstream os(_OutputFile.c_str()); os << "Parameters used by \"" << programName << "\" (" - << programDescription << ")" << endl << endl; + << programDescription << ")" << std::endl << std::endl; os << *this; }; @@ -671,80 +671,80 @@ public: * provided by parameters */ void printHelp() { - vector::iterator p; + std::vector::iterator p; // unsigned i; // print program name and description - cout << this->programName <<": "<programName <<": "<valType() != Param::TITLE ) { // if( p->valType() != Param::BOOL ){ - // cout << ( (!p->required())?"[":""); - // cout <shortName()<<" value"<required())?"]":"")<<" "; + // std::cout << ( (!p->required())?"[":""); + // std::cout <shortName()<<" value"<required())?"]":"")<<" "; // }else{ - // cout << "["<shortName()<<"] "; + // std::cout << "["<shortName()<<"] "; // } // } // for p - cout << "Where:"<valType() != Param::TITLE ) { // Victor: 04-Jan-2000 // Modified because the - and -- prefixes are not needed. /* - cout << "-" << p->shortName() + std::cout << "-" << p->shortName() <<", --"<longName()<<":\t" - <description()<description()<shortName() + std::cout << p->shortName() <<", " << p->longName()<<":\t" - <description()<description()<valType() ) { - case Param::INT: cout <<"Integer"; break; - case Param::UL: cout <<"Unsigned Long Integer"; break; - case Param::FLOAT: cout <<"Float"; break; - case Param::STRING: cout <<"String"; break; - case Param::ARRAY: cout <<"An array of strings, enclosed within < >"; break; - case Param::BOOL: cout << "Flag"; break; + case Param::INT: std::cout <<"Integer"; break; + case Param::UL: std::cout <<"Unsigned Long Integer"; break; + case Param::FLOAT: std::cout <<"Float"; break; + case Param::STRING: std::cout <<"String"; break; + case Param::ARRAY: std::cout <<"An array of std::strings, enclosed within < >"; break; + case Param::BOOL: std::cout << "Flag"; break; case Param::TITLE: break; } // switch if(p->valType() == Param::BOOL) - cout << ") True if present" << endl; + std::cout << ") True if present" << std::endl; else - cout<<") "<<( (p->required())?"Required":"Optional" )<<". By default: "<defValue()<required())?"Required":"Optional" )<<". By default: "<defValue()<description() << endl; + std::cout << "\n\t # " << p->description() << std::endl; } } // for p - cout << endl; + std::cout << std::endl; }; /** - * This class managges unknown argument exceptions. + * This class managges unknown argument std::exceptions. */ - class UnknownArg : public logic_error { + class UnknownArg : public std::logic_error { public: /** * Constructor - * @param _arg string to be shown when the exception occurs + * @param _arg std::string to be shown when the std::exception occurs */ - UnknownArg( const string& _arg): logic_error( "Invalid argument: "+_arg ) { }; + UnknownArg( const std::string& _arg): std::logic_error( "Invalid argument: "+_arg ) { }; }; /** * This class managges bad param types. */ - class BadType : public logic_error { + class BadType : public std::logic_error { public: /** @@ -752,40 +752,40 @@ public: * @param _param The param * @param _value The value of the param */ - BadType(const string& _param, const string& _value, const string& _correctType) - : logic_error("The value '" + _value + "' assigned to the argument " + _param + " isn't a correct "+_correctType) { }; + BadType(const std::string& _param, const std::string& _value, const std::string& _correctType) + : std::logic_error("The value '" + _value + "' assigned to the argument " + _param + " isn't a correct "+_correctType) { }; }; /** - * This class managges exceptions produced when there isn't a value for a parameter. + * This class managges std::exceptions produced when there isn't a value for a parameter. */ - class MissingVal : public logic_error { + class MissingVal : public std::logic_error { public: /** * Constructor * @param _param The param */ - MissingVal(const string& _param) : logic_error("Missing value for parameter " + _param) {}; + MissingVal(const std::string& _param) : std::logic_error("Missing value for parameter " + _param) {}; }; /** - * This class managges exceptions produced when the user forgot a required parameter. + * This class managges std::exceptions produced when the user forgot a required parameter. */ - class MissingReqParam : public logic_error { + class MissingReqParam : public std::logic_error { public: /** * Constructor * @param _shortName The param's short name */ - MissingReqParam(const string& _shortName) : logic_error("Missing required parameter " + _shortName) {}; + MissingReqParam(const std::string& _shortName) : std::logic_error("Missing required parameter " + _shortName) {}; }; /** - * This class managges exceptions du to < without a > in array value + * This class managges std::exceptions du to < without a > in array value */ - class BadArrayParam : public logic_error { + class BadArrayParam : public std::logic_error { public: /** @@ -793,17 +793,17 @@ public: * @param _param The param * @param _first_word The first word read after the "<" */ - BadArrayParam(const string& _param, const string &_first_word) : - logic_error("Array parameter " + _param + ": No matching > (" + _first_word + BadArrayParam(const std::string& _param, const std::string &_first_word) : + std::logic_error("Array parameter " + _param + ": No matching > (" + _first_word + "... )") {}; }; - void createParamFile( ostream& _os ) { - vector::iterator p; + void createParamFile( std::ostream& _os ) { + std::vector::iterator p; for ( p=params.begin(); p!=params.end(); p++ ) { switch( p->valType() ) { case Param::TITLE: - _os << endl << "# -- "; + _os << std::endl << "# -- "; break; case Param::BOOL: _os << ((p->value()=="true" )?"":"#") @@ -819,16 +819,16 @@ public: _os << p->longName()<<"\t"<value(); break; } // switch - _os << "\t #" << p->description() << endl; + _os << "\t #" << p->description() << std::endl; } } private: - vector params; - string programName; - string programDescription; + std::vector params; + std::string programName; + std::string programDescription; int parse_argc; char **parse_argv; - string InputFileName; + std::string InputFileName; }; diff --git a/eo/src/obsolete/eoPopOps.h b/eo/src/obsolete/eoPopOps.h index b719ec23..bd1dbf68 100644 --- a/eo/src/obsolete/eoPopOps.h +++ b/eo/src/obsolete/eoPopOps.h @@ -68,7 +68,7 @@ class eoMonPopOp: public eoObject{ /** Inherited from eoObject. Returns the class name. @see eoObject */ - virtual string className() const {return "eoMonPopOp";}; + virtual std::string className() const {return "eoMonPopOp";}; //@} }; @@ -101,7 +101,7 @@ class eoBinPopOp: public eoObject{ /** Inherited from eoObject. Returns the class name. @see eoObject */ - virtual string className() const {return "eoBinPopOp";}; + virtual std::string className() const {return "eoBinPopOp";}; //@} }; @@ -135,7 +135,7 @@ class eoSelectOne: public eoObject{ /** Inherited from eoObject. Returns the class name. @see eoObject */ - virtual string className() const {return "eoSelectOne";}; + virtual std::string className() const {return "eoSelectOne";}; //@} }; diff --git a/eo/src/obsolete/eoProportional.h b/eo/src/obsolete/eoProportional.h index 6840f697..7116e786 100644 --- a/eo/src/obsolete/eoProportional.h +++ b/eo/src/obsolete/eoProportional.h @@ -48,7 +48,7 @@ public: total((pop.size() == 0) ? -1.0 : sum_fitness(pop)) { if (minimizing_fitness()) - throw logic_error("eoProportional: minimizing fitness"); + throw std::logic_error("eoProportional: minimizing fitness"); } void setup(const eoPop& _pop) diff --git a/eo/src/obsolete/eoProportionalGOpSel.h b/eo/src/obsolete/eoProportionalGOpSel.h index 68eb8ce6..a52bac60 100644 --- a/eo/src/obsolete/eoProportionalGOpSel.h +++ b/eo/src/obsolete/eoProportionalGOpSel.h @@ -44,7 +44,7 @@ public : } /// - virtual string className() const { return "eoGOpSelector"; }; + virtual std::string className() const { return "eoGOpSelector"; }; }; diff --git a/eo/src/obsolete/eoProportionalOpSel.h b/eo/src/obsolete/eoProportionalOpSel.h index 00ea5fb9..72c17dc2 100644 --- a/eo/src/obsolete/eoProportionalOpSel.h +++ b/eo/src/obsolete/eoProportionalOpSel.h @@ -31,7 +31,7 @@ //----------------------------------------------------------------------------- -#include // runtime_error +#include // std::runtime_error #include // greater #include @@ -42,8 +42,8 @@ //----------------------------------------------------------------------------- /** This class selects operators according to probability. All operator percentages -should add up to one; if not, an exception will be raised.\\ -Operators are represented as pairs (proportion,operator) +should add up to one; if not, an std::exception will be raised.\\ +Operators are represented as std::pairs (proportion,operator) */ template class eoProportionalOpSel: public eoOpSelector, @@ -63,14 +63,14 @@ public: /** Gets a non-const reference to an operator, so that it can be changed, modified or whatever @param _id a previously assigned ID - @throw runtime_error if the ID does not exist*/ + @throw std::runtime_error if the ID does not exist*/ virtual eoOp& getOp( ID _id ) { MMF::iterator i=begin(); ID j = 1; while ( (i++!=end()) && (j++ != _id) ); if ( i == end() ) - throw runtime_error( "No such id in eoProportionalOpSel::op\n" ); + throw std::runtime_error( "No such id in eoProportionalOpSel::op\n" ); return *(i->second); //return i->second; } @@ -87,7 +87,7 @@ public: /** Remove an operator from the operator set @param _id a previously assigned ID - @throw runtime_error if the ID does not exist + @throw std::runtime_error if the ID does not exist */ virtual void deleteOp( ID _id ) { unsigned j; @@ -98,7 +98,7 @@ public: return; } if ( i == end() ) - throw runtime_error( "No such id in eoProportionalOpSel::op\n" ); + throw std::runtime_error( "No such id in eoProportionalOpSel::op\n" ); }; /// Returns a genetic operator according to the established criteria @@ -111,7 +111,7 @@ public: acc +=i->first; } if ( acc != 1.0 ) - throw runtime_error( "Operator rates added up different from 1.0" ); + throw std::runtime_error( "Operator rates added up different from 1.0" ); // If here, operators ordered by rate and no problem float aRnd = rng.uniform(); @@ -121,7 +121,7 @@ public: acc += i->first; } while ( (acc <= aRnd ) && (i++!=end() ) ); if ( i == end() ) - throw runtime_error( "Operator not found in eoProportionalOpSelector" ); + throw std::runtime_error( "Operator not found in eoProportionalOpSelector" ); return i->second; //return i->second; } @@ -130,18 +130,18 @@ 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 "eoProportionalOpSel"; }; + virtual std::string className() const { return "eoProportionalOpSel"; }; /** Print itself: inherited from eoObject implementation. Declared virtual so that it can be reimplemented anywhere. Instance from base classes are processed in base classes, so you don´t have to worry about, for instance, fitness. - @param _s the ostream in which things are written*/ - virtual void printOn( ostream& _s ) const{ - _s << className().c_str() << endl; + @param _s the std::ostream in which things are written*/ + virtual void printOn( std::ostream& _s ) const{ + _s << className().c_str() << std::endl; for ( MMF::const_iterator i=begin(); i!=end(); i++ ) { - _s << i->first << "\t" << *(i->second )<< endl; + _s << i->first << "\t" << *(i->second )<< std::endl; } } diff --git a/eo/src/obsolete/eoRandomBreed.h b/eo/src/obsolete/eoRandomBreed.h index dd22d843..61b76e08 100644 --- a/eo/src/obsolete/eoRandomBreed.h +++ b/eo/src/obsolete/eoRandomBreed.h @@ -27,13 +27,13 @@ #include -/** Takes those on the selection list and creates a list of new individuals +/** Takes those on the selection std::list and creates a std::list of new individuals * Destroys the genetic pool */ template class EORandomBreed: public EOBreeder{ public: - typedef vector< EOOp * > vecOpT; + typedef std::vector< EOOp * > vecOpT; /// Ctor EORandomBreed():vecOp() {}; @@ -54,12 +54,12 @@ public: vecOp.push_back( _eop); }; - /// Takes the operator pointed to from the operator list + /// Takes the operator pointed to from the operator std::list virtual void deleteOp( const EOOp* _eop); /** Takes the genetic pool, and returns next generation, destroying the * genetic pool container - * Non-const because it might order the operator vector. In this case, + * Non-const because it might order the operator std::vector. In this case, * it mates all members of the population randomly */ virtual void operator() ( EOPop< EOT >& _ptVeo ); @@ -133,7 +133,7 @@ template class EORandomBreedLog: public EORandomBreed{ public: - typedef vector< EOOp * > vecOpT; + typedef std::vector< EOOp * > vecOpT; /// Ctor EORandomBreedLog( EOFactory & _eof ):EORandomBreed(), factory( _eof ) {}; @@ -148,7 +148,7 @@ public: /** Takes the genetic pool, and returns next generation, destroying the * genetic pool container - * Non-const because it might order the operator vector. In this case, it mates + * Non-const because it might order the operator std::vector. In this case, it mates * all population randomly */ virtual void operator() ( EOPop< EOT >& _ptVeo ) { diff --git a/eo/src/obsolete/eoRandomSelect.h b/eo/src/obsolete/eoRandomSelect.h index 53b7a03e..26faa9ea 100644 --- a/eo/src/obsolete/eoRandomSelect.h +++ b/eo/src/obsolete/eoRandomSelect.h @@ -78,11 +78,11 @@ template class eoRandomSelect: public eoBinPopOp * Should call base class, just in case. - * @param _s A istream. + * @param _s A std::istream. */ - virtual void readFrom(istream& _s) { + virtual void readFrom(std::istream& _s) { _s >> repRate; @@ -96,9 +96,9 @@ template class eoRandomSelect: public eoBinPopOp base classes, so you don´t have to worry about, for instance, fitness. - @param _s the ostream in which things are written*/ + @param _s the std::ostream in which things are written*/ - virtual void printOn( ostream& _s ) const{ + virtual void printOn( std::ostream& _s ) const{ _s << repRate; @@ -112,7 +112,7 @@ template class eoRandomSelect: public eoBinPopOp */ - string className() const {return "eoRandomSelect";}; + std::string className() const {return "eoRandomSelect";}; diff --git a/eo/src/obsolete/eoRank.h b/eo/src/obsolete/eoRank.h index 67d6707f..588fb1da 100644 --- a/eo/src/obsolete/eoRank.h +++ b/eo/src/obsolete/eoRank.h @@ -40,9 +40,9 @@ /** - * Takes those on the selection list and creates a list of new individuals + * Takes those on the selection std::list and creates a std::list of new individuals * Destroys the genetic pool. There's no requisite on EOT, other than the - * genetic operators can be instantiated with it, so it fully depends on + * genetic operators can be instantiated with it, so it fully depstd::ends on * the genetic operators used. If generic genetic operators are used, then * EOT must be an EO */ @@ -61,14 +61,14 @@ class eoRank: public eoSelect, public eoObject, public eoPrintable /** Takes the genetic pool, and returns next generation, destroying the * genetic pool container - * Non-const because it might order the operator vector*/ + * Non-const because it might order the operator std::vector*/ virtual void operator() ( const eoPop< EOT >& _ptVeo, eoPop< EOT >& _siblings ) const { unsigned inLen = _ptVeo.size(); // size of subPop if ( !inLen ) - throw runtime_error( "zero population in eoRank"); + throw std::runtime_error( "zero population in eoRank"); for ( unsigned i = 0; i < repNewPopSize; i ++ ) { // Create a copy of a random input EO with copy ctor. The members of the @@ -113,13 +113,13 @@ class eoRank: public eoSelect, public eoObject, public eoPrintable /** Return the class id. - @return the class name as a string + @return the class name as a std::string */ - virtual string className() const { return "eoRank"; }; + virtual std::string className() const { return "eoRank"; }; - virtual void printOn( ostream& _s ) const + virtual void printOn( std::ostream& _s ) const { _s << repNewPopSize; }; diff --git a/eo/src/obsolete/eoScheme.h b/eo/src/obsolete/eoScheme.h index 5920fdb6..a66695b0 100644 --- a/eo/src/obsolete/eoScheme.h +++ b/eo/src/obsolete/eoScheme.h @@ -81,8 +81,8 @@ class eoScheme: public eoAlgo{ eoScheme(Parser & parser) { // read the popsize parser.AddTitle("Description of evolution"); - string Evol; - string SelectString; + std::string Evol; + std::string SelectString; // temporary float rate_offspring; @@ -92,9 +92,9 @@ class eoScheme: public eoAlgo{ popsize = parser.getInt("-EP", "--population", "10", "Population size" ); } - catch (exception & e) + catch (std::exception & e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; parser.printHelp(); exit(1); } @@ -128,9 +128,9 @@ class eoScheme: public eoAlgo{ ptreplace = new eoInclusion(); // put here the choice of elitism } - catch (exception & e) + catch (std::exception & e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; parser.printHelp(); exit(1); } @@ -156,9 +156,9 @@ class eoScheme: public eoAlgo{ ptselect_mate = new eoDetTournament((int)_rate); } } - catch (exception & e) + catch (std::exception & e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; parser.printHelp(); exit(1); } @@ -178,9 +178,9 @@ class eoScheme: public eoAlgo{ ptselect_mate = new eoUniformSelect(); ptreplace = new eoESPlus(); } - catch (exception & e) + catch (std::exception & e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; parser.printHelp(); exit(1); } @@ -197,9 +197,9 @@ class eoScheme: public eoAlgo{ ptselect_mate = new eoUniformSelect(); ptreplace = new eoESComma(); } - catch (exception & e) + catch (std::exception & e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; parser.printHelp(); exit(1); } @@ -218,9 +218,9 @@ class eoScheme: public eoAlgo{ "Size of stocahstic replacement tournament" ); ptreplace = new eoEPTournament(tsize); } - catch (exception & e) + catch (std::exception & e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; parser.printHelp(); exit(1); } @@ -249,7 +249,7 @@ class eoScheme: public eoAlgo{ /** Inherited from eoObject. Returns the class name. @see eoObject */ - string className() const {return "eoScheme";}; + std::string className() const {return "eoScheme";}; //@} private: unsigned popsize; /* but should it be here ??? */ @@ -275,7 +275,7 @@ class eoScheme: public eoAlgo{ in SSGA, nb_offspring = 1 (usually) elitism can be used anywhere - though stupid in ES, EP and SSGA who are - elist by definition + estd::list by definition */ #endif _EOSCHEME_H @@ -319,7 +319,7 @@ class eoScheme: public eoAlgo{ mate = select_mate(pop, tmp); // though useless ig mutation else mate = tmp; // assumed: mate will not be used! - cout << op->className() << " for offspring " << i << endl; + std::cout << op->className() << " for offspring " << i << std::endl; tmp = (*op)( tmp, mate, pop ); op = seqselop.Op(&id); } diff --git a/eo/src/obsolete/eoSteadyStateEA.h b/eo/src/obsolete/eoSteadyStateEA.h index 7be4870f..caa9ebed 100644 --- a/eo/src/obsolete/eoSteadyStateEA.h +++ b/eo/src/obsolete/eoSteadyStateEA.h @@ -63,11 +63,11 @@ template class eoSteadyStateEA: public eoAlgo { step(pop); } - catch (exception& e) + catch (std::exception& e) { - string s = e.what(); + std::string s = e.what(); s.append( " in eoSteadyStateEA "); - throw runtime_error( s ); + throw std::runtime_error( s ); } } while ( continuator( pop ) ); diff --git a/eo/src/obsolete/eoStochTournament.h b/eo/src/obsolete/eoStochTournament.h index 78a5f1fd..5569ce62 100644 --- a/eo/src/obsolete/eoStochTournament.h +++ b/eo/src/obsolete/eoStochTournament.h @@ -48,7 +48,7 @@ template class eoStochTournament: public eoSelectOne { // consistency check 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; } } diff --git a/eo/src/obsolete/eoStochTournamentInserter.h b/eo/src/obsolete/eoStochTournamentInserter.h index 002f3d9c..3856aecc 100644 --- a/eo/src/obsolete/eoStochTournamentInserter.h +++ b/eo/src/obsolete/eoStochTournamentInserter.h @@ -66,7 +66,7 @@ public : return *this; } - string className(void) const { return "eoStochTournamentInserter"; } + std::string className(void) const { return "eoStochTournamentInserter"; } private : double t_rate; diff --git a/eo/src/obsolete/eoStringMutation.h b/eo/src/obsolete/eoStringMutation.h index ee8590de..1612da4a 100644 --- a/eo/src/obsolete/eoStringMutation.h +++ b/eo/src/obsolete/eoStringMutation.h @@ -51,7 +51,7 @@ class eoStringMutation: public eoMutation { /** Inherited from eoObject @see eoObject */ - string className() const {return "eoStringMutation";}; + std::string className() const {return "eoStringMutation";}; //@} diff --git a/eo/src/obsolete/eoTournament.h b/eo/src/obsolete/eoTournament.h index 6cc01390..01dc4619 100644 --- a/eo/src/obsolete/eoTournament.h +++ b/eo/src/obsolete/eoTournament.h @@ -73,7 +73,7 @@ public: unsigned thisSize = _vEO.size(); - // Build vector + // Build std::vector for ( unsigned j = 0; j < thisSize*perc; j ++ ) { // Randomly select a tournamentSize set, and choose the best eoPop veoTournament; @@ -84,10 +84,10 @@ public: veoTournament.push_back( newEO ); } - eoPop::const_iterator best = max_element(veoTournament.begin(), + eoPop::const_iterator best = std::max_element(veoTournament.begin(), veoTournament.end()); if (best == veoTournament.end()) { - throw runtime_error("error in void eoTournament::operator(eoPop&, eoPop&)"); + throw std::runtime_error("error in void eoTournament::operator(eoPop&, eoPop&)"); } // The best individual is chosen for the new population @@ -106,11 +106,11 @@ public: * Should call base class, just in case. - * @param _s A istream. + * @param _s A std::istream. */ - virtual void readFrom(istream& _s) { + virtual void readFrom(std::istream& _s) { _s >> perc >> repTournamentSize; @@ -124,11 +124,11 @@ public: base classes, so you don´t have to worry about, for instance, fitness. - @param _s the ostream in which things are written*/ + @param _s the std::ostream in which things are written*/ - virtual void printOn( ostream& _s ) const{ + virtual void printOn( std::ostream& _s ) const{ - _s << perc << endl << repTournamentSize << endl; + _s << perc << std::endl << repTournamentSize << std::endl; } @@ -140,7 +140,7 @@ public: */ - string className() const {return "eoTournament";}; + std::string className() const {return "eoTournament";}; diff --git a/eo/src/obsolete/eoTranspose.h b/eo/src/obsolete/eoTranspose.h index 7d2a8d74..51671830 100644 --- a/eo/src/obsolete/eoTranspose.h +++ b/eo/src/obsolete/eoTranspose.h @@ -41,7 +41,7 @@ class eoTranspose: public eoMonOp { public: - // Specialization for a vector + // Specialization for a std::vector void operator()(eoFixedLength& _eo ) { unsigned pos1 = rng.random(_eo.size()), @@ -54,7 +54,7 @@ public: _eo.invalidate(); } - // Specialization for a list + // Specialization for a std::list void operator()(eoVariableLength& _eo ) { unsigned pos1 = rng.random(_eo.size()), @@ -85,7 +85,7 @@ public: /** Inherited from eoObject @see eoObject */ - virtual string className() const {return "eoTranspose";}; + virtual std::string className() const {return "eoTranspose";}; //@} }; diff --git a/eo/src/obsolete/eoUniformXOver.h b/eo/src/obsolete/eoUniformXOver.h index 961efa8b..76623a0e 100644 --- a/eo/src/obsolete/eoUniformXOver.h +++ b/eo/src/obsolete/eoUniformXOver.h @@ -110,7 +110,7 @@ class eoUniformXOver: public eoQuadraticOp< EOT > if (rate < 0 || rate > 1) - runtime_error("UxOver --> invalid rate"); + std::runtime_error("UxOver --> invalid rate"); } @@ -152,7 +152,7 @@ class eoUniformXOver: public eoQuadraticOp< EOT > */ - string className() const {return "eoUniformXOver";}; + std::string className() const {return "eoUniformXOver";}; //@} diff --git a/eo/src/obsolete/eoVector.h b/eo/src/obsolete/eoVector.h index d9a24dc8..315683f5 100644 --- a/eo/src/obsolete/eoVector.h +++ b/eo/src/obsolete/eoVector.h @@ -2,7 +2,7 @@ ----------------------------------------------------------------------------- eoVector.h - Turns an STL vector into an EO + Turns an STL std::vector into an EO (c) GeNeura Team, 1998 This library is free software; you can redistribute it and/or @@ -28,19 +28,19 @@ #define _eoVector_H // STL libraries -#include // For vector +#include // For std::vector #include #include #include #include -/** Adaptor that turns an STL vector into an EO +/** Adaptor that turns an STL std::vector into an EO with the same gene type as the type with which - the vector has been instantiated + the std::vector has been instantiated */ template -class eoVector: public eo1d, public vector { +class eoVector: public eo1d, public std::vector { public: typedef T Type ; @@ -52,7 +52,7 @@ public: @param _val Common initial value */ eoVector( unsigned _size = 0, T _val = 0) - : eo1d(), vector( _size, _val ){ }; + : eo1d(), std::vector( _size, _val ){ }; /** Ctor using a random number generator @param _size Lineal length of the object @@ -60,22 +60,22 @@ public: */ eoVector( unsigned _size, eoRnd& _rnd ); - /** Ctor from a istream. The T class should accept reading from a istream. It doesn't read fitness, + /** Ctor from a std::istream. The T class should accept reading from a std::istream. It doesn't read fitness, which is supposed to be dynamic and dependent on environment. @param _is the input stream; should have all values in a single line, separated by whitespace */ - eoVector( istream& _is); + eoVector( std::istream& _is); /// copy ctor eoVector( const eoVector & _eo ) - : eo1d( _eo ), vector( _eo ){ }; + : eo1d( _eo ), std::vector( _eo ){ }; /// Assignment operator const eoVector& operator =( const eoVector & _eo ) { if ( this != &_eo ){ eo1d::operator=( _eo ); - vector::operator=( _eo ); + std::vector::operator=( _eo ); } return *this; } @@ -86,7 +86,7 @@ which is supposed to be dynamic and dependent on environment. //@} /** methods that implement the eo1d protocol - @exception out_of_range if _i is larger than EO´s size + @std::exception out_of_range if _i is larger than EO´s size */ virtual T getGene( unsigned _i ) const { if ( _i >= length() ) @@ -95,7 +95,7 @@ which is supposed to be dynamic and dependent on environment. }; /** methods that implement the eo1d protocol - @exception out_of_range if _i is larger than EO´s size + @std::exception out_of_range if _i is larger than EO´s size */ virtual void setGene( unsigned _i, const T& _value ) { if ( _i >= size() ) @@ -104,11 +104,11 @@ which is supposed to be dynamic and dependent on environment. }; /** methods that implement the eo1d protocol - @exception out_of_range if _i is larger than EO´s size + @std::exception out_of_range if _i is larger than EO´s size */ virtual void insertGene( unsigned _i, T _val ) { if (_i <= size() ) { - vector::iterator i = begin()+_i; + std::vector::iterator i = begin()+_i; insert( i, _val ); } else { throw out_of_range( "out_of_range when inserting a gene"); @@ -116,11 +116,11 @@ which is supposed to be dynamic and dependent on environment. }; /** Eliminates the gene at position _i - @exception out_of_range if _i is larger than EO´s size + @std::exception out_of_range if _i is larger than EO´s size */ virtual void deleteGene( unsigned _i ) { if (_i < this->size() ) { - vector::iterator i = this->begin()+_i; + std::vector::iterator i = this->begin()+_i; this->erase( i ); } else { throw out_of_range( "out_of_range when deleting a gene"); @@ -137,7 +137,7 @@ which is supposed to be dynamic and dependent on environment. /** Inherited from eoObject @see eoObject */ - string className() const {return "eoVector";}; + std::string className() const {return "eoVector";}; //@} }; @@ -149,7 +149,7 @@ which is supposed to be dynamic and dependent on environment. //____________________________________________________________________________________ template eoVector::eoVector( unsigned _size, eoRnd& _rnd ) - : eo1d(), vector( _size ){ + : eo1d(), std::vector( _size ){ for ( iterator i = begin(); i != end(); i ++ ) { *i = _rnd(); } @@ -157,8 +157,8 @@ eoVector::eoVector( unsigned _size, eoRnd& _rnd ) //____________________________________________________________________________________ template -eoVector::eoVector( istream& _is) - : eo1d(), vector( ){ +eoVector::eoVector( std::istream& _is) + : eo1d(), std::vector( ){ while (_is ) { T tmp; _is >> tmp; diff --git a/eo/src/obsolete/eoWrappedOps.h b/eo/src/obsolete/eoWrappedOps.h index cd7432ef..805bb29e 100644 --- a/eo/src/obsolete/eoWrappedOps.h +++ b/eo/src/obsolete/eoWrappedOps.h @@ -176,7 +176,7 @@ class eoCombinedOp : public eoGeneralOp counter++; if (counter > 1000) { - throw logic_error("eoCombinedOp: no termination after 1000 tries, did you forget to insert individuals in your eoGeneralOp?"); + throw std::logic_error("eoCombinedOp: no termination after 1000 tries, did you forget to insert individuals in your eoGeneralOp?"); } } while (next.size() < intermediate.size()); diff --git a/eo/src/obsolete/eoXOver2.h b/eo/src/obsolete/eoXOver2.h index ddb1682e..d1f53852 100644 --- a/eo/src/obsolete/eoXOver2.h +++ b/eo/src/obsolete/eoXOver2.h @@ -69,7 +69,7 @@ public: /** Inherited from eoObject @see eoObject */ - string className() const {return "eoXOver2";}; + std::string className() const {return "eoXOver2";}; //@} private: @@ -91,7 +91,7 @@ private: len= (len1 > len2)?len2:len1; if ( (_j > len) || (_i> len ) ) - throw runtime_error( "xOver2: applying xOver past boundaries"); + throw std::runtime_error( "xOver2: applying xOver past boundaries"); for ( unsigned i = _i; i < _j; i++ ) { Type tmp = _eo.gene( i ); diff --git a/eo/src/other/eoExternalEO.h b/eo/src/other/eoExternalEO.h index 37e1036a..80380670 100644 --- a/eo/src/other/eoExternalEO.h +++ b/eo/src/other/eoExternalEO.h @@ -46,12 +46,12 @@ public : Init externalEo with the struct itself and set fitness to zero */ eoExternalEO(const External& ext) : EO(), External(ext) {} - eoExternalEO(istream& is) : EO(), External(ext) { readFrom(is); } + eoExternalEO(std::istream& is) : EO(), External(ext) { readFrom(is); } /** * Read object, the external struct needs to have an operator>> defined */ - virtual void readFrom(istream& _is) + virtual void readFrom(std::istream& _is) { EO::readFrom(_is); _is >> static_cast(*this); @@ -59,9 +59,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 { EO::printOn(_os); _os << static_cast(*this); diff --git a/eo/src/other/eoString.h b/eo/src/other/eoString.h index 88e6d463..e37adba1 100644 --- a/eo/src/other/eoString.h +++ b/eo/src/other/eoString.h @@ -29,15 +29,13 @@ #include #include -using namespace std; - //----------------------------------------------------------------------------- // eoString //----------------------------------------------------------------------------- -/** Adaptor that turns an STL string into an EO */ +/** Adaptor that turns an STL std::string into an EO */ template -class eoString: public EO, public string +class eoString: public EO, public std::string { public: @@ -46,8 +44,8 @@ public: /// Canonical part of the objects: several ctors, copy ctor, dtor and assignment operator //@{ /// ctor - eoString( const string& _str ="" ) - : string( _str ) {}; + eoString( const std::string& _str ="" ) + : std::string( _str ) {}; /** @name Methods from eoObject readFrom and printOn are directly inherited from eo1d @@ -56,7 +54,7 @@ public: /** Inherited from eoObject @see eoObject */ - virtual string className() const {return "eoString";}; + virtual std::string className() const {return "eoString";}; //@} diff --git a/eo/src/paradisEO/comm/eoListener.h b/eo/src/paradisEO/comm/eoListener.h index 8be16927..6ac32f5b 100644 --- a/eo/src/paradisEO/comm/eoListener.h +++ b/eo/src/paradisEO/comm/eoListener.h @@ -38,7 +38,7 @@ // In the near future ... Enabling different kinds of EO to send/receive .. -template class eoListener : public vector > { +template class eoListener : public std::vector > { public : @@ -91,11 +91,11 @@ public : } /** - To broadcast the string identifier of the local process to the + To broadcast the std::string identifier of the local process to the whole neighbouring ... */ - void publish (string label) { + void publish (std::string label) { eoPublishMessTo mess (label) ; for (int i = 0 ; i < size () ; i ++) @@ -123,7 +123,7 @@ public : } while (! b) ; } - void destroy (string label) { + void destroy (std::string label) { eoKillMessTo mess ; for (int i = 0 ; i < len ; i ++) { diff --git a/eo/src/paradisEO/comm/eoLocalListener.h b/eo/src/paradisEO/comm/eoLocalListener.h index a0b342d8..b11e2176 100644 --- a/eo/src/paradisEO/comm/eoLocalListener.h +++ b/eo/src/paradisEO/comm/eoLocalListener.h @@ -50,7 +50,7 @@ template class eoEOSendMessFrom ; template class eoPublishMessFrom ; template class eoKillMessFrom ; -template class eoLocalListener : public queue > { +template class eoLocalListener : public std::queue > { public : @@ -125,7 +125,7 @@ public : String identifier of this algo/agent ? */ - string & label () { + std::string & label () { return name_id ; } @@ -142,18 +142,18 @@ public : void destroy () { - cout << "Agent [" << name_id << "] stopped ..." << endl ; + std::cout << "Agent [" << name_id << "] stopped ..." << std::endl ; MPI :: Finalize () ; exit (0) ; } - char host_name [255] ; // Host string identifier + char host_name [255] ; // Host std::string identifier private : MPI :: Comm * comm ; // MPI Communicator - string name_id ; // String id. + std::string name_id ; // String id. int num_id ; // MPI id. bool req_EO ; diff --git a/eo/src/paradisEO/comm/messages/eoMessTo.h b/eo/src/paradisEO/comm/messages/eoMessTo.h index 98efdef7..913f99a2 100644 --- a/eo/src/paradisEO/comm/messages/eoMessTo.h +++ b/eo/src/paradisEO/comm/messages/eoMessTo.h @@ -40,11 +40,11 @@ template class eoMessTo { public : /** - Constructor. A string identifier, being defined in subclasses + Constructor. A std::string identifier, being defined in subclasses is given for any kind of messages. */ - eoMessTo (string _label) : + eoMessTo (std::string _label) : label (_label), comm (MPI :: COMM_WORLD) { @@ -64,7 +64,7 @@ protected : MPI :: Comm & comm ; // MPI Communicator - string label ; // String identifier of the message + std::string label ; // String identifier of the message } ; diff --git a/eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h index 5f8a2e77..f4824d25 100644 --- a/eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h +++ b/eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h @@ -57,7 +57,7 @@ public : void operator () () { loc_listen.push (pop) ; - // cout << "Reception de " << pop.size () << "individus " << endl ; + // std::cout << "Reception de " << pop.size () << "individus " << std::endl ; } private : diff --git a/eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h index 6986f519..bd30c04a 100644 --- a/eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h +++ b/eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h @@ -34,7 +34,7 @@ template class eoLocalListener ; message to be then received ... */ -template class eoHeaderMessFrom : public string { +template class eoHeaderMessFrom : public std::string { public : diff --git a/eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h index 66c55454..4521fa7c 100644 --- a/eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h +++ b/eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h @@ -58,7 +58,7 @@ public : private : - string label ; // String identifier ... + std::string label ; // String identifier ... } ; diff --git a/eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h b/eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h index ad27fece..127214c7 100644 --- a/eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h +++ b/eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h @@ -54,7 +54,7 @@ public : eoMessTo :: operator () (loc_listen) ; - ostrstream f ; + std::ostrstream f ; pop.printOn (f) ; comm.Send (f.str (), f.pcount (), MPI :: CHAR, loc_listen.number (), 0) ; loc_listen.need_immigration () = false ; diff --git a/eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h b/eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h index 4126d901..a7f368e4 100644 --- a/eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h +++ b/eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h @@ -35,18 +35,18 @@ template class eoLocalListener ; message to be then sent ... */ -template class eoHeaderMessTo : public string { +template class eoHeaderMessTo : public std::string { public : /** Constructor. - The string identifiant id given in parameter. + The std::string identifiant id given in parameter. */ - eoHeaderMessTo (string label) : + eoHeaderMessTo (std::string label) : - string (label), + std::string (label), comm (MPI :: COMM_WORLD) { } diff --git a/eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h b/eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h index 81005295..0b7f8134 100644 --- a/eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h +++ b/eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h @@ -22,7 +22,7 @@ */ /** - To let know from distributed algos the string identifier + To let know from distributed algos the std::string identifier of the home process ... */ @@ -42,7 +42,7 @@ public : Constructor */ - eoPublishMessTo (string & _label + eoPublishMessTo (std::string & _label ) : eoMessTo ("eoPublishMessTo"), label (_label) { @@ -57,7 +57,7 @@ public : private : - string label ; // String identifier to send ... + std::string label ; // String identifier to send ... } ; diff --git a/eo/src/paradisEO/eoPopAgent.h b/eo/src/paradisEO/eoPopAgent.h index 3e81f824..093fca23 100644 --- a/eo/src/paradisEO/eoPopAgent.h +++ b/eo/src/paradisEO/eoPopAgent.h @@ -43,7 +43,7 @@ public : Constructor */ - eoPopAgent (string _label, + eoPopAgent (std::string _label, eoListener & _listen, eoPopAlgo & _algo ) : @@ -68,7 +68,7 @@ public : while (! listen [i].empty ()) { eoPop & pop = listen [i].front () ; - cout << "Agent [" << label << "] on " << listen.here ().host_name << " : Receiving " << pop.size () << " individuals ..." << endl ; + std::cout << "Agent [" << label << "] on " << listen.here ().host_name << " : Receiving " << pop.size () << " individuals ..." << std::endl ; algo (pop) ; eoEOSendMessTo mess (pop) ; mess (listen [i]) ; // Coming back ... @@ -80,7 +80,7 @@ public : private : - string label ; // string identifier + std::string label ; // std::string identifier eoListener & listen ; // EO's listener eoPopAlgo & algo ; // Local supplied algo diff --git a/eo/src/paradisEO/eoSolAgent.h b/eo/src/paradisEO/eoSolAgent.h index 722e8bef..96683bbd 100644 --- a/eo/src/paradisEO/eoSolAgent.h +++ b/eo/src/paradisEO/eoSolAgent.h @@ -43,7 +43,7 @@ public : Constructor */ - eoSolAgent (string _label, + eoSolAgent (std::string _label, eoListener & _listen, eoSolAlgo & _algo ) : @@ -68,7 +68,7 @@ public : while (! listen [i].empty ()) { EOT & sol = listen [i].front () ; - cout << "Agent [" << label << "] on " << listen.here ().host_name << " : Receiving one individual ..." << endl ; + std::cout << "Agent [" << label << "] on " << listen.here ().host_name << " : Receiving one individual ..." << std::endl ; algo (sol) ; eoPop pop ; pop.push_back (sol) ; @@ -82,7 +82,7 @@ public : private : - string label ; // string identifier + std::string label ; // std::string identifier eoListener & listen ; // EO's listener eoSolAlgo & algo ; // Local supplied algo diff --git a/eo/src/paradisEO/eval/eoDistEvalEasyEA.h b/eo/src/paradisEO/eval/eoDistEvalEasyEA.h index c4934298..49395fcc 100644 --- a/eo/src/paradisEO/eval/eoDistEvalEasyEA.h +++ b/eo/src/paradisEO/eval/eoDistEvalEasyEA.h @@ -44,7 +44,7 @@ public : eoDistEvalEasyEA (eoListener & _listen, eoEasyEA & _ea, - string _label + std::string _label ) : pop_eval (eoDistPopEvalFunc (_listen, _label, _ea.eval)), eoEasyEA (_ea.continuator, diff --git a/eo/src/paradisEO/eval/eoDistPopEvalFunc.h b/eo/src/paradisEO/eval/eoDistPopEvalFunc.h index 93d20cdd..00170c03 100644 --- a/eo/src/paradisEO/eval/eoDistPopEvalFunc.h +++ b/eo/src/paradisEO/eval/eoDistPopEvalFunc.h @@ -36,7 +36,7 @@ public : */ eoDistPopEvalFunc (eoListener & _listen, - string & _label, + std::string & _label, eoEvalFunc & _eval ) : listen (_listen), @@ -58,8 +58,8 @@ public : } if (num_eval == 0) { - cout << "No [" << label << "] available ..." << endl ; - cout << "Waiting for a few seconds ..." << endl ; + std::cout << "No [" << label << "] available ..." << std::endl ; + std::cout << "Waiting for a few seconds ..." << std::endl ; sleep (2) ; } } while (num_eval == 0) ; @@ -120,7 +120,7 @@ public : private : eoListener & listen ; - string label ; // String identifier of evaluators + std::string label ; // String identifier of evaluators eoEvalFunc & eval ; } ; diff --git a/eo/src/paradisEO/eval/eoEvaluator.h b/eo/src/paradisEO/eval/eoEvaluator.h index bc510e6d..eb2a98e6 100644 --- a/eo/src/paradisEO/eval/eoEvaluator.h +++ b/eo/src/paradisEO/eval/eoEvaluator.h @@ -44,7 +44,7 @@ public : Constructor */ - eoEvaluator (string _label, + eoEvaluator (std::string _label, eoListener & _listen, eoEvalFunc & _eval ) : diff --git a/eo/src/paradisEO/island/eoConnectivity.h b/eo/src/paradisEO/island/eoConnectivity.h index 8db27ab9..fdfdd83e 100644 --- a/eo/src/paradisEO/island/eoConnectivity.h +++ b/eo/src/paradisEO/island/eoConnectivity.h @@ -44,7 +44,7 @@ public : */ eoConnectivity (eoListener & _listen, - vector & _sel_neigh + std::vector & _sel_neigh ) : listen (_listen), sel_neigh (_sel_neigh) { @@ -56,22 +56,22 @@ public : immigrants from ... */ - virtual vector *> from () = 0 ; + virtual std::vector *> from () = 0 ; /** Computes the subset of neighbours to send emigrants to ... */ - virtual vector *> to () = 0 ; + virtual std::vector *> to () = 0 ; protected : eoListener & listen ; - vector sel_neigh ; + std::vector sel_neigh ; - bool selected (string & id) { + bool selected (std::string & id) { for (int i = 0 ; i < sel_neigh.size () ; i ++) if (sel_neigh [i] == id) diff --git a/eo/src/paradisEO/island/eoIslandsEasyEA.h b/eo/src/paradisEO/island/eoIslandsEasyEA.h index f0b643b6..df747151 100644 --- a/eo/src/paradisEO/island/eoIslandsEasyEA.h +++ b/eo/src/paradisEO/island/eoIslandsEasyEA.h @@ -50,7 +50,7 @@ public : Constructor */ - eoIslandsEasyEA (string _id, + eoIslandsEasyEA (std::string _id, eoListener & _listen, eoConnectivity & _conn, eoEasyEA & _ea, @@ -87,7 +87,7 @@ private : // Internal components - string id ; // String identifiant of this algorithm + std::string id ; // String identifiant of this algorithm eoListener & listen ; // The neighbouring of concurrent algos eoConnectivity & conn ; // Communication topology eoCheckPoint chkp ; diff --git a/eo/src/paradisEO/island/eoMigUpdater.h b/eo/src/paradisEO/island/eoMigUpdater.h index d15cdb92..bfdbf3db 100644 --- a/eo/src/paradisEO/island/eoMigUpdater.h +++ b/eo/src/paradisEO/island/eoMigUpdater.h @@ -85,14 +85,14 @@ public : listen.update () ; // listen.display () ; - vector *> src = conn.from (), dest = conn.to () ; + std::vector *> src = conn.from (), dest = conn.to () ; // Any coming immigrants ? for (int i = 0 ; i < src.size () ; i ++) { src [i] -> update () ; while (! src [i] -> empty ()) { replace (* pop, src [i] -> front ()) ; - cout << "[" << listen.here ().host_name << "] Arrival of " << src [i] -> front ().size () << " individuals ..." << endl ; + std::cout << "[" << listen.here ().host_name << "] Arrival of " << src [i] -> front ().size () << " individuals ..." << std::endl ; src [i] -> pop () ; } } diff --git a/eo/src/paradisEO/island/topologies/eoFullConnectivity.h b/eo/src/paradisEO/island/topologies/eoFullConnectivity.h index 7c8b2116..9ee3d78d 100644 --- a/eo/src/paradisEO/island/topologies/eoFullConnectivity.h +++ b/eo/src/paradisEO/island/topologies/eoFullConnectivity.h @@ -39,15 +39,15 @@ public : */ eoFullConnectivity (eoListener & _listen, - vector & _sel_neigh + std::vector & _sel_neigh ) : eoConnectivity (_listen, _sel_neigh) { } - virtual vector *> from () { + virtual std::vector *> from () { listen.update () ; - vector *> v ; + std::vector *> v ; for (int i = 0 ; i < listen.size () ; i ++) if (i != listen.here ().number () && selected (listen [i].label ())) @@ -56,11 +56,11 @@ public : return v ; } - virtual vector *> to () { + virtual std::vector *> to () { listen.update () ; - vector *> v ; + std::vector *> v ; for (int i = 0 ; i < listen.size () ; i ++) if (i != listen.here ().number () && selected (listen [i].label ())) diff --git a/eo/src/paradisEO/island/topologies/eoRingConnectivity.h b/eo/src/paradisEO/island/topologies/eoRingConnectivity.h index 7de042ac..b2f654ec 100644 --- a/eo/src/paradisEO/island/topologies/eoRingConnectivity.h +++ b/eo/src/paradisEO/island/topologies/eoRingConnectivity.h @@ -27,7 +27,7 @@ #include /** - Each algorithm has a single pair of entering and outgoing + Each algorithm has a single std::pair of entering and outgoing neighbours, so that the unit constitutes a circular topology. */ @@ -40,15 +40,15 @@ public : */ eoRingConnectivity (eoListener & _listen, - vector & _sel_neigh + std::vector & _sel_neigh ) : eoConnectivity (_listen, _sel_neigh) { } - virtual vector *> from () { + virtual std::vector *> from () { listen.update () ; - vector *> v ; + std::vector *> v ; int i, k = listen.size () ; for (i = 0 ; i < k ; i ++) { @@ -69,11 +69,11 @@ public : */ - virtual vector *> to () { + virtual std::vector *> to () { listen.update () ; - vector *> v ; + std::vector *> v ; int i, k = listen.size () ; for (i = 0 ; i < k ; i ++) diff --git a/eo/src/pyeo/PyEO.h b/eo/src/pyeo/PyEO.h index 086d830c..8ab69ede 100644 --- a/eo/src/pyeo/PyEO.h +++ b/eo/src/pyeo/PyEO.h @@ -66,7 +66,7 @@ class PyFitness : public boost::python::object extract x(object::operator[](i)); if (!x.check()) - throw runtime_error("PyFitness: does not contain doubles"); + throw std::runtime_error("PyFitness: does not contain doubles"); return x(); } @@ -101,9 +101,9 @@ class PyFitness : public boost::python::object return other.operator<(*this); } - //void printOn(ostream& os) const { const object& o = *this; os << o; } - //friend ostream& operator<<(ostream& os, const PyFitness& p) { p.printOn(os); return os; } - //friend istream& operator>>(istream& is, PyFitness& p) { object o; is >> o; p = o; return is; } + //void printOn(std::ostream& os) const { const object& o = *this; os << o; } + //friend std::ostream& operator<<(std::ostream& os, const PyFitness& p) { p.printOn(os); return os; } + //friend std::istream& operator>>(std::istream& is, PyFitness& p) { object o; is >> o; p = o; return is; } }; struct PyEO : public EO< PyFitness > @@ -117,7 +117,7 @@ struct PyEO : public EO< PyFitness > void setGenome(object g) { genome = g; } object genome; - std::string to_string() const + std::string to_std::string() const { std::string result; result += extract(str(getFitness())); @@ -131,7 +131,7 @@ struct PyEO : public EO< PyFitness > }; -ostream& operator<<(ostream& os, const PyEO& _eo); +std::ostream& operator<<(std::ostream& os, const PyEO& _eo); struct PyEO_pickle_suite : boost::python::pickle_suite { diff --git a/eo/src/pyeo/pickle.h b/eo/src/pyeo/pickle.h index b5930626..d6e20d13 100644 --- a/eo/src/pyeo/pickle.h +++ b/eo/src/pyeo/pickle.h @@ -30,18 +30,18 @@ template struct T_pickle_suite : boost::python::pickle_suite { static - std::string print_to_string(const T& t) + std::string print_to_std::string(const T& t) { std::ostrstream os; t.printOn(os); - os << ends; + os << std::ends; return os.str(); } static boost::python::tuple getstate(const T& t) { - std::string s = print_to_string(t); + std::string s = print_to_std::string(t); return boost::python::make_tuple( boost::python::str(s)); } @@ -54,14 +54,14 @@ struct T_pickle_suite : boost::python::pickle_suite } }; -/** Defines persistency through pickle support by using strings +/** Defines persistency through pickle support by using std::strings * so while we're at it, we will .def("__str__") as well */ template boost::python::class_& pickle(boost::python::class_& c) { return c.def_pickle(T_pickle_suite()) - .def("__str__", T_pickle_suite::print_to_string); + .def("__str__", T_pickle_suite::print_to_std::string); } #endif diff --git a/eo/src/utils/compatibility.h b/eo/src/utils/compatibility.h index 0bab1f08..29481b8f 100644 --- a/eo/src/utils/compatibility.h +++ b/eo/src/utils/compatibility.h @@ -52,7 +52,7 @@ Olivier: this has been removed in .NET :) One step more standard... #ifdef min #undef min -#undef max // as they come in pairs +#undef max // as they come in std::pairs #endif // add min and max to std... diff --git a/eo/src/utils/eoCheckPoint.h b/eo/src/utils/eoCheckPoint.h index 729a0c74..544595e1 100644 --- a/eo/src/utils/eoCheckPoint.h +++ b/eo/src/utils/eoCheckPoint.h @@ -33,7 +33,7 @@ #include /** eoCheckPoint is a container class. - It contains vectors of (pointers to) + It contains std::vectors of (pointers to) eoContinue (modif. MS July 16. 2002) eoStats, eoUpdater and eoMonitor it is an eoContinue, so its operator() will be called every generation - @@ -76,7 +76,7 @@ bool eoCheckPoint::operator()(const eoPop& _pop) { unsigned i; - vector sorted_pop; + std::vector sorted_pop; if (!sorted.empty()) { _pop.sort(sorted_pop); diff --git a/eo/src/utils/eoData.h b/eo/src/utils/eoData.h index 877b4720..6fd9a8b5 100644 --- a/eo/src/utils/eoData.h +++ b/eo/src/utils/eoData.h @@ -27,11 +27,9 @@ //----------------------------------------------------------------------------- -#include // vector +#include // std::vector #include // set -#include // string - -using namespace std; +#include // std::string #ifdef _MSC_VER diff --git a/eo/src/utils/eoDistance.h b/eo/src/utils/eoDistance.h index ddc3d2f3..2ffb8ccc 100644 --- a/eo/src/utils/eoDistance.h +++ b/eo/src/utils/eoDistance.h @@ -38,7 +38,7 @@ class eoDistance : public eoBF /** This is a generic class for Euclidain distance computation: - assumes the 2 things are vectors of something that is double-castable + assumes the 2 things are std::vectors of something that is double-castable */ template< class EOT > diff --git a/eo/src/utils/eoFDCStat.h b/eo/src/utils/eoFDCStat.h index 134a64f0..55aca737 100644 --- a/eo/src/utils/eoFDCStat.h +++ b/eo/src/utils/eoFDCStat.h @@ -84,11 +84,11 @@ public : value() = num/(sqrt(sumDist)*sqrt(sumFit)); } - /** accessors to the private eoValueParam > + /** accessors to the private eoValueParam > */ - const eoValueParam > & theDist() + const eoValueParam > & theDist() { return distToBest; } - const eoValueParam > & theFit() + const eoValueParam > & theFit() { return fitnesses; } @@ -96,13 +96,13 @@ private: eoDistance & dist; EOT theBest; bool boolOpt; // whether the best is known or not - eoValueParam > distToBest; - eoValueParam > fitnesses; + eoValueParam > distToBest; + eoValueParam > fitnesses; }; /** Specific class for FDCStat monitoring: * As I failed to have FDC stat as an eoStat, this is the trick - * to put the 2 eoParam > into a monitor + * to put the 2 eoParam > into a monitor * This class does nothing else. */ template @@ -110,7 +110,7 @@ class eoFDCFileSnapshot : public eoFileSnapshot // is an eoMonitor { public: /** Ctor: in addition to the parameters of the ctor of an eoFileSnapshot - we need here an eoFDCStat. The 2 vectors (distances to optimum + we need here an eoFDCStat. The 2 std::vectors (distances to optimum and fitnesses) are added to the monitor so they can be processed later to a file - and eventually by gnuplot */ @@ -127,7 +127,7 @@ public: /** just to be sure the add method is not called further */ virtual void add(const eoParam& _param) - { throw runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); } + { throw std::runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); } private: eoFDCStat & FDCstat; diff --git a/eo/src/utils/eoFileMonitor.h b/eo/src/utils/eoFileMonitor.h index 13479b68..543bd593 100644 --- a/eo/src/utils/eoFileMonitor.h +++ b/eo/src/utils/eoFileMonitor.h @@ -21,7 +21,7 @@ Contact: todos@geneura.ugr.es, http://geneura.ugr.es Marc.Schoenauer@polytechnique.fr mkeijzer@dhi.dk -CVS Info: $Date: 2002-12-09 21:04:47 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoFileMonitor.h,v 1.10 2002-12-09 21:04:47 evomarc Exp $ $Author: evomarc $ +CVS Info: $Date: 2003-02-27 19:21:19 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoFileMonitor.h,v 1.11 2003-02-27 19:21:19 okoenig Exp $ $Author: okoenig $ */ //----------------------------------------------------------------------------- @@ -51,11 +51,11 @@ public : { if (! _keep) { - ofstream os(filename.c_str()); + std::ofstream os(filename.c_str()); if (!os) { - string str = "eoFileMonitor: Could not open " + filename; - throw runtime_error(str); + std::string str = "eoFileMonitor: Could not open " + filename; + throw std::runtime_error(str); } } } @@ -65,7 +65,7 @@ public : void printHeader(void); virtual void printHeader(std::ostream& os); - virtual string getFileName() // for eoGnuPlot + virtual std::string getFileName() // for eoGnuPlot { return filename;} private : std::string filename; diff --git a/eo/src/utils/eoFileSnapshot.h b/eo/src/utils/eoFileSnapshot.h index a43f1d65..354d2c2a 100644 --- a/eo/src/utils/eoFileSnapshot.h +++ b/eo/src/utils/eoFileSnapshot.h @@ -38,7 +38,7 @@ Prints snapshots of fitnesses to a (new) file every N generations Assumes that the parameters that are passed to the monitor -(method add in eoMonitor.h) are eoValueParam > of same size. +(method add in eoMonitor.h) are eoValueParam > of same size. A dir is created and one file per snapshot is created there - so you can later generate a movie! @@ -46,34 +46,34 @@ so you can later generate a movie! TODO: The counter is handled internally, but this should be changed so that you can pass e.g. an evalcounter (minor) -I failed to templatize everything so that it can handle eoParam > +I failed to templatize everything so that it can handle eoParam > for any type T, simply calling their getValue method ... */ class eoFileSnapshot : public eoMonitor { public : - typedef vector vDouble; - typedef eoValueParam > vDoubleParam; + typedef std::vector vDouble; + typedef eoValueParam > vDoubleParam; eoFileSnapshot(std::string _dirname, unsigned _frequency = 1, std::string _filename = "gen", std::string _delim = " "): dirname(_dirname), frequency(_frequency), filename(_filename), delim(_delim), counter(0), boolChanged(true) { - string s = "test -d " + dirname; + std::string s = "test -d " + dirname; int res = system(s.c_str()); // test for (unlikely) errors if ( (res==-1) || (res==127) ) - throw runtime_error("Problem executing test of dir in eoFileSnapshot"); + throw std::runtime_error("Problem executing test of dir in eoFileSnapshot"); // now make sure there is a dir without any genXXX file in it if (res) // no dir present { - s = string("mkdir ")+dirname; + s = std::string("mkdir ")+dirname; } else { - s = string("/bin/rm ")+dirname+ "/" + filename + "*"; + s = std::string("/bin/rm ")+dirname+ "/" + filename + "*"; } system(s.c_str()); // all done @@ -89,20 +89,20 @@ public : /** accessor to the current filename: needed by the gnuplot subclass */ - string getFileName() {return currentFileName;} + std::string getFileName() {return currentFileName;} /** sets the current filename depending on the counter */ void setCurrentFileName() { char buff[255]; - ostrstream oscount(buff, 254); + std::ostrstream oscount(buff, 254); oscount << counter; oscount << std::ends; currentFileName = dirname + "/" + filename + oscount.str(); } - /** The operator(void): opens the ostream and calls the write method + /** The operator(void): opens the std::ostream and calls the write method */ eoMonitor& operator()(void) { @@ -115,40 +115,40 @@ public : counter++; boolChanged = true; setCurrentFileName(); - ofstream os(currentFileName.c_str()); + std::ofstream os(currentFileName.c_str()); if (!os) { - string str = "eoFileSnapshot: Could not open " + currentFileName; - throw runtime_error(str); + std::string str = "eoFileSnapshot: Could not open " + currentFileName; + throw std::runtime_error(str); } return operator()(os); } - /** The operator(): write on an ostream + /** The operator(): write on an std::ostream */ eoMonitor& operator()(std::ostream& _os) { - const eoValueParam > * ptParam = - static_cast >* >(vec[0]); + const eoValueParam > * ptParam = + static_cast >* >(vec[0]); - const vector v = ptParam->value(); - if (vec.size() == 1) // only one vector: -> add number in front + const std::vector v = ptParam->value(); + if (vec.size() == 1) // only one std::vector: -> add number in front { for (unsigned k=0; k > vv(vec.size()); + std::vector > vv(vec.size()); vv[0]=v; for (unsigned i=1; i >* >(vec[1]); + ptParam = static_cast >* >(vec[1]); vv[i] = ptParam->value(); if (vv[i].size() != v.size()) - throw runtime_error("Dimension error in eoSnapshotMonitor"); + throw std::runtime_error("Dimension error in eoSnapshotMonitor"); } for (unsigned k=0; k >*>(&_param)) + if (!dynamic_cast >*>(&_param)) { - throw logic_error(string("eoFileSnapshot: I can only monitor vectors of doubles, sorry. The offending parameter name = ") + _param.longName()); + throw std::logic_error(std::string("eoFileSnapshot: I can only monitor std::vectors of doubles, sorry. The offending parameter name = ") + _param.longName()); } eoMonitor::add(_param); } diff --git a/eo/src/utils/eoGnuplot.h b/eo/src/utils/eoGnuplot.h index f53b6b5b..0d61e40c 100644 --- a/eo/src/utils/eoGnuplot.h +++ b/eo/src/utils/eoGnuplot.h @@ -47,7 +47,7 @@ class eoGnuplot { public: // Ctor - eoGnuplot(std::string _title, std::string _extra = string("")) : + eoGnuplot(std::string _title, std::string _extra = std::string("")) : firstTime(true) { // opens pipe with Gnuplot @@ -65,7 +65,7 @@ class eoGnuplot } /// Class name. - virtual string className() const { return "eoGnuplot"; } + virtual std::string className() const { return "eoGnuplot"; } /** send a command to gnuplot directly */ @@ -105,8 +105,8 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) ///////////////////////////////////////////////////////// { char snum[255]; - ostrstream os(snum, 254); - os << "300x200-0+" << numWindow*220 << ends; + std::ostrstream os(snum, 254); + os << "300x200-0+" << numWindow*220 << std::ends; numWindow++; char *args[6]; args[0] = strdup( "gnuplot" ); @@ -117,7 +117,7 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) args[5] = 0; gpCom = PipeComOpenArgv( "gnuplot", args ); if( ! gpCom ) - throw runtime_error("Impossible to spawn gnuplot\n"); + throw std::runtime_error("Impossible to spawn gnuplot\n"); else { PipeComSend( gpCom, "set grid\n" ); PipeComSend( gpCom, _extra.c_str() ); @@ -139,7 +139,7 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) * Created......: Mon Mar 13 13:50:11 1995 * Description..: Communication par pipe bidirectionnel avec un autre process * - * Ident........: $Id: eoGnuplot.h,v 1.5 2002-08-23 15:40:59 evomarc Exp $ + * Ident........: $Id: eoGnuplot.h,v 1.6 2003-02-27 19:21:18 okoenig Exp $ * ---------------------------------------------------------------------- */ diff --git a/eo/src/utils/eoGnuplot1DMonitor.h b/eo/src/utils/eoGnuplot1DMonitor.h index 2f5e3bfc..00799f6e 100644 --- a/eo/src/utils/eoGnuplot1DMonitor.h +++ b/eo/src/utils/eoGnuplot1DMonitor.h @@ -67,7 +67,7 @@ class eoGnuplot1DMonitor: public eoFileMonitor, public eoGnuplot virtual void FirstPlot(); /// Class name. - virtual string className() const { return "eoGnuplot1DMonitor"; } + virtual std::string className() const { return "eoGnuplot1DMonitor"; } private: }; @@ -103,10 +103,10 @@ inline void eoGnuplot1DMonitor::FirstPlot() { if (vec.size() < 2) { - throw runtime_error("Must have some stats to plot!\n"); + throw std::runtime_error("Must have some stats to plot!\n"); } char buff[1024]; - ostrstream os(buff, 1024); + std::ostrstream os(buff, 1024); os << "plot"; for (unsigned i=1; i> value; readFrom(value); return; @@ -165,7 +165,7 @@ public: // minimal check if ( rate < 0.0 ) - throw runtime_error("Negative rate read in eoHowMany::readFrom"); + throw std::runtime_error("Negative rate read in eoHowMany::readFrom"); } /** The unary - operator: reverses the computation */ diff --git a/eo/src/utils/eoMOFitnessStat.h b/eo/src/utils/eoMOFitnessStat.h index 27b2d704..dd77740f 100644 --- a/eo/src/utils/eoMOFitnessStat.h +++ b/eo/src/utils/eoMOFitnessStat.h @@ -33,13 +33,13 @@ The fitnesses of a whole population, as a vector */ template -class eoFitnessStat : public eoSortedStat > +class eoFitnessStat : public eoSortedStat > { public : eoFitnessStat(std::string _description = "AllFitnesses") : - eoSortedStat >(vector(0), _description) {} + eoSortedStat >(std::vector(0), _description) {} - virtual void operator()(const vector& _popPters) + virtual void operator()(const std::vector& _popPters) { value().resize(_popPters.size()); for (unsigned i=0; i<_popPters.size(); i++) @@ -51,17 +51,25 @@ public : /** For multi-objective fitness, we need to translate a stat > into a vector, so each objective gets a seperate stat */ +#ifdef _MSC_VER +// The follownig is needed to avoid some bug in Visual Studio 6.0 +typedef double PartFitDefault; +template +class eoMOFitnessStat : public eoSortedStat > +#else template -class eoMOFitnessStat : public eoSortedStat > +class eoMOFitnessStat : public eoSortedStat > +#endif + { public : /** Ctor: say what component you want */ eoMOFitnessStat(unsigned _objective, std::string _description = "MO-Fitness") : - eoSortedStat >(vector(0), _description), + eoSortedStat >(std::vector(0), _description), objective(_objective) {} - virtual void operator()(const vector& _popPters) + virtual void operator()(const std::vector& _popPters) { value().resize(_popPters.size()); diff --git a/eo/src/utils/eoMonitor.h b/eo/src/utils/eoMonitor.h index d71a2a0f..9ac2d7a6 100644 --- a/eo/src/utils/eoMonitor.h +++ b/eo/src/utils/eoMonitor.h @@ -21,7 +21,7 @@ Contact: todos@geneura.ugr.es, http://geneura.ugr.es Marc.Schoenauer@polytechnique.fr mak@dhi.dk -CVS Info: $Date: 2001-04-03 10:08:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoMonitor.h,v 1.9 2001-04-03 10:08:07 jmerelo Exp $ $Author: jmerelo $ +CVS Info: $Date: 2003-02-27 19:21:18 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoMonitor.h,v 1.10 2003-02-27 19:21:18 okoenig Exp $ $Author: okoenig $ */ //----------------------------------------------------------------------------- @@ -37,7 +37,7 @@ CVS Info: $Date: 2001-04-03 10:08:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs class eoParam; /** - The abstract monitor class is a vector of parameter pointers. Use + The abstract monitor class is a std::vector of parameter pointers. Use either push_back a pointer or add a reference to a parameter. Derived classes will then implement the operator()(void) which will stream or pipe the current values of the parameters to wherever you diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index c69b2ff4..1a0354a4 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -103,7 +103,7 @@ public: void defValue ( std::string str ) { repDefault = str; }; /** - * Returns the value of the param as a string + * Returns the value of the param as a std::string */ /** * Returns if required or not. @@ -123,8 +123,8 @@ private: any scalar value type. It makes use of std::strstream to get and set values. This should be changed to std::stringstream when that class is available in g++. - Note also that there is a template specialization for pair and - for vector. These stream their contents delimited with whitespace. + Note also that there is a template specialization for std::pair and + for std::vector. These stream their contents delimited with whitespace. */ template @@ -174,7 +174,7 @@ public : }; /* - Specialization for string + Specialization for std::string */ template <> std::string eoValueParam::getValue(void) const @@ -197,7 +197,7 @@ void eoValueParam::setValue(std::string _value) } -/// Because MSVC does not support partial specialization, the pair is a double, not a T +/// Because MSVC does not support partial specialization, the std::pair is a double, not a T template <> std::string eoValueParam >::getValue(void) const { @@ -208,7 +208,7 @@ std::string eoValueParam >::getValue(void) const return os.str(); } -/// Because MSVC does not support partial specialization, the pair is a double, not a T +/// Because MSVC does not support partial specialization, the std::pair is a double, not a T template <> void eoValueParam >::setValue(std::string _value) { @@ -217,9 +217,9 @@ void eoValueParam >::setValue(std::string _value) is >> repValue.second; } -// The vector > +// The std::vector > ////////////////////////////////// -/// Because MSVC does not support partial specialization, the vector is a vector of doubles, not a T +/// Because MSVC does not support partial specialization, the std::vector is a std::vector of doubles, not a T template <> std::string eoValueParam > >::getValue(void) const { @@ -235,7 +235,7 @@ std::string eoValueParam > >::getValue(void) con return os.str(); } -/// Because MSVC does not support partial specialization, the vector is a vector of doubles, not a T +/// Because MSVC does not support partial specialization, the std::vector is a std::vector of doubles, not a T template <> void eoValueParam > >::setValue(std::string _value) { @@ -256,9 +256,9 @@ void eoValueParam > >::setValue(std::string _val } } -// The vector +// The std::vector ////////////////////////////////// -/// Because MSVC does not support partial specialization, the vector is a double, not a T +/// Because MSVC does not support partial specialization, the std::vector is a double, not a T template <> std::string eoValueParam >::getValue(void) const { @@ -269,7 +269,7 @@ std::string eoValueParam >::getValue(void) const return os.str(); } -/// Because MSVC does not support partial specialization, the vector is a double, not a T +/// Because MSVC does not support partial specialization, the std::vector is a double, not a T template <> void eoValueParam >::setValue(std::string _value) { @@ -280,9 +280,9 @@ void eoValueParam >::setValue(std::string _value) std::copy(std::istream_iterator(is), std::istream_iterator(), repValue.begin()); } -// The vector +// The std::vector ////////////////////////////////// -/// Because MSVC does not support partial specialization, the vector is a eoMinimizingFitness, not a T +/// Because MSVC does not support partial specialization, the std::vector is a eoMinimizingFitness, not a T template <> std::string eoValueParam >::getValue(void) const { @@ -293,7 +293,7 @@ std::string eoValueParam >::getValue(void) cons return os.str(); } -/// Because MSVC does not support partial specialization, the vector is a eoMinimizingFitness, not a T +/// Because MSVC does not support partial specialization, the std::vector is a eoMinimizingFitness, not a T // NOTE: g++ doesn support it either!!! template <> void eoValueParam >::setValue(std::string _value) @@ -305,19 +305,19 @@ void eoValueParam >::setValue(std::string _valu std::copy(std::istream_iterator(is), std::istream_iterator(), repValue.begin()); } -// The vector +// The std::vector ////////////////////////////////// template <> std::string eoValueParam >::getValue(void) const { - throw std::runtime_error("I cannot getValue for a vector"); + throw std::runtime_error("I cannot getValue for a std::vector"); return std::string(""); } template <> void eoValueParam >::setValue(std::string) { - throw std::runtime_error("I cannot setValue for a vector"); + throw std::runtime_error("I cannot setValue for a std::vector"); return; } @@ -325,19 +325,19 @@ void eoValueParam >::setValue(std::string) class eoContainerParam : public eoParam { public : - eoContainerParam (ContainerType& value, string _shortName, string _longName, - string _default, - string _description, + eoContainerParam (ContainerType& value, std::string _shortName, std::string _longName, + std::string _default, + std::string _description, bool _required, bool _change ) : value(_value), eoParam(_shortName, _longName, _description, _default, _required, _change) {} - // void setValue(const string & _value) + // void setValue(const std::string & _value) // { - // std::istringstream is(_value); - // copy(istream_iterator(is), istream_iterator(), back_inserter(value)); + // std::istd::stringstream is(_value); + // copy(std::istream_iterator(is), std::istream_iterator(), back_inserter(value)); // } private : @@ -348,9 +348,9 @@ private : * Another helper class for parsing parameters like * Keyword(arg1, arg2, ...) * - * It is basically a pair > - * first string is keyword - * the vector contains all arguments (as strings) + * It is basically a std::pair > + * first std::string is keyword + * the std::vector contains all arguments (as std::strings) * See make_algo.h */ @@ -403,7 +403,7 @@ public: // so here we do have arguments std::string t = _value.substr(pos+1);// the arguments _value.resize(pos); - first = _value; // done for the keyword (NOTE: may be empty string!) + first = _value; // done for the keyword (NOTE: may be empty std::string!) // now all arguments std::string delim(" (),"); diff --git a/eo/src/utils/eoParser.h b/eo/src/utils/eoParser.h index 08fec402..5c1f07a3 100644 --- a/eo/src/utils/eoParser.h +++ b/eo/src/utils/eoParser.h @@ -24,7 +24,7 @@ */ //----------------------------------------------------------------------------- /** -CVS Info: $Date: 2002-09-18 15:36:41 $ $Version$ $Author: evomarc $ +CVS Info: $Date: 2003-02-27 19:21:17 $ $Version$ $Author: okoenig $ */ #ifndef eoParser_h #define eoParser_h @@ -118,17 +118,17 @@ public: * @param _lFileParamName Name of the parameter specifying the configuration file (--param-file) * @param _shortHand Single charachter shorthand for specifying the configuration file */ - eoParser ( unsigned _argc, char **_argv , string _programDescription = "", - string _lFileParamName = "param-file", char _shortHand = 'p'); + eoParser ( unsigned _argc, char **_argv , std::string _programDescription = "", + std::string _lFileParamName = "param-file", char _shortHand = 'p'); /** Processes the parameter and puts it in the appropriate section for readability */ void processParam(eoParam& param, std::string section = ""); - void readFrom(istream& is); + void readFrom(std::istream& is); - void printOn(ostream& os) const; + void printOn(std::ostream& os) const; /// className for readibility std::string className(void) const { return "Parser"; } @@ -139,9 +139,9 @@ public: * Prints an automatic help in the specified output using the information * provided by parameters */ - void printHelp(ostream& os); + void printHelp(std::ostream& os); - string ProgramName() { return programName; } + std::string ProgramName() { return programName; } /** * checks if _param has been actually entered by the user @@ -194,7 +194,7 @@ private: void doRegisterParam(eoParam& param) const; - std::pair getValue(eoParam& _param) const; + std::pair getValue(eoParam& _param) const; void updateParameters() const; @@ -203,13 +203,13 @@ private: // used to store all parameters that are processed MultiMapType params; - string programName; - string programDescription; + std::string programName; + std::string programDescription; - typedef map ShortNameMapType; + typedef std::map ShortNameMapType; ShortNameMapType shortNameMap; - typedef map LongNameMapType; + typedef std::map LongNameMapType; LongNameMapType longNameMap; eoValueParam needHelp; diff --git a/eo/src/utils/eoPopStat.h b/eo/src/utils/eoPopStat.h index abe51459..80ecb6fd 100644 --- a/eo/src/utils/eoPopStat.h +++ b/eo/src/utils/eoPopStat.h @@ -28,7 +28,7 @@ eoPopString and eoSortedPopString -that transform the population into a string +that transform the population into a std::string that can be used to dump to the screen */ @@ -38,9 +38,9 @@ that can be used to dump to the screen #include -/** Thanks to MS/VC++, eoParam mechanism is unable to handle vectors of stats. +/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats. This snippet is a workaround: -This class will "print" a whole population into a string - that you can later +This class will "print" a whole population into a std::string - that you can later send to any stream This is the plain version - see eoPopString for the Sorted version @@ -48,15 +48,15 @@ Note: this Stat should probably be used only within eoStdOutMonitor, and not inside an eoFileMonitor, as the eoState construct will work much better there. */ template -class eoPopStat : public eoStat +class eoPopStat : public eoStat { public : - /** default Ctor, void string by default, as it appears + /** default Ctor, void std::string by default, as it appears on the description line once at beginning of evolution. and is meaningless there. _howMany defaults to 0, that is, the whole population*/ - eoPopStat(unsigned _howMany = 0, string _desc ="") - : eoStat("", _desc), combien( _howMany) {} + eoPopStat(unsigned _howMany = 0, std::string _desc ="") + : eoStat("", _desc), combien( _howMany) {} /** Fills the value() of the eoParam with the dump of the population. Adds a \n before so it does not get mixed up with the rest of the stats @@ -70,7 +70,7 @@ void operator()(const eoPop& _pop) for (unsigned i = 0; i < howMany; ++i) { std::ostrstream os(buffer, 1022); // leave space for emergency terminate - os << _pop[i] << endl << ends; + os << _pop[i] << std::endl << std::ends; // paranoid: buffer[1022] = '\0'; @@ -81,9 +81,9 @@ private: unsigned combien; }; -/** Thanks to MS/VC++, eoParam mechanism is unable to handle vectors of stats. +/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats. This snippet is a workaround: -This class will "print" a whole population into a string - that you can later +This class will "print" a whole population into a std::string - that you can later send to any stream This is the Sorted version - see eoPopString for the plain version @@ -91,22 +91,22 @@ Note: this Stat should probably be used only within eoStdOutMonitor, and not inside an eoFileMonitor, as the eoState construct will work much better there. */ template -class eoSortedPopStat : public eoSortedStat +class eoSortedPopStat : public eoSortedStat { public : - /** default Ctor, void string by default, as it appears + /** default Ctor, void std::string by default, as it appears * on the description line once at beginning of evolution. and * is meaningless there _howMany defaults to 0, that is, the whole * population */ - eoSortedPopStat(unsigned _howMany = 0, string _desc ="") : - eoSortedStat("", _desc) , combien( _howMany) {} + eoSortedPopStat(unsigned _howMany = 0, std::string _desc ="") : + eoSortedStat("", _desc) , combien( _howMany) {} /** Fills the value() of the eoParam with the dump of the population. Adds a \n before so it does not get mixed up with the rest of the stats that are written by the monitor it is probably used from. */ - void operator()(const vector& _pop) + void operator()(const std::vector& _pop) { char buffer[1023]; // about one K of space per member value() = ""; // empty @@ -114,7 +114,7 @@ public : for (unsigned i = 0; i < howMany; ++i) { std::ostrstream os(buffer, 1022); // leave space for emergency terminate - os << *_pop[i] << endl << ends; + os << *_pop[i] << std::endl << std::ends; // paranoid: buffer[1022] = '\0'; diff --git a/eo/src/utils/eoRNG.h b/eo/src/utils/eoRNG.h index 1c8d8f63..a1bd8276 100644 --- a/eo/src/utils/eoRNG.h +++ b/eo/src/utils/eoRNG.h @@ -41,7 +41,7 @@ // (and paraphrasing a bit in places), the Mersenne Twister is ``designed // with consideration of the flaws of various existing generators,'' has // a period of 2^19937 - 1, gives a sequence that is 623-dimensionally -// equidistributed, and ``has passed many stringent tests, including the +// equidistributed, and ``has passed many std::stringent tests, including the // die-hard test of G. Marsaglia and the load test of P. Hellekalek and // S. Wegenkittl.'' It is efficient in memory usage (typically using 2506 // to 5012 bytes of static data, depending on data type sizes, and the code @@ -212,7 +212,7 @@ public : /** roulette_wheel(vec, total = 0) does a roulette wheel selection - on the input vector vec. If the total is not supplied, it is + on the input std::vector vec. If the total is not supplied, it is calculated. It returns an integer denoting the selected argument. */ template @@ -237,7 +237,7 @@ public : } /// - void printOn(ostream& _os) const + void printOn(std::ostream& _os) const { for (int i = 0; i < N; ++i) { @@ -248,7 +248,7 @@ public : } /// - void readFrom(istream& _is) + void readFrom(std::istream& _is) { for (int i = 0; i < N; ++i) { diff --git a/eo/src/utils/eoRealBounds.cpp b/eo/src/utils/eoRealBounds.cpp index 3f1632a0..647f3db0 100644 --- a/eo/src/utils/eoRealBounds.cpp +++ b/eo/src/utils/eoRealBounds.cpp @@ -16,7 +16,7 @@ eoRealVectorNoBounds eoDummyVectorNoBounds(0); ///////////// helper read functions - could be somewhere else // removes leading delimiters - return false if nothing else left -bool remove_leading(std::string & _s, const string _delim) +bool remove_leading(std::string & _s, const std::string _delim) { size_t posDebToken = _s.find_first_not_of(_delim); if (posDebToken >= _s.size()) @@ -27,7 +27,7 @@ bool remove_leading(std::string & _s, const string _delim) double read_double(std::string _s) { - istrstream is(_s.c_str()); + std::istrstream is(_s.c_str()); double r; is >> r; return r; @@ -35,7 +35,7 @@ double read_double(std::string _s) int read_int(std::string _s) { - istrstream is(_s.c_str()); + std::istrstream is(_s.c_str()); int i; is >> i; return i; @@ -56,9 +56,9 @@ eoRealVectorBounds::eoRealVectorBounds(const eoRealVectorBounds & _b): // the readFrom method of eoRealVectorNoBounds: // only calls the readFrom(string) - for param reading -void eoRealVectorBounds::readFrom(istream& _is) +void eoRealVectorBounds::readFrom(std::istream& _is) { - string value; + std::string value; _is >> value; readFrom(value); return; @@ -79,7 +79,7 @@ void eoRealVectorBounds::readFrom(std::string _value) resize(0); // now read - string delim(",; "); + std::string delim(",; "); while (_value.size()>0) { if (!remove_leading(_value, delim)) // only delimiters were left @@ -91,38 +91,38 @@ void eoRealVectorBounds::readFrom(std::string _value) break; } // ending char - string closeChar = (_value[posDeb] == '(' ? string(")") : string("]") ); + std::string closeChar = (_value[posDeb] == '(' ? std::string(")") : std::string("]") ); - size_t posFin = _value.find_first_of(string(closeChar)); + size_t posFin = _value.find_first_of(std::string(closeChar)); if (posFin >= _value.size()) - throw runtime_error("Syntax error when reading bounds"); + throw std::runtime_error("Syntax error when reading bounds"); // y a-t-il un nbre devant unsigned count = 1; if (posDeb > 0) // something before opening { - string sCount = _value.substr(0, posDeb); + std::string sCount = _value.substr(0, posDeb); count = read_int(sCount); if (count <= 0) - throw runtime_error("Syntax error when reading bounds"); + throw std::runtime_error("Syntax error when reading bounds"); } // the bounds - string sBounds = _value.substr(posDeb+1, posFin-posDeb-1); + std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1); // and remove from original string _value = _value.substr(posFin+1); remove_leading(sBounds, delim); size_t posDelim = sBounds.find_first_of(delim); if (posDelim >= sBounds.size()) - throw runtime_error("Syntax error when reading bounds"); + throw std::runtime_error("Syntax error when reading bounds"); bool minBounded=false, maxBounded=false; double minBound=0, maxBound=0; // min bound - string sMinBounds = sBounds.substr(0,posDelim); - if (sMinBounds != string("-inf")) + std::string sMinBounds = sBounds.substr(0,posDelim); + if (sMinBounds != std::string("-inf")) { minBounded = true; minBound = read_double(sMinBounds); @@ -131,8 +131,8 @@ void eoRealVectorBounds::readFrom(std::string _value) // max bound size_t posEndDelim = sBounds.find_first_not_of(delim,posDelim); - string sMaxBounds = sBounds.substr(posEndDelim); - if (sMaxBounds != string("+inf")) + std::string sMaxBounds = sBounds.substr(posEndDelim); + if (sMaxBounds != std::string("+inf")) { maxBounded = true; maxBound = read_double(sMaxBounds); diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index 73bd761c..0ed662b0 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -27,7 +27,7 @@ #ifndef _eoRealBounds_h #define _eoRealBounds_h -#include // exceptions! +#include // std::exceptions! #include /** @@ -56,8 +56,8 @@ it exceeds it So mutation can choose - iterate trying until they fall in bounds, -- only try once and "repair" by using the foldsInBounds method -- only try once and repair using the truncate method (will create a +- only try once and "restd::pair" by using the foldsInBounds method +- only try once and restd::pair using the truncate method (will create a huge bias toward the bound if the soluiton is not far from the bounds) There is also a uniform() method that generates a uniform value @@ -107,20 +107,20 @@ public: virtual void truncate(double &) = 0; /** get minimum value - * @exception if does not exist + * @std::exception if does not exist */ virtual double minimum() = 0; /** get maximum value - * @exception if does not exist + * @std::exception if does not exist */ virtual double maximum() = 0; /** get range - * @exception if unbounded + * @std::exception if unbounded */ virtual double range() = 0; /** random generator of uniform numbers in bounds - * @exception if unbounded + * @std::exception if unbounded */ virtual double uniform(eoRng & _rng = eo::rng) = 0; @@ -145,39 +145,39 @@ public: virtual double minimum() { - throw logic_error("Trying to get minimum of unbounded eoRealBounds"); + throw std::logic_error("Trying to get minimum of unbounded eoRealBounds"); } virtual double maximum() { - throw logic_error("Trying to get maximum of unbounded eoRealBounds"); + throw std::logic_error("Trying to get maximum of unbounded eoRealBounds"); } virtual double range() { - throw logic_error("Trying to get range of unbounded eoRealBounds"); + throw std::logic_error("Trying to get range of unbounded eoRealBounds"); } virtual double uniform(eoRng & _rng = eo::rng) { - throw logic_error("Trying to generate uniform values in unbounded eoRealBounds"); + throw std::logic_error("Trying to generate uniform values in unbounded eoRealBounds"); } // methods from eoPersistent /** * Read object. - * @param _is A istream. + * @param _is A std::istream. * but reading should not be done here, because of bound problems * see eoRealVectorBounds */ - virtual void readFrom(istream& _is) + virtual void readFrom(std::istream& _is) { - throw runtime_error("Should not use eoRealBounds::readFrom"); + throw std::runtime_error("Should not use eoRealBounds::readFrom"); } /** * Write object. It's called printOn since it prints the object on a stream. - * @param _os A ostream. + * @param _os A std::ostream. */ - virtual void printOn(ostream& _os) const + virtual void printOn(std::ostream& _os) const { _os << "[-inf,+inf]"; } @@ -279,20 +279,20 @@ public : // methods from eoPersistent /** * Read object. - * @param _is A istream. + * @param _is A std::istream. * but reading should not be done here, because of bound problems * see eoRealVectorBounds */ - virtual void readFrom(istream& _is) + virtual void readFrom(std::istream& _is) { - throw runtime_error("Should not use eoRealInterval::readFrom"); + throw std::runtime_error("Should not use eoRealInterval::readFrom"); } /** * Write object. It's called printOn since it prints the object on a stream. - * @param _os A ostream. + * @param _os A std::ostream. */ - virtual void printOn(ostream& _os) const + virtual void printOn(std::ostream& _os) const { _os << "[" << repMinimum << "," << repMaximum << "]"; } @@ -328,17 +328,17 @@ public : virtual double maximum() { - throw logic_error("Trying to get maximum of eoRealBelowBound"); + throw std::logic_error("Trying to get maximum of eoRealBelowBound"); } virtual double range() { - throw logic_error("Trying to get range of eoRealBelowBound"); + throw std::logic_error("Trying to get range of eoRealBelowBound"); } // random generators virtual double uniform(eoRng & _rng = eo::rng) { - throw logic_error("Trying to generate uniform values in eoRealBelowBound"); + throw std::logic_error("Trying to generate uniform values in eoRealBelowBound"); } // description @@ -375,20 +375,20 @@ public : // methods from eoPersistent /** * Read object. - * @param _is A istream. + * @param _is A std::istream. * but reading should not be done here, because of bound problems * see eoRealVectorBounds */ - virtual void readFrom(istream& _is) + virtual void readFrom(std::istream& _is) { - throw runtime_error("Should not use eoRealBelowBound::readFrom"); + throw std::runtime_error("Should not use eoRealBelowBound::readFrom"); } /** * Write object. It's called printOn since it prints the object on a stream. - * @param _os A ostream. + * @param _os A std::ostream. */ - virtual void printOn(ostream& _os) const + virtual void printOn(std::ostream& _os) const { _os << "[" << repMinimum << ",+inf]"; } @@ -423,17 +423,17 @@ public : virtual double minimum() { - throw logic_error("Trying to get minimum of eoRealAboveBound"); + throw std::logic_error("Trying to get minimum of eoRealAboveBound"); } virtual double range() { - throw logic_error("Trying to get range of eoRealAboveBound"); + throw std::logic_error("Trying to get range of eoRealAboveBound"); } // random generators virtual double uniform(eoRng & _rng = eo::rng) { - throw logic_error("Trying to generate uniform values in eoRealAboveBound"); + throw std::logic_error("Trying to generate uniform values in eoRealAboveBound"); } // description @@ -470,20 +470,20 @@ public : // methods from eoPersistent /** * Read object. - * @param _is A istream. + * @param _is A std::istream. * but reading should not be done here, because of bound problems * see eoRealVectorBounds */ - virtual void readFrom(istream& _is) + virtual void readFrom(std::istream& _is) { - throw runtime_error("Should not use eoRealAboveBound::readFrom"); + throw std::runtime_error("Should not use eoRealAboveBound::readFrom"); } /** * Write object. It's called printOn since it prints the object on a stream. - * @param _os A ostream. + * @param _os A std::ostream. */ - virtual void printOn(ostream& _os) const + virtual void printOn(std::ostream& _os) const { _os << "[-inf," << repMaximum << "]"; } diff --git a/eo/src/utils/eoRealVectorBounds.h b/eo/src/utils/eoRealVectorBounds.h index 2fa1ffeb..11144b39 100644 --- a/eo/src/utils/eoRealVectorBounds.h +++ b/eo/src/utils/eoRealVectorBounds.h @@ -27,7 +27,7 @@ #ifndef _eoRealVectorBounds_h #define _eoRealVectorBounds_h -#include // exceptions! +#include // std::exceptions! #include #include @@ -40,9 +40,9 @@ /** Vector type for bounds (see eoRealBounds.h for scalar types) ------------ -Class eoRealVectorBounds implements the vectorized version: -it is basically a vector of eoRealBounds * and forwards all request -to the elements of the vector. +Class eoRealVectorBounds implements the std::vectorized version: +it is basically a std::vector of eoRealBounds * and forwards all request +to the elements of the std::vector. This file also contains the global variables and eoDummyVectorNoBounds that are used as defaults in ctors (i.e. when no @@ -55,7 +55,7 @@ eoRealVectorBounds which derives from the preceding *and* eoPersistent and also has a mechanism for memory handling of the pointers it has to allocate */ -class eoRealBaseVectorBounds : public vector +class eoRealBaseVectorBounds : public std::vector { public: // virtual desctructor (to avoid warning?) @@ -63,18 +63,18 @@ public: /** Default Ctor. */ - eoRealBaseVectorBounds() : vector(0) {} + eoRealBaseVectorBounds() : std::vector(0) {} /** Ctor: same bounds for everybody, given as an eoRealBounds */ eoRealBaseVectorBounds(unsigned _dim, eoRealBounds & _bounds) : - vector(_dim, &_bounds) + std::vector(_dim, &_bounds) {} /** Ctor, particular case of dim-2 */ eoRealBaseVectorBounds(eoRealBounds & _xbounds, eoRealBounds & _ybounds) : - vector(0) + std::vector(0) { push_back( &_xbounds); push_back( &_ybounds); @@ -127,9 +127,9 @@ public: (*this)[_i]->foldsInBounds(_r); } - /** Folds all variables of a vector of real values into the bounds + /** Folds all variables of a std::vector of real values into the bounds */ - virtual void foldsInBounds(vector & _v) + virtual void foldsInBounds(std::vector & _v) { for (unsigned i=0; itruncate(_r); } - /** truncates all variables of a vector of real values to the bounds + /** truncates all variables of a std::vector of real values to the bounds */ - virtual void truncate(vector & _v) + virtual void truncate(std::vector & _v) { for (unsigned i=0; i _v) + virtual bool isInBounds(std::vector _v) { for (unsigned i=0; iminimum();} virtual double maximum(unsigned _i) {return (*this)[_i]->maximum();} virtual double range(unsigned _i) {return (*this)[_i]->range();} /** Computes the average range - * An exception will be raised if one of the component is unbounded + * An std::exception will be raised if one of the component is unbounded */ virtual double averageRange() { @@ -187,7 +187,7 @@ public: } /** Generates a random number in i_th range - * An exception will be raised if one of the component is unbounded + * An std::exception will be raised if one of the component is unbounded */ virtual double uniform(unsigned _i, eoRng & _rng = eo::rng) { @@ -195,10 +195,10 @@ public: return r; } - /** fills a vector with uniformly chosen variables in bounds - * An exception will be raised if one of the component is unbounded + /** fills a std::vector with uniformly chosen variables in bounds + * An std::exception will be raised if one of the component is unbounded */ - void uniform(vector & _v, eoRng & _rng = eo::rng) + void uniform(std::vector & _v, eoRng & _rng = eo::rng) { _v.resize(size()); for (unsigned i=0; i _min, vector _max) : + eoRealVectorBounds(std::vector _min, std::vector _max) : factor(_min.size(), 1), ownedBounds(0) { if (_max.size() != _min.size()) @@ -276,10 +276,10 @@ public: } } - /** Ctor from a string - * and don't worry, the readFrom(string) starts by setting everything to 0! + /** Ctor from a std::string + * and don't worry, the readFrom(std::string) starts by setting everything to 0! */ - eoRealVectorBounds(string _s) : eoRealBaseVectorBounds() + eoRealVectorBounds(std::string _s) : eoRealBaseVectorBounds() { readFrom(_s); } @@ -287,7 +287,7 @@ public: /** Dtor: destroy all ownedBounds - BUG ???*/ virtual ~eoRealVectorBounds() { -// cout << "Dtor, avec size = " << ownedBounds.size() << endl; +// std::cout << "Dtor, avec size = " << ownedBounds.size() << std::endl; // for (unsigned i = 0; i < ownedBounds.size(); ++i) // { // delete ownedBounds[i]; @@ -298,19 +298,19 @@ public: // methods from eoPersistent /** * Read object from a stream - * only calls the readFrom(string) - for param reading - * @param _is A istream. + * only calls the readFrom(std::string) - for param reading + * @param _is A std::istream. */ - virtual void readFrom(istream& _is) ; + virtual void readFrom(std::istream& _is) ; /** - * Read object from a string - * @param _is A istream. + * Read object from a std::string + * @param _is A std::istream. */ - virtual void readFrom(string _s) ; + virtual void readFrom(std::string _s) ; /** overload printOn method to save space */ - virtual void printOn(ostream& _os) const + virtual void printOn(std::ostream& _os) const { if (factor[0]>1) _os << factor[0] ; @@ -336,10 +336,10 @@ public: * because of ownedBounds */ eoRealVectorBounds(const eoRealVectorBounds &); -private:// WARNING: there is no reason for both vector below +private:// WARNING: there is no reason for both std::vector below //to be synchronized in any manner - vector factor; // list of nb of "grouped" bounds - vector ownedBounds; + std::vector factor; // std::list of nb of "grouped" bounds + std::vector ownedBounds; // keep this one private eoRealVectorBounds& operator=(const eoRealVectorBounds&); }; @@ -347,7 +347,7 @@ private:// WARNING: there is no reason for both vector below ////////////////////////////////////////////////////////////// /** the dummy unbounded eoRealVectorBounds: usefull if you don't need bounds! * everything is inlined. - * Warning: we do need this class, and not only a vector + * Warning: we do need this class, and not only a std::vector */ class eoRealVectorNoBounds: public eoRealVectorBounds { @@ -373,43 +373,43 @@ public: virtual bool isMaxBounded(unsigned) {return false;} virtual void foldsInBounds(unsigned, double &) {return;} - virtual void foldsInBounds(vector &) {return;} + virtual void foldsInBounds(std::vector &) {return;} virtual void truncate(unsigned, double &) {return;} - virtual void truncate(vector &) {return;} + virtual void truncate(std::vector &) {return;} virtual bool isInBounds(unsigned, double) {return true;} - virtual bool isInBounds(vector) {return true;} + virtual bool isInBounds(std::vector) {return true;} // accessors virtual double minimum(unsigned) { - throw logic_error("Trying to get minimum of eoRealVectorNoBounds"); + throw std::logic_error("Trying to get minimum of eoRealVectorNoBounds"); } virtual double maximum(unsigned) { - throw logic_error("Trying to get maximum of eoRealVectorNoBounds"); + throw std::logic_error("Trying to get maximum of eoRealVectorNoBounds"); } virtual double range(unsigned) { - throw logic_error("Trying to get range of eoRealVectorNoBounds"); + throw std::logic_error("Trying to get range of eoRealVectorNoBounds"); } virtual double averageRange() { - throw logic_error("Trying to get average range of eoRealVectorNoBounds"); + throw std::logic_error("Trying to get average range of eoRealVectorNoBounds"); } // random generators virtual double uniform(unsigned, eoRng & _rng = eo::rng) { - throw logic_error("No uniform distribution on eoRealVectorNoBounds"); + throw std::logic_error("No uniform distribution on eoRealVectorNoBounds"); } - // fills a vector with uniformly chosen variables in bounds - void uniform(vector &, eoRng & _rng = eo::rng) + // fills a std::vector with uniformly chosen variables in bounds + void uniform(std::vector &, eoRng & _rng = eo::rng) { - throw logic_error("No uniform distribution on eoRealVectorNoBounds"); + throw std::logic_error("No uniform distribution on eoRealVectorNoBounds"); } }; diff --git a/eo/src/utils/eoRndGenerators.h b/eo/src/utils/eoRndGenerators.h index 76d9a991..ab5a3049 100644 --- a/eo/src/utils/eoRndGenerators.h +++ b/eo/src/utils/eoRndGenerators.h @@ -74,7 +74,7 @@ template class eoUniformGenerator : public eoRndGenerator minim(_min), range(_max-_min), uniform(_rng) { if (_min>_max) - throw logic_error("Min is greater than Max in uniform_generator"); + throw std::logic_error("Min is greater than Max in uniform_generator"); } /** diff --git a/eo/src/utils/eoScalarFitnessStat.h b/eo/src/utils/eoScalarFitnessStat.h index 9bf8b017..83495833 100644 --- a/eo/src/utils/eoScalarFitnessStat.h +++ b/eo/src/utils/eoScalarFitnessStat.h @@ -31,19 +31,19 @@ #include /** - The fitnesses of a whole population, as a vector + The fitnesses of a whole population, as a std::vector */ template -class eoScalarFitnessStat : public eoSortedStat > +class eoScalarFitnessStat : public eoSortedStat > { public : eoScalarFitnessStat(std::string _description = "FitnessES", eoRealVectorBounds & _bounds = eoDummyVectorNoBounds) : - eoSortedStat >(vector(0), _description) , + eoSortedStat >(std::vector(0), _description) , range(*_bounds[0]) {} - virtual void operator()(const vector& _popPters) + virtual void operator()(const std::vector& _popPters) { value().resize(_popPters.size()); for (unsigned i=0; i<_popPters.size(); i++) diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index ef013716..67abbc3c 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -27,17 +27,18 @@ #ifndef _eoStat_h #define _eoStat_h +#include // accumulate + #include #include #include -#include // accumulate #include /** Base class for all statistics that need to be calculated over the (unsorted) population (I guess it is not really necessary? MS. - Depends, there might be reasons to have a stat that is not an eoValueParam, + Depstd::ends, there might be reasons to have a stat that is not an eoValueParam, but maybe I'm just kidding myself, MK) */ template @@ -63,10 +64,10 @@ public : Base class for statistics calculated over a sorted snapshot of the population */ template -class eoSortedStatBase : public eoUF&, void> +class eoSortedStatBase : public eoUF&, void> { public: - virtual void lastCall(const vector&) {} + virtual void lastCall(const std::vector&) {} }; /** @@ -111,9 +112,9 @@ public : virtual void operator()(const eoPop& _pop) { #ifdef _MSC_VER - doit(_pop, EOT::Fitness()); // specializations for scalar and vector + doit(_pop, EOT::Fitness()); // specializations for scalar and std::vector #else - doit(_pop, typename EOT::Fitness()); // specializations for scalar and vector + doit(_pop, typename EOT::Fitness()); // specializations for scalar and std::vector #endif } private : @@ -192,10 +193,10 @@ public : eoNthElementFitnessStat(int _which, std::string _description = "nth element fitness") : eoSortedStat(Fitness(), _description), which(_which) {} - virtual void operator()(const vector& _pop) + virtual void operator()(const std::vector& _pop) { if (which > _pop.size()) - throw logic_error("fitness requested of element outside of pop"); + throw std::logic_error("fitness requested of element outside of pop"); doit(_pop, Fitness()); } @@ -226,11 +227,11 @@ private : value().resize(traits::nObjectives()); // copy of pointers, what the heck - vector tmp_pop = _pop; + std::vector tmp_pop = _pop; for (unsigned o = 0; o < value().size(); ++o) { - typename vector::iterator nth = tmp_pop.begin() + which; + typename std::vector::iterator nth = tmp_pop.begin() + which; std::nth_element(tmp_pop.begin(), nth, tmp_pop.end(), CmpFitness(o, traits::maximizing(o))); value()[o] = (*nth)->fitness()[o]; } @@ -238,7 +239,7 @@ private : // for everything else template - void doit(const vector& _pop, T) + void doit(const std::vector& _pop, T) { value() = _pop[which]->fitness(); } @@ -319,7 +320,7 @@ private : for (unsigned o = 0; o < traits::nObjectives(); ++o) { - typename eoPop::const_iterator it = max_element(_pop.begin(), _pop.end(), CmpFitness(o, traits::maximizing(o))); + typename eoPop::const_iterator it = std::max_element(_pop.begin(), _pop.end(), CmpFitness(o, traits::maximizing(o))); value()[o] = it->fitness()[o]; } } diff --git a/eo/src/utils/eoUniformInit.h b/eo/src/utils/eoUniformInit.h index aeb6a05e..575398bb 100644 --- a/eo/src/utils/eoUniformInit.h +++ b/eo/src/utils/eoUniformInit.h @@ -77,7 +77,7 @@ template class eoUniformInit : public eoInit minim(_min), range(_max-_min), uniform(_rng) { if (_min>_max) - throw logic_error("Min is greater than Max in uniform_generator"); + throw std::logic_error("Min is greater than Max in uniform_generator"); } /** diff --git a/eo/src/utils/rnd_generators.h b/eo/src/utils/rnd_generators.h index 7c43b90d..292205bd 100644 --- a/eo/src/utils/rnd_generators.h +++ b/eo/src/utils/rnd_generators.h @@ -51,7 +51,7 @@ template class uniform_generator minim(_min), range(_max-_min), uniform(_rng) { if (_min>_max) - throw logic_error("Min is greater than Max in uniform_generator"); + throw std::logic_error("Min is greater than Max in uniform_generator"); } T operator()(void) { return minim+static_cast(uniform.uniform(range)); } @@ -94,7 +94,7 @@ template class random_generator minim(_min), range(_max-_min), random(_rng) { if (_min>_max) - throw logic_error("Min is greater than Max in random_generator"); + throw std::logic_error("Min is greater than Max in random_generator"); } T operator()(void) { return (T) (minim + random.random(range)); } diff --git a/eo/src/utils/selectors.h b/eo/src/utils/selectors.h index 297a0523..f12dd771 100644 --- a/eo/src/utils/selectors.h +++ b/eo/src/utils/selectors.h @@ -114,7 +114,7 @@ double sum_fitness(const eoPop& _pop, std::pair& _minmax) double v = static_cast(it->fitness()); _minmax.first = std::min(_minmax.first, v); - _minmax.second = std::max(_minmax.second, v); + _minmax.second = max(_minmax.second, v); rawTotal += v; } diff --git a/eo/test/fitness_traits.cpp b/eo/test/fitness_traits.cpp index d0183313..19edb27a 100644 --- a/eo/test/fitness_traits.cpp +++ b/eo/test/fitness_traits.cpp @@ -290,7 +290,7 @@ void algo(eoPop& _pop) eoPop offspring; // how to get the scaling info into this guy?? offspring.setPerf2Worth(_pop.getPerf2Worth()); // like this! - copy(_pop.begin(), _pop.end(), back_inserter(offspring)); + std::copy(_pop.begin(), _pop.end(), back_inserter(offspring)); offspring.sort(); // should call scale @@ -307,9 +307,9 @@ void minimization_test() eo1.performance(1.0); eo2.performance(2.0); - cout << "With minimizing fitness" << endl; - cout << eo1.fitness() << " < " << eo2.fitness() << " returns " << (eo1 < eo2) << endl; - cout << eo2.fitness() << " < " << eo1.fitness() << " returns " << (eo2 < eo1) << endl; + std::cout << "With minimizing fitness" << std::endl; + std::cout << eo1.fitness() << " < " << eo2.fitness() << " returns " << (eo1 < eo2) << std::endl; + std::cout << eo2.fitness() << " < " << eo1.fitness() << " returns " << (eo2 < eo1) << std::endl; } void the_main() @@ -325,10 +325,10 @@ void the_main() eo1.fitness(10); // could also use performance() eo3.fitness(5); - cout << eo1.fitness() << endl; - cout << eo3.fitness() << endl; + std::cout << eo1.fitness() << std::endl; + std::cout << eo3.fitness() << std::endl; - cout << "eo1 < eo3 = " << (eo1 < eo3) << endl; + std::cout << "eo1 < eo3 = " << (eo1 < eo3) << std::endl; scaled_eo eo2; @@ -340,14 +340,14 @@ void the_main() try { - cout << eo2.fitness() << endl; - cout << "did not throw" << endl; + std::cout << eo2.fitness() << std::endl; + std::cout << "did not throw" << std::endl; assert(false); // should throw } - catch(exception& e) + catch(std::exception& e) { - cout << "Fitness threw exception, as it should" << endl; - cout << e.what() << endl; + std::cout << "Fitness threw exception, as it should" << std::endl; + std::cout << e.what() << std::endl; } /* Set the worth and all is well (this is normally done by some perf2worth functor */ @@ -355,10 +355,10 @@ void the_main() eo2.worth(3); eo4.worth(5); - cout << "with maximization " << endl; - cout << eo2.fitness() << endl; - cout << eo4.fitness() << endl; - cout << eo2.fitness() << " < " << eo4.fitness() << " returns " << (eo2 < eo4) << endl; + std::cout << "with maximization " << std::endl; + std::cout << eo2.fitness() << std::endl; + std::cout << eo4.fitness() << std::endl; + std::cout << eo2.fitness() << " < " << eo4.fitness() << " returns " << (eo2 < eo4) << std::endl; /* Test the minimization of fitness */ minimization_test(); @@ -373,7 +373,7 @@ void the_main() algo(pop0); - cout << pop0[0].fitness() << endl; + std::cout << pop0[0].fitness() << std::endl; assert(pop0[0].fitness() == 1); @@ -389,14 +389,14 @@ void the_main() // at this point getting the fitness should throw try { - cout << pop1[0].fitness() << endl; - cout << "did not throw" << endl; + std::cout << pop1[0].fitness() << std::endl; + std::cout << "did not throw" << std::endl; assert(false); // should throw } - catch(exception& e) + catch(std::exception& e) { - cout << "Fitness threw exception, as it should" << endl; - cout << e.what() << endl; + std::cout << "Fitness threw exception, as it should" << std::endl; + std::cout << e.what() << std::endl; } // at this point trying to scale should throw @@ -405,9 +405,9 @@ void the_main() algo(pop1); // should complain that it cannot scale assert(false); // so it would never get here } - catch(exception& e) + catch(std::exception& e) { // but rather ends here - cout << e.what() << endl; + std::cout << e.what() << std::endl; } // ok, now set the scaling @@ -415,7 +415,7 @@ void the_main() algo(pop1); - cout << "the fitness has been transformed from " << pop1[0].performance() << " to exp(-1) = " << pop1[0].fitness() << endl; + std::cout << "the fitness has been transformed from " << pop1[0].performance() << " to exp(-1) = " << pop1[0].fitness() << std::endl; } int main() @@ -424,9 +424,9 @@ int main() { the_main(); } - catch(exception& e) + catch(std::exception& e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; } } diff --git a/eo/test/t-MGE-control.cpp b/eo/test/t-MGE-control.cpp index c7d857d2..d9db93a7 100644 --- a/eo/test/t-MGE-control.cpp +++ b/eo/test/t-MGE-control.cpp @@ -44,9 +44,9 @@ int main() pop.push_back(chrom); } - cout << "population:" << endl; + std::cout << "population:" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; // selection eoStochTournamentSelect lottery(0.9 ); @@ -83,17 +83,17 @@ int main() { ea(pop); } - catch (exception& e) + catch (std::exception& e) { - cout << "exception: " << e.what() << endl;; + std::cout << "exception: " << e.what() << std::endl;; exit(EXIT_FAILURE); } - cout << "pop" << endl; + std::cout << "pop" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; - cout << "\n --> Number of Evaluations = " << eval.getValue() << endl; + std::cout << "\n --> Number of Evaluations = " << eval.getValue() << std::endl; return 0; } diff --git a/eo/test/t-MGE.cpp b/eo/test/t-MGE.cpp index 4fd76f43..b19aba9b 100644 --- a/eo/test/t-MGE.cpp +++ b/eo/test/t-MGE.cpp @@ -44,9 +44,9 @@ int main() pop.push_back(chrom); } - cout << "population:" << endl; + std::cout << "population:" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; // selection eoStochTournamentSelect lottery(0.9 ); @@ -87,17 +87,17 @@ int main() { ea(pop); } - catch (exception& e) + catch (std::exception& e) { - cout << "exception: " << e.what() << endl;; + std::cout << "exception: " << e.what() << std::endl;; exit(EXIT_FAILURE); } - cout << "pop" << endl; + std::cout << "pop" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; - cout << "\n --> Number of Evaluations = " << eval.getValue() << endl; + std::cout << "\n --> Number of Evaluations = " << eval.getValue() << std::endl; return 0; } diff --git a/eo/test/t-MGE1bit.cpp b/eo/test/t-MGE1bit.cpp index d6ab91e5..c4e68d05 100644 --- a/eo/test/t-MGE1bit.cpp +++ b/eo/test/t-MGE1bit.cpp @@ -44,9 +44,9 @@ int main() pop.push_back(chrom); } - cout << "population:" << endl; + std::cout << "population:" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; // selection eoStochTournamentSelect lottery(0.9 ); @@ -87,17 +87,17 @@ int main() { ea(pop); } - catch (exception& e) + catch (std::exception& e) { - cout << "exception: " << e.what() << endl;; + std::cout << "exception: " << e.what() << std::endl;; exit(EXIT_FAILURE); } - cout << "pop" << endl; + std::cout << "pop" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; - cout << "\n --> Number of Evaluations = " << eval.getValue() << endl; + std::cout << "\n --> Number of Evaluations = " << eval.getValue() << std::endl; return 0; } diff --git a/eo/test/t-eo.cpp b/eo/test/t-eo.cpp index f5cd88fa..aea451c3 100644 --- a/eo/test/t-eo.cpp +++ b/eo/test/t-eo.cpp @@ -14,8 +14,8 @@ int main() { Chrom chrom1, chrom2; - cout << "chrom1 = " << chrom1 << endl - << "chrom2 = " << chrom2 << endl; + std::cout << "chrom1 = " << chrom1 << std::endl + << "chrom2 = " << chrom2 << std::endl; return 0; } diff --git a/eo/test/t-eoAtomOps.cpp b/eo/test/t-eoAtomOps.cpp index 020c3017..d1c70de7 100644 --- a/eo/test/t-eoAtomOps.cpp +++ b/eo/test/t-eoAtomOps.cpp @@ -56,11 +56,11 @@ main(int argc, char *argv[]) { eoAtomRandom randomer( charNE ); eoAtomMutation< eoString > mutator2 ( randomer, 0.5 ); - cout << "Before aString " << aString << endl; + std::cout << "Before aString " << aString << std::endl; mutator( aString); - cout << " after mutator " << aString << endl; + std::cout << " after mutator " << aString << std::endl; mutator2( aString); - cout << " after mutator2 " << aString << endl;; + std::cout << " after mutator2 " << aString << std::endl;; return 0; // to avoid VC++ complaints } diff --git a/eo/test/t-eoBaseFunctions.cpp b/eo/test/t-eoBaseFunctions.cpp index 636b0a38..6f6745ac 100644 --- a/eo/test/t-eoBaseFunctions.cpp +++ b/eo/test/t-eoBaseFunctions.cpp @@ -21,6 +21,6 @@ int main() eo2 _2; int i = _2(); - cout << i << '\n'; + std::cout << i << '\n'; return i; -} \ No newline at end of file +} diff --git a/eo/test/t-eoCheckpointing.cpp b/eo/test/t-eoCheckpointing.cpp index 32491b61..6e826a4a 100644 --- a/eo/test/t-eoCheckpointing.cpp +++ b/eo/test/t-eoCheckpointing.cpp @@ -49,8 +49,8 @@ int the_main(int argc, char **argv) eoValueParam rate(0.01, "mutationRatePerBit", "Initial value for mutation rate per bit"); eoValueParam factor(0.99, "mutationFactor", "Decrease factor for mutation rate"); eoValueParam seed(time(0), "seed", "Random number seed"); - eoValueParam load_name("", "Load","Load",'L'); - eoValueParam save_name("", "Save","Save",'S'); + eoValueParam load_name("", "Load","Load",'L'); + eoValueParam save_name("", "Save","Save",'S'); // Register them parser.processParam(rate, "Genetic Operators"); @@ -122,7 +122,7 @@ int the_main(int argc, char **argv) if (parser.userNeedsHelp()) { - parser.printHelp(cout); + parser.printHelp(std::cout); return 0; } @@ -153,7 +153,7 @@ int the_main(int argc, char **argv) while (time(0) == now) {} // wait a second to test timed saver - cout << "gen " << generationCounter.value() << endl; + std::cout << "gen " << generationCounter.value() << std::endl; } // run the algorithm @@ -161,7 +161,7 @@ int the_main(int argc, char **argv) // Save when needed if (save_name.value() != "") { - string file_name = save_name.value(); + std::string file_name = save_name.value(); save_name.value() = ""; // so that it does not appear in the parser section of the state file state.save(file_name); } @@ -175,9 +175,9 @@ int main(int argc, char **argv) { the_main(argc, argv); } - catch(exception& e) + catch(std::exception& e) { - cout << "Exception: " << e.what() << endl; + std::cout << "Exception: " << e.what() << std::endl; } } diff --git a/eo/test/t-eoESAll.cpp b/eo/test/t-eoESAll.cpp index 1752faa8..8d728ec4 100644 --- a/eo/test/t-eoESAll.cpp +++ b/eo/test/t-eoESAll.cpp @@ -46,22 +46,22 @@ int main_function(int argc, char *argv[]) // Run the appropriate algorithm if (simpleParam.value() == false) { - cout << "Using eoReal" << endl; + std::cout << "Using eoReal" << std::endl; runAlgorithm(eoReal(), parser, state); } else if (stdevsParam.value() == false) { - cout << "Using eoEsSimple" << endl; + std::cout << "Using eoEsSimple" << std::endl; runAlgorithm(eoEsSimple(), parser, state); } else if (corrParam.value() == false) { - cout << "Using eoEsStdev" << endl; + std::cout << "Using eoEsStdev" << std::endl; runAlgorithm(eoEsStdev(), parser, state); } else { - cout << "Using eoEsFull" << endl; + std::cout << "Using eoEsFull" << std::endl; runAlgorithm(eoEsFull(), parser, state); } @@ -84,9 +84,9 @@ int main(int argc, char **argv) { main_function(argc, argv); } - catch(exception& e) + catch(std::exception& e) { - cout << "Exception: " << e.what() << '\n'; + std::cout << "Exception: " << e.what() << '\n'; } } @@ -136,13 +136,13 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state) //// GO /////// - cout << "Initial Population\n"; - pop.sortedPrintOn(cout); - cout << endl; + std::cout << "Initial Population\n"; + pop.sortedPrintOn(std::cout); + std::cout << std::endl; run_ea(ga, pop); // run the ga - cout << "Final Population\n"; - pop.sortedPrintOn(cout); - cout << endl; + std::cout << "Final Population\n"; + pop.sortedPrintOn(std::cout); + std::cout << std::endl; } diff --git a/eo/test/t-eoESFull.cpp b/eo/test/t-eoESFull.cpp index 05d9c421..7b555025 100644 --- a/eo/test/t-eoESFull.cpp +++ b/eo/test/t-eoESFull.cpp @@ -99,9 +99,9 @@ int main(int argc, char **argv) { main_function(argc, argv); } - catch(exception& e) + catch(std::exception& e) { - cout << "Exception: " << e.what() << '\n'; + std::cout << "Exception: " << e.what() << '\n'; } return 1; @@ -174,6 +174,6 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoRealVectorBounds& _ es(pop); pop.sort(); - cout << "Final population\n" << pop << endl; + std::cout << "Final population\n" << pop << std::endl; } diff --git a/eo/test/t-eoESOps.cpp b/eo/test/t-eoESOps.cpp index dc25ca99..d583ada6 100644 --- a/eo/test/t-eoESOps.cpp +++ b/eo/test/t-eoESOps.cpp @@ -54,9 +54,9 @@ main(int argc, char *argv[]) { FirstEO.StdDevLength(), FirstEO.size(), FirstEO.CorCffLength() ); - cout << "First EO " << FirstEO << endl; + std::cout << "First EO " << FirstEO << std::endl; MyMut(FirstEO); - cout << "First EO mutated" << FirstEO << endl; + std::cout << "First EO mutated" << FirstEO << std::endl; /* // Evolution and population parameters @@ -88,10 +88,10 @@ main(int argc, char *argv[]) { unsigned i, iind; - cout << "Initial population: \n" << endl; + std::cout << "Initial population: \n" << std::endl; for (i = 0; i < pop.size(); ++i) { eval(pop[i]); - cout << pop[i].fitness() << "\t" << pop[i] << endl; + std::cout << pop[i].fitness() << "\t" << pop[i] << std::endl; } // the Operators @@ -107,9 +107,9 @@ main(int argc, char *argv[]) { ea(pop); - cout << "Final population: \n" << endl; + std::cout << "Final population: \n" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << pop[i].fitness() << "\t" << pop[i] << endl; + std::cout << pop[i].fitness() << "\t" << pop[i] << std::endl; return 0; */ } diff --git a/eo/test/t-eoEasyEA.cpp b/eo/test/t-eoEasyEA.cpp index 160d0304..1b201cfa 100644 --- a/eo/test/t-eoEasyEA.cpp +++ b/eo/test/t-eoEasyEA.cpp @@ -38,9 +38,9 @@ main() pop.push_back(chrom); } - cout << "population:" << endl; + std::cout << "population:" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; // selection @@ -68,15 +68,15 @@ main() { ea(pop); } - catch (exception& e) + catch (std::exception& e) { - cout << "exception: " << e.what() << endl;; + std::cout << "exception: " << e.what() << std::endl;; exit(EXIT_FAILURE); } - cout << "pop" << endl; + std::cout << "pop" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << "\t" << pop[i] << " " << pop[i].fitness() << endl; + std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; return 0; } diff --git a/eo/test/t-eoExternalEO.cpp b/eo/test/t-eoExternalEO.cpp index 889b8574..f8f71c93 100644 --- a/eo/test/t-eoExternalEO.cpp +++ b/eo/test/t-eoExternalEO.cpp @@ -20,7 +20,7 @@ struct UserDefStruct enum Enum { just, another, test } d; }; -ostream& operator<<(ostream& os, const UserDefStruct& str) +std::ostream& operator<<(std::ostream& os, const UserDefStruct& str) { return os << str.a << ' ' << str.b << ' ' << str.c << ' ' << static_cast(str.d) << ' '; } @@ -40,7 +40,7 @@ istream& operator>>(istream& is, UserDefStruct& str) UserDefStruct RandomStruct() { - cout << "RandomStruct\n"; + std::cout << "RandomStruct\n"; UserDefStruct result; @@ -57,7 +57,7 @@ UserDefStruct RandomStruct() bool UserDefMutate(UserDefStruct& a) { - cout << "UserDefMutate\n"; + std::cout << "UserDefMutate\n"; a = RandomStruct(); // just for testing if (rng.flip(0.1f)) @@ -69,7 +69,7 @@ bool UserDefMutate(UserDefStruct& a) bool UserDefBinCrossover(UserDefStruct& a, const UserDefStruct& b) { - cout << "UserDefBinCrossover\n"; + std::cout << "UserDefBinCrossover\n"; if (rng.flip(0.5)) a.a = b.a; @@ -84,7 +84,7 @@ bool UserDefBinCrossover(UserDefStruct& a, const UserDefStruct& b) bool UserDefQuadCrossover(UserDefStruct& a, UserDefStruct& b) { - cout << "UserDefQuadCrossover\n"; + std::cout << "UserDefQuadCrossover\n"; if (rng.flip(0.5)) swap(a.a, b.a); if (rng.flip(0.5)) @@ -99,7 +99,7 @@ bool UserDefQuadCrossover(UserDefStruct& a, UserDefStruct& b) float UserDefEvalFunc(const UserDefStruct& a) { - cout << "UserDefEvalFunc\n"; + std::cout << "UserDefEvalFunc\n"; return a.b; } @@ -121,11 +121,11 @@ int main() EoType eo2; init(eo2); - cout << "before mutation " << eo1 << '\n'; + std::cout << "before mutation " << eo1 << '\n'; mutate(eo1); - cout << "after mutation " << eo1 << '\n'; + std::cout << "after mutation " << eo1 << '\n'; cross1(eo1, eo2); - cout << "after crossover " << eo1 << '\n'; + std::cout << "after crossover " << eo1 << '\n'; cross2(eo1,eo2); diff --git a/eo/test/t-eoGA.cpp b/eo/test/t-eoGA.cpp index 6763edea..effac3b0 100644 --- a/eo/test/t-eoGA.cpp +++ b/eo/test/t-eoGA.cpp @@ -55,18 +55,18 @@ int main(int argc, char* argv[]) // evaluate intial population AFTER help and status in case it takes time apply(eval, pop); // print it out - cout << "Initial Population\n"; - pop.sortedPrintOn(cout); - cout << endl; + std::cout << "Initial Population\n"; + pop.sortedPrintOn(std::cout); + std::cout << std::endl; run_ea(ga, pop); // run the ga - cout << "Final Population\n"; - pop.sortedPrintOn(cout); - cout << endl; + std::cout << "Final Population\n"; + pop.sortedPrintOn(std::cout); + std::cout << std::endl; } - catch(exception& e) + catch(std::exception& e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; } } diff --git a/eo/test/t-eoGOpSel.cpp b/eo/test/t-eoGOpSel.cpp index 7b6043f0..2606bab6 100644 --- a/eo/test/t-eoGOpSel.cpp +++ b/eo/test/t-eoGOpSel.cpp @@ -75,9 +75,9 @@ main() pop.push_back(chrom); } - cout << "population:" << endl; + std::cout << "population:" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << pop[i] << " " << pop[i].fitness() << endl; + std::cout << pop[i] << " " << pop[i].fitness() << std::endl; eoBinBitFlip bitflip; eoBinCrossover xover; @@ -123,7 +123,7 @@ main() state.registerObject(pop); - state.save(std::cout); + state.save(std::std::cout); return 0; } diff --git a/eo/test/t-eoGenOp.cpp b/eo/test/t-eoGenOp.cpp index dd13ba32..e85fe19a 100644 --- a/eo/test/t-eoGenOp.cpp +++ b/eo/test/t-eoGenOp.cpp @@ -32,16 +32,16 @@ struct Dummy : public EO { - typedef double Type; + typedef double Type; Dummy(std::string _s="") : s(_s) {} - void printOn(ostream & _os) const + void printOn(std::ostream & _os) const { EO::printOn(_os); _os << " - " << s ; } - string s; + std::string s; }; typedef Dummy EOT; @@ -59,9 +59,9 @@ class monop : public eoMonOp _eo.fitness(_eo.fitness()+pSize); return false; } - string className() const {return sig;} + std::string className() const {return sig;} private: - string sig; + std::string sig; }; class binop: public eoBinOp @@ -74,13 +74,13 @@ class binop: public eoBinOp _eo1.fitness(_eo1.fitness()+f); return false; } - string className() const {return "binop";} + std::string className() const {return "binop";} }; class quadop: public eoQuadOp { public : - string className() const {return "quadop";} + std::string className() const {return "quadop";} bool operator()(EOT& a, EOT& b) { EOT oi = a; @@ -98,7 +98,7 @@ class quadop: public eoQuadOp class quadClone: public eoQuadOp { public : - string className() const {return "quadclone";} + std::string className() const {return "quadclone";} bool operator()(EOT& , EOT& ) {return false;} }; @@ -120,7 +120,7 @@ class one2threeOp : public eoGenOp // :-) eo.s = "v(" + eo.s + ", 0)"; // only now change the thing // oh right, and invalidate fitnesses } - virtual string className() const {return "one2threeOp";} + virtual std::string className() const {return "one2threeOp";} }; @@ -136,7 +136,7 @@ class two2oneOp : public eoGenOp // :-) eo.s = "221(" + eo.s + ", " + eo2.s + ")"; // oh right, and invalidate fitnesses } - virtual string className() const {return "two2oneOp";} + virtual std::string className() const {return "two2oneOp";} }; class three2threeOp : public eoGenOp // :-) @@ -152,14 +152,14 @@ class three2threeOp : public eoGenOp // :-) EOT a = eo1; EOT b = eo2; EOT c = eo3; - cout << "les selectionnes: a=" << a << " et b=" << b << " et c=" << c << endl; + std::cout << "les selectionnes: a=" << a << " et b=" << b << " et c=" << c << std::endl; eo1.s = "323-1(" + a.s + ", " + b.s + ", " + c.s + ")"; eo2.s = "323-2(" + a.s + ", " + b.s + ", " + c.s + ")"; eo3.s = "323-3(" + a.s + ", " + b.s + ", " + c.s + ")"; // oh right, and invalidate fitnesses - cout << "les enfants: a=" << eo1 << " et b=" << eo2 << " et c=" << eo3 << endl; + std::cout << "les enfants: a=" << eo1 << " et b=" << eo2 << " et c=" << eo3 << std::endl; } - virtual string className() const {return "three2threeOp";} + virtual std::string className() const {return "three2threeOp";} }; @@ -172,13 +172,13 @@ void init(eoPop & _pop, unsigned _pSize) } else { - throw runtime_error("init pop with 0 size"); + throw std::runtime_error("init pop with 0 size"); } for (unsigned i=0; i<_pSize; i++) { char s[255]; - ostrstream os(s, 254); - os << i << ends; + std::ostrstream os(s, 254); + os << i << std::ends; _pop[i] = Dummy(s); _pop[i].fitness(i); } @@ -200,7 +200,7 @@ int the_main(int argc, char **argv) // i.e. in case you need parameters somewhere else, postpone these if (parser.userNeedsHelp()) { - parser.printHelp(cout); + parser.printHelp(std::cout); exit(1); } @@ -267,7 +267,7 @@ int the_main(int argc, char **argv) init(pop, pSize); // sort pop so seqPopulator is identical to SelectPopulator(SequentialSelect) pop.sort(); - cout << "Population initiale\n" << pop << endl; + std::cout << "Population initiale\n" << pop << std::endl; // To simulate SGA: first a prop between quadOp and quadClone eoProportionalOp pSGAOp; @@ -286,25 +286,25 @@ int the_main(int argc, char **argv) while (offspring.size() < pop.size()) { virtualSGA(popit); - cout << "SeqPopulator boucle et incremente\n"; + std::cout << "SeqPopulator boucle et incremente\n"; ++popit; } } catch(eoPopulator::OutOfIndividuals&) { - cout << "Warning: not enough individuals to handle\n"; + std::cout << "Warning: not enough individuals to handle\n"; } - swap(pop, offspring); + std::swap(pop, offspring); offspring.clear(); // ok, now print - cout << "Apres virtualSGA \n" << pop << endl; + std::cout << "Apres virtualSGA \n" << pop << std::endl; init(pop, pSize); - cout << "=========================================================\n"; - cout << "Now the eoSelectPopulator version !" << endl; + std::cout << "=========================================================\n"; + std::cout << "Now the eoSelectPopulator version !" << std::endl; eoSequentialSelect seqSelect; // select.init(); should be sorted out: is it the setup method??? @@ -313,18 +313,18 @@ int the_main(int argc, char **argv) while (offspring.size() < 2*pop.size()) { virtualSGA(it_step3); - cout << "SelectPopulator boucle et incremente\n"; + std::cout << "SelectPopulator boucle et incremente\n"; ++it_step3; } - swap(pop, offspring); + std::swap(pop, offspring); offspring.clear(); // ok, now print - cout << "Apres SGA-like eoSelectivePopulator\n" << pop << endl; + std::cout << "Apres SGA-like eoSelectivePopulator\n" << pop << std::endl; - cout << "=========================================================\n"; - cout << "Now the pure addition !" << endl; + std::cout << "=========================================================\n"; + std::cout << "Now the pure addition !" << std::endl; init(pop, pSize); eoSelectivePopulator it_step4(pop, offspring, seqSelect); @@ -334,11 +334,11 @@ int the_main(int argc, char **argv) ++it_step4; } - swap(pop, offspring); + std::swap(pop, offspring); offspring.clear(); // ok, now print - cout << "Apres Quad+Mon ds un eoSelectivePopulator\n" << pop << endl; + std::cout << "Apres Quad+Mon ds un eoSelectivePopulator\n" << pop << std::endl; // On teste 1->3 init(pop, pSize); @@ -349,11 +349,11 @@ int the_main(int argc, char **argv) ++it_step5; } - swap(pop, offspring); + std::swap(pop, offspring); offspring.clear(); // ok, now print - cout << "Apres 1->3 seul ds un eoSelectivePopulator\n" << pop << endl; + std::cout << "Apres 1->3 seul ds un eoSelectivePopulator\n" << pop << std::endl; // On teste 3->3 init(pop, pSize); @@ -364,11 +364,11 @@ int the_main(int argc, char **argv) ++it_step6; } - swap(pop, offspring); + std::swap(pop, offspring); offspring.clear(); // ok, now print - cout << "Apres 3->3 seul ds un eoSelectivePopulator\n" << pop << endl; + std::cout << "Apres 3->3 seul ds un eoSelectivePopulator\n" << pop << std::endl; return 1; @@ -380,9 +380,9 @@ int main(int argc, char **argv) { the_main(argc, argv); } - catch(exception& e) + catch(std::exception& e) { - cout << "Exception: " << e.what() << endl; + std::cout << "Exception: " << e.what() << std::endl; } } diff --git a/eo/test/t-eoNonUniform.cpp b/eo/test/t-eoNonUniform.cpp index 647b78c9..3a59bc8c 100644 --- a/eo/test/t-eoNonUniform.cpp +++ b/eo/test/t-eoNonUniform.cpp @@ -11,20 +11,20 @@ main() { eoNonUniform nu(1000); - cout << "----------------------------------------------------------" << endl + std::cout << "----------------------------------------------------------" << std::endl << "nu.step() = " << nu.step() - << "\t nu.num_step() = " << nu.num_step() << endl - << "----------------------------------------------------------" << endl; + << "\t nu.num_step() = " << nu.num_step() << std::endl + << "----------------------------------------------------------" << std::endl; eoLinear l1(0, 1, nu), l2(1, 0, nu); eoNegExp2 n1(0.1, 8, nu), n2(0.75, 3, nu); for (; nu; ++nu) { - cout << nu.step() + std::cout << nu.step() << "\t" << l1() << "\t" << l2() << "\t" << n1() << "\t" << n2() - << endl; + << std::endl; } } diff --git a/eo/test/t-eoPBIL.cpp b/eo/test/t-eoPBIL.cpp index b62d3081..1c28c459 100644 --- a/eo/test/t-eoPBIL.cpp +++ b/eo/test/t-eoPBIL.cpp @@ -121,9 +121,9 @@ int main(int argc, char* argv[]) dea(distrib); // run the dea - cout << "Final Distribution\n"; - distrib.printOn(cout); - cout << endl; + std::cout << "Final Distribution\n"; + distrib.printOn(std::cout); + std::cout << std::endl; #if !defined(NO_GNUPLOT) // wait - for graphical output @@ -134,8 +134,8 @@ int main(int argc, char* argv[]) } #endif } - catch(exception& e) + catch(std::exception& e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; } } diff --git a/eo/test/t-eoPareto.cpp b/eo/test/t-eoPareto.cpp index 2d5cc48c..e9a290b6 100644 --- a/eo/test/t-eoPareto.cpp +++ b/eo/test/t-eoPareto.cpp @@ -95,7 +95,7 @@ public: { unsigned sz = _parents.size(); _parents.reserve(_parents.size() + _offspring.size()); - copy(_offspring.begin(), _offspring.end(), back_inserter(_parents)); + std::copy(_offspring.begin(), _offspring.end(), back_inserter(_parents)); // calculate worths perf2worth(_parents); @@ -131,7 +131,7 @@ eoPerf2Worth& make_perf2worth(eoParser& parser, eoState& state) if (what > 2) { - cout << "Warning, need an integer < 3 for perf2worth" << endl; + std::cout << "Warning, need an integer < 3 for perf2worth" << std::endl; // should actually set parser flag, but I don't care } @@ -210,7 +210,7 @@ void the_main(int argc, char* argv[]) if (parser.userNeedsHelp()) { - parser.printHelp(cout); + parser.printHelp(std::cout); return; } @@ -225,9 +225,9 @@ int main(int argc, char* argv[]) { the_main(argc, argv); } - catch (exception& e) + catch (std::exception& e) { - cout << "Exception thrown: " << e.what() << endl; + std::cout << "Exception thrown: " << e.what() << std::endl; throw e; // make sure it does not pass the test } } diff --git a/eo/test/t-eoParetoFitness.cpp b/eo/test/t-eoParetoFitness.cpp index 1cbf3373..1adcb170 100644 --- a/eo/test/t-eoParetoFitness.cpp +++ b/eo/test/t-eoParetoFitness.cpp @@ -42,11 +42,11 @@ template void compare(F & _eo1, F & _eo2) { if (_eo1.dominates(_eo2)) - cout << _eo1 << " dominates " << _eo2 << endl; + std::cout << _eo1 << " dominates " << _eo2 << std::endl; else if (_eo2.dominates(_eo1)) - cout << _eo2 << " dominates " << _eo1 << endl; + std::cout << _eo2 << " dominates " << _eo1 << std::endl; else - cout << "None of " << _eo1 << " and " << _eo2 << "dominates the other" << endl; + std::cout << "None of " << _eo1 << " and " << _eo2 << "dominates the other" << std::endl; return; } @@ -75,7 +75,7 @@ int main() if (!f0.dominates(f2)) { - cout << f2 << " not dominated by " << f0; + std::cout << f2 << " not dominated by " << f0; throw; } @@ -83,13 +83,13 @@ int main() if (f0.dominates(f1) || f1.dominates(f0)) { - cout << f0 << " and " << f1 << " dominate"; + std::cout << f0 << " and " << f1 << " dominate"; throw; } if (! (f0 == f0)) { - cout << "f0 == f0 failed" << endl; + std::cout << "f0 == f0 failed" << std::endl; throw; } @@ -132,7 +132,7 @@ int main() // now the run-time set-able number of objectives //////////////////////////////////////////// - cout << "On y va" << endl; + std::cout << "On y va" << std::endl; // setup fitness WARNING do not try to allocate any EO before that (runtime error) @@ -140,7 +140,7 @@ int main() b[0]=true; b[1]=false; VarFitness::setUp(2, b); - cout << "\nMAXimizing on Obj 0 and MINimizing on Obj 1\n"; + std::cout << "\nMAXimizing on Obj 0 and MINimizing on Obj 1\n"; VarFitness mv0; VarFitness mv1; @@ -166,11 +166,11 @@ int main() compare (mv1,mv3); compare (mv2,mv3); - cout << "\nChanging now the min <-> max\n"; + std::cout << "\nChanging now the min <-> max\n"; b[0]=false; b[1]=true; VarFitness::setUp(2, b); - cout << "\nMINimizing on Obj 0 and MAXimizing on Obj 1\n"; + std::cout << "\nMINimizing on Obj 0 and MAXimizing on Obj 1\n"; compare (mv0,mv1); compare (mv0,mv2); compare (mv0,mv3); @@ -178,7 +178,7 @@ int main() compare (mv1,mv3); compare (mv2,mv3); - cout << "\nTesting WARNING\n"; + std::cout << "\nTesting WARNING\n"; b.resize(3); b[0]=false; b[1]=true; @@ -186,9 +186,9 @@ int main() VarFitness::setUp(3, b); } - catch(exception& e) + catch(std::exception& e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; } } diff --git a/eo/test/t-eoRandom.cpp b/eo/test/t-eoRandom.cpp index 1091ddc3..30da63e3 100644 --- a/eo/test/t-eoRandom.cpp +++ b/eo/test/t-eoRandom.cpp @@ -24,7 +24,7 @@ */ /** -CVS Info: $Date: 2001-04-24 04:52:04 $ $Author: evomarc $ $Revision: 1.12 $ +CVS Info: $Date: 2003-02-27 19:20:24 $ $Author: okoenig $ $Revision: 1.13 $ */ //----------------------------------------------------------------------------- @@ -47,16 +47,16 @@ int main() { eoUniformGenerator utest( 10000000U, 10000U); throw; // if this succeeds something is wrong, make sure that that is noticed } - catch (logic_error& e) + catch (std::logic_error& e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; } - ofstream os("t-eoRandom.out"); + std::ofstream os("t-eoRandom.out"); for ( unsigned i = 0; i < 100; i ++) { - os << u1() << "\t" << u2() << "\t" << u3() << endl; + os << u1() << "\t" << u2() << "\t" << u3() << std::endl; } return 0; // to avoid VC++ complaints diff --git a/eo/test/t-eoReal.cpp b/eo/test/t-eoReal.cpp index 8002136c..851e1982 100644 --- a/eo/test/t-eoReal.cpp +++ b/eo/test/t-eoReal.cpp @@ -55,18 +55,18 @@ int main(int argc, char* argv[]) // evaluate intial population AFTER help and status in case it takes time apply(eval, pop); // print it out - cout << "Initial Population\n"; - pop.sortedPrintOn(cout); - cout << endl; + std::cout << "Initial Population\n"; + pop.sortedPrintOn(std::cout); + std::cout << std::endl; run_ea(ea, pop); // run the ea - cout << "Final Population\n"; - pop.sortedPrintOn(cout); - cout << endl; + std::cout << "Final Population\n"; + pop.sortedPrintOn(std::cout); + std::cout << std::endl; } - catch(exception& e) + catch(std::exception& e) { - cout << e.what() << endl; + std::cout << e.what() << std::endl; } } diff --git a/eo/test/t-eoReplacement.cpp b/eo/test/t-eoReplacement.cpp index 34d63555..a0f02406 100644 --- a/eo/test/t-eoReplacement.cpp +++ b/eo/test/t-eoReplacement.cpp @@ -20,7 +20,7 @@ struct Dummy : public EO { typedef double Type; - void printOn(ostream & _os) const + void printOn(std::ostream & _os) const { _os << " - "; EO::printOn(_os); @@ -73,14 +73,14 @@ int the_main(int argc, char **argv) if (parser.userNeedsHelp()) { - parser.printHelp(cout); + parser.printHelp(std::cout); exit(1); } unsigned i; - cout << "Testing the replacements\nParents SIze = " << pSize - << " and offspring size = " << oSize << endl; + std::cout << "Testing the replacements\nParents SIze = " << pSize + << " and offspring size = " << oSize << std::endl; rng.reseed(42); @@ -94,7 +94,7 @@ int the_main(int argc, char **argv) for (i=0; i offspring.size() ) - cout << "Skipping Comma Replacement, more parents than offspring\n"; + std::cout << "Skipping Comma Replacement, more parents than offspring\n"; else { - cout << "eoCommaReplacement\n"; - cout << "==================\n"; + std::cout << "eoCommaReplacement\n"; + std::cout << "==================\n"; commaReplace(parents, offspring); - cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + std::cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << std::endl; // Comma with weak elitism parents = orgParents; offspring = orgOffspring; - cout << "The same, with WEAK elitism\n"; - cout << "===========================\n"; + std::cout << "The same, with WEAK elitism\n"; + std::cout << "===========================\n"; weakElitistReplace(parents, offspring); - cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + std::cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << std::endl; } // preparing SSGA replace worse @@ -167,31 +167,31 @@ cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originall offspring = orgOffspring; if (parents.size() < offspring.size() ) - cout << "Skipping all SSGA Replacements, more offspring than parents\n"; + std::cout << "Skipping all SSGA Replacements, more offspring than parents\n"; else { - cout << "SSGA replace worse\n"; - cout << "==================\n"; + std::cout << "SSGA replace worse\n"; + std::cout << "==================\n"; ssgaWorseReplace(parents, offspring); - cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + std::cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << std::endl; // SSGA deterministic tournament parents = orgParents; offspring = orgOffspring; - cout << "SSGA deterministic tournament\n"; - cout << "=============================\n"; + std::cout << "SSGA deterministic tournament\n"; + std::cout << "=============================\n"; ssgaDTReplace(parents, offspring); - cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + std::cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << std::endl; // SSGA stochastic tournament parents = orgParents; offspring = orgOffspring; - cout << "SSGA stochastic tournament\n"; - cout << "==========================\n"; + std::cout << "SSGA stochastic tournament\n"; + std::cout << "==========================\n"; ssgaDTReplace(parents, offspring); - cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + std::cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << std::endl; } // the general replacement @@ -200,10 +200,10 @@ cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originall parents = orgParents; offspring = orgOffspring; - cout << "General - strong elitism\n"; - cout << "========================\n"; + std::cout << "General - strong elitism\n"; + std::cout << "========================\n"; sAdReplace(parents, offspring); - cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + std::cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << std::endl; return 1; @@ -215,9 +215,9 @@ int main(int argc, char **argv) { the_main(argc, argv); } - catch(exception& e) + catch(std::exception& e) { - cout << "Exception: " << e.what() << endl; + std::cout << "Exception: " << e.what() << std::endl; } } diff --git a/eo/test/t-eoSSGA.cpp b/eo/test/t-eoSSGA.cpp index be2f210a..d1c467e5 100644 --- a/eo/test/t-eoSSGA.cpp +++ b/eo/test/t-eoSSGA.cpp @@ -31,7 +31,7 @@ class eoMyEval : public eoEvalFunc void operator()(EOT& _eo) { - _eo.fitness(*max_element(_eo.begin(), _eo.end())); + _eo.fitness(*std::max_element(_eo.begin(), _eo.end())); } }; @@ -41,7 +41,7 @@ class Xover : public eoBinOp bool operator()(EOT& _eo, const EOT& _eo2) { unsigned point = rng.random(_eo.size()); - copy(_eo2.begin() + point, _eo2.end(), _eo.begin() + point); + std::copy(_eo2.begin() + point, _eo2.end(), _eo.begin() + point); return true; } }; diff --git a/eo/test/t-eoSelect.cpp b/eo/test/t-eoSelect.cpp index 6e2139b0..4f3078e9 100644 --- a/eo/test/t-eoSelect.cpp +++ b/eo/test/t-eoSelect.cpp @@ -15,7 +15,7 @@ struct Dummy : public EO { typedef double Type; - void printOn(ostream & _os) const + void printOn(std::ostream & _os) const { _os << " - "; EO::printOn(_os); @@ -44,15 +44,15 @@ unsigned isInPop(EOT & _indi, eoPop & _pop) } unsigned int pSize; // global variable, bouh! -string fitnessType; // yes, a global variable :-) +std::string fitnessType; // yes, a global variable :-) eoDummyPop parentsOrg; template -void testSelectMany(eoSelect & _select, string _name) +void testSelectMany(eoSelect & _select, std::string _name) { unsigned i; - cout << "\n\n" << fitnessType + _name << endl; - cout << "===============\n"; + std::cout << "\n\n" << fitnessType + _name << std::endl; + std::cout << "===============\n"; eoDummyPop parents(parentsOrg); eoDummyPop offspring(0); @@ -61,28 +61,28 @@ void testSelectMany(eoSelect & _select, string _name) _select(parents, offspring); // compute stats - vector nb(parents.size(), 0); + std::vector nb(parents.size(), 0); for (i=0; i(offspring[i], parents); if (trouve == parents.size()) // pas trouve - throw runtime_error("Pas trouve ds parents"); + throw std::runtime_error("Pas trouve ds parents"); nb[trouve]++; } // dump to file so you can plot using gnuplot - dir name is hardcoded! - string fName = "ResSelect/" + fitnessType + _name + ".select"; - ofstream os(fName.c_str()); + std::string fName = "ResSelect/" + fitnessType + _name + ".select"; + std::ofstream os(fName.c_str()); for (i=0; i " << ( (double)nb[i])/offspring.size() << endl; - os << i << " " << ( (double)nb[i])/offspring.size() << endl; + std::cout << i << " -> " << ( (double)nb[i])/offspring.size() << std::endl; + os << i << " " << ( (double)nb[i])/offspring.size() << std::endl; } } template void testSelectOne(eoSelectOne & _select, eoHowMany & _offspringRate, - eoHowMany & _fertileRate, string _name) + eoHowMany & _fertileRate, std::string _name) { eoTruncatedSelectOne truncSelect(_select, _fertileRate); eoSelectMany percSelect(truncSelect, _offspringRate); @@ -118,42 +118,42 @@ eoValueParam tournamentSizeParam = parser.createParam(unsigned(2), "to eoValueParam rankingExponentParam = parser.createParam(1.0, "rankingExponent", "Exponent for the ranking selection",'e'); double rankingExponent = rankingExponentParam.value(); - eoValueParam fitTypeParam = parser.createParam(string("linear"), "fitType", "Type of fitness (linear, exp, log, super",'f'); + eoValueParam fitTypeParam = parser.createParam(std::string("linear"), "fitType", "Type of fitness (linear, exp, log, super",'f'); fitnessType = fitTypeParam.value(); if (parser.userNeedsHelp()) { - parser.printHelp(cout); + parser.printHelp(std::cout); exit(0); } // hard-coded directory name ... system("mkdir ResSelect"); - cout << "Testing the Selections\nParents size = " << pSize + std::cout << "Testing the Selections\nParents size = " << pSize << ", offspring rate = " << oRate; - cout << " and putting rsulting files in dir ResSelect" << endl; + std::cout << " and putting rsulting files in dir ResSelect" << std::endl; // initialize parent population parentsOrg.resize(pSize); - if (fitnessType == string("linear")) + if (fitnessType == std::string("linear")) for (unsigned i=0; i& seedParam = parser.createParam(uint32(0), "seed", "Random number seed", 'S'); @@ -177,7 +177,7 @@ eoValueParam tournamentSizeParam = parser.createParam(unsigned(2), "to testSelectOne(newRankingSelect, oRate, fRate, fileName); // Exponential ranking using the perf2Worth construct - cout << "rankingExponent " << rankingExponent << endl; + std::cout << "rankingExponent " << rankingExponent << std::endl; eoRankingSelect expRankingSelect(rankingPressure,rankingExponent); sprintf(fileName,"ExpRank_%g_%g",rankingPressure, rankingExponent); testSelectOne(expRankingSelect, oRate, fRate, fileName); @@ -215,9 +215,9 @@ int main(int argc, char **argv) { the_main(argc, argv); } - catch(exception& e) + catch(std::exception& e) { - cout << "Exception: " << e.what() << endl; + std::cout << "Exception: " << e.what() << std::endl; return 1; } } diff --git a/eo/test/t-eoStateAndParser.cpp b/eo/test/t-eoStateAndParser.cpp index 62d16891..bceb192b 100644 --- a/eo/test/t-eoStateAndParser.cpp +++ b/eo/test/t-eoStateAndParser.cpp @@ -48,12 +48,12 @@ int the_main(int argc, char **argv) eoValueParam seed(time(0), "seed", "Random number seed"); // test if user entered or if default value used if (parser.isItThere(seed)) - cout << "YES\n"; + std::cout << "YES\n"; else - cout << "NO\n"; + std::cout << "NO\n"; - eoValueParam load_name("", "Load","Load",'L'); - eoValueParam save_name("", "Save","Save",'S'); + eoValueParam load_name("", "Load","Load",'L'); + eoValueParam save_name("", "Save","Save",'S'); // Register them @@ -69,7 +69,7 @@ int the_main(int argc, char **argv) parser.processParam(boundParam, "Genetic Operators"); - cout << "Bounds: " << boundParam.value() << endl; + std::cout << "Bounds: " << boundParam.value() << std::endl; eoState state; state.registerObject(parser); @@ -89,7 +89,7 @@ int the_main(int argc, char **argv) if (parser.userNeedsHelp()) { - parser.printHelp(cout); + parser.printHelp(std::cout); return 0; } @@ -112,7 +112,7 @@ int the_main(int argc, char **argv) // Save when needed if (save_name.value() != "") { - string file_name = save_name.value(); + std::string file_name = save_name.value(); save_name.value() = ""; // so that it does not appear in the parser section of the state file state.save(file_name); } @@ -120,7 +120,7 @@ int the_main(int argc, char **argv) for (int i = 0; i < 100; ++i) rng.rand(); - cout << "a random number is " << rng.random(1024) << endl;; + std::cout << "a random number is " << rng.random(1024) << std::endl;; return 1; } @@ -131,9 +131,9 @@ int main(int argc, char **argv) { the_main(argc, argv); } - catch(exception& e) + catch(std::exception& e) { - cout << "Exception: " << e.what() << endl; + std::cout << "Exception: " << e.what() << std::endl; } } diff --git a/eo/test/t-eoSymreg.cpp b/eo/test/t-eoSymreg.cpp index 226b1a73..f83f3aaa 100644 --- a/eo/test/t-eoSymreg.cpp +++ b/eo/test/t-eoSymreg.cpp @@ -194,7 +194,7 @@ private : template void print_best(eoPop& pop) { - cout << endl; + std::cout << std::endl; FitnessType best = pop[0].fitness(); int index = 0; @@ -207,13 +207,13 @@ void print_best(eoPop& pop) } } - cout << "\t"; + std::cout << "\t"; string str; pop[index].apply(str); - cout << str.c_str(); - cout << endl << "RMS Error = " << pop[index].fitness() << endl; + std::cout << str.c_str(); + std::cout << std::endl << "RMS Error = " << pop[index].fitness() << std::endl; } int main() @@ -274,7 +274,7 @@ int main() // GP generation eoEasyEA gp(checkPoint, eval, select, transform, replace); - cout << "Initialization done" << endl; + std::cout << "Initialization done" << std::endl; print_best(pop); @@ -282,9 +282,9 @@ int main() { gp(pop); } - catch (exception& e) + catch (std::exception& e) { - cout << "exception: " << e.what() << endl;; + std::cout << "exception: " << e.what() << std::endl;; exit(EXIT_FAILURE); } diff --git a/eo/test/t-eoUniform.cpp b/eo/test/t-eoUniform.cpp index 5e14a728..04c23e5c 100644 --- a/eo/test/t-eoUniform.cpp +++ b/eo/test/t-eoUniform.cpp @@ -2,7 +2,7 @@ // t-eouniform //----------------------------------------------------------------------------- -#include // cout +#include // std::cout #include // ostrstream, istrstream #include // eoBin @@ -12,9 +12,9 @@ main() { eoUniform u1(-2.5,3.5); eoUniform u2(0.003, 0 ); eoUniform u3( 10000U, 10000000U); - cout << "u1\t\tu2\t\tu3" << endl; + std::cout << "u1\t\tu2\t\tu3" << std::endl; for ( unsigned i = 0; i < 100; i ++) { - cout << u1() << "\t" << u2() << "\t" << u3() << endl; + std::cout << u1() << "\t" << u2() << "\t" << u3() << std::endl; } } diff --git a/eo/test/t-eoVector.cpp b/eo/test/t-eoVector.cpp index 759414c4..8554b3eb 100644 --- a/eo/test/t-eoVector.cpp +++ b/eo/test/t-eoVector.cpp @@ -25,7 +25,7 @@ */ //----------------------------------------------------------------------------- -#include // cout +#include // std::cout #include // ostrstream, istrstream #include @@ -59,11 +59,11 @@ int main() init(chrom); - cout << chrom << endl; + std::cout << chrom << std::endl; Chrom2 chrom2(chrom); - cout << chrom2 << endl; + std::cout << chrom2 << std::endl; // eoInitVariableLength initvar( diff --git a/eo/test/t-eoVirus.cpp b/eo/test/t-eoVirus.cpp index 5ad4067f..612906a9 100644 --- a/eo/test/t-eoVirus.cpp +++ b/eo/test/t-eoVirus.cpp @@ -23,7 +23,7 @@ */ //----------------------------------------------------------------------------- -#include // cout +#include // std::cout #include // ostrstream, istrstream #include // general EO #include "../contrib/MGE/VirusOp.h" @@ -47,30 +47,30 @@ int main() Chrom chrom(SIZE), chrom2(SIZE); chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); - cout << chrom << endl; - cout << chrom2 << endl; + std::cout << chrom << std::endl; + std::cout << chrom2 << std::endl; // Virus Mutation VirusBitFlip vf; unsigned i; for ( i = 0; i < 10; i++ ) { vf( chrom ); - cout << chrom << endl; + std::cout << chrom << std::endl; } // Chrom Mutation - cout << "Chrom mutation--------" << endl; + std::cout << "Chrom mutation--------" << std::endl; VirusMutation vm; for ( i = 0; i < 10; i++ ) { vm( chrom ); - cout << chrom << endl; + std::cout << chrom << std::endl; } // Chrom Transmision - cout << "Chrom transmission--------" << endl; + std::cout << "Chrom transmission--------" << std::endl; VirusTransmission vt; vt( chrom2, chrom ); - cout << chrom2 << endl; + std::cout << chrom2 << std::endl; return 0; diff --git a/eo/test/t-eobin.cpp b/eo/test/t-eobin.cpp index 691f86b4..220df5fa 100644 --- a/eo/test/t-eobin.cpp +++ b/eo/test/t-eobin.cpp @@ -23,7 +23,7 @@ */ //----------------------------------------------------------------------------- -#include // cout +#include // std::cout #include // ostrstream, istrstream #include // general EO #include // bitstring representation & operators @@ -45,91 +45,91 @@ void main_function() Chrom chrom(SIZE), chrom2; chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); - cout << "chrom: " << chrom << endl; + std::cout << "chrom: " << chrom << std::endl; chrom[0] = chrom[SIZE - 1] = true; chrom.fitness(binary_value(chrom)); - cout << "chrom: " << chrom << endl; + std::cout << "chrom: " << chrom << std::endl; chrom[0] = chrom[SIZE - 1] = false; chrom.fitness(binary_value(chrom)); - cout << "chrom: " << chrom << endl; + std::cout << "chrom: " << chrom << std::endl; chrom[0] = chrom[SIZE - 1] = true; chrom.fitness(binary_value(chrom)); - cout << "chrom.className() = " << chrom.className() << endl; + std::cout << "chrom.className() = " << chrom.className() << std::endl; - cout << "chrom: " << chrom << endl - << "chrom2: " << chrom2 << endl; + std::cout << "chrom: " << chrom << std::endl + << "chrom2: " << chrom2 << std::endl; char buff[1024]; - ostrstream os(buff, 1024); + std::ostrstream os(buff, 1024); os << chrom; - istrstream is(os.str()); + std::istrstream is(os.str()); is >> chrom2; chrom.fitness(binary_value(chrom2)); - cout << "\nTesting reading, writing\n"; - cout << "chrom: " << chrom << "\nchrom2: " << chrom2 << '\n'; + std::cout << "\nTesting reading, writing\n"; + std::cout << "chrom: " << chrom << "\nchrom2: " << chrom2 << '\n'; - fill(chrom.begin(), chrom.end(), false); - cout << "--------------------------------------------------" - << endl << "eoMonOp's aplied to .......... " << chrom << endl; + std::fill(chrom.begin(), chrom.end(), false); + std::cout << "--------------------------------------------------" + << std::endl << "eoMonOp's aplied to .......... " << chrom << std::endl; eoInitFixedLength random(chrom.size(), gen); random(chrom); chrom.fitness(binary_value(chrom)); - cout << "after eoBinRandom ............ " << chrom << endl; + std::cout << "after eoBinRandom ............ " << chrom << std::endl; eoOneBitFlip bitflip; bitflip(chrom); chrom.fitness(binary_value(chrom)); - cout << "after eoBitFlip .............. " << chrom << endl; + std::cout << "after eoBitFlip .............. " << chrom << std::endl; eoBitMutation mutation(0.5); mutation(chrom); chrom.fitness(binary_value(chrom)); - cout << "after eoBinMutation(0.5) ..... " << chrom << endl; + std::cout << "after eoBinMutation(0.5) ..... " << chrom << std::endl; eoBitInversion inversion; inversion(chrom); chrom.fitness(binary_value(chrom)); - cout << "after eoBinInversion ......... " << chrom << endl; + std::cout << "after eoBinInversion ......... " << chrom << std::endl; eoBitNext next; next(chrom); chrom.fitness(binary_value(chrom)); - cout << "after eoBinNext .............. " << chrom << endl; + std::cout << "after eoBinNext .............. " << chrom << std::endl; eoBitPrev prev; prev(chrom); chrom.fitness(binary_value(chrom)); - cout << "after eoBinPrev .............. " << chrom << endl; + std::cout << "after eoBinPrev .............. " << chrom << std::endl; - fill(chrom.begin(), chrom.end(), false); chrom.fitness(binary_value(chrom)); - fill(chrom2.begin(), chrom2.end(), true); chrom2.fitness(binary_value(chrom2)); - cout << "--------------------------------------------------" - << endl << "eoBinOp's aplied to ... " - << chrom << " " << chrom2 << endl; + std::fill(chrom.begin(), chrom.end(), false); chrom.fitness(binary_value(chrom)); + std::fill(chrom2.begin(), chrom2.end(), true); chrom2.fitness(binary_value(chrom2)); + std::cout << "--------------------------------------------------" + << std::endl << "eoBinOp's aplied to ... " + << chrom << " " << chrom2 << std::endl; eo1PtBitXover xover; - fill(chrom.begin(), chrom.end(), false); - fill(chrom2.begin(), chrom2.end(), true); + std::fill(chrom.begin(), chrom.end(), false); + std::fill(chrom2.begin(), chrom2.end(), true); xover(chrom, chrom2); chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); - cout << "eoBinCrossover ........ " << chrom << " " << chrom2 << endl; + std::cout << "eoBinCrossover ........ " << chrom << " " << chrom2 << std::endl; for (i = 1; i < SIZE; i++) { eoNPtsBitXover nxover(i); - fill(chrom.begin(), chrom.end(), false); - fill(chrom2.begin(), chrom2.end(), true); + std::fill(chrom.begin(), chrom.end(), false); + std::fill(chrom2.begin(), chrom2.end(), true); nxover(chrom, chrom2); chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); - cout << "eoBinNxOver(" << i << ") ........ " - << chrom << " " << chrom2 << endl; + std::cout << "eoBinNxOver(" << i << ") ........ " + << chrom << " " << chrom2 << std::endl; } for (i = 1; i < SIZE / 2; i++) for (j = 1; j < SIZE / 2; j++) { eoBitGxOver gxover(i, j); - fill(chrom.begin(), chrom.end(), false); - fill(chrom2.begin(), chrom2.end(), true); + std::fill(chrom.begin(), chrom.end(), false); + std::fill(chrom2.begin(), chrom2.end(), true); gxover(chrom, chrom2); chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); - cout << "eoBinGxOver(" << i << ", " << j << ") ..... " - << chrom << " " << chrom2 << endl; + std::cout << "eoBinGxOver(" << i << ", " << j << ") ..... " + << chrom << " " << chrom2 << std::endl; } // test SGA algorithm @@ -163,9 +163,9 @@ void main_function() pop.sort(); - cout << "Population " << pop << endl; + std::cout << "Population " << pop << std::endl; - cout << "\nBest: " << pop[0].fitness() << '\n'; + std::cout << "\nBest: " << pop[0].fitness() << '\n'; /* @@ -174,16 +174,16 @@ void main_function() // Check multiOps eoMultiMonOp mOp( &next ); mOp.adOp( &bitflip ); - cout << "before multiMonOp............ " << chrom << endl; + std::cout << "before multiMonOp............ " << chrom << std::endl; mOp( chrom ); - cout << "after multiMonOp .............. " << chrom << endl; + std::cout << "after multiMonOp .............. " << chrom << std::endl; eoBinGxOver gxover(2, 4); eoMultiBinOp mbOp( &gxover ); mOp.adOp( &bitflip ); - cout << "before multiBinOp............ " << chrom << " " << chrom2 << endl; + std::cout << "before multiBinOp............ " << chrom << " " << chrom2 << std::endl; mbOp( chrom, chrom2 ); - cout << "after multiBinOp .............. " << chrom << " " << chrom2 < bitflip; eoBinCrossover xover; @@ -77,9 +77,9 @@ main() // reevaluation of fitness for_each(pop.begin(), pop.end(), BinaryValue()); - cout << "new population:" << endl; + std::cout << "new population:" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << pop[i] << " " << pop[i].fitness() << endl; + std::cout << pop[i] << " " << pop[i].fitness() << std::endl; return 0; } diff --git a/eo/test/t-eofitness.cpp b/eo/test/t-eofitness.cpp index 33068781..1999e9fd 100644 --- a/eo/test/t-eofitness.cpp +++ b/eo/test/t-eofitness.cpp @@ -5,7 +5,7 @@ #include // time #include // srand, rand -#include // cout +#include // std::cout #include @@ -21,35 +21,35 @@ int test_fitness(Fitness a, Fitness b) // Fitness a = aval; //static_cast(rand()) / RAND_MAX; // Fitness b = bval; //static_cast(rand()) / RAND_MAX; - cout.precision(2); + std::cout.precision(2); unsigned repeat = 2; while (repeat--) { - cout << "------------------------------------------------------" << endl; - cout << "testing < "; + std::cout << "------------------------------------------------------" << std::endl; + std::cout << "testing < "; if (a < b) - cout << a << " < " << b << " is true" << endl; + std::cout << a << " < " << b << " is true" << std::endl; else - cout << a << " < " << b << " is false" < "; + std::cout << "testing > "; if (a > b) - cout << a << " > " << b << " is true" << endl; + std::cout << a << " > " << b << " is true" << std::endl; else - cout << a << " > " << b << " is false" < " << b << " is false" < i) - cout << pop[i] << " " << pop[i].fitness() << " \t"; + std::cout << pop[i] << " " << pop[i].fitness() << " \t"; else - cout << "\t\t"; + std::cout << "\t\t"; if (pop2.size() > i) - cout << pop2[i] << " " << pop2[i].fitness(); - cout << endl; + std::cout << pop2[i] << " " << pop2[i].fitness(); + std::cout << std::endl; } eoInclusion inclusion(0.75); @@ -71,22 +71,22 @@ main() pop5 = pop2; inclusion3(pop, pop5); - cout << endl - << "0.75 \t\t1.0 \t\t1.5" << endl - << "---- \t\t--- \t\t---" << endl; + std::cout << std::endl + << "0.75 \t\t1.0 \t\t1.5" << std::endl + << "---- \t\t--- \t\t---" << std::endl; for (i = 0; i < pop5.size(); i++) { if (pop3.size() > i) - cout << pop3[i] << " " << pop3[i].fitness() << " \t"; + std::cout << pop3[i] << " " << pop3[i].fitness() << " \t"; else - cout << " \t\t"; + std::cout << " \t\t"; if (pop4.size() > i) - cout << pop4[i] << " " << pop4[i].fitness() << " \t"; + std::cout << pop4[i] << " " << pop4[i].fitness() << " \t"; else - cout << " \t\t"; + std::cout << " \t\t"; if (pop5.size() > i) - cout << pop5[i] << " " << pop5[i].fitness(); - cout << endl; + std::cout << pop5[i] << " " << pop5[i].fitness(); + std::cout << std::endl; } } } diff --git a/eo/test/t-eoinsertion.cpp b/eo/test/t-eoinsertion.cpp index 993c228f..051ca821 100644 --- a/eo/test/t-eoinsertion.cpp +++ b/eo/test/t-eoinsertion.cpp @@ -52,18 +52,18 @@ main() pop2.push_back(chrom); } - cout << "--------------------------------------------------" << endl - << "breeders \tpop" << endl - << "--------------------------------------------------" << endl; + std::cout << "--------------------------------------------------" << std::endl + << "breeders \tpop" << std::endl + << "--------------------------------------------------" << std::endl; for (i = 0; i < max(pop.size(), pop2.size()); i++) { if (pop.size() > i) - cout << pop[i] << " " << pop[i].fitness() << " \t"; + std::cout << pop[i] << " " << pop[i].fitness() << " \t"; else - cout << "\t\t"; + std::cout << "\t\t"; if (pop2.size() > i) - cout << pop2[i] << " " << pop2[i].fitness(); - cout << endl; + std::cout << pop2[i] << " " << pop2[i].fitness(); + std::cout << std::endl; } eoInsertion insertion(0.75); @@ -81,22 +81,22 @@ main() pop5 = pop2; insertion3(popx, pop5); - cout << endl - << "0.75 \t\t1.0 \t\t1.5" << endl - << "---- \t\t--- \t\t---" << endl; + std::cout << std::endl + << "0.75 \t\t1.0 \t\t1.5" << std::endl + << "---- \t\t--- \t\t---" << std::endl; for (i = 0; i < pop5.size(); i++) { if (pop3.size() > i) - cout << pop3[i] << " " << pop3[i].fitness() << " \t"; + std::cout << pop3[i] << " " << pop3[i].fitness() << " \t"; else - cout << " \t\t"; + std::cout << " \t\t"; if (pop4.size() > i) - cout << pop4[i] << " " << pop4[i].fitness() << " \t"; + std::cout << pop4[i] << " " << pop4[i].fitness() << " \t"; else - cout << " \t\t"; + std::cout << " \t\t"; if (pop5.size() > i) - cout << pop5[i] << " " << pop5[i].fitness(); - cout << endl; + std::cout << pop5[i] << " " << pop5[i].fitness(); + std::cout << std::endl; } } } diff --git a/eo/test/t-eolottery.cpp b/eo/test/t-eolottery.cpp index 6fd97d2f..e0392638 100644 --- a/eo/test/t-eolottery.cpp +++ b/eo/test/t-eolottery.cpp @@ -35,18 +35,18 @@ main() pop.push_back(chrom); } - cout << "original population:" << endl; + std::cout << "original population:" << std::endl; sort(pop.begin(), pop.end()); for (i = 0; i < pop.size(); i++) - cout << pop[i] << " " << pop[i].fitness() << endl; + std::cout << pop[i] << " " << pop[i].fitness() << std::endl; eoLottery lottery; lottery(pop, pop2); - cout << "selected by lottery population:" << endl; + std::cout << "selected by lottery population:" << std::endl; sort(pop2.begin(), pop2.end()); for (i = 0; i < pop2.size(); i++) - cout << pop2[i] << " " << pop2[i].fitness() << endl; + std::cout << pop2[i] << " " << pop2[i].fitness() << std::endl; return 0; } diff --git a/eo/test/t-eoproblem.cpp b/eo/test/t-eoproblem.cpp index e7c36666..066efb62 100644 --- a/eo/test/t-eoproblem.cpp +++ b/eo/test/t-eoproblem.cpp @@ -5,7 +5,7 @@ #include // time #include // fabs -#include // cout +#include // std::cout #include // eoVector, eoProblem //----------------------------------------------------------------------------- @@ -14,9 +14,9 @@ typedef eoVector Chrom; //----------------------------------------------------------------------------- -ostream& operator<<(ostream& os, const Chrom& chrom) +std::ostream& operator<<(std::ostream& os, const Chrom& chrom) { - copy(chrom.begin(), chrom.end(), ostream_iterator(os)); + copy(chrom.begin(), chrom.end(), std::ostream_iterator(os)); return os; } @@ -46,8 +46,8 @@ int main() chrom[0] = ((float)rand()) / ((float)RAND_MAX); chrom.fitness(easy(chrom)); - cout << "chrom = " << chrom << endl - << "chrom.fitness() = " << chrom.fitness() << endl; + std::cout << "chrom = " << chrom << std::endl + << "chrom.fitness() = " << chrom.fitness() << std::endl; return 0; } diff --git a/eo/test/t-selectOne.cpp b/eo/test/t-selectOne.cpp index 56da601c..e401188e 100644 --- a/eo/test/t-selectOne.cpp +++ b/eo/test/t-selectOne.cpp @@ -63,24 +63,24 @@ main() } // print population - cout << "population:" << endl; + std::cout << "population:" << std::endl; for (i = 0; i < pop.size(); ++i) - cout << pop[i] << " " << pop[i].fitness() << endl; + std::cout << pop[i] << " " << pop[i].fitness() << std::endl; // Declare 1-selectors eoUniformSelect uSelect; Chrom aChrom; aChrom = uSelect( pop ); - cout << "Uniform Select " << aChrom << " " << aChrom.fitness() << endl; + std::cout << "Uniform Select " << aChrom << " " << aChrom.fitness() << std::endl; eoStochTournament sSelect(0.7); aChrom = sSelect( pop ); - cout << "Stochastic Tournament " << aChrom << " " << aChrom.fitness() << endl; + std::cout << "Stochastic Tournament " << aChrom << " " << aChrom.fitness() << std::endl; eoDetTournament dSelect(3); aChrom = dSelect( pop ); - cout << "Deterministic Tournament " << aChrom << " " << aChrom.fitness() << endl; + std::cout << "Deterministic Tournament " << aChrom << " " << aChrom.fitness() << std::endl; return 0; } diff --git a/eo/tutorial/Lesson1/FirstBitGA.cpp b/eo/tutorial/Lesson1/FirstBitGA.cpp index 710f9b78..4e7ea1ab 100644 --- a/eo/tutorial/Lesson1/FirstBitGA.cpp +++ b/eo/tutorial/Lesson1/FirstBitGA.cpp @@ -15,6 +15,9 @@ #include #include +// Use functions from namespace std +using namespace std; + // REPRESENTATION //----------------------------------------------------------------------------- // define your individuals diff --git a/eo/tutorial/Lesson1/FirstRealGA.cpp b/eo/tutorial/Lesson1/FirstRealGA.cpp index 74ed459b..76556882 100644 --- a/eo/tutorial/Lesson1/FirstRealGA.cpp +++ b/eo/tutorial/Lesson1/FirstRealGA.cpp @@ -15,6 +15,9 @@ #include #include +// Use functions from namespace std +using namespace std; + // REPRESENTATION //----------------------------------------------------------------------------- // define your individuals diff --git a/eo/tutorial/Lesson1/exercise1.3.cpp b/eo/tutorial/Lesson1/exercise1.3.cpp index 89e8cc54..d2702ad1 100644 --- a/eo/tutorial/Lesson1/exercise1.3.cpp +++ b/eo/tutorial/Lesson1/exercise1.3.cpp @@ -22,6 +22,8 @@ // define your individuals typedef eoBit Indi; // A bitstring with fitness double +using namespace std; + //----------------------------------------------------------------------------- /** a simple fitness function that computes the number of ones of a bitstring @param _indi A biststring individual diff --git a/eo/tutorial/Lesson2/FirstBitEA.cpp b/eo/tutorial/Lesson2/FirstBitEA.cpp index 08eb2b99..f5ca1afa 100644 --- a/eo/tutorial/Lesson2/FirstBitEA.cpp +++ b/eo/tutorial/Lesson2/FirstBitEA.cpp @@ -15,6 +15,9 @@ #include #include +// Use functions from namespace std +using namespace std; + // REPRESENTATION //----------------------------------------------------------------------------- // define your individuals diff --git a/eo/tutorial/Lesson2/FirstRealEA.cpp b/eo/tutorial/Lesson2/FirstRealEA.cpp index b0ceb446..1f9686f9 100644 --- a/eo/tutorial/Lesson2/FirstRealEA.cpp +++ b/eo/tutorial/Lesson2/FirstRealEA.cpp @@ -20,6 +20,9 @@ // define your individuals typedef eoReal Indi; +// Use functions from namespace std +using namespace std; + // EVALFUNC //----------------------------------------------------------------------------- // a simple fitness function that computes the euclidian norm of a real vector diff --git a/eo/tutorial/Lesson2/binary_value.h b/eo/tutorial/Lesson2/binary_value.h index a31c0864..f2f5d6ca 100644 --- a/eo/tutorial/Lesson2/binary_value.h +++ b/eo/tutorial/Lesson2/binary_value.h @@ -7,7 +7,7 @@ @param _chrom A binary chromosome */ // INIT -double binary_value(const vector& _chrom) +double binary_value(const std::vector& _chrom) { double sum = 0; for (unsigned i = 0; i < _chrom.size(); i++) diff --git a/eo/tutorial/Lesson2/exercise2.3.cpp b/eo/tutorial/Lesson2/exercise2.3.cpp index 70636b56..e07dd768 100644 --- a/eo/tutorial/Lesson2/exercise2.3.cpp +++ b/eo/tutorial/Lesson2/exercise2.3.cpp @@ -31,6 +31,8 @@ typedef eoBit Indi; // A bitstring with fitness double // GENERAL //----------------------------------------------------------------------------- +using namespace std; + void main_function(int argc, char **argv) { // PARAMETRES diff --git a/eo/tutorial/Lesson3/SecondBitEA.cpp b/eo/tutorial/Lesson3/SecondBitEA.cpp index ab83faa2..7a7bbb0c 100644 --- a/eo/tutorial/Lesson3/SecondBitEA.cpp +++ b/eo/tutorial/Lesson3/SecondBitEA.cpp @@ -16,6 +16,9 @@ #include #include +// Use functions from namespace std +using namespace std; + // EVAL #include "binary_value.h" diff --git a/eo/tutorial/Lesson3/SecondRealEA.cpp b/eo/tutorial/Lesson3/SecondRealEA.cpp index 1128d1c6..df2bed9a 100644 --- a/eo/tutorial/Lesson3/SecondRealEA.cpp +++ b/eo/tutorial/Lesson3/SecondRealEA.cpp @@ -22,6 +22,9 @@ // define your individuals typedef eoReal Indi; +// Use functions from namespace std +using namespace std; + // EVALFUNC //----------------------------------------------------------------------------- // a simple fitness function that computes the euclidian norm of a real vector diff --git a/eo/tutorial/Lesson3/binary_value.h b/eo/tutorial/Lesson3/binary_value.h index a31c0864..f2f5d6ca 100644 --- a/eo/tutorial/Lesson3/binary_value.h +++ b/eo/tutorial/Lesson3/binary_value.h @@ -7,7 +7,7 @@ @param _chrom A binary chromosome */ // INIT -double binary_value(const vector& _chrom) +double binary_value(const std::vector& _chrom) { double sum = 0; for (unsigned i = 0; i < _chrom.size(); i++) diff --git a/eo/tutorial/Lesson3/exercise3.1.cpp b/eo/tutorial/Lesson3/exercise3.1.cpp index de51f750..cde1cc53 100644 --- a/eo/tutorial/Lesson3/exercise3.1.cpp +++ b/eo/tutorial/Lesson3/exercise3.1.cpp @@ -25,6 +25,8 @@ // define your genotype and fitness types typedef eoBit Indi; +using namespace std; + // the main_function: nothing changed(!), except variable initialization void main_function(int argc, char **argv) { diff --git a/eo/tutorial/ParadisEO/Lesson1/IslandBitEA.cpp b/eo/tutorial/ParadisEO/Lesson1/IslandBitEA.cpp index 2b2b1024..97adb8e8 100644 --- a/eo/tutorial/ParadisEO/Lesson1/IslandBitEA.cpp +++ b/eo/tutorial/ParadisEO/Lesson1/IslandBitEA.cpp @@ -5,6 +5,8 @@ typedef eoBit Indi; // A bitstring with fitness double #include "binary_value.h" +using namespace std; + void main_function(int argc, char ** argv) { // Some parameters ... diff --git a/eo/tutorial/ParadisEO/Lesson1/IslandBitEA1.cpp b/eo/tutorial/ParadisEO/Lesson1/IslandBitEA1.cpp index 17d47d21..04114ec0 100644 --- a/eo/tutorial/ParadisEO/Lesson1/IslandBitEA1.cpp +++ b/eo/tutorial/ParadisEO/Lesson1/IslandBitEA1.cpp @@ -5,6 +5,8 @@ typedef eoBit Indi; // A bitstring with fitness double #include "binary_value.h" +using namespace std; + void main_function(int argc, char ** argv) { // Some parameters ... diff --git a/eo/tutorial/ParadisEO/Lesson1/IslandBitEA2.cpp b/eo/tutorial/ParadisEO/Lesson1/IslandBitEA2.cpp index 98a9b2b5..5b616a30 100644 --- a/eo/tutorial/ParadisEO/Lesson1/IslandBitEA2.cpp +++ b/eo/tutorial/ParadisEO/Lesson1/IslandBitEA2.cpp @@ -5,6 +5,8 @@ typedef eoBit Indi; // A bitstring with fitness double #include "binary_value.h" +using namespace std; + void main_function(int argc, char ** argv) { // Some parameters ... diff --git a/eo/tutorial/ParadisEO/Lesson1/binary_value.h b/eo/tutorial/ParadisEO/Lesson1/binary_value.h index a31c0864..f2f5d6ca 100644 --- a/eo/tutorial/ParadisEO/Lesson1/binary_value.h +++ b/eo/tutorial/ParadisEO/Lesson1/binary_value.h @@ -7,7 +7,7 @@ @param _chrom A binary chromosome */ // INIT -double binary_value(const vector& _chrom) +double binary_value(const std::vector& _chrom) { double sum = 0; for (unsigned i = 0; i < _chrom.size(); i++)