diff --git a/eo/src/do/make_pop.h b/eo/src/do/make_pop.h index d8ae0766..52892be1 100644 --- a/eo/src/do/make_pop.h +++ b/eo/src/do/make_pop.h @@ -27,7 +27,7 @@ #ifndef _make_pop_h #define _make_pop_h -#include // for time(0) for random seeding +#include // for time(0) for random seeding #include #include #include diff --git a/eo/src/eoDistribUpdater.h b/eo/src/eoDistribUpdater.h index 88f6d24b..1749994f 100644 --- a/eo/src/eoDistribUpdater.h +++ b/eo/src/eoDistribUpdater.h @@ -42,6 +42,9 @@ template class eoDistribUpdater : public eoBF &, eoPop &, void> -{}; +{ +public: + virtual void operator()(eoDistribution &, eoPop &)=0; +}; #endif diff --git a/eo/src/eoSelectOne.h b/eo/src/eoSelectOne.h index 29857034..34b0782f 100644 --- a/eo/src/eoSelectOne.h +++ b/eo/src/eoSelectOne.h @@ -37,7 +37,11 @@ @see eoSelectMany, eoSelectRandom, eoDetTournament, eoStochTournament, eoProportional */ +#ifdef _MSC_VER +template +#else template +#endif class eoSelectOne : public eoUF&, const EOT&> { public : diff --git a/eo/src/es/eoEsChromInit.h b/eo/src/es/eoEsChromInit.h index 39939740..9e80679a 100644 --- a/eo/src/es/eoEsChromInit.h +++ b/eo/src/es/eoEsChromInit.h @@ -99,10 +99,10 @@ private : // Adaptive mutation through a whole correlation matrix void create_self_adapt(eoEsFull& result) { - unsigned theSize = eoRealInitBounded::size(); + unsigned i, theSize = eoRealInitBounded::size(); result.stdevs.resize(theSize); - for (unsigned i = 0; i < theSize; ++i) + for (i = 0; i < theSize; ++i) { // should we scale sigmas to the corresponding object variable range? result.stdevs[i] = sigma; @@ -110,7 +110,7 @@ private : // nb of rotation angles: N*(N-1)/2 (in general!) result.correlations.resize(theSize*(theSize - 1) / 2); - for (unsigned i = 0; i < result.correlations.size(); ++i) + for (i = 0; i < result.correlations.size(); ++i) { // uniform in [-PI, PI) result.correlations[i] = rng.uniform(2 * M_PI) - M_PI; diff --git a/eo/src/ga/eoPBILAdditive.h b/eo/src/ga/eoPBILAdditive.h index 577c2328..9f32859b 100644 --- a/eo/src/ga/eoPBILAdditive.h +++ b/eo/src/ga/eoPBILAdditive.h @@ -1,7 +1,7 @@ // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- //----------------------------------------------------------------------------- -// eoPBILDistrib.h +// eoPBILAdditive.h // (c) Marc Schoenauer, Maarten Keijzer, 2001 /* This library is free software; you can redistribute it and/or diff --git a/eo/src/ga/eoPBILDistrib.h b/eo/src/ga/eoPBILDistrib.h index 9d0558d0..96a781bc 100644 --- a/eo/src/ga/eoPBILDistrib.h +++ b/eo/src/ga/eoPBILDistrib.h @@ -61,9 +61,6 @@ public: _eo.invalidate(); // DO NOT FORGET!!! } - /** update method - still PURE VIRTUAL */ - // virtual void update(eoPop&) = 0; // update from a population - /** Accessor to the genome size */ unsigned Size() {return genomeSize;} diff --git a/eo/src/ga/eoPBILOrg.h b/eo/src/ga/eoPBILOrg.h index d4cf8c05..da949064 100644 --- a/eo/src/ga/eoPBILOrg.h +++ b/eo/src/ga/eoPBILOrg.h @@ -1,7 +1,7 @@ // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- //----------------------------------------------------------------------------- -// eoPBILDistrib.h +// eoPBILOrg.h // (c) Marc Schoenauer, Maarten Keijzer, 2001 /* This library is free software; you can redistribute it and/or @@ -31,7 +31,7 @@ /** * Distribution Class for PBIL algorithm - * (Population-Based Incremental Learning, Baluja and Caruana 96) + * (Population-Based Incremental Learning, Baluja and Caruana 95) * * This class implements the update rule from the original paper: * diff --git a/eo/src/ga/make_PBILdistrib.h b/eo/src/ga/make_PBILdistrib.h index c662b9c0..2698cc34 100644 --- a/eo/src/ga/make_PBILdistrib.h +++ b/eo/src/ga/make_PBILdistrib.h @@ -53,10 +53,22 @@ eoPBILDistrib & do_make_PBILdistrib(eoParser & _parser, eoState& _state, E if (seedParam.value() == 0) seedParam.value() = time(0); - // the representation dependent stuff - unsigned chromSize = _parser.createParam(unsigned(10), "chromSize", "The length of the bitstrings", 'n',"Algorithm").value(); - - eoPBILDistrib * ptDistrib = new eoPBILDistrib(chromSize); + // chromosome size: + unsigned theSize; + // but it might have been already read in the definition fo the performance + eoParam* ptParam = _parser.getParamWithLongName(string("chromSize")); + + if (!ptParam) // not already defined: read it here + { + theSize = _parser.createParam(unsigned(10), "chromSize", "The length of the bitstrings", 'n',"Problem").value(); + } + else // it was read before, get its value + { + eoValueParam* ptChromSize = dynamic_cast*>(ptParam); + theSize = ptChromSize->value(); + } + + eoPBILDistrib * ptDistrib = new eoPBILDistrib(theSize); _state.storeFunctor(ptDistrib); // now the initialization: read a previously saved distribution, or random diff --git a/eo/src/ga/make_genotype_ga.h b/eo/src/ga/make_genotype_ga.h index 16cef294..f162328b 100644 --- a/eo/src/ga/make_genotype_ga.h +++ b/eo/src/ga/make_genotype_ga.h @@ -63,11 +63,11 @@ eoInit & do_make_genotype(eoParser& _parser, eoState& _state, EOT) // for bitstring, only thing needed is the 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(string("chromSize")); if (!ptParam) // not already defined: read it here { - theSize = _parser.createParam(unsigned(10), "ChromSize", "The length of the bitstrings", 'n',"Problem").value(); + theSize = _parser.createParam(unsigned(10), "chromSize", "The length of the bitstrings", 'n',"Problem").value(); } else // it was read before, get its value { diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index 47e68027..c991b3a7 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -239,16 +239,16 @@ template <> void eoValueParam > >::setValue(std::string _value) { std::istrstream is(_value.c_str()); - unsigned sz; + unsigned i,j,sz; is >> sz; repValue.resize(sz); - for (unsigned i = 0; i < repValue.size(); ++i) + for (i = 0; i < repValue.size(); ++i) { unsigned sz2; is >> sz2; repValue[i].resize(sz2); - for (unsigned j = 0; j < sz2; ++j) + for (j = 0; j < sz2; ++j) { is >> repValue[i][j]; } diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index 5877ab54..71d6d575 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -82,8 +82,12 @@ public : Average fitness of a population, fitness can be a double, eoMinimizingFitness, eoMaximizingFitness or eoParetoFitness. In the case of pareto optimization it will calculate the average of each objective. */ -template -class eoAverageStat : public eoStat + +#ifdef _MSC_VER +template class eoAverageStat : public eoStat +#else +template class eoAverageStat : public eoStat +#endif { public : typedef typename EOT::Fitness fitness_type; @@ -99,7 +103,11 @@ public : virtual void operator()(const eoPop& _pop) { +#ifdef _MSC_VER + doit(_pop, EOT::Fitness()); // specializations for scalar and vector +#else doit(_pop, typename EOT::Fitness()); // specializations for scalar and vector +#endif } private : @@ -248,17 +256,22 @@ public : /** Best fitness in the population */ +#ifdef _MSC_VER +template +class eoBestFitnessStat : public eoStat +#else template class eoBestFitnessStat : public eoStat +#endif { public : typedef typename EOT::Fitness Fitness; - eoBestFitnessStat(std::string _description = "Best ") : eoStat(typename EOT::Fitness(), _description) {} + eoBestFitnessStat(std::string _description = "Best ") : eoStat(Fitness(), _description) {} void operator()(const eoPop& _pop) { - doit(_pop, typename EOT::Fitness()); + doit(_pop, Fitness()); } private : diff --git a/eo/test/t-eoESAll.cpp b/eo/test/t-eoESAll.cpp index 7afa2aef..cd6436e7 100644 --- a/eo/test/t-eoESAll.cpp +++ b/eo/test/t-eoESAll.cpp @@ -116,7 +116,7 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state) // initialize the population - and evaluate // yes, this is representation indepedent once you have an eoInit eoPop& pop = make_pop(_parser, _state, init); - apply(eval, pop); + apply(eval, pop); // stopping criteria eoContinue & term = make_continue(_parser, _state, eval); diff --git a/eo/test/t-eoGA.cpp b/eo/test/t-eoGA.cpp index 9fa1fd66..31a22ae3 100644 --- a/eo/test/t-eoGA.cpp +++ b/eo/test/t-eoGA.cpp @@ -52,7 +52,7 @@ int main(int argc, char* argv[]) //// GO /////// // evaluate intial population AFTER help and status in case it takes time - apply(eval, pop); + apply(eval, pop); // print it out cout << "Initial Population\n"; pop.sortedPrintOn(cout); diff --git a/eo/test/t-eoReal.cpp b/eo/test/t-eoReal.cpp index 09e7ced5..8002136c 100644 --- a/eo/test/t-eoReal.cpp +++ b/eo/test/t-eoReal.cpp @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) //// GO /////// // evaluate intial population AFTER help and status in case it takes time - apply(eval, pop); + apply(eval, pop); // print it out cout << "Initial Population\n"; pop.sortedPrintOn(cout);