Moved epAtom* out of the obsolete dir; added some CVS headers to some files, and made everything work with my elipse classes
This commit is contained in:
parent
6f6ce7d81a
commit
06dd2dc314
6 changed files with 22 additions and 12 deletions
98
eo/src/eoAtomMutation.h
Normal file
98
eo/src/eoAtomMutation.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
// -*- 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 <iterator>
|
||||
|
||||
// EO includes
|
||||
#include <eoOp.h>
|
||||
#include <utils/eoRNG.h>
|
||||
#include <eoAtomMutator.h>
|
||||
|
||||
/** 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 EOT>
|
||||
class eoAtomMutation: public eoMonOp<EOT> {
|
||||
public:
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef EOT::AtomType Type;
|
||||
#else
|
||||
typedef typename EOT::AtomType Type;
|
||||
#endif
|
||||
|
||||
///
|
||||
eoAtomMutation(eoAtomMutator<Type>& _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<Type>& atomMutator;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
41
eo/src/eoAtomMutator.h
Normal file
41
eo/src/eoAtomMutator.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// -*- 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 <eoFunctor.h>
|
||||
|
||||
/** 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 T>
|
||||
class eoAtomMutator: public eoUF<T&, bool> {};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
mak@dhi.dk
|
||||
CVS Info: $Date: 2001-03-21 12:10:13 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoFunctor.h,v 1.5 2001-03-21 12:10:13 jmerelo Exp $ $Author: jmerelo $
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
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/eoOp.h,v 1.27 2001-03-21 12:10:13 jmerelo Exp $ $Author: jmerelo $
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -63,7 +64,6 @@ how to build them from a description in a file.
|
|||
|
||||
*/
|
||||
template<class EOType>
|
||||
|
||||
class eoOp
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -115,4 +115,4 @@ class eoSTLBF : public std::binary_function<A1, A2, R>
|
|||
|
||||
// TODO: put automated wrappers here...
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
mak@dhi.dk
|
||||
|
||||
CVS Info: $Date: 2001-03-21 12:10:13 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVector.h,v 1.9 2001-03-21 12:10:13 jmerelo Exp $ $Author: jmerelo $
|
||||
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -32,9 +35,11 @@
|
|||
/**
|
||||
|
||||
Base class for fixed length chromosomes, just derives from EO and vector and
|
||||
redirects the smaller than operator to EO (fitness based comparison)
|
||||
redirects the smaller than operator to EO (fitness based comparison). GeneType
|
||||
must have the following methods: void ctor (needed for the vector<>), copy ctor,
|
||||
|
||||
|
||||
*/
|
||||
|
||||
template <class FitT, class GeneType>
|
||||
class eoVector : public EO<FitT>, public std::vector<GeneType>
|
||||
{
|
||||
|
|
|
|||
Reference in a new issue