diff --git a/eo/src/eoAtomMutation.h b/eo/src/eoAtomMutation.h deleted file mode 100644 index dae8ff61..00000000 --- a/eo/src/eoAtomMutation.h +++ /dev/null @@ -1,98 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// eoAtomMutation.h -// (c) 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 - - CVS Info: $Date: 2001-03-21 12:10:13 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/Attic/eoAtomMutation.h,v 1.7 2001-03-21 12:10:13 jmerelo Exp $ $Author: jmerelo $ -*/ -//----------------------------------------------------------------------------- -#ifndef _EOATOMMUTATION_H -#define _EOATOMMUTATION_H - -// STL includes -#include - -// EO includes -#include -#include -#include - -/** Atomic mutation of an EO. Acts on containers, and applies a mutation - operator to each element of the container with some probability. EOT must - be a container of any type -*/ -template -class eoAtomMutation: public eoMonOp { -public: - -#ifdef _MSC_VER - typedef EOT::AtomType Type; -#else - typedef typename EOT::AtomType Type; -#endif - - /// - eoAtomMutation(eoAtomMutator& _atomMut, const double _rate=0.0) - : eoMonOp< EOT >(), rate(_rate), atomMutator( _atomMut ) {}; - - /// - virtual ~eoAtomMutation() {}; - - /// - virtual bool operator()( EOT& _eo ) { - typename EOT::iterator i; - for ( i = _eo.begin(); i != _eo.end(); i ++ ) - if ( rng.flip( rate ) ) { - atomMutator( *i ); - } - return true; - } - - /** To print me on a stream. - @param os The ostream. - */ - void printOn(ostream& os) const { - os << rate ; - } - - /** To read me from a stream. - @param is The istream */ - void readFrom(istream& is) { - is >> rate ; - } - - /** @name Methods from eoObject - */ - //@{ - /** Inherited from eoObject - @see eoObject - */ - string className() const {return "eoMutation";}; - //@} - -private: - - double rate; - eoAtomMutator& atomMutator; -}; - - -#endif - diff --git a/eo/src/eoAtomMutator.h b/eo/src/eoAtomMutator.h deleted file mode 100644 index a143a55a..00000000 --- a/eo/src/eoAtomMutator.h +++ /dev/null @@ -1,41 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// eoAtomMutator.h -// (c) 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 - CVS Info: $Date: 2001-03-21 12:10:13 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/Attic/eoAtomMutator.h,v 1.4 2001-03-21 12:10:13 jmerelo Exp $ $Author: jmerelo $ - */ -//----------------------------------------------------------------------------- -#ifndef _EOATOMMUTATOR_H -#define _EOATOMMUTATOR_H - -#include - -/** Abstract base class for functors that modify a single element in an EO - that is composed of several atomic components. An atom would, for instance, flip - a bit, or change a real number, or things like that. The header is completely - empty and thus just provides a name rather than functionality. -*/ - -template -class eoAtomMutator: public eoUF {}; - - -#endif - diff --git a/eo/src/eoVariableLengthCrossover.h b/eo/src/eoVariableLengthCrossover.h index 7d8da085..be7d4b88 100644 --- a/eo/src/eoVariableLengthCrossover.h +++ b/eo/src/eoVariableLengthCrossover.h @@ -21,6 +21,7 @@ Contact: todos@geneura.ugr.es, http://geneura.ugr.es Marc.Schoenauer@polytechnique.fr mak@dhi.dk + CVS Info: $Date: 2001-03-21 13:09:47 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.5 2001-03-21 13:09:47 jmerelo Exp $ $Author: jmerelo $ */ //----------------------------------------------------------------------------- diff --git a/eo/src/eoVariableLengthMutation.h b/eo/src/eoVariableLengthMutation.h index 6bea7d11..2a2d87d3 100644 --- a/eo/src/eoVariableLengthMutation.h +++ b/eo/src/eoVariableLengthMutation.h @@ -21,6 +21,7 @@ Contact: todos@geneura.ugr.es, http://geneura.ugr.es Marc.Schoenauer@polytechnique.fr mak@dhi.dk + CVS Info: $Date: 2001-03-21 13:09:47 $ $Version$ $Author: jmerelo $ */ //----------------------------------------------------------------------------- @@ -28,8 +29,8 @@ #define _eoVariableLengthMutation_h #include -#include #include +#include /** Base classes for generic mutations on variable length chromosomes. @@ -64,6 +65,34 @@ private: eoMonOp & atomMutation; }; +/** THis ones applies its atomic mutation depending on a probability + */ +template +class eoVlRateMutation : public eoMonOp +{ +public : + + typedef typename EOT::AtomType AtomType; + + // default ctor: requires an Atom mutation + eoVlRateMutation(eoMonOp & _atomMutation, double _rate=0.0) : + atomMutation(_atomMutation), rate( _rate ) {} + + bool operator()(EOT & _eo) + { + bool modified=false; + typename EOT::iterator i; + for ( i = _eo.begin(); i != _eo.end(); i ++ ) + if ( rng.flip( rate ) ) { + modified |= atomMutation( *i ); + } + return modified; + } +private: + double rate; + eoMonOp & atomMutation; +}; + /** This ones applies its atomic mutation to a fixed number of genes (1 by default) */