From 3b2125e060bf036c720bdfd1141da8383f8cbaac Mon Sep 17 00:00:00 2001 From: evomarc Date: Fri, 9 Feb 2001 05:10:25 +0000 Subject: [PATCH] Left-out from the big change of general op interface! --- eo/src/obsolete/eoEvolutionStrategy.h | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 eo/src/obsolete/eoEvolutionStrategy.h diff --git a/eo/src/obsolete/eoEvolutionStrategy.h b/eo/src/obsolete/eoEvolutionStrategy.h new file mode 100644 index 00000000..b863ae8a --- /dev/null +++ b/eo/src/obsolete/eoEvolutionStrategy.h @@ -0,0 +1,101 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoEvolutionStrategy.h +// (c) Maarten Keijzer 2000, GeNeura Team, 1998 +/* + 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. + + 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 + */ +//----------------------------------------------------------------------------- + +#ifndef _eoEvolutionStrategy_h +#define _eoEvolutionStrategy_h + +//----------------------------------------------------------------------------- + +#include +#include +/** eoEvolutionStrategy: +*/ + +template +class eoEvolutionStrategy: public eoAlgo +{ + public: + struct plus_strategy{}; + struct comma_strategy{}; + + eoEvolutionStrategy( + eoContinue& _continuator, + eoEvalFunc& _eval, + eoGOpSelector& _opSel, + float _lambdaRate, + comma_strategy) + : selectPerc(randomSelect, _lambdaRate), + transform(_opSel), + easyEA(_continuator, _eval, selectPerc, transform, noElitism, truncate) + {} + + eoEvolutionStrategy( + eoContinue& _continuator, + eoEvalFunc& _eval, + eoGOpSelector& _opSel, + float _lambdaRate, + plus_strategy) + : selectPerc(randomSelect, _lambdaRate), + transform(_opSel), + easyEA(_continuator, _eval, selectPerc, transform, plus, truncate) + {} + + + /// Apply a few generation of evolution to the population. + virtual void operator()(eoPop& _pop) + { + easyEA(_pop); + } + + private: + + eoPlus plus; + eoNoElitism noElitism; + eoTruncate truncate; + eoRandomSelect randomSelect; + eoSelectPerc selectPerc; + eoInplaceTransform2 transform; + + /// easyEA is contained rather than a base because of member initialization order! + eoEasyEA easyEA; +}; + +template +eoEvolutionStrategy make_es(eoContinue& _continuator, + eoEvalFunc& _eval, + eoGOpSelector& _opSel, + float _lambdaRate, + bool _comma) + +{ + if (_comma) + return eoEvolutionStrategy(_continuator, _eval, _opSel, _lambdaRate, eoEvolutionStrategy::comma_strategy()); + //else + return eoEvolutionStrategy(_continuator, _eval, _opSel, _lambdaRate, eoEvolutionStrategy::plus_strategy()); +} + +//----------------------------------------------------------------------------- + +#endif eoSelectTransformReduce_h +