From adbc5dd461b9aea179b60c7f8bb53f9ff704bdc4 Mon Sep 17 00:00:00 2001 From: kuepper Date: Wed, 7 Dec 2005 15:40:23 +0000 Subject: [PATCH] fixes for gcc-4 compilation -- still have a linker problem --- eo/src/eoFunctorStore.h | 62 ++++++++++++++++++---------------- eo/src/es/eoRealOp.h | 54 ++++++++++++++--------------- eo/src/es/make_genotype_real.h | 6 ++++ eo/src/ga/eoBit.h | 1 + 4 files changed, 66 insertions(+), 57 deletions(-) diff --git a/eo/src/eoFunctorStore.h b/eo/src/eoFunctorStore.h index 4b69462b1..02855b47b 100644 --- a/eo/src/eoFunctorStore.h +++ b/eo/src/eoFunctorStore.h @@ -4,24 +4,24 @@ // eoFunctorStore.h // (c) Maarten Keijzer 2000, GeNeura Team, 2000 /* - 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 - version 2 of the License, or (at your option) any later version. + 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 + version 2 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Contact: todos@geneura.ugr.es, http://geneura.ugr.es - Marc.Schoenauer@polytechnique.fr - mak@dhi.dk - */ + Contact: todos@geneura.ugr.es, http://geneura.ugr.es + Marc.Schoenauer@polytechnique.fr + mak@dhi.dk +*/ //----------------------------------------------------------------------------- #ifndef _eoFunctorStore_h @@ -32,9 +32,9 @@ class eoFunctorBase; /** -eoFunctorStore is a class that stores functors that are allocated on the -heap. This class can be used in factories to store allocated memory for -dynamically created functors. + eoFunctorStore is a class that stores functors that are allocated on the + heap. This class can be used in factories to store allocated memory for + dynamically created functors. */ class eoFunctorStore { @@ -46,23 +46,25 @@ public: // virtual destructor so we don't need to define it in derived classes virtual ~eoFunctorStore(); - /// Add an eoFunctorBase to the store - template - Functor& storeFunctor(Functor* r) + /// Add an eoFunctorBase to the store + template + Functor& storeFunctor(Functor* r) { - // If the compiler complains about the following line, check if you really are giving it a pointer to an eoFunctorBase derived object - vec.push_back(r); - return *r; + // If the compiler complains about the following line, + // check if you really are giving it a pointer to an + // eoFunctorBase derived object + vec.push_back(r); + return *r; } - private : +private : - /// no copying allowed - eoFunctorStore(const eoFunctorStore&); + /// no copying allowed + eoFunctorStore(const eoFunctorStore&); - /// no copying allowed - eoFunctorStore operator=(const eoFunctorStore&); - std::vector vec; + /// no copying allowed + eoFunctorStore operator=(const eoFunctorStore&); + std::vector vec; }; #endif diff --git a/eo/src/es/eoRealOp.h b/eo/src/es/eoRealOp.h index c2eae2f15..6fabf2f2a 100644 --- a/eo/src/es/eoRealOp.h +++ b/eo/src/es/eoRealOp.h @@ -3,7 +3,7 @@ //----------------------------------------------------------------------------- // eoRealOp.h // (c) Maarten Keijzer 2000 - Marc Schoenauer 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 @@ -54,7 +54,7 @@ template class eoUniformMutation: public eoMonOp * @param _p_change the probability to change a given coordinate */ eoUniformMutation(const double& _epsilon, const double& _p_change = 1.0): - homogeneous(true), bounds(eoDummyVectorNoBounds), epsilon(1, _epsilon), + homogeneous(true), bounds(eoDummyVectorNoBounds), epsilon(1, _epsilon), p_change(1, _p_change) {} /** @@ -65,8 +65,8 @@ template class eoUniformMutation: public eoMonOp */ eoUniformMutation(eoRealVectorBounds & _bounds, const double& _epsilon, const double& _p_change = 1.0): - homogeneous(false), bounds(_bounds), epsilon(_bounds.size(), _epsilon), - p_change(_bounds.size(), _p_change) + homogeneous(false), bounds(_bounds), epsilon(_bounds.size(), _epsilon), + p_change(_bounds.size(), _p_change) { // scale to the range - if any for (unsigned i=0; i class eoUniformMutation: public eoMonOp * @param _p_change the VECTOR of probabilities for each coordinates */ eoUniformMutation(eoRealVectorBounds & _bounds, - const std::vector& _epsilon, + const std::vector& _epsilon, const std::vector& _p_change): - homogeneous(false), bounds(_bounds), epsilon(_epsilon), + homogeneous(false), bounds(_bounds), epsilon(_epsilon), p_change(_p_change) {} /// The class name. @@ -152,7 +152,7 @@ template class eoDetUniformMutation: public eoMonOp * @param number of coordinate to modify */ eoDetUniformMutation(const double& _epsilon, const unsigned& _no = 1): - homogeneous(true), bounds(eoDummyVectorNoBounds), + homogeneous(true), bounds(eoDummyVectorNoBounds), epsilon(1, _epsilon), no(_no) {} /** @@ -161,10 +161,10 @@ template class eoDetUniformMutation: public eoMonOp * @param _epsilon the range for uniform nutation (to be scaled if necessary) * @param number of coordinate to modify */ - eoDetUniformMutation(eoRealVectorBounds & _bounds, - const double& _epsilon, const unsigned& _no = 1): - homogeneous(false), bounds(_bounds), - epsilon(_bounds.size(), _epsilon), no(_no) + eoDetUniformMutation(eoRealVectorBounds & _bounds, + const double& _epsilon, const unsigned& _no = 1): + homogeneous(false), bounds(_bounds), + epsilon(_bounds.size(), _epsilon), no(_no) { // scale to the range - if any for (unsigned i=0; i class eoDetUniformMutation: public eoMonOp * @param _epsilon the VECTOR of ranges for uniform mutation * @param number of coordinate to modify */ - eoDetUniformMutation(eoRealVectorBounds & _bounds, - const std::vector& _epsilon, - const unsigned& _no = 1): - homogeneous(false), bounds(_bounds), epsilon(_epsilon), no(_no) + eoDetUniformMutation(eoRealVectorBounds & _bounds, + const std::vector& _epsilon, + const unsigned& _no = 1): + homogeneous(false), bounds(_bounds), epsilon(_epsilon), no(_no) { // scale to the range - if any for (unsigned i=0; i class eoSegmentCrossover: public eoQuadOp /** * Constructor with bounds * @param _bounds an eoRealVectorBounds that contains the bounds - * @param _alphaMin the amount of exploration OUTSIDE the parents + * @param _alphaMin the amount of exploration OUTSIDE the parents * as in BLX-alpha notation (Eshelman and Schaffer) * 0 == contractive application * Must be positive */ - eoSegmentCrossover(eoRealVectorBounds & _bounds, - const double& _alpha = 0.0) : + eoSegmentCrossover(eoRealVectorBounds & _bounds, + const double& _alpha = 0.0) : bounds(_bounds), alpha(_alpha), range(1+2*_alpha) {} /// The class name. @@ -356,14 +356,14 @@ template class eoHypercubeCrossover: public eoQuadOp /** * Constructor with bounds * @param _bounds an eoRealVectorBounds that contains the bounds - * @param _alphaMin the amount of exploration OUTSIDE the parents + * @param _alphaMin the amount of exploration OUTSIDE the parents * as in BLX-alpha notation (Eshelman and Schaffer) * 0 == contractive application * Must be positive */ - eoHypercubeCrossover(eoRealVectorBounds & _bounds, - const double& _alpha = 0.0): - bounds(_bounds), alpha(_alpha), range(1+2*_alpha) + eoHypercubeCrossover(eoRealVectorBounds & _bounds, + const double& _alpha = 0.0): + bounds(_bounds), alpha(_alpha), range(1+2*_alpha) { if (_alpha < 0) throw std::runtime_error("BLX coefficient should be positive"); @@ -395,7 +395,7 @@ template class eoHypercubeCrossover: public eoQuadOp } } else // check the bounds - // do not try to get a bound on the linear factor, but rather + // do not try to get a bound on the linear factor, but rather // on the object variables themselves for (i=0; i<_eo1.size(); i++) { @@ -462,7 +462,7 @@ template class eoRealUXover: public eoQuadOp * @param _preference bias in the choice (usually, no bias == 0.5) */ eoRealUXover(const float& _preference = 0.5): preference(_preference) - { + { if ( (_preference <= 0.0) || (_preference >= 1.0) ) std::runtime_error("UxOver --> invalid preference"); } @@ -497,7 +497,7 @@ template class eoRealUXover: public eoQuadOp private: float preference; }; - + //----------------------------------------------------------------------------- //@} diff --git a/eo/src/es/make_genotype_real.h b/eo/src/es/make_genotype_real.h index 1967fae49..a2077793e 100644 --- a/eo/src/es/make_genotype_real.h +++ b/eo/src/es/make_genotype_real.h @@ -75,6 +75,12 @@ eoEsChromInit & do_make_genotype(eoParser& _parser, eoState& _state, EOT) "initBounds", "Bounds for initialization (MUST be bounded)", 'B', "Genotype Initialization"); + // now some initial value for sigmas - even if useless? + // should be used in Normal mutation + eoValueParam& sigmaParam + = _parser.getORcreateParam(std::string("0.3"), "sigmaInit", + "Initial value for Sigmas (with a '%' -> scaled by the range of each variable)", + 's',"Genotype Initialization"); // check if there is a vecSigmaInit eoParam *vecSigmaParam = _parser.getParamWithLongName("vecSigmaInit"); if(vecSigmaParam) { diff --git a/eo/src/ga/eoBit.h b/eo/src/ga/eoBit.h index d77d3218c..7d8748935 100644 --- a/eo/src/ga/eoBit.h +++ b/eo/src/ga/eoBit.h @@ -59,6 +59,7 @@ public: using eoVector< FitT, bool >::begin; using eoVector< FitT, bool >::end; + using eoVector< FitT, bool >::resize; using eoVector< FitT, bool >::size; /**