diff --git a/eo/src/eoDEA.h b/eo/src/eoDEA.h new file mode 100644 index 00000000..bb717ae1 --- /dev/null +++ b/eo/src/eoDEA.h @@ -0,0 +1,46 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoDEA.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 + 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: Marc.Schoenauer@polytechnique.fr + mkeijzer@dhi.dk + */ +//----------------------------------------------------------------------------- + +#ifndef _eoDEA_h +#define _eoDEA_h + +//----------------------------------------------------------------------------- + +#include + +/** eoDEA: Distribution Evolution Algorithm within EO + * + * The abstract class for algorithms that evolve a probability distribution + * on the spaces of populations rather than a population + * + * It IS NOT an eoAlgo, as it evolves a distribution, not a population +*/ + +template class eoDEA: public eoUF&, void> +{ +}; + +#endif + diff --git a/eo/src/eoDistribUpdater.h b/eo/src/eoDistribUpdater.h new file mode 100644 index 00000000..88f6d24b --- /dev/null +++ b/eo/src/eoDistribUpdater.h @@ -0,0 +1,47 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoDistribUpdater.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 + 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: Marc.Schoenauer@polytechnique.fr + mkeijzer@dhi.dk + */ +//----------------------------------------------------------------------------- + +#ifndef _eoDistribUpdater_H +#define _eoDistribUpdater_H + +#include + +#include +#include + +/** + * Base class for Distribution Evolution Algorithms within EO: + * the update rule of distribution + * + * It takes one distribution and updates it according to one population + * +*/ + +template +class eoDistribUpdater : + public eoBF &, eoPop &, void> +{}; + +#endif diff --git a/eo/src/eoDistribution.h b/eo/src/eoDistribution.h new file mode 100644 index 00000000..9facd916 --- /dev/null +++ b/eo/src/eoDistribution.h @@ -0,0 +1,52 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoDistribution.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 + 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: Marc.Schoenauer@polytechnique.fr + mkeijzer@dhi.dk + */ +//----------------------------------------------------------------------------- + +#ifndef _eoDistribution_H +#define _eoDistribution_H + +#include + +#include +#include + +/** + * Abstract class for Distribution Evolution Algorithms within EO: + * the distribution itself + * + * It basically IS AN eoInit - operator()(EOT &) generates new indis + * + * The instances will probably be eoValueParam of some kind + * see eoPBILDistrib.h +*/ + +template +class eoDistribution : public eoInit, + public eoPersistent, public eoObject +{ +public: + virtual void operator()(EOT &) = 0; // DO NOT FORGET TO INVALIDATE the EOT +}; + +#endif diff --git a/eo/src/eoSimpleDEA.h b/eo/src/eoSimpleDEA.h new file mode 100644 index 00000000..ea785250 --- /dev/null +++ b/eo/src/eoSimpleDEA.h @@ -0,0 +1,105 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoSimpleDEA.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 + 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: Marc.Schoenauer@polytechnique.fr + mkeijzer@dhi.dk + */ +//----------------------------------------------------------------------------- + +#ifndef _eoSimpleDEA_h +#define _eoSimpleDEA_h + +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +/** eoSimpleDEA: a very simple Distribution Evolution Algorithm + * + * The algorithm that evolves a probability distribution + * on the spaces of populations with the loop + * generate a population from the current distribution + * evaluate that population + * update the distribution +*/ + +template class eoSimpleDEA: public eoDEA +{ + public: + + /** Ctor from an eoDistribUpdater + * ... plus an eoEval and eoContinue of course + */ + eoSimpleDEA(eoDistribUpdater& _update, + eoEvalFunc& _eval, + unsigned _popSize, + eoContinue& _continuator + ) : + update(_update), + eval(_eval), + popSize(_popSize), + continuator(_continuator) + {} + + /** The algorithm: + * generate pop from distrib, + * evaluate pop, + * update distrib + */ + virtual void operator()(eoDistribution& _distrib) + { + eoPop pop(popSize, _distrib); + do + { + try + { + apply(_distrib, pop); // re-init. of _pop from distrib + + apply(eval, pop); // eval of current population + + update(_distrib, pop); // updates distrib from _pop + + } + catch (exception& e) + { + string s = e.what(); + s.append( " in eoSimpleDEA"); + throw runtime_error( s ); + } + } while ( continuator( pop ) ); + } + + private: + eoDistribUpdater & update; + + eoEvalFunc& eval; + + unsigned popSize; + + eoContinue& continuator; +}; + +//----------------------------------------------------------------------------- + +#endif +