From 0f985c627e5e8718e3f184baa0a2be5b9351c796 Mon Sep 17 00:00:00 2001 From: evomarc Date: Sun, 28 Jan 2001 07:31:34 +0000 Subject: [PATCH] Modified to use eoRealBounds rather than eoEsObjectiveBounds --- eo/src/es/eoEsMutate.h | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/eo/src/es/eoEsMutate.h b/eo/src/es/eoEsMutate.h index 54c406fe..7521eb04 100644 --- a/eo/src/es/eoEsMutate.h +++ b/eo/src/es/eoEsMutate.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include @@ -73,7 +73,7 @@ public: @param _init proxy class for initializating the three parameters eoEsMutate needs @param _bounds the bounds for the objective variables */ - eoEsMutate(eoEsMutationInit& _init, eoEsObjectiveBounds& _bounds) : bounds(_bounds) + eoEsMutate(eoEsMutationInit& _init, eoRealVectorBounds& _bounds) : bounds(_bounds) { init(EOT(), _init); // initialize on actual type used } @@ -102,9 +102,8 @@ public: { _eo[i] += _eo.stdev * rng.normal(); } + bounds.foldsInBounds(_eo); - keepInBounds(_eo); - _eo.invalidate(); } @@ -136,8 +135,8 @@ public: _eo[i] += stdev * rng.normal(); } - keepInBounds(_eo); - + bounds.foldsInBounds(_eo); + _eo.invalidate(); } @@ -219,34 +218,23 @@ public: for (i = 0; i < _eo.size(); i++) _eo[i] += VarStp[i]; - keepInBounds(_eo); + bounds.foldsInBounds(_eo); _eo.invalidate(); } - void keepInBounds(eoFixedLength& _eo) const - { - for (unsigned i = 0; i < _eo.size(); ++i) - { - if (_eo[i] < bounds.minimum(i)) - _eo[i] = bounds.minimum(i); - else if (_eo[i] > bounds.maximum(i)) - _eo[i] = bounds.maximum(i); - } - } - private : void init(eoEsSimple, eoEsMutationInit& _init) { - unsigned size = bounds.chromSize(); + unsigned size = bounds.size(); TauLcl = _init.TauLcl(); TauLcl /= sqrt((double) size); } void init(eoEsStdev, eoEsMutationInit& _init) { - unsigned size = bounds.chromSize(); + unsigned size = bounds.size(); TauLcl = _init.TauLcl(); TauGlb = _init.TauGlb(); @@ -268,7 +256,7 @@ public: double TauGlb; /* Global factor for mutation of std deviations */ double TauBeta; /* Factor for mutation of correlation parameters */ - eoEsObjectiveBounds& bounds; + eoRealVectorBounds& bounds; static const double stdev_eps; };