Added Marc's ES files and .dsp files for others
This commit is contained in:
parent
0d8648c0e6
commit
449ed17ff8
51 changed files with 6359 additions and 4825 deletions
274
eo/src/EO.h
274
eo/src/EO.h
|
|
@ -1,137 +1,137 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// EO.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EO_H
|
||||
#define EO_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdexcept> // runtime_error
|
||||
#include <eoObject.h>
|
||||
#include <eoPersistent.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** EO is a base class for evolvable objects, that is, the subjects of evolution.
|
||||
EOs have only got a fitness, which at the same time needs to be only an object with the
|
||||
operation less than (<) defined. Fitness says how good is the object; evolution or change
|
||||
of these objects is left to the genetic operators. A fitness less than another means a
|
||||
worse fitness, in whatever the context; thus, fitness is always maximized; although
|
||||
it can be minimized with a proper definition of the < operator.\\
|
||||
The fitness object must have, besides an void ctor, a copy ctor.
|
||||
*/
|
||||
template<class F> class EO: public eoObject, public eoPersistent
|
||||
{
|
||||
public:
|
||||
typedef F Fitness;
|
||||
|
||||
/** Default constructor.
|
||||
Fitness must have a ctor which takes 0 as a value; we can not use void ctors here
|
||||
since default types like float have no void initializer. VC++ allows it, but gcc does not
|
||||
*/
|
||||
EO(): repFitness(0), invalidFitness(true) {}
|
||||
|
||||
/** Ctor from stream.
|
||||
Fitness must have defined the lecture from an istream.
|
||||
*/
|
||||
EO( istream& _is ) {
|
||||
_is >> repFitness;
|
||||
invalidFitness = false;
|
||||
};
|
||||
|
||||
/// Copy ctor
|
||||
EO( const EO& _eo ): repFitness( _eo.repFitness ), invalidFitness( _eo.invalidFitness ) {};
|
||||
|
||||
/// Virtual dtor
|
||||
virtual ~EO() {};
|
||||
|
||||
/// Return fitness value.
|
||||
Fitness fitness() const
|
||||
{
|
||||
if (invalid())
|
||||
//throw runtime_error("invalid fitness");
|
||||
cout << "invalid fitness" << endl;
|
||||
return repFitness;
|
||||
}
|
||||
|
||||
// Set fitness as invalid.
|
||||
void invalidate() { invalidFitness = true; }
|
||||
|
||||
/** Set fitness. At the same time, validates it.
|
||||
* @param _fitness New fitness value.
|
||||
*/
|
||||
void fitness(const Fitness& _fitness)
|
||||
{
|
||||
repFitness = _fitness;
|
||||
invalidFitness = false;
|
||||
}
|
||||
|
||||
/** Return true If fitness value is invalid, false otherwise.
|
||||
* @return true If fitness is invalid.
|
||||
*/
|
||||
bool invalid() const { return invalidFitness; }
|
||||
|
||||
/** Returns true if
|
||||
@return true if the fitness is higher
|
||||
*/
|
||||
bool operator<(const EO& _eo2) const { return fitness() < _eo2.fitness();}
|
||||
|
||||
/// Methods inherited from eoObject
|
||||
//@{
|
||||
|
||||
/** Return the class id.
|
||||
* @return the class name as a string
|
||||
*/
|
||||
virtual string className() const { return "EO"; };
|
||||
|
||||
/**
|
||||
* Read object.\\
|
||||
* Calls base class, just in case that one had something to do. The read and print
|
||||
* methods should be compatible and have the same format. In principle, format is
|
||||
* "plain": they just print a number
|
||||
* @param _is a istream.
|
||||
* @throw runtime_exception If a valid object can't be read.
|
||||
*/
|
||||
virtual void readFrom(istream& _is) {
|
||||
_is >> repFitness;
|
||||
invalidFitness = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const {
|
||||
_os << repFitness << endl;
|
||||
}
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
Fitness repFitness; // value of fitness for this chromosome
|
||||
bool invalidFitness; // true if the value of fitness is invalid
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif EO_H
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// EO.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EO_H
|
||||
#define EO_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdexcept> // runtime_error
|
||||
#include <eoObject.h>
|
||||
#include <eoPersistent.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** EO is a base class for evolvable objects, that is, the subjects of evolution.
|
||||
EOs have only got a fitness, which at the same time needs to be only an object with the
|
||||
operation less than (<) defined. Fitness says how good is the object; evolution or change
|
||||
of these objects is left to the genetic operators. A fitness less than another means a
|
||||
worse fitness, in whatever the context; thus, fitness is always maximized; although
|
||||
it can be minimized with a proper definition of the < operator.\\
|
||||
The fitness object must have, besides an void ctor, a copy ctor.
|
||||
*/
|
||||
template<class F> class EO: public eoObject, public eoPersistent
|
||||
{
|
||||
public:
|
||||
typedef F Fitness;
|
||||
|
||||
/** Default constructor.
|
||||
Fitness must have a ctor which takes 0 as a value; we can not use void ctors here
|
||||
since default types like float have no void initializer. VC++ allows it, but gcc does not
|
||||
*/
|
||||
EO(): repFitness(0), invalidFitness(true) {}
|
||||
|
||||
/** Ctor from stream.
|
||||
Fitness must have defined the lecture from an istream.
|
||||
*/
|
||||
EO( istream& _is ) {
|
||||
_is >> repFitness;
|
||||
invalidFitness = false;
|
||||
};
|
||||
|
||||
/// Copy ctor
|
||||
EO( const EO& _eo ): repFitness( _eo.repFitness ), invalidFitness( _eo.invalidFitness ) {};
|
||||
|
||||
/// Virtual dtor
|
||||
virtual ~EO() {};
|
||||
|
||||
/// Return fitness value.
|
||||
Fitness fitness() const
|
||||
{
|
||||
if (invalid())
|
||||
//throw runtime_error("invalid fitness");
|
||||
cout << "invalid fitness" << endl;
|
||||
return repFitness;
|
||||
}
|
||||
|
||||
// Set fitness as invalid.
|
||||
void invalidate() { invalidFitness = true; }
|
||||
|
||||
/** Set fitness. At the same time, validates it.
|
||||
* @param _fitness New fitness value.
|
||||
*/
|
||||
void fitness(const Fitness& _fitness)
|
||||
{
|
||||
repFitness = _fitness;
|
||||
invalidFitness = false;
|
||||
}
|
||||
|
||||
/** Return true If fitness value is invalid, false otherwise.
|
||||
* @return true If fitness is invalid.
|
||||
*/
|
||||
bool invalid() const { return invalidFitness; }
|
||||
|
||||
/** Returns true if
|
||||
@return true if the fitness is higher
|
||||
*/
|
||||
bool operator<(const EO& _eo2) const { return fitness() < _eo2.fitness();}
|
||||
|
||||
/// Methods inherited from eoObject
|
||||
//@{
|
||||
|
||||
/** Return the class id.
|
||||
* @return the class name as a string
|
||||
*/
|
||||
virtual string className() const { return "EO"; };
|
||||
|
||||
/**
|
||||
* Read object.\\
|
||||
* Calls base class, just in case that one had something to do. The read and print
|
||||
* methods should be compatible and have the same format. In principle, format is
|
||||
* "plain": they just print a number
|
||||
* @param _is a istream.
|
||||
* @throw runtime_exception If a valid object can't be read.
|
||||
*/
|
||||
virtual void readFrom(istream& _is) {
|
||||
_is >> repFitness;
|
||||
invalidFitness = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const {
|
||||
_os << repFitness << endl;
|
||||
}
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
Fitness repFitness; // value of fitness for this chromosome
|
||||
bool invalidFitness; // true if the value of fitness is invalid
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif EO_H
|
||||
|
|
|
|||
|
|
@ -8,5 +8,16 @@ lib_LIBRARIES = libeo.a
|
|||
libeo_a_SOURCES = eoPrintable.cpp eoPersistent.cpp
|
||||
|
||||
libeoincdir = $(includedir)/eo
|
||||
libeoinc_HEADERS = eo EO.h eoDup.h eoMultiMonOp.h eoPop.h eoUniform.h eoESChrom.h eoNegExp.h eoProblem.h eoVector.h eoFitness.h eoNormal.h eoRnd.h eoXOver2.h eo1d.h eoID.h eoObject.h eoString.h eoAged.h eoKill.h eoOp.h eoTranspose.h eoBin.h eoPrintable.h eoPersistent.h eoLottery.h eoMutation.h eoPopOps.h eoUniform.h eoInsertion.h eoInclusion.h eoBitOp.h eoBitOpFactory.h eo2d.h eo2dVector.h eoData.h eoProportionalOpSel.h eoOpSelector.h eoBreeder.h eoEvalFunc.h eoEvalFuncPtr.h eoEvaluator.h eoTerm.h eoGenTerm.h eoFitTerm.h eoGeneration.h eoAlgo.h eoEasyEA.h eoNonUniform.h eoRNG.h eoParser.h
|
||||
libeoinc_HEADERS = EO.h eo eo1d.h eo2d.h eo2dVector.h eoAged.h eoAlgo.h\
|
||||
eoAtomBitFlip.h eoAtomCreep.h eoAtomMutation.h eoAtomMutator.h \
|
||||
eoAtomRandom.h eoBin.h eoBitOp.h eoBitOpFactory.h eoBreeder.h\
|
||||
eoData.h eoDup.h eoESChrom.h eoESFullChrom.h eoESFullMut.h eoEasyEA.h\
|
||||
eoEvalFunc.h eoEvalFuncPtr.h eoEvaluator.h eoFitTerm.h eoFitness.h\
|
||||
eoGenTerm.h eoGeneration.h eoID.h eoInclusion.h eoInsertion.h\
|
||||
eoKill.h eoLottery.h eoMultiMonOp.h eoMutation.h eoNegExp.h\
|
||||
eoNonUniform.h eoNormal.h eoObject.h eoOp.h eoOpSelector.h\
|
||||
eoParser.h eoPersistent.h eoPop.h eoPopOps.h eoPrintable.h\
|
||||
eoProblem.h eoProportionalOpSel.h eoRNG.h eoRnd.h eoString.h\
|
||||
eoTerm.h eoTranspose.h eoUniform.h eoVector.h eoXOver2.h
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,333 +1,333 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File............: eo2dVector.h
|
||||
Author..........: Geneura Team (this file: Victor Rivas, vrivas@ujaen.es)
|
||||
Date............: 29-Sep-1999, at Fac. of Sciences, Univ. of Granada (Spain)
|
||||
Description.....: Implementation of a 2-dimensional chromosome usign STL
|
||||
vectors.
|
||||
|
||||
================ Modif. 1 ================
|
||||
Author........:
|
||||
Date..........:
|
||||
Description...:
|
||||
|
||||
QUEDA: Operador de asignación, lectura desde istream, escritura a ostream
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// eo2dVector.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef _eo2dVector_H
|
||||
#define _eo2dVector_H
|
||||
|
||||
// STL libraries
|
||||
#include <vector> // For vector<int>
|
||||
#include <stdexcept>
|
||||
#include <strstream>
|
||||
#include <iostream.h>
|
||||
|
||||
#include <eo2d.h>
|
||||
#include <eoRnd.h>
|
||||
|
||||
/** Adaptor that turns an STL vector of vectror into an EO
|
||||
with the same gene type as the type with which
|
||||
the vector of vector has been instantiated.
|
||||
*/
|
||||
template <class T, class fitnessT>
|
||||
class eo2dVector: public eo2d<T, fitnessT>, public vector< vector<T> > {
|
||||
public:
|
||||
typedef T Type ;
|
||||
|
||||
/** @name Canonical part of the objects: several ctors, copy ctor, \
|
||||
* dtor and assignment operator.
|
||||
*/
|
||||
//@{
|
||||
|
||||
/** Ctor.
|
||||
@param _rows Number of rows.
|
||||
@param _cols Number of columns.
|
||||
@param _val Common initial value
|
||||
*/
|
||||
eo2dVector( const unsigned _rows = 0,
|
||||
const unsigned _cols = 0,
|
||||
T _val = T() )
|
||||
: eo2d<T, fitnessT>(), vector< vector<T> >( _rows, vector<T>( _cols, _val ) ){};
|
||||
|
||||
/** Ctor using a random number generator.
|
||||
@param _rows Number of rows.
|
||||
@param _cols Number of columns.
|
||||
@param _rnd A random "T-type" generator, which returns a random value each time it´s called.
|
||||
*/
|
||||
eo2dVector( const unsigned _rows,
|
||||
const unsigned _cols,
|
||||
eoRnd<T>& _rnd );
|
||||
|
||||
/** Ctor from a istream. The T class should accept reading from a istream. It doesn't read fitness,
|
||||
which is supposed to be dynamic and dependent on environment.
|
||||
@param _is the input stream; should have all values in a single line, separated by whitespace
|
||||
*/
|
||||
//eo2dVector( istream& _is);
|
||||
|
||||
|
||||
/// copy ctor
|
||||
eo2dVector( const eo2dVector & _eo )
|
||||
: eo2d<T, fitnessT>( _eo ), vector< vector<T> >( _eo ){ };
|
||||
|
||||
/// Assignment operator
|
||||
/*
|
||||
const eo2dVector& operator =( const eo2dVector & _eo ) {
|
||||
if ( this != &_eo ){
|
||||
eo2d<T, fitnessT>::operator=( _eo );
|
||||
vector< <vector<T> >::operator=( _eo );
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
/// dtor
|
||||
virtual ~eo2dVector() {};
|
||||
|
||||
//@}
|
||||
/** Reads and returns a copy of the gene in position _r,_c.\
|
||||
This implies that T must have a copy ctor .
|
||||
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
|
||||
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File............: eo2dVector.h
|
||||
Author..........: Geneura Team (this file: Victor Rivas, vrivas@ujaen.es)
|
||||
Date............: 29-Sep-1999, at Fac. of Sciences, Univ. of Granada (Spain)
|
||||
Description.....: Implementation of a 2-dimensional chromosome usign STL
|
||||
vectors.
|
||||
|
||||
================ Modif. 1 ================
|
||||
Author........:
|
||||
Date..........:
|
||||
Description...:
|
||||
|
||||
QUEDA: Operador de asignación, lectura desde istream, escritura a ostream
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// eo2dVector.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef _eo2dVector_H
|
||||
#define _eo2dVector_H
|
||||
|
||||
// STL libraries
|
||||
#include <vector> // For vector<int>
|
||||
#include <stdexcept>
|
||||
#include <strstream>
|
||||
#include <iostream.h>
|
||||
|
||||
#include <eo2d.h>
|
||||
#include <eoRnd.h>
|
||||
|
||||
/** Adaptor that turns an STL vector of vectror into an EO
|
||||
with the same gene type as the type with which
|
||||
the vector of vector has been instantiated.
|
||||
*/
|
||||
template <class T, class fitnessT>
|
||||
class eo2dVector: public eo2d<T, fitnessT>, public vector< vector<T> > {
|
||||
public:
|
||||
typedef T Type ;
|
||||
|
||||
/** @name Canonical part of the objects: several ctors, copy ctor, \
|
||||
* dtor and assignment operator.
|
||||
*/
|
||||
//@{
|
||||
|
||||
/** Ctor.
|
||||
@param _rows Number of rows.
|
||||
@param _cols Number of columns.
|
||||
@param _val Common initial value
|
||||
*/
|
||||
eo2dVector( const unsigned _rows = 0,
|
||||
const unsigned _cols = 0,
|
||||
T _val = T() )
|
||||
: eo2d<T, fitnessT>(), vector< vector<T> >( _rows, vector<T>( _cols, _val ) ){};
|
||||
|
||||
/** Ctor using a random number generator.
|
||||
@param _rows Number of rows.
|
||||
@param _cols Number of columns.
|
||||
@param _rnd A random "T-type" generator, which returns a random value each time it´s called.
|
||||
*/
|
||||
eo2dVector( const unsigned _rows,
|
||||
const unsigned _cols,
|
||||
eoRnd<T>& _rnd );
|
||||
|
||||
/** Ctor from a istream. The T class should accept reading from a istream. It doesn't read fitness,
|
||||
which is supposed to be dynamic and dependent on environment.
|
||||
@param _is the input stream; should have all values in a single line, separated by whitespace
|
||||
*/
|
||||
//eo2dVector( istream& _is);
|
||||
|
||||
|
||||
/// copy ctor
|
||||
eo2dVector( const eo2dVector & _eo )
|
||||
: eo2d<T, fitnessT>( _eo ), vector< vector<T> >( _eo ){ };
|
||||
|
||||
/// Assignment operator
|
||||
/*
|
||||
const eo2dVector& operator =( const eo2dVector & _eo ) {
|
||||
if ( this != &_eo ){
|
||||
eo2d<T, fitnessT>::operator=( _eo );
|
||||
vector< <vector<T> >::operator=( _eo );
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
/// dtor
|
||||
virtual ~eo2dVector() {};
|
||||
|
||||
//@}
|
||||
/** Reads and returns a copy of the gene in position _r,_c.\
|
||||
This implies that T must have a copy ctor .
|
||||
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
|
||||
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
|
||||
@return what's inside the gene, with the correct type
|
||||
@exception out_of_range if _r >=numOfRows()
|
||||
@exception out_of_range if _c >=numOfCols()
|
||||
*/
|
||||
virtual T getGene( const unsigned _r,
|
||||
const unsigned _c ) const {
|
||||
if ( _r >= numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::getGene: row out of range. "
|
||||
<< "It should be <" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _c >= numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::getGene: column out of range. "
|
||||
<< "It should be <" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
return (*this)[_r][_c];
|
||||
};
|
||||
/** Overwrites the gene placed in position _r,_c with a
|
||||
* new value. This means that the assignment operator
|
||||
* for T must be defined .
|
||||
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
|
||||
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
|
||||
@exception out_of_range if _r >=numOfRows()
|
||||
@exception out_of_range if _c >=numOfCols()
|
||||
*/
|
||||
virtual T getGene( const unsigned _r,
|
||||
const unsigned _c ) const {
|
||||
if ( _r >= numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::getGene: row out of range. "
|
||||
<< "It should be <" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _c >= numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::getGene: column out of range. "
|
||||
<< "It should be <" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
return (*this)[_r][_c];
|
||||
};
|
||||
/** Overwrites the gene placed in position _r,_c with a
|
||||
* new value. This means that the assignment operator
|
||||
* for T must be defined .
|
||||
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
|
||||
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
|
||||
@return what's inside the gene, with the correct type
|
||||
@exception out_of_range if _r >=numOfRows()
|
||||
@exception out_of_range if _c >=numOfCols()
|
||||
*/
|
||||
virtual void setGene( const unsigned _r,
|
||||
const unsigned _c,
|
||||
const T& _value ) {
|
||||
if ( _r >= numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::setGene: row out of range. "
|
||||
<< "It should be <" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _c >= numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::setGene: column out of range. "
|
||||
<< "It should be <" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
(*this)[_r][_c]=_value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Inserts a row, moving the rest to the bottom.
|
||||
* If _r = numOfRows(), it insert it at the end.
|
||||
* Obviously, changes number of rows.
|
||||
@param _r Position where the new row will be inserted.
|
||||
@param _val Vector containing the new values to be inserted.
|
||||
@exception invalid_argument If _val has not numOfCols() components.
|
||||
@exception out_of_range If _r is greater than numOfRows()
|
||||
*/
|
||||
virtual void insertRow( const unsigned _r,
|
||||
const vector<T>& _val ) {
|
||||
// Test errors.
|
||||
if ( _r > numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertRow: row out of range. "
|
||||
<< "It should be <=" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _val.size() != numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertRow: "
|
||||
<< "Incorrect number of values to be added. "
|
||||
<< "It should be ==" << numOfCols() << '\0' << endl;
|
||||
throw invalid_argument( msg.str() );
|
||||
}
|
||||
|
||||
// Insert the row.
|
||||
vector< vector<T> >::iterator ite = begin()+_r;
|
||||
insert( ite, _val );
|
||||
};
|
||||
|
||||
/** Eliminates the row at position _r; all the other genes will
|
||||
be shifted up.
|
||||
@param _r Number of he row to be deleted.
|
||||
@exception out_of_range if _r >=numOfRows()
|
||||
*/
|
||||
virtual void deleteRow( const unsigned _r ) {
|
||||
// Test error.
|
||||
if ( _r >= numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::deleteRow: "
|
||||
<< "Row out of range. "
|
||||
<< "It should be <" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
// Delete row.
|
||||
vector< vector<T> >::iterator ite = this->begin()+_r;
|
||||
this->erase( ite );
|
||||
};
|
||||
|
||||
/** Inserts a column, moving the rest to the right.
|
||||
* If _c = numOfCols(), it insert it at the end.
|
||||
* Obviously, changes number of cols.
|
||||
@param _r Position where the new column will be inserted.
|
||||
@param _val Vector containing the new values to be inserted.
|
||||
@exception invalid_argument if _val has not numOfRows() components.
|
||||
*/
|
||||
virtual void insertCol( const unsigned _c,
|
||||
const vector<T>& _val ) {
|
||||
// Test errors.
|
||||
if ( _c > numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertCol: "
|
||||
<< "Column out of range. "
|
||||
<< "It should be >=" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _val.size() != numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertCol: "
|
||||
<< "Incorrect number of values to be added. "
|
||||
<< "It should be ==" << numOfRows() << '\0' << endl;
|
||||
throw invalid_argument( msg.str() );
|
||||
}
|
||||
|
||||
// Insert column.
|
||||
for( unsigned r=0; r<numOfRows(); ++r ) {
|
||||
vector<vector<T> >::iterator it1 = begin()+r;
|
||||
vector<T>::iterator it2 = (*it1).begin()+_c;
|
||||
(*it1).insert( it2, _val[r] );
|
||||
};
|
||||
}
|
||||
|
||||
/** Eliminates the column at position _c; all the other columns will
|
||||
be shifted left.
|
||||
@param _c Number of he column to be deleted.
|
||||
@exception out_of_range if _c >=numOfCols()
|
||||
*/
|
||||
virtual void deleteCol( const unsigned _c ) {
|
||||
// Test error.
|
||||
if ( _c >= numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::deleteCol: "
|
||||
<< "Column out of range. "
|
||||
<< "It should be <" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
// Delete columns.
|
||||
for( unsigned r=0; r<numOfRows(); ++r ) {
|
||||
vector<vector<T> >::iterator it1 = begin()+r;
|
||||
vector<T>::iterator it2 = (*it1).begin()+_c;
|
||||
(*it1).erase( it2 );
|
||||
}
|
||||
};
|
||||
|
||||
/// Returns the number of rows in the eo2d
|
||||
virtual unsigned numOfRows() const {
|
||||
return size();
|
||||
};
|
||||
|
||||
/// Returns the number of columns in the eo2d
|
||||
virtual unsigned numOfCols() const {
|
||||
return begin()->size();
|
||||
};
|
||||
|
||||
|
||||
/** @name Methods from eoObject
|
||||
readFrom and printOn are directly inherited from eo1d
|
||||
*/
|
||||
//@{
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
string className() const {return "eo2dVector";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//____________________________ Some method implementation ____________________
|
||||
|
||||
// Ctors_______________________________________________________________________
|
||||
//_____________________________________________________________________________
|
||||
template <class T, class fitnessT>
|
||||
eo2dVector<T,fitnessT>::eo2dVector( const unsigned _rows,
|
||||
const unsigned _cols,
|
||||
eoRnd<T>& _rnd )
|
||||
: eo2d<T, fitnessT>(), vector< vector<T> >( _rows, vector<T>( _cols, T() ) ){
|
||||
for ( vector< vector<T> >::iterator i = begin(); i != end(); ++i ) {
|
||||
for( vector<T>::iterator j=(*i).begin(); j!= (*i).end(); ++j ) {
|
||||
*j = _rnd();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//_____________________________________________________________________________
|
||||
/*template <class T, class fitnessT>
|
||||
eoVector<T,fitnessT>::eoVector( istream& _is)
|
||||
: eo1d<T, fitnessT>(), vector<T>( ){
|
||||
while (_is ) {
|
||||
T tmp;
|
||||
_is >> tmp;
|
||||
push_back( tmp );
|
||||
}
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <class T, class fitnessT>
|
||||
ostream& operator<<( ostream& _os, const eo2dVector<T,fitnessT>& _eo) {
|
||||
for( unsigned i=0; i<_eo.numOfRows(); ++i ) {
|
||||
for( unsigned j=0; j<_eo.numOfCols(); ++j ) {
|
||||
_os << _eo.getGene( i,j ) << " ";
|
||||
}
|
||||
_os << endl;
|
||||
}
|
||||
return _os;
|
||||
};
|
||||
|
||||
#endif
|
||||
@exception out_of_range if _r >=numOfRows()
|
||||
@exception out_of_range if _c >=numOfCols()
|
||||
*/
|
||||
virtual void setGene( const unsigned _r,
|
||||
const unsigned _c,
|
||||
const T& _value ) {
|
||||
if ( _r >= numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::setGene: row out of range. "
|
||||
<< "It should be <" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _c >= numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::setGene: column out of range. "
|
||||
<< "It should be <" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
(*this)[_r][_c]=_value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Inserts a row, moving the rest to the bottom.
|
||||
* If _r = numOfRows(), it insert it at the end.
|
||||
* Obviously, changes number of rows.
|
||||
@param _r Position where the new row will be inserted.
|
||||
@param _val Vector containing the new values to be inserted.
|
||||
@exception invalid_argument If _val has not numOfCols() components.
|
||||
@exception out_of_range If _r is greater than numOfRows()
|
||||
*/
|
||||
virtual void insertRow( const unsigned _r,
|
||||
const vector<T>& _val ) {
|
||||
// Test errors.
|
||||
if ( _r > numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertRow: row out of range. "
|
||||
<< "It should be <=" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _val.size() != numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertRow: "
|
||||
<< "Incorrect number of values to be added. "
|
||||
<< "It should be ==" << numOfCols() << '\0' << endl;
|
||||
throw invalid_argument( msg.str() );
|
||||
}
|
||||
|
||||
// Insert the row.
|
||||
vector< vector<T> >::iterator ite = begin()+_r;
|
||||
insert( ite, _val );
|
||||
};
|
||||
|
||||
/** Eliminates the row at position _r; all the other genes will
|
||||
be shifted up.
|
||||
@param _r Number of he row to be deleted.
|
||||
@exception out_of_range if _r >=numOfRows()
|
||||
*/
|
||||
virtual void deleteRow( const unsigned _r ) {
|
||||
// Test error.
|
||||
if ( _r >= numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::deleteRow: "
|
||||
<< "Row out of range. "
|
||||
<< "It should be <" << numOfRows() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
// Delete row.
|
||||
vector< vector<T> >::iterator ite = this->begin()+_r;
|
||||
this->erase( ite );
|
||||
};
|
||||
|
||||
/** Inserts a column, moving the rest to the right.
|
||||
* If _c = numOfCols(), it insert it at the end.
|
||||
* Obviously, changes number of cols.
|
||||
@param _r Position where the new column will be inserted.
|
||||
@param _val Vector containing the new values to be inserted.
|
||||
@exception invalid_argument if _val has not numOfRows() components.
|
||||
*/
|
||||
virtual void insertCol( const unsigned _c,
|
||||
const vector<T>& _val ) {
|
||||
// Test errors.
|
||||
if ( _c > numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertCol: "
|
||||
<< "Column out of range. "
|
||||
<< "It should be >=" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
if ( _val.size() != numOfRows() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::insertCol: "
|
||||
<< "Incorrect number of values to be added. "
|
||||
<< "It should be ==" << numOfRows() << '\0' << endl;
|
||||
throw invalid_argument( msg.str() );
|
||||
}
|
||||
|
||||
// Insert column.
|
||||
for( unsigned r=0; r<numOfRows(); ++r ) {
|
||||
vector<vector<T> >::iterator it1 = begin()+r;
|
||||
vector<T>::iterator it2 = (*it1).begin()+_c;
|
||||
(*it1).insert( it2, _val[r] );
|
||||
};
|
||||
}
|
||||
|
||||
/** Eliminates the column at position _c; all the other columns will
|
||||
be shifted left.
|
||||
@param _c Number of he column to be deleted.
|
||||
@exception out_of_range if _c >=numOfCols()
|
||||
*/
|
||||
virtual void deleteCol( const unsigned _c ) {
|
||||
// Test error.
|
||||
if ( _c >= numOfCols() ) {
|
||||
ostrstream msg;
|
||||
msg << "ERROR in eo2dVector::deleteCol: "
|
||||
<< "Column out of range. "
|
||||
<< "It should be <" << numOfCols() << '\0' << endl;
|
||||
throw out_of_range( msg.str() );
|
||||
}
|
||||
// Delete columns.
|
||||
for( unsigned r=0; r<numOfRows(); ++r ) {
|
||||
vector<vector<T> >::iterator it1 = begin()+r;
|
||||
vector<T>::iterator it2 = (*it1).begin()+_c;
|
||||
(*it1).erase( it2 );
|
||||
}
|
||||
};
|
||||
|
||||
/// Returns the number of rows in the eo2d
|
||||
virtual unsigned numOfRows() const {
|
||||
return size();
|
||||
};
|
||||
|
||||
/// Returns the number of columns in the eo2d
|
||||
virtual unsigned numOfCols() const {
|
||||
return begin()->size();
|
||||
};
|
||||
|
||||
|
||||
/** @name Methods from eoObject
|
||||
readFrom and printOn are directly inherited from eo1d
|
||||
*/
|
||||
//@{
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
string className() const {return "eo2dVector";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//____________________________ Some method implementation ____________________
|
||||
|
||||
// Ctors_______________________________________________________________________
|
||||
//_____________________________________________________________________________
|
||||
template <class T, class fitnessT>
|
||||
eo2dVector<T,fitnessT>::eo2dVector( const unsigned _rows,
|
||||
const unsigned _cols,
|
||||
eoRnd<T>& _rnd )
|
||||
: eo2d<T, fitnessT>(), vector< vector<T> >( _rows, vector<T>( _cols, T() ) ){
|
||||
for ( vector< vector<T> >::iterator i = begin(); i != end(); ++i ) {
|
||||
for( vector<T>::iterator j=(*i).begin(); j!= (*i).end(); ++j ) {
|
||||
*j = _rnd();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//_____________________________________________________________________________
|
||||
/*template <class T, class fitnessT>
|
||||
eoVector<T,fitnessT>::eoVector( istream& _is)
|
||||
: eo1d<T, fitnessT>(), vector<T>( ){
|
||||
while (_is ) {
|
||||
T tmp;
|
||||
_is >> tmp;
|
||||
push_back( tmp );
|
||||
}
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <class T, class fitnessT>
|
||||
ostream& operator<<( ostream& _os, const eo2dVector<T,fitnessT>& _eo) {
|
||||
for( unsigned i=0; i<_eo.numOfRows(); ++i ) {
|
||||
for( unsigned j=0; j<_eo.numOfCols(); ++j ) {
|
||||
_os << _eo.getGene( i,j ) << " ";
|
||||
}
|
||||
_os << endl;
|
||||
}
|
||||
return _os;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
124
eo/src/eoAged.h
124
eo/src/eoAged.h
|
|
@ -1,41 +1,41 @@
|
|||
// eoAged.h
|
||||
// eoAged.h
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoAge.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EOAGED_H
|
||||
#define EOAGED_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // istream, ostream
|
||||
#include <string> // para string
|
||||
// (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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EOAGED_H
|
||||
#define EOAGED_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // istream, ostream
|
||||
#include <string> // para string
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoAge
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoAge
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** eoAge is a template class that adds an age to an object.\\
|
||||
Requisites for template instantiation are that the object must admit a default ctor
|
||||
|
|
@ -43,18 +43,18 @@ and a copy ctor. The Object must be an eoObject, thus, it must have its methods:
|
|||
printOn, readFrom.
|
||||
@see eoObject
|
||||
*/
|
||||
template <class Object>
|
||||
class eoAged: public Object
|
||||
{
|
||||
public:
|
||||
template <class Object>
|
||||
class eoAged: public Object
|
||||
{
|
||||
public:
|
||||
/// Main ctor from an already built Object.
|
||||
eoAged( const Object& _o): Object( _o ), age(0) {};
|
||||
|
||||
/// Copy constructor.
|
||||
|
||||
/// Copy constructor.
|
||||
eoAged( const eoAged& _a): Object( _a ), age( _a.age ) {};
|
||||
|
||||
/// Virtual dtor. They are needed in virtual class hierarchies
|
||||
virtual ~eoAged() {};
|
||||
virtual ~eoAged() {};
|
||||
|
||||
|
||||
///returns the age of the object
|
||||
|
|
@ -66,32 +66,32 @@ class eoAged: public Object
|
|||
/** @name Methods from eoObject
|
||||
readFrom and printOn are directly inherited from eo1d
|
||||
*/
|
||||
//@{
|
||||
/** Return the class id. This should be redefined in each class; but
|
||||
it's got code as an example of implementation. Only "leaf" classes
|
||||
can be non-virtual.
|
||||
*/
|
||||
virtual string className() const { return string("eoAged")+Object::className(); };
|
||||
|
||||
/**
|
||||
* Read object.
|
||||
* @param _is A istream.
|
||||
* @throw runtime_exception If a valid object can't be read.
|
||||
*/
|
||||
//@{
|
||||
/** Return the class id. This should be redefined in each class; but
|
||||
it's got code as an example of implementation. Only "leaf" classes
|
||||
can be non-virtual.
|
||||
*/
|
||||
virtual string className() const { return string("eoAged")+Object::className(); };
|
||||
|
||||
/**
|
||||
* Read object.
|
||||
* @param _is A istream.
|
||||
* @throw runtime_exception If a valid object can't be read.
|
||||
*/
|
||||
virtual void readFrom(istream& _is) {
|
||||
Object::readFrom( _is );
|
||||
_is >> age;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A ostream.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Write object. It's called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const{
|
||||
Object::printOn( _os );
|
||||
_os << age;
|
||||
}
|
||||
}
|
||||
//@}
|
||||
|
||||
private:
|
||||
|
|
@ -102,7 +102,7 @@ class eoAged: public Object
|
|||
it´s turned into an Aged object*/
|
||||
eoAged(): Object(), age(0) {};
|
||||
|
||||
unsigned long age;
|
||||
unsigned long age;
|
||||
};
|
||||
|
||||
#endif EOAGE_H
|
||||
|
||||
#endif EOAGE_H
|
||||
|
|
|
|||
57
eo/src/eoAtomBitFlip.h
Normal file
57
eo/src/eoAtomBitFlip.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoAtomCreep.h
|
||||
// Increments or decrements by one a single element
|
||||
// (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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _EOATOMCREEP_H
|
||||
#define _EOATOMCREEP_H
|
||||
|
||||
/** Flips a single bit
|
||||
*/
|
||||
template <class T>
|
||||
class eoAtomBitFlip: public eoAtomMutator<bool> {
|
||||
public:
|
||||
|
||||
///
|
||||
eoAtomBitFlip() {};
|
||||
|
||||
///
|
||||
virtual ~eoAtomBitFlip() {};
|
||||
|
||||
///
|
||||
virtual void operator()( T& _val ) const {
|
||||
_val = !val;
|
||||
}
|
||||
|
||||
/** @name Methods from eoObject
|
||||
*/
|
||||
//@{
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
string className() const {return "eoAtomBitFlip";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
65
eo/src/eoAtomCreep.h
Normal file
65
eo/src/eoAtomCreep.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoAtomCreep.h
|
||||
// Increments or decrements by one a single element
|
||||
// (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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _EOATOMCREEP_H
|
||||
#define _EOATOMCREEP_H
|
||||
|
||||
#include <eoRNG.h>
|
||||
#include <eoAtomMutator.h>
|
||||
|
||||
/** With uniform probability, decrements or increments by one the value.
|
||||
The value type must admit post increment and decrement.
|
||||
*/
|
||||
template <class T>
|
||||
class eoAtomCreep: public eoAtomMutator<T> {
|
||||
public:
|
||||
|
||||
///
|
||||
eoAtomCreep() {};
|
||||
|
||||
///
|
||||
virtual ~eoAtomCreep() {};
|
||||
|
||||
///
|
||||
virtual void operator()( T& _val ) const {
|
||||
if ( rng.flip( 0.5 ) ) {
|
||||
_val++;
|
||||
} else {
|
||||
_val--;
|
||||
}
|
||||
}
|
||||
|
||||
/** @name Methods from eoObject
|
||||
*/
|
||||
//@{
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
virtual string className() const {return "eoAtomCreep";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
95
eo/src/eoAtomMutation.h
Normal file
95
eo/src/eoAtomMutation.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
// -*- 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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _EOATOMMUTATION_H
|
||||
#define _EOATOMMUTATION_H
|
||||
|
||||
// STL includes
|
||||
#include <iterator>
|
||||
|
||||
// EO includes
|
||||
#include <eoOp.h>
|
||||
#include <eoUniform.h>
|
||||
#include <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 tipe
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoAtomMutation: public eoMonOp<EOT> {
|
||||
public:
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef EOT::Type Type;
|
||||
#else
|
||||
typedef typename EOT::Type Type;
|
||||
#endif
|
||||
|
||||
///
|
||||
eoAtomMutation(const eoAtomMutator<Type>& _atomMut, const double _rate=0.0)
|
||||
: eoMonOp< EOT >(), rate(_rate), atomMutator( _atomMut ) {};
|
||||
|
||||
///
|
||||
virtual ~eoAtomMutation() {};
|
||||
|
||||
///
|
||||
virtual void operator()( EOT& _eo ) const {
|
||||
typename EOT::iterator i;
|
||||
for ( i = _eo.begin(); i != _eo.end(); i ++ )
|
||||
if ( rng.flip( rate ) ) {
|
||||
atomMutator( *i );
|
||||
}
|
||||
}
|
||||
|
||||
/** 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;
|
||||
const eoAtomMutator<Type>& atomMutator;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
61
eo/src/eoAtomMutator.h
Normal file
61
eo/src/eoAtomMutator.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// -*- 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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _EOATOMMUTATOR_H
|
||||
#define _EOATOMMUTATOR_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.
|
||||
*/
|
||||
template <class T>
|
||||
class eoAtomMutator: public eoPrintable {
|
||||
public:
|
||||
|
||||
///
|
||||
eoAtomMutator() {};
|
||||
|
||||
///
|
||||
virtual ~eoAtomMutator() {};
|
||||
|
||||
///
|
||||
virtual void operator()( T& _val ) const = 0;
|
||||
|
||||
/** @name Methods from eoObject
|
||||
*/
|
||||
//@{
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
///
|
||||
virtual string className() const {return "eoAtomMutator";};
|
||||
|
||||
///
|
||||
void printOn(ostream& _os) const { _os << className() << endl; };
|
||||
|
||||
//@}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
63
eo/src/eoAtomRandom.h
Normal file
63
eo/src/eoAtomRandom.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoAtomRandom.h
|
||||
// Increments or decrements by one a single element
|
||||
// (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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _EOATOMCREEP_H
|
||||
#define _EOATOMCREEP_H
|
||||
|
||||
#include <eoRandom.h>
|
||||
|
||||
/** Modifies using a random number generator, that is entered in the ctor.
|
||||
The RNG must return positive or negative numbers, whatever.
|
||||
*/
|
||||
template <class T>
|
||||
class eoAtomRandom: public eoAtomMutator<T> {
|
||||
public:
|
||||
|
||||
///
|
||||
eoAtomRandom( eoRandom& _rng): rng( _rng ) {};
|
||||
|
||||
///
|
||||
virtual ~eoAtomRandom() {};
|
||||
|
||||
///
|
||||
virtual void operator()( T& _val ) const {
|
||||
_val += rng();
|
||||
}
|
||||
|
||||
/** @name Methods from eoObject
|
||||
*/
|
||||
//@{
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
string className() const {return "eoAtomRandom";};
|
||||
//@}
|
||||
|
||||
private:
|
||||
eoRandom rng;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
156
eo/src/eoBin.h
156
eo/src/eoBin.h
|
|
@ -1,78 +1,78 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoBin.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef eoBin_h
|
||||
#define eoBin_h
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // ostream, istream
|
||||
#include <functional> // bind2nd
|
||||
#include <string> // string
|
||||
#include <eoVector.h> // EO
|
||||
|
||||
/*****************************************************************************
|
||||
* eoBin: implementation of binary chromosome. *
|
||||
* based on STL's bit_vector (vector<bool>). *
|
||||
*****************************************************************************/
|
||||
|
||||
template <class F> class eoBin: public eoVector<bool, F>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
* @param size Size of the binary string.
|
||||
*/
|
||||
eoBin(unsigned size = 0, bool value = false):
|
||||
eoVector<bool,F>(size, value) {}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param size Size of the binary string.
|
||||
*/
|
||||
eoBin(unsigned size, const eoRnd<bool>& rnd): eoVector<bool,F>(size)
|
||||
{
|
||||
generate(begin(), end(), rnd);
|
||||
}
|
||||
|
||||
/** Constructor from istream.
|
||||
@param is The istream to read from.*/
|
||||
eoBin(istream& _is):eoVector<bool,F>(_is){};
|
||||
|
||||
/// My class name.
|
||||
string className() const
|
||||
{
|
||||
return "eoBin";
|
||||
}
|
||||
|
||||
/**
|
||||
* To print me on a stream.
|
||||
* @param os The ostream.
|
||||
*/
|
||||
void printOn(ostream& os) const
|
||||
{
|
||||
copy(begin(), end(), ostream_iterator<bool>(os));
|
||||
}
|
||||
|
||||
/**
|
||||
* To read me from a stream.
|
||||
* @param is The istream.
|
||||
*/
|
||||
void readFrom(istream& is)
|
||||
{
|
||||
string bits;
|
||||
is >> bits;
|
||||
if (is)
|
||||
{
|
||||
resize(bits.size());
|
||||
transform(bits.begin(), bits.end(), begin(),
|
||||
bind2nd(equal_to<char>(), '1'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif eoBin_h
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoBin.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef eoBin_h
|
||||
#define eoBin_h
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // ostream, istream
|
||||
#include <functional> // bind2nd
|
||||
#include <string> // string
|
||||
#include <eoVector.h> // EO
|
||||
|
||||
/*****************************************************************************
|
||||
* eoBin: implementation of binary chromosome. *
|
||||
* based on STL's bit_vector (vector<bool>). *
|
||||
*****************************************************************************/
|
||||
|
||||
template <class F> class eoBin: public eoVector<bool, F>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
* @param size Size of the binary string.
|
||||
*/
|
||||
eoBin(unsigned size = 0, bool value = false):
|
||||
eoVector<bool,F>(size, value) {}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param size Size of the binary string.
|
||||
*/
|
||||
eoBin(unsigned size, const eoRnd<bool>& rnd): eoVector<bool,F>(size)
|
||||
{
|
||||
generate(begin(), end(), rnd);
|
||||
}
|
||||
|
||||
/** Constructor from istream.
|
||||
@param is The istream to read from.*/
|
||||
eoBin(istream& _is):eoVector<bool,F>(_is){};
|
||||
|
||||
/// My class name.
|
||||
string className() const
|
||||
{
|
||||
return "eoBin";
|
||||
}
|
||||
|
||||
/**
|
||||
* To print me on a stream.
|
||||
* @param os The ostream.
|
||||
*/
|
||||
void printOn(ostream& os) const
|
||||
{
|
||||
copy(begin(), end(), ostream_iterator<bool>(os));
|
||||
}
|
||||
|
||||
/**
|
||||
* To read me from a stream.
|
||||
* @param is The istream.
|
||||
*/
|
||||
void readFrom(istream& is)
|
||||
{
|
||||
string bits;
|
||||
is >> bits;
|
||||
if (is)
|
||||
{
|
||||
resize(bits.size());
|
||||
transform(bits.begin(), bits.end(), begin(),
|
||||
bind2nd(equal_to<char>(), '1'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif eoBin_h
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
// eoBitOpFactory.h
|
||||
// eoBitOpFactory.h
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoOpFactory.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
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 _EOBITOPFACTORY_H
|
||||
#define _EOBITOPFACTORY_H
|
||||
|
|
@ -52,12 +52,12 @@ public:
|
|||
/** Another factory method: creates an object from an istream, reading from
|
||||
it whatever is needed to create the object. Usually, the format for the istream will be\\
|
||||
objectType parameter1 parameter2 ... parametern\\
|
||||
If there are problems, an exception is raised; it should be caught at the
|
||||
If there are problems, an exception is raised; it should be caught at the
|
||||
upper level, because it might be something for that level\\
|
||||
At the same time, it catches exceptions thrown at a lower level, which will
|
||||
indicate that whatever is in the stream is for this method to process
|
||||
@param _is an stream from where a single line will be read
|
||||
@throw runtime_exception if the object type is not known
|
||||
indicate that whatever is in the stream is for this method to process
|
||||
@param _is an stream from where a single line will be read
|
||||
@throw runtime_exception if the object type is not known
|
||||
*/
|
||||
virtual eoOp<EOT>* make(istream& _is) {
|
||||
eoOp<EOT> * opPtr = NULL;
|
||||
|
|
@ -112,7 +112,7 @@ public:
|
|||
return opPtr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,81 +1,82 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoBreeder.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef eoBreeder_h
|
||||
#define eoBreeder_h
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <vector> // vector
|
||||
#include <eoUniform.h> // eoUniform
|
||||
#include <eoOp.h> // eoOp, eoMonOp, eoBinOp
|
||||
#include <eoPop.h> // eoPop
|
||||
#include <eoPopOps.h> // eoTransform
|
||||
#include <eoOpSelector.h> // eoOpSelector
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*****************************************************************************
|
||||
* eoBreeder: transforms a population using genetic operators. *
|
||||
* For every operator there is a rated to be applyed. *
|
||||
*****************************************************************************/
|
||||
|
||||
template<class Chrom> class eoBreeder: public eoTransform<Chrom>
|
||||
{
|
||||
public:
|
||||
/// Default constructor.
|
||||
eoBreeder( eoOpSelector<Chrom>& _opSel): opSel( _opSel ) {}
|
||||
|
||||
/// Destructor.
|
||||
virtual ~eoBreeder() {}
|
||||
|
||||
/**
|
||||
* Transforms a population.
|
||||
* @param pop The population to be transformed.
|
||||
*/
|
||||
void operator()(eoPop<Chrom>& pop)
|
||||
{
|
||||
for (unsigned i = 0; i < pop.size(); i++) {
|
||||
eoOp<Chrom>* op = opSel.Op();
|
||||
switch (op->readArity()) {
|
||||
case unary:
|
||||
{
|
||||
eoMonOp<Chrom>* monop = static_cast<eoMonOp<Chrom>* >(op);
|
||||
(*monop)( pop[i] );
|
||||
break;
|
||||
}
|
||||
case binary:
|
||||
{
|
||||
eoBinOp<Chrom>* binop = static_cast<eoBinOp<Chrom>* >(op);
|
||||
eoUniform<unsigned> u(0, pop.size() );
|
||||
(*binop)(pop[i], pop[ u() ] );
|
||||
break;
|
||||
}
|
||||
case Nary:
|
||||
{
|
||||
eoNaryOp<Chrom>* Nop = static_cast<eoNaryOp<Chrom>* >(op);
|
||||
eoUniform<unsigned> u(0, pop.size() );
|
||||
eoPop<Chrom> tmpVec;
|
||||
tmpVec.push_back( pop[i] );
|
||||
for ( unsigned i = 0; i < u(); i ++ ) {
|
||||
tmpVec.push_back( pop[ u() ] );
|
||||
}
|
||||
(*Nop)( tmpVec );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// The class name.
|
||||
string classname() const { return "eoBreeder"; }
|
||||
|
||||
private:
|
||||
eoOpSelector<Chrom>& opSel;
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif eoBreeder_h
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoBreeder.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef eoBreeder_h
|
||||
#define eoBreeder_h
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <vector> // vector
|
||||
#include <eoUniform.h> // eoUniform
|
||||
#include <eoOp.h> // eoOp, eoMonOp, eoBinOp
|
||||
#include <eoPop.h> // eoPop
|
||||
#include <eoPopOps.h> // eoTransform
|
||||
#include <eoOpSelector.h> // eoOpSelector
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*****************************************************************************
|
||||
* eoBreeder: transforms a population using genetic operators. *
|
||||
* For every operator there is a rated to be applyed. *
|
||||
*****************************************************************************/
|
||||
|
||||
template<class Chrom> class eoBreeder: public eoTransform<Chrom>
|
||||
{
|
||||
public:
|
||||
/// Default constructor.
|
||||
eoBreeder( eoOpSelector<Chrom>& _opSel): opSel( _opSel ) {}
|
||||
|
||||
/// Destructor.
|
||||
virtual ~eoBreeder() {}
|
||||
|
||||
/**
|
||||
* Transforms a population.
|
||||
* @param pop The population to be transformed.
|
||||
*/
|
||||
void operator()(eoPop<Chrom>& pop)
|
||||
{
|
||||
for (unsigned i = 0; i < pop.size(); i++) {
|
||||
eoOp<Chrom>* op = opSel.Op();
|
||||
switch (op->readArity()) {
|
||||
case unary:
|
||||
{
|
||||
eoMonOp<Chrom>* monop = static_cast<eoMonOp<Chrom>* >(op);
|
||||
(*monop)( pop[i] );
|
||||
break;
|
||||
}
|
||||
case binary:
|
||||
{
|
||||
eoBinOp<Chrom>* binop = static_cast<eoBinOp<Chrom>* >(op);
|
||||
eoUniform<unsigned> u(0, pop.size() );
|
||||
(*binop)(pop[i], pop[ u() ] );
|
||||
break;
|
||||
}
|
||||
case Nary:
|
||||
{
|
||||
eoNaryOp<Chrom>* Nop = static_cast<eoNaryOp<Chrom>* >(op);
|
||||
eoUniform<unsigned> u(0, pop.size() );
|
||||
eoPop<Chrom> inVec, outVec;
|
||||
inVec.push_back( pop[i] );
|
||||
unsigned numberOfOperands = u();
|
||||
for ( unsigned i = 0; i < numberOfOperands; i ++ ) {
|
||||
inVec.push_back( pop[ u() ] );
|
||||
}
|
||||
(*Nop)( inVec, outVec );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// The class name.
|
||||
string classname() const { return "eoBreeder"; }
|
||||
|
||||
private:
|
||||
eoOpSelector<Chrom>& opSel;
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif eoBreeder_h
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoData.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EODATA_H
|
||||
#define EODATA_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <vector> // vector
|
||||
#include <set> // set
|
||||
#include <string> // string
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoData.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EODATA_H
|
||||
#define EODATA_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <vector> // vector
|
||||
#include <set> // set
|
||||
#include <string> // string
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <limits> // MAXDOUBLE
|
||||
|
|
@ -20,22 +20,22 @@ using namespace std;
|
|||
#define MINFLOAT numeric_limits<float>::min()
|
||||
#define MAXDOUBLE numeric_limits<double>::max()
|
||||
#define MAXINT numeric_limits<int>::max()
|
||||
#else
|
||||
#include <float.h>
|
||||
#else
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <values.h>
|
||||
#include <values.h>
|
||||
#ifndef MAXFLOAT
|
||||
#define MAXFLOAT (float)1e127
|
||||
#define MAXDOUBLE (double)1.79769313486231570e+308
|
||||
#define MAXINT 2147483647
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <math.h>
|
||||
#define _isnan isnan
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif EODATA_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <math.h>
|
||||
#define _isnan isnan
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif EODATA_H
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
// eoDup.h
|
||||
// eoDup.h
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoKill.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
|
||||
*/
|
||||
/*
|
||||
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 _EODUP_h
|
||||
|
|
|
|||
|
|
@ -3,23 +3,23 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoESChrom.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
|
||||
*/
|
||||
/*
|
||||
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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
|||
270
eo/src/eoESFullChrom.h
Normal file
270
eo/src/eoESFullChrom.h
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoESInd.h
|
||||
// (c) GeNeura Team, 1998 - EEAAX 1999
|
||||
/*
|
||||
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
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _EOESFULLCHROM_H
|
||||
#define _EOESFULLCHROM_H
|
||||
|
||||
// STL libraries
|
||||
#include <vector> // For vector<>
|
||||
#include <stdexcept>
|
||||
#include <strstream>
|
||||
#include <iostream> // for ostream
|
||||
|
||||
// EO includes
|
||||
#include <eoVector.h>
|
||||
#include <eoRNG.h>
|
||||
/**@name Chromosomes for evolution strategies
|
||||
Each chromosome in an evolution strategies is composed of a vector of floating point
|
||||
values plus a vector of sigmas, that are added to them during mutation and a vector of correlations
|
||||
*/
|
||||
//@{
|
||||
|
||||
|
||||
/**@name individuals for evolution strategies -MS- 22/10/99
|
||||
Each individual in an evolution strategy is composed of
|
||||
a vector of floating point values
|
||||
a vector of std deviations
|
||||
a vector of rotation angles (for correlated mutations)
|
||||
|
||||
THese individuals CANNOT BE IMPLEMENTED as vectors of anything
|
||||
at least in the case of correlated mutations
|
||||
*/
|
||||
//@{
|
||||
|
||||
template <typename fitT = float >
|
||||
class eoESFullChrom : public eoVector<double, fitT> {
|
||||
public:
|
||||
/// constructor
|
||||
eoESFullChrom( unsigned _num_genes = 1,
|
||||
unsigned _num_sigma = 1, unsigned _num_correl = 0,
|
||||
bool _verbose = false,
|
||||
double _ObjMin = 0, double _ObjMax = 1,
|
||||
double _StdDevInit = 0.3 ):
|
||||
eoVector<double, fitT>(_num_genes),
|
||||
// ObjVar( _num_genes ), now an eoVector<double>
|
||||
StdDev( _num_sigma ),
|
||||
CorCff( _num_correl ),
|
||||
verbose( _verbose ),
|
||||
ObjMin( _ObjMin ),
|
||||
ObjMax(_ObjMax ),
|
||||
StdDevInit( _StdDevInit ) {}
|
||||
|
||||
/// copy constructor
|
||||
eoESFullChrom( const eoESFullChrom& _eo ):
|
||||
eoVector<double, fitT> ( _eo ), // ObjVar ( _eo.ObjVar ),
|
||||
StdDev ( _eo.StdDev ), CorCff( _eo.CorCff ), verbose( _eo.verbose ),
|
||||
ObjMin( _eo.ObjMin ), ObjMax(_eo.ObjMax ), StdDevInit( _eo.StdDevInit ) {}
|
||||
|
||||
|
||||
/* another constructor, for compatibility reasons */
|
||||
eoESFullChrom(istream& _s) {cout << "Not Yet implemented\n";exit(1);};
|
||||
|
||||
/* And now the useful constructor: from a parser (should be in the
|
||||
factory, if such a thing exists one day for eoESFullChrom
|
||||
*/
|
||||
eoESFullChrom(Parser & parser) : StdDev(0), CorCff(0) {
|
||||
parser.AddTitle("Description of ES individuals");
|
||||
int num_genes, num_sigma;
|
||||
bool correlated_mutations;
|
||||
try {
|
||||
num_genes = parser.getInt("-Io", "--NbObjVar", "2",
|
||||
"Number of Object Variables" );
|
||||
num_sigma = parser.getInt("-Is", "--NbSigma", "1",
|
||||
"Number of Standard Deviations" );
|
||||
correlated_mutations = parser.getBool("-Ic", "--Correlated",
|
||||
"Correlated mutation?" );
|
||||
ObjMin = parser.getFloat("-Im", "--min", "0",
|
||||
"Minimum value for object variables" );
|
||||
ObjMax = parser.getFloat("-IM", "--max", "1",
|
||||
"Maximum value for object variables" );
|
||||
StdDevInit = parser.getFloat("-II", "--SigmaInit", "0.3",
|
||||
"Initial value for std. dev. (scaled by range)" );
|
||||
verbose = parser.getBool("-Iv", "--verbose",
|
||||
"Verbose listing of ES individuals (mutation parameters");
|
||||
}
|
||||
catch (exception & e)
|
||||
{
|
||||
cout << e.what() << endl;
|
||||
parser.printHelp();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// consistency tests
|
||||
if (! num_sigma) { // no std dev??? EXCEPTION
|
||||
throw invalid_argument( "No standard deviation: choose another representation please" );
|
||||
}
|
||||
if (num_sigma > num_genes) {
|
||||
cout << "WARNING, Number of Standard Deviations > Number of Object Variables\nAdjusted!\n";
|
||||
num_sigma = num_genes;
|
||||
// modify the Param value - so .status is OK
|
||||
char sloc[20];
|
||||
sprintf(sloc, "%d", num_genes);
|
||||
parser.setParamValue("--NbSigma", sloc);
|
||||
}
|
||||
// adjust the sizes!!!
|
||||
resize(num_genes);
|
||||
if (num_sigma)
|
||||
StdDev.resize(num_sigma);
|
||||
if (correlated_mutations) {
|
||||
if (num_sigma < num_genes) {
|
||||
cout << "WARNING less Std Dev. than number of variables + Correlated mutations\n";
|
||||
cout << "Though possible, this is a strange setting" << endl;
|
||||
}
|
||||
// nb of rotation angles: N*(N-1)/2 (in general!)
|
||||
CorCff.resize ( (2*num_genes - num_sigma)*(num_sigma - 1) / 2 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// Operator =
|
||||
const eoESFullChrom& operator = ( const eoESFullChrom& _eo ) {
|
||||
if ( this != &_eo ) {
|
||||
// Change EO part
|
||||
eoVector<double, fitT>::operator = (_eo);
|
||||
|
||||
// Change this part
|
||||
// ObjVar = _eo.ObjVar;
|
||||
StdDev = _eo.StdDev;
|
||||
CorCff = _eo.CorCff;
|
||||
verbose = _eo.verbose;
|
||||
ObjMin = _eo.ObjMin;
|
||||
ObjMax = _eo.ObjMax;
|
||||
StdDevInit = _eo.StdDevInit;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// destructor
|
||||
virtual ~eoESFullChrom() {}
|
||||
|
||||
///
|
||||
double getStdDev( unsigned _i ) const {
|
||||
if ( _i >= length() )
|
||||
throw out_of_range( "out_of_range when reading StdDev");
|
||||
return StdDev[ _i ];
|
||||
}
|
||||
|
||||
///
|
||||
void setStdDev( unsigned _i, double _val ) {
|
||||
if ( _i < length() ) {
|
||||
StdDev[_i] = _val;
|
||||
} else
|
||||
throw out_of_range( "out_of_range when writing StdDev");
|
||||
}
|
||||
|
||||
///
|
||||
double getCorCff( unsigned _i ) const {
|
||||
if ( _i >= length() )
|
||||
throw out_of_range( "out_of_range when reading CorCff");
|
||||
return CorCff[ _i ];
|
||||
}
|
||||
|
||||
///
|
||||
void setCorCff( unsigned _i, double _val ) {
|
||||
if ( _i < length() ) {
|
||||
CorCff[_i] = _val;
|
||||
} else
|
||||
throw out_of_range( "out_of_range when writing CorCff");
|
||||
}
|
||||
|
||||
///
|
||||
void insertGene( unsigned _i, double _val ) {
|
||||
throw FixedLengthChromosome();
|
||||
};
|
||||
|
||||
///
|
||||
void deleteGene( unsigned _i ) {
|
||||
throw FixedLengthChromosome();
|
||||
};
|
||||
|
||||
///
|
||||
unsigned length() const { return size();}/* formerly ObjVar.size() */
|
||||
unsigned StdDevLength() const { return StdDev.size();}
|
||||
unsigned CorCffLength() const { return CorCff.size();}
|
||||
|
||||
|
||||
/** Print itself: inherited from eoObject implementation.
|
||||
Instance from base classes are processed in
|
||||
base classes, so you don´t have to worry about, for instance, fitness.
|
||||
@param _s the ostream in which things are written*/
|
||||
virtual void printOn( ostream& _s ) const{
|
||||
copy( begin(), end(), ostream_iterator<double>( _s, " ") );
|
||||
// The formatting instructinos shoudl be left to the caller
|
||||
// _s << "\n";
|
||||
if (verbose) {
|
||||
_s << "\n\tStd Dev. " ;
|
||||
copy( StdDev.begin(), StdDev.end(), ostream_iterator<double>( _s, " ") );
|
||||
if (CorCff.size()) {
|
||||
_s << "\n\t";
|
||||
copy( CorCff.begin(), CorCff.end(), ostream_iterator<double>( _s, " ") );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** This exception should be thrown when trying to insert or delete a gene
|
||||
in a fixed length chromosome
|
||||
*/
|
||||
class FixedLengthChromosome : public exception {
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
FixedLengthChromosome()
|
||||
: exception() { };
|
||||
|
||||
~FixedLengthChromosome() {};
|
||||
};
|
||||
|
||||
// accessors
|
||||
double getObjMin() const {return ObjMin;}
|
||||
double getObjMax() const {return ObjMax;}
|
||||
double getStdDevInit () const {return StdDevInit;}
|
||||
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
virtual string className() const {return "eoESFullChrom";};
|
||||
|
||||
private:
|
||||
// vector<double> ObjVar; /* object variable vector */
|
||||
// or shoudl the class be subclass of EOVector<double> ???
|
||||
|
||||
vector<double> StdDev; /* standard deviation vector */
|
||||
vector<double> CorCff; /* correlation coefficient vector */
|
||||
|
||||
bool verbose; /* Print std deviations or not */
|
||||
|
||||
/** the range is used for mutation AND random initialization,
|
||||
* while the StdDevInit is used only for random initialization
|
||||
* this in a little inconsistent!
|
||||
*/
|
||||
double ObjMin, ObjMax; /* Range for Object variables */
|
||||
double StdDevInit; /* Initial value of Standard Deviations */
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
243
eo/src/eoESFullMut.h
Normal file
243
eo/src/eoESFullMut.h
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoESMute.h : ES mutation
|
||||
// (c) GeNeura Team, 1998 for the EO part
|
||||
// Th. Baeck 1994 and EEAAX 1999 for the ES part
|
||||
/*
|
||||
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
|
||||
marc.schoenauer@polytechnique.fr
|
||||
http://eeaax.cmap.polytchnique.fr/
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef _EOESMUT_H
|
||||
#define _EOESMUT_H
|
||||
|
||||
#include <eoParser.h>
|
||||
#include <eoRNG.h>
|
||||
#include <cmath> // for exp
|
||||
|
||||
#include <eoESFullChrom.h>
|
||||
#include <eoOp.h>
|
||||
|
||||
const double ES_SIGEPS = 1.0e-40; /* ES lower bound for sigma values */
|
||||
// should not be a parameter ...
|
||||
|
||||
/** ES-style mutation in the large: Obviously, valid only for eoESInd
|
||||
*/
|
||||
template <class fitT>
|
||||
class eoESMutate: public eoMonOp< eoESFullChrom<fitT> > {
|
||||
public:
|
||||
///
|
||||
eoESMutate( double _TauLcl, double _TauGlb, double _TauBeta )
|
||||
: eoMonOp< eoESFullChrom<fitT> >( ), TauLcl(_TauLcl), TauGlb(_TauGlb),
|
||||
TauBeta(_TauBeta) {};
|
||||
|
||||
/* The parser constructor
|
||||
*/
|
||||
eoESMutate(Parser & parser, unsigned _stdDevLength, unsigned _size, bool _correlated ):
|
||||
eoMonOp< eoESFullChrom<fitT> >( ) {
|
||||
parser.AddTitle("Parameters of ES mutation (before renormalization)");
|
||||
try { // we know that there is at least 1 std dev.
|
||||
if (_stdDevLength == 1) {
|
||||
TauLcl = parser.getInt("-Ml", "--TauLcl", "1",
|
||||
"TauLcl, Mutation rate for the only Std Dev." );
|
||||
// different normalization in that case -- Thomas Baeck
|
||||
TauLcl /= sqrt((double) _size);
|
||||
}
|
||||
else { /* more than 1 std dev */
|
||||
TauLcl = parser.getFloat("-Ml", "--TauLcl", "1",
|
||||
"Local mutation rate for Std Dev." );
|
||||
TauGlb = parser.getFloat("-Mg", "--TauGlb", "1",
|
||||
"Global mutation rate for Std Dev." );
|
||||
// renormalization
|
||||
TauLcl /= sqrt( 2.0 * sqrt( (double)_size ) );
|
||||
TauGlb /= sqrt( 2.0 * ( (double) _size ) );
|
||||
|
||||
if ( _correlated ) { // Correlated Mutations
|
||||
TauBeta = parser.getFloat("-Mb", "--TauBeta", "0.0873",
|
||||
"Mutation rate for corr. coeff." );
|
||||
// rotation angles: no normalization
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (exception & e)
|
||||
{
|
||||
cout << e.what() << endl;
|
||||
parser.printHelp();
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
/// needed virtual dtor
|
||||
virtual ~eoESMutate() {};
|
||||
|
||||
// virtual separation depending wether correlated mutations are present
|
||||
virtual void operator() ( eoESFullChrom<fitT> & _eo ) const {
|
||||
if (_eo.CorCffLength())
|
||||
CorrelatedMutation(_eo);
|
||||
else
|
||||
StandardMutation(_eo);
|
||||
}
|
||||
|
||||
/** @name Methods from eoObject
|
||||
readFrom and printOn are directly inherited from eoObject
|
||||
*/
|
||||
//@{
|
||||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
virtual string className() const {return "eoESMutate";};
|
||||
|
||||
private:
|
||||
/// mutations - standard et correlated
|
||||
// =========
|
||||
/*
|
||||
* Standard mutation of object variables and standard
|
||||
* deviations in ESs.
|
||||
* If there are fewer different standard deviations available
|
||||
* than the dimension of the objective function requires, the
|
||||
* last standard deviation is responsible for ALL remaining
|
||||
* object variables.
|
||||
* Schwefel 1977: Numerische Optimierung von Computer-Modellen
|
||||
* mittels der Evolutionsstrategie, pp. 165 ff.
|
||||
*/
|
||||
|
||||
virtual void StandardMutation( eoESFullChrom<fitT> & _eo ) const {
|
||||
unsigned i,k;
|
||||
double Glb, StdLoc;
|
||||
|
||||
if (_eo.StdDevLength() == 1) { /* single StdDev -> No global factor */
|
||||
StdLoc = _eo.getStdDev(0);
|
||||
StdLoc *= exp(TauLcl*rng.normal());
|
||||
if (StdLoc < ES_SIGEPS)
|
||||
StdLoc = ES_SIGEPS;
|
||||
_eo.setStdDev(0, StdLoc);
|
||||
_eo.setGene( 0, _eo.getGene(0) + StdLoc*rng.normal());
|
||||
i = 1;
|
||||
}
|
||||
else { /* more than one std dev. */
|
||||
Glb = exp(TauGlb*rng.normal());
|
||||
for (i = 0; i < _eo.length() && i < _eo.StdDevLength(); i++) {
|
||||
StdLoc = _eo.getStdDev(i);
|
||||
StdLoc *= Glb * exp(TauLcl*rng.normal());
|
||||
if (StdLoc < ES_SIGEPS)
|
||||
StdLoc = ES_SIGEPS;
|
||||
_eo.setStdDev(i, StdLoc);
|
||||
_eo.setGene( i, _eo.getGene(i) + StdLoc*rng.normal());
|
||||
}
|
||||
}
|
||||
// last object variables: same STdDev than the preceding one
|
||||
for (k = i; k < _eo.length(); k++) {
|
||||
_eo.setGene( k, _eo.getGene(k) + StdLoc*rng.normal() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Correlated mutations in ESs, according to the following
|
||||
* sources:
|
||||
* H.-P. Schwefel: Internal Report of KFA Juelich, KFA-STE-IB-3/80
|
||||
* p. 43, 1980
|
||||
* G. Rudolph: Globale Optimierung mit parallelen Evolutions-
|
||||
* strategien, Diploma Thesis, University of Dortmund, 1990
|
||||
*/
|
||||
|
||||
// Code from Thomas Baeck
|
||||
|
||||
virtual void CorrelatedMutation( eoESFullChrom<fitT> & _eo ) const {
|
||||
|
||||
|
||||
int i, k, n1, n2, nq;
|
||||
|
||||
double d1, d2, S, C, Glb;
|
||||
double tmp;
|
||||
/*
|
||||
* First: mutate standard deviations (as above).
|
||||
*/
|
||||
|
||||
Glb = exp(TauGlb*rng.normal());
|
||||
for (i = 0; i < _eo.StdDevLength(); i++) {
|
||||
tmp = _eo.getStdDev(i);
|
||||
_eo.setStdDev( i, tmp*Glb*exp(TauLcl*rng.normal()) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Mutate rotation angles.
|
||||
*/
|
||||
|
||||
for (i = 0; i < _eo.CorCffLength(); i++) {
|
||||
tmp = _eo.getCorCff(i);
|
||||
tmp += TauBeta*rng.normal();
|
||||
// danger of VERY long loops --MS--
|
||||
// while (CorCff[i] > M_PI)
|
||||
// CorCff[i] -= 2.0 * M_PI;
|
||||
// while (CorCff[i] < - M_PI)
|
||||
// CorCff[i] += 2.0 * M_PI;
|
||||
if ( fabs(tmp) > M_PI ) {
|
||||
tmp -= M_PI * (int) (tmp/M_PI) ;
|
||||
}
|
||||
_eo.setCorCff(i, tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform correlated mutations.
|
||||
*/
|
||||
vector<double> VarStp(_eo.size());
|
||||
for (i = 0; i < _eo.size() && i < _eo.StdDevLength(); i++)
|
||||
VarStp[i] = _eo.getStdDev(i)*rng.normal();
|
||||
for (k = i; k < _eo.size(); k++)
|
||||
VarStp[k] = _eo.getStdDev(i-1)*rng.normal();
|
||||
nq = _eo.CorCffLength() - 1;
|
||||
for (k = _eo.size()-_eo.StdDevLength(); k < _eo.size()-1; k++) {
|
||||
n1 = _eo.size() - k - 1;
|
||||
n2 = _eo.size() - 1;
|
||||
for (i = 0; i < k; i++) {
|
||||
d1 = VarStp[n1];
|
||||
d2 = VarStp[n2];
|
||||
S = sin( _eo.getCorCff(nq) );
|
||||
C = cos( _eo.getCorCff(nq) );
|
||||
VarStp[n2] = d1 * S + d2 * C;
|
||||
VarStp[n1] = d1 * C - d2 * S;
|
||||
n2--;
|
||||
nq--;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < _eo.size(); i++)
|
||||
_eo[i] += VarStp[i];
|
||||
|
||||
}
|
||||
// the data
|
||||
//=========
|
||||
double TauLcl; /* Local factor for mutation of std deviations */
|
||||
double TauGlb; /* Global factor for mutation of std deviations */
|
||||
double TauBeta; /* Factor for mutation of correlation parameters */
|
||||
};
|
||||
|
||||
/*
|
||||
* Correlated mutations in ESs, according to the following
|
||||
* sources:
|
||||
* H.-P. Schwefel: Internal Report of KFA Juelich, KFA-STE-IB-3/80
|
||||
* p. 43, 1980
|
||||
* G. Rudolph: Globale Optimierung mit parallelen Evolutions-
|
||||
* strategien, Diploma Thesis, University of Dortmund, 1990
|
||||
*/
|
||||
// Not yet implemented!
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,84 +1,84 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoEasyEA.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoEasyEA_h
|
||||
#define _eoEasyEA_h
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eoGeneration.h> // eoPop
|
||||
#include <eoTerm.h>
|
||||
|
||||
/** EOEasyEA:
|
||||
An easy-to-use evolutionary algorithm; you can use any chromosome,
|
||||
and any selection transformation, merging and evaluation
|
||||
algorithms; you can even change in runtime parameters of those
|
||||
sub-algorithms
|
||||
*/
|
||||
|
||||
template<class Chrom> class eoEasyEA: public eoAlgo<Chrom>
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
eoEasyEA(eoSelect<Chrom>& _select,
|
||||
eoTransform<Chrom>& _transform,
|
||||
eoMerge<Chrom>& _replace,
|
||||
eoEvalFunc<Chrom>& _evaluator,
|
||||
eoTerm<Chrom>& _terminator)
|
||||
:step(_select, _transform, _replace, _evaluator),
|
||||
terminator( _terminator){};
|
||||
|
||||
/// Constructor from an already created generation
|
||||
eoEasyEA(eoGeneration<Chrom>& _gen,
|
||||
eoTerm<Chrom>& _terminator):
|
||||
step(_gen),
|
||||
terminator( _terminator){};
|
||||
|
||||
/// Apply one generation of evolution to the population.
|
||||
virtual void operator()(eoPop<Chrom>& pop) {
|
||||
do {
|
||||
try
|
||||
{
|
||||
step(pop);
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
string s = e.what();
|
||||
s.append( " in eoEasyEA ");
|
||||
throw runtime_error( s );
|
||||
}
|
||||
} while ( terminator( pop ) );
|
||||
}
|
||||
|
||||
/// Class name.
|
||||
string className() const { return "eoEasyEA"; }
|
||||
|
||||
private:
|
||||
eoGeneration<Chrom> step;
|
||||
eoTerm<Chrom>& terminator;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif eoEasyEA_h
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoEasyEA.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoEasyEA_h
|
||||
#define _eoEasyEA_h
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eoGeneration.h> // eoPop
|
||||
#include <eoTerm.h>
|
||||
|
||||
/** EOEasyEA:
|
||||
An easy-to-use evolutionary algorithm; you can use any chromosome,
|
||||
and any selection transformation, merging and evaluation
|
||||
algorithms; you can even change in runtime parameters of those
|
||||
sub-algorithms
|
||||
*/
|
||||
|
||||
template<class Chrom> class eoEasyEA: public eoAlgo<Chrom>
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
eoEasyEA(eoSelect<Chrom>& _select,
|
||||
eoTransform<Chrom>& _transform,
|
||||
eoMerge<Chrom>& _replace,
|
||||
eoEvalFunc<Chrom>& _evaluator,
|
||||
eoTerm<Chrom>& _terminator)
|
||||
:step(_select, _transform, _replace, _evaluator),
|
||||
terminator( _terminator){};
|
||||
|
||||
/// Constructor from an already created generation
|
||||
eoEasyEA(eoGeneration<Chrom>& _gen,
|
||||
eoTerm<Chrom>& _terminator):
|
||||
step(_gen),
|
||||
terminator( _terminator){};
|
||||
|
||||
/// Apply one generation of evolution to the population.
|
||||
virtual void operator()(eoPop<Chrom>& pop) {
|
||||
do {
|
||||
try
|
||||
{
|
||||
step(pop);
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
string s = e.what();
|
||||
s.append( " in eoEasyEA ");
|
||||
throw runtime_error( s );
|
||||
}
|
||||
} while ( terminator( pop ) );
|
||||
}
|
||||
|
||||
/// Class name.
|
||||
string className() const { return "eoEasyEA"; }
|
||||
|
||||
private:
|
||||
eoGeneration<Chrom> step;
|
||||
eoTerm<Chrom>& terminator;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif eoEasyEA_h
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoOp.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EOEVALFUNCPTR_H
|
||||
#define EOEVALFUNCPTR_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
/** EOEvalFuncPtr: This class
|
||||
* takes an existing function pointer and converts it into a evaluation
|
||||
* function class. That way, old style C or C++ functions can be adapted to EO
|
||||
* function classes.
|
||||
*/
|
||||
template< class EOT >
|
||||
struct eoEvalFuncPtr: public eoEvalFunc<EOT> {
|
||||
|
||||
eoEvalFuncPtr( void (* _eval)( EOT& ) )
|
||||
: eoEvalFunc(), evalFunc( _eval ) {};
|
||||
|
||||
/// Effectively applies the evaluation function to an EO
|
||||
virtual void operator() ( EOT & _eo ) const {
|
||||
(*evalFunc)( _eo );
|
||||
};
|
||||
|
||||
private:
|
||||
void (* evalFunc )( EOT& );
|
||||
};
|
||||
|
||||
#endif
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoOp.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
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef EOEVALFUNCPTR_H
|
||||
#define EOEVALFUNCPTR_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
/** EOEvalFuncPtr: This class
|
||||
* takes an existing function pointer and converts it into a evaluation
|
||||
* function class. That way, old style C or C++ functions can be adapted to EO
|
||||
* function classes.
|
||||
*/
|
||||
template< class EOT >
|
||||
struct eoEvalFuncPtr: public eoEvalFunc<EOT> {
|
||||
|
||||
eoEvalFuncPtr( void (* _eval)( EOT& ) )
|
||||
: eoEvalFunc<EOT>(), evalFunc( _eval ) {};
|
||||
|
||||
/// Effectively applies the evaluation function to an EO
|
||||
virtual void operator() ( EOT & _eo ) const {
|
||||
(*evalFunc)( _eo );
|
||||
};
|
||||
|
||||
private:
|
||||
void (* evalFunc )( EOT& );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,58 +3,58 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// eoEvaluator.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
|
||||
*/
|
||||
/*
|
||||
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 _EOEVALUATOR_H
|
||||
#ifndef _EOEVALUATOR_H
|
||||
#define _EOEVALUATOR_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <eoPopOps.h>
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Evaluator takes a vector of EOs and evaluates its fitness
|
||||
* returning void. Template instances must be of fitness and EO type
|
||||
*/
|
||||
template<class EOT>
|
||||
class eoEvaluator: public eoTransform<EOT>{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Evaluator takes a vector of EOs and evaluates its fitness
|
||||
* returning void. Template instances must be of fitness and EO type
|
||||
*/
|
||||
template<class EOT>
|
||||
class eoEvaluator: public eoTransform<EOT>{
|
||||
public:
|
||||
/// ctor
|
||||
eoEvaluator( const eoEvalFunc< EOT> & _ef )
|
||||
: eoTransform<EOT>(), repEF( _ef ){};
|
||||
|
||||
/// Needed virtual destructor
|
||||
virtual ~eoEvaluator() {};
|
||||
|
||||
/* Sets the evaluation function
|
||||
virtual void EF( const eoEvalFunc< EOT> & _ef ) { repEF= _ef;};*/
|
||||
|
||||
/// Needed virtual destructor
|
||||
virtual ~eoEvaluator() {};
|
||||
|
||||
/* Sets the evaluation function
|
||||
virtual void EF( const eoEvalFunc< EOT> & _ef ) { repEF= _ef;};*/
|
||||
|
||||
/// Gets the evaluation function
|
||||
virtual const eoEvalFunc< EOT>& EF() { return repEF;};
|
||||
|
||||
|
||||
/** This is the actual function operator(); it is left without implementation.
|
||||
It takes a vector of pointers to eo
|
||||
* @param _vEO is a vector of pointers to eo, that will be evaluated
|
||||
It takes a vector of pointers to eo
|
||||
* @param _vEO is a vector of pointers to eo, that will be evaluated
|
||||
*/
|
||||
|
||||
virtual void operator() ( EOT& _eot ) const = 0;
|
||||
|
||||
virtual void operator() ( EOT& _eot ) const = 0;
|
||||
|
||||
///@name eoObject methods
|
||||
//@{
|
||||
|
|
@ -62,11 +62,11 @@ public:
|
|||
virtual string className() const { return "eoEvaluator"; }
|
||||
|
||||
/** Read and print are left without implementation */
|
||||
//@}
|
||||
//@}
|
||||
|
||||
private:
|
||||
const eoEvalFunc< EOT> & repEF;
|
||||
};
|
||||
//@}
|
||||
|
||||
#endif
|
||||
const eoEvalFunc< EOT> & repEF;
|
||||
};
|
||||
//@}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue