From d418459a0121216d02dab8d5eda221c7c8c30a82 Mon Sep 17 00:00:00 2001 From: kuepper Date: Mon, 29 Aug 2005 07:32:13 +0000 Subject: [PATCH] Install eoPropGAGenOp.h Add #include in eoEsChromInit.h in order to make gcc-4.0 happy. --- eo/src/Makefile.am | 1 + eo/src/es/eoEsChromInit.h | 24 ++++++------ eo/src/es/make_genotype_real.h | 68 ++++++++++++++++++---------------- 3 files changed, 50 insertions(+), 43 deletions(-) diff --git a/eo/src/Makefile.am b/eo/src/Makefile.am index 7daecb48..6b9f66c6 100644 --- a/eo/src/Makefile.am +++ b/eo/src/Makefile.am @@ -71,6 +71,7 @@ pkginclude_HEADERS = eo \ eoPopEvalFunc.h \ eoPopulator.h \ eoPrintable.h \ + eoPropGAGenOp.h \ eoProportionalCombinedOp.h \ eoProportionalSelect.h \ eoRandomSelect.h \ diff --git a/eo/src/es/eoEsChromInit.h b/eo/src/es/eoEsChromInit.h index 66711e1b..bac0d552 100644 --- a/eo/src/es/eoEsChromInit.h +++ b/eo/src/es/eoEsChromInit.h @@ -27,6 +27,7 @@ #ifndef _eoEsChromInit_H #define _eoEsChromInit_H +#include #include #include #include @@ -62,16 +63,17 @@ public: typedef typename EOT::Fitness FitT; - /** Ctor: @param - * eoRealVectorBounds& _bounds : bounds for uniform initialization - * double _sigma : initial value for the stddev - * bool _to_scale : wether sigma should be multiplied by the range of each variable - * added December 2004 - MS (together with the whole comment :-) - */ - eoEsChromInit(eoRealVectorBounds& _bounds, double _sigma = 0.3, bool _to_scale=false) : - eoRealInitBounded(_bounds) - { - // a bit of pre-computations, to ave time later (even if some are useless) + /** Ctor: + + @param eoRealVectorBounds& _bounds : bounds for uniform initialization + @param _sigma : initial value for the stddev + @param _to_scale : wether sigma should be multiplied by the range of each variable + added December 2004 - MS (together with the whole comment :-) + */ + eoEsChromInit(eoRealVectorBounds& _bounds, double _sigma = 0.3, bool _to_scale=false) + : eoRealInitBounded(_bounds) + { + // a bit of pre-computations, to save time later (even if some are useless) // first, the case of one unique sigma if (_to_scale) // sigma is scaled by the average range (if that means anything!) @@ -96,7 +98,7 @@ public: } else lesSigmas[i] = _sigma; - } + } void operator()(EOT& _eo) { diff --git a/eo/src/es/make_genotype_real.h b/eo/src/es/make_genotype_real.h index 9aecc06e..b92be7bf 100644 --- a/eo/src/es/make_genotype_real.h +++ b/eo/src/es/make_genotype_real.h @@ -37,12 +37,14 @@ #include #endif -#include -#include -#include +#include + +#include "es/eoReal.h" +#include "es/eoEsChromInit.h" +#include "utils/eoRealVectorBounds.h" // also need the parser and param includes -#include -#include +#include "utils/eoParser.h" +#include "utils/eoState.h" /* @@ -71,30 +73,35 @@ template eoEsChromInit & do_make_genotype(eoParser& _parser, eoState& _state, EOT) { - // the fitness type - typedef typename EOT::Fitness FitT; - - // for eoReal, only thing needed is the size - but might have been created elswhere ... - eoValueParam& vecSize = _parser.getORcreateParam(unsigned(10), "vecSize", "The number of variables ", 'n',"Genotype Initialization"); + // the fitness type + typedef typename EOT::Fitness FitT; + // for eoReal, only thing needed is the size - but might have been created elswhere ... + eoValueParam& vecSize + = _parser.getORcreateParam(unsigned(10), "vecSize", + "The number of variables ", + 'n',"Genotype Initialization"); // to build an eoReal Initializer, we need bounds: [-1,1] by default - eoValueParam& boundsParam = _parser.getORcreateParam(eoRealVectorBounds(vecSize.value(),-1,1), "initBounds", "Bounds for initialization (MUST be bounded)", 'B', "Genotype Initialization"); - - // now some initial value for sigmas - even if useless? - // shoudl be used in Normal mutation - std::string & sigmaString = _parser.getORcreateParam(std::string("0.3"), "sigmaInit", - "Initial value for Sigmas (with a '%' -> scaled by the range of each variable)", + eoValueParam& boundsParam + = _parser.getORcreateParam(eoRealVectorBounds(vecSize.value(), -1, 1), + "initBounds", + "Bounds for initialization (MUST be bounded)", + 'B', "Genotype Initialization"); + // now some initial value for sigmas - even if useless? + // shoudl be used in Normal mutation + std::string& sigmaString + = _parser.getORcreateParam(std::string("0.3"), "sigmaInit", + "Initial value for Sigmas (with a '%' -> scaled by the range of each variable)", 's',"Genotype Initialization").value(); - // check for % - bool to_scale = false; // == no % + bool to_scale = false; size_t pos = sigmaString.find('%'); - if (pos < sigmaString.size()) // found a % - { + if (pos < sigmaString.size()) + { + // found a % - use scaling and get rid of '%' to_scale = true; - sigmaString.resize(pos); // get rid of % - } - + sigmaString.resize(pos); + } #ifdef HAVE_SSTREAM std::istringstream is(sigmaString); #else @@ -102,16 +109,13 @@ eoEsChromInit & do_make_genotype(eoParser& _parser, eoState& _state, EOT) #endif double sigma; is >> sigma; - // minimum check - if ( (sigma < 0) ) - throw std::runtime_error("Negative sigma in make_genotype"); - - eoEsChromInit * init = - new eoEsChromInit(boundsParam.value(), sigma, to_scale); - // satore in state - _state.storeFunctor(init); - return *init; + if ( (sigma < 0) ) + throw std::runtime_error("Negative sigma in make_genotype"); + eoEsChromInit * init = new eoEsChromInit(boundsParam.value(), sigma, to_scale); + // store in state + _state.storeFunctor(init); + return *init; } #endif