diff --git a/eo/src/eoFunctorStore.cpp b/eo/src/eoFunctorStore.cpp index 8d552132..eae212b8 100644 --- a/eo/src/eoFunctorStore.cpp +++ b/eo/src/eoFunctorStore.cpp @@ -1,7 +1,7 @@ #ifdef _MSC_VER // to avoid long name warnings #pragma warning(disable:4786) -#endif +#endif #include #include @@ -9,8 +9,7 @@ /// clears the memory eoFunctorStore::~eoFunctorStore() { - for (size_t i = 0; i < vec.size(); ++i) - { + for(size_t i = 0; i < vec.size(); ++i) { delete vec[i]; } } diff --git a/eo/src/eoFunctorStore.h b/eo/src/eoFunctorStore.h index cb6b5daa..4b69462b 100644 --- a/eo/src/eoFunctorStore.h +++ b/eo/src/eoFunctorStore.h @@ -38,13 +38,13 @@ dynamically created functors. */ class eoFunctorStore { - public : +public: - /// Default Ctor - eoFunctorStore() {} + /// Default Ctor + eoFunctorStore() {} - // virtual destructor so we don't need to define it in derived classes - virtual ~eoFunctorStore(); + // virtual destructor so we don't need to define it in derived classes + virtual ~eoFunctorStore(); /// Add an eoFunctorBase to the store template diff --git a/eo/src/eoStochasticUniversalSelect.h b/eo/src/eoStochasticUniversalSelect.h index ac64f149..09864057 100755 --- a/eo/src/eoStochasticUniversalSelect.h +++ b/eo/src/eoStochasticUniversalSelect.h @@ -3,7 +3,7 @@ //----------------------------------------------------------------------------- // eoStochasticUniversalSelect.h // (c) Maarten Keijzer 2003 -/* +/* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -41,11 +41,11 @@ */ //----------------------------------------------------------------------------- -template class eoStochasticUniversalSelect: public eoSelectOne +template class eoStochasticUniversalSelect: public eoSelectOne { public: /// Sanity check - eoStochasticUniversalSelect(const eoPop& pop = eoPop()) + eoStochasticUniversalSelect(const eoPop& pop = eoPop()) { if (minimizing_fitness()) throw std::logic_error("eoStochasticUniversalSelect: minimizing fitness"); @@ -54,27 +54,27 @@ public: void setup(const eoPop& _pop) { if (_pop.size() == 0) return; - + std::vector cumulative(_pop.size()); - + cumulative[0] = _pop[0].fitness(); - for (unsigned i = 1; i < _pop.size(); ++i) + for (unsigned i = 1; i < _pop.size(); ++i) { cumulative[i] = _pop[i].fitness() + cumulative[i-1]; } - + indices.reserve(_pop.size()); indices.resize(0); double fortune = rng.uniform() * cumulative.back(); double step = cumulative.back() / double(_pop.size()); - + unsigned i = std::upper_bound(cumulative.begin(), cumulative.end(), fortune) - cumulative.begin(); - + while (indices.size() < _pop.size()) { - + while (cumulative[i] < fortune) {i++;} // linear search is good enough as we average one step each time - + indices.push_back(i); fortune += step; if (fortune >= cumulative.back()) { // start at the beginning @@ -85,16 +85,16 @@ public: // shuffle for (int i = indices.size() - 1; i > 0; --i) { int j = rng.random(i+1); - swap(indices[i], indices[j]); + std::swap(indices[i], indices[j]); } } - - /** do the selection, + + /** do the selection, */ - const EOT& operator()(const eoPop& _pop) + const EOT& operator()(const eoPop& _pop) { if (indices.empty()) setup(_pop); - + unsigned index = indices.back(); indices.pop_back(); return _pop[index]; diff --git a/eo/src/ga/eoPBILOrg.h b/eo/src/ga/eoPBILOrg.h index b236412a..80bf2d09 100644 --- a/eo/src/ga/eoPBILOrg.h +++ b/eo/src/ga/eoPBILOrg.h @@ -3,7 +3,7 @@ //----------------------------------------------------------------------------- // eoPBILOrg.h // (c) Marc Schoenauer, Maarten Keijzer, 2001 -/* +/* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -30,7 +30,7 @@ #include /** - * Distribution Class for PBIL algorithm + * Distribution Class for PBIL algorithm * (Population-Based Incremental Learning, Baluja and Caruana 95) * * This class implements the update rule from the original paper: @@ -43,13 +43,13 @@ class eoPBILOrg : public eoDistribUpdater { public: /** Ctor with size of genomes, and update parameters */ - eoPBILOrg(double _LR, double _tolerance=0.0 ) : + eoPBILOrg(double _LR, double _tolerance=0.0 ) : LR(_LR), maxBound(1.0-_tolerance), minBound(_tolerance) {} /** Update the distribution from the current population */ - virtual void operator()(eoDistribution & _distrib, eoPop& _pop) + virtual void operator()(eoDistribution & _distrib, eoPop& _pop) { const EOT & best = _pop.best_element(); eoPBILDistrib& distrib = dynamic_cast&>(_distrib); @@ -62,11 +62,11 @@ public: p[g] *= (1-LR); if ( best[g] ) p[g] += LR; - // else nothing + // else nothing // stay away from 0 and 1 - p[g] = min(maxBound, p[g]); - p[g] = max(minBound, p[g]); + p[g] = std::min(maxBound, p[g]); + p[g] = std::max(minBound, p[g]); } }