diff --git a/eo/Makefile.am b/eo/Makefile.am index cb4127aa..1f6b0801 100644 --- a/eo/Makefile.am +++ b/eo/Makefile.am @@ -5,3 +5,4 @@ ############################################################################### SUBDIRS = src test + diff --git a/eo/doc/Makefile.am b/eo/doc/Makefile.am new file mode 100644 index 00000000..d2936d58 --- /dev/null +++ b/eo/doc/Makefile.am @@ -0,0 +1,7 @@ +############################################################################### +## +## Makefile.am for eo/doc +## +############################################################################### + +############################################################################### diff --git a/eo/src/Makefile.am b/eo/src/Makefile.am index 0bd70623..eaa8b4f6 100644 --- a/eo/src/Makefile.am +++ b/eo/src/Makefile.am @@ -7,4 +7,4 @@ lib_LTLIBRARIES = libeo.la libeo_la_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 +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 diff --git a/eo/src/eo b/eo/src/eo index 7fb1ceb9..0bd7f3bf 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -39,12 +39,19 @@ #include #include -#include // what's the matter with you? -#include // what's the matter with you? - #include -//#include +#include + + + +//----------------------------------------------------------------------------- +// to be continued ... +//----------------------------------------------------------------------------- + +#include // what's the matter with you? +#include // what's the matter with you? +// #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoInsertion.h b/eo/src/eoInsertion.h new file mode 100644 index 00000000..f05c29c5 --- /dev/null +++ b/eo/src/eoInsertion.h @@ -0,0 +1,49 @@ +//----------------------------------------------------------------------------- +// eoInsertion.h +//----------------------------------------------------------------------------- + +#ifndef eoInsertion_h +#define eoInsertion_h + +//----------------------------------------------------------------------------- + +#include + +//----------------------------------------------------------------------------- +// eoInsertion +//----------------------------------------------------------------------------- + +template class eoInsertion: public eoMerge +{ + public: + /// (Default) Constructor. + eoInsertion(const float& _rate = 1.0): eoMerge(_rate) {} + + /// + /// @param breeders + /// @param pop + void operator()(const eoPop& breeders, eoPop& pop) + { + cout << pop << endl; + + sort(pop.begin(), pop.end()); + + cout << pop << endl; + + cout << "cte = " + << (int)(pop.size() * (rate() - 1) - breeders.size()) << endl; + + pop.erase(pop.end() + (int)(pop.size() * (rate() - 1) - breeders.size()), + pop.end()); + + cout << "cte = " + << (int)(pop.size() * (rate() - 1) - breeders.size()) << endl; + + copy(breeders.begin(), breeders.end(), + back_insert_iterator >(pop)); + } +}; + +//----------------------------------------------------------------------------- + +#endif eoInsertion_h diff --git a/eo/src/eoPopOps.h b/eo/src/eoPopOps.h index 7eabb475..cc0a10f9 100644 --- a/eo/src/eoPopOps.h +++ b/eo/src/eoPopOps.h @@ -8,7 +8,6 @@ #ifndef _EOPOPOPS_H #define _EOPOPOPS_H - using namespace std; /** @@ -99,13 +98,13 @@ class eoMerge: public eoObject{ * @param breeders Tranformed individuals. * @param pop The original population at the begining, the result at the end */ - virtual operator () ( const eoPop& breeders, eoPop& pop ) = 0; + virtual void operator () ( const eoPop& breeders, eoPop& pop ) = 0; - /** @name Methods from eoObject */ + /** @name Methods from eoObject */ //@{ - /** readFrom and printOn are not overriden + /** readFrom and printOn are not overriden */ - /** Inherited from eoObject. Returns the class name. + /** Inherited from eoObject. Returns the class name. @see eoObject */ string className() const {return "eoMerge";}; @@ -113,6 +112,10 @@ class eoMerge: public eoObject{ /// Return the rate to be selected from the original population float rate() const { return rep_rate; } + + /// Set the rate to be obtained after replacement. + /// @param _rate The rate. + void rate(const float& _rate) { rep_rate = _rate; } private: float rep_rate;