diff --git a/eo/README b/eo/README index e9df88db..96a7b4f4 100644 --- a/eo/README +++ b/eo/README @@ -9,4 +9,13 @@ instead of $> ./configure -before making the libraries. \ No newline at end of file +before making the libraries. + +Documentation can be found in: + eo/doc/html + +And \latex sources for a reference manual in: + eo/doc/latex + +There are currently no examples except the programs in the test directory. +Only the files mentioned in Makefile.am will actually compile. diff --git a/eo/configure.in b/eo/configure.in index 6f2ecb46..9ad61a7d 100644 --- a/eo/configure.in +++ b/eo/configure.in @@ -1,7 +1,7 @@ AC_INIT(src/eo) dnl Change the version number here -AM_INIT_AUTOMAKE(eo, 0.9.1) +AM_INIT_AUTOMAKE(eo, 0.9.11) AC_PROG_CXX diff --git a/eo/src/apply.h b/eo/src/apply.h index c0ad8a07..234bf771 100644 --- a/eo/src/apply.h +++ b/eo/src/apply.h @@ -29,8 +29,11 @@ #include #include +/** + Applies a unary function to a vector of things. +*/ template -void apply(eoUnaryFunctor& _proc, std::vector& _pop) +void apply(eoUF& _proc, std::vector& _pop) { for (unsigned i = 0; i < _pop.size(); ++i) { diff --git a/eo/src/eoAlgo.h b/eo/src/eoAlgo.h index ac9307a5..74ad2963 100644 --- a/eo/src/eoAlgo.h +++ b/eo/src/eoAlgo.h @@ -36,7 +36,7 @@ population-transforming algorithms. */ template< class EOT > -class eoAlgo : public eoUnaryFunctor&> +class eoAlgo : public eoUF&, void> {}; diff --git a/eo/src/eoBreed.h b/eo/src/eoBreed.h index e57f5d89..53498344 100644 --- a/eo/src/eoBreed.h +++ b/eo/src/eoBreed.h @@ -40,7 +40,7 @@ function. @see eoSelect, eoTransform, eoSelectTransform */ template -class eoBreed : public eoBinaryFunctor&, eoPop&> +class eoBreed : public eoBF&, eoPop&, void> {}; /** diff --git a/eo/src/eoContinue.h b/eo/src/eoContinue.h index 0576d5d9..2d7998c4 100644 --- a/eo/src/eoContinue.h +++ b/eo/src/eoContinue.h @@ -33,7 +33,7 @@ * false for termination */ template< class EOT> -class eoContinue : public eoUnaryFunctor&> {}; +class eoContinue : public eoUF&, bool> {}; #endif diff --git a/eo/src/eoEvalFunc.h b/eo/src/eoEvalFunc.h index 0dde11e1..8ef1a020 100644 --- a/eo/src/eoEvalFunc.h +++ b/eo/src/eoEvalFunc.h @@ -38,7 +38,7 @@ EO, the requirements on this EO will depend on the evaluator. */ -template class eoEvalFunc : public eoUnaryFunctor +template class eoEvalFunc : public eoUF { public : typedef typename EOT::Fitness EOFitT; diff --git a/eo/src/eoFunctor.h b/eo/src/eoFunctor.h index 41125f2f..3c8edb45 100644 --- a/eo/src/eoFunctor.h +++ b/eo/src/eoFunctor.h @@ -26,6 +26,8 @@ #ifndef _eoFunctor_h #define _eoFunctor_h +#include + /// Base class for functors to get a nice hierarchy diagram class eoFunctorBase { @@ -41,19 +43,19 @@ public : }; /** - Basic Procedure. Derive from this class when defining + Basic Function. Derive from this class when defining any procedure. It defines a result_type that can be used to determine the return type Argument and result types can be any type including void for result_type **/ template -class eoProcedure : public eoFunctorBase +class eoF : public eoFunctorBase { public : /// virtual dtor here so there is no need to define it in derived classes - virtual ~eoProcedure() {} + virtual ~eoF() {} typedef R result_type; @@ -68,28 +70,25 @@ public : @see eoCounter, make_counter */ template -eoFunctorBase::procedure_tag functor_category(const eoProcedure&) +eoFunctorBase::procedure_tag functor_category(const eoF&) { return eoFunctorBase::procedure_tag(); } /** Basic Unary Functor. Derive from this class when defining - any unary function. First template argument is result_type, second - is first_argument_type. + any unary function. First template argument is the first_argument_type, + second result_type. Argument and result types can be any type including void for result_type **/ -template -class eoUnaryFunctor : public eoFunctorBase +template +class eoUF : public eoFunctorBase, public std::unary_function { public : /// virtual dtor here so there is no need to define it in derived classes - virtual ~eoUnaryFunctor() {} - - typedef R result_type; - typedef A1 first_argument_type; + virtual ~eoUF() {} /// The pure virtual function that needs to be implemented by the subclass virtual R operator()(A1) = 0; @@ -101,7 +100,7 @@ public : @see eoCounter, make_counter */ template -eoFunctorBase::unary_function_tag functor_category(const eoUnaryFunctor&) +eoFunctorBase::unary_function_tag functor_category(const eoUF&) { return eoFunctorBase::unary_function_tag(); } @@ -114,16 +113,16 @@ eoFunctorBase::unary_function_tag functor_category(const eoUnaryFunctor&) Argument and result types can be any type including void for result_type **/ -template -class eoBinaryFunctor : public eoFunctorBase +template +class eoBF : public eoFunctorBase, public std::binary_function { public : /// virtual dtor here so there is no need to define it in derived classes - virtual ~eoBinaryFunctor() {} + virtual ~eoBF() {} - typedef R result_type; - typedef A1 first_argument_type; - typedef A2 second_argument_type; + //typedef R result_type; + //typedef A1 first_argument_type; + //typedef A2 second_argument_type; /// The pure virtual function that needs to be implemented by the subclass virtual R operator()(A1, A2) = 0; @@ -135,7 +134,7 @@ public : @see eoCounter, make_counter */ template -eoFunctorBase::binary_function_tag functor_category(const eoBinaryFunctor&) +eoFunctorBase::binary_function_tag functor_category(const eoBF&) { return eoFunctorBase::binary_function_tag(); } diff --git a/eo/src/eoGOpBreeder.h b/eo/src/eoGOpBreeder.h index 12d811c2..13c8a717 100644 --- a/eo/src/eoGOpBreeder.h +++ b/eo/src/eoGOpBreeder.h @@ -18,8 +18,13 @@ #include #include +/** + Base class for breeders using generalized operators, I'm not sure if we + will maintain the generalized operators in their current form, so + it might change. +*/ template -class eoGOpBreeder: public eoUnaryFunctor&> +class eoGOpBreeder: public eoUF&, void> { public: /// Default constructor. diff --git a/eo/src/eoIndiSelector.h b/eo/src/eoIndiSelector.h index 0d96514d..ea4fc34c 100644 --- a/eo/src/eoIndiSelector.h +++ b/eo/src/eoIndiSelector.h @@ -41,7 +41,7 @@ */ template -class eoIndiSelector : public eoProcedure +class eoIndiSelector : public eoF { public : diff --git a/eo/src/eoInit.h b/eo/src/eoInit.h index c1f0548d..bf64dc10 100644 --- a/eo/src/eoInit.h +++ b/eo/src/eoInit.h @@ -38,7 +38,7 @@ */ template -class eoInit : public eoUnaryFunctor +class eoInit : public eoUF {}; /** diff --git a/eo/src/eoInserter.h b/eo/src/eoInserter.h index e49057cf..f498cd61 100644 --- a/eo/src/eoInserter.h +++ b/eo/src/eoInserter.h @@ -38,7 +38,7 @@ new individuals into the (intermediate) population for example. */ template -class eoInserter : public eoUnaryFunctor&, const EOT&> +class eoInserter : public eoUF&> { public : virtual ~eoInserter() {} diff --git a/eo/src/eoMerge.h b/eo/src/eoMerge.h index d2c8f813..4261d249 100644 --- a/eo/src/eoMerge.h +++ b/eo/src/eoMerge.h @@ -45,7 +45,7 @@ * next generation. */ -template class eoMerge: public eoBinaryFunctor&, eoPop&> +template class eoMerge: public eoBF&, eoPop&, void> {}; /** diff --git a/eo/src/eoOp.h b/eo/src/eoOp.h index 33d207c9..4dd9672c 100644 --- a/eo/src/eoOp.h +++ b/eo/src/eoOp.h @@ -79,7 +79,7 @@ private: /** eoMonOp is the monary operator: genetic operator that takes only one EO */ template -class eoMonOp: public eoOp, public eoUnaryFunctor +class eoMonOp: public eoOp, public eoUF { public: /// Ctor @@ -92,7 +92,7 @@ public: * operator() with two operands, only the first one can be modified */ template -class eoBinOp: public eoOp, public eoBinaryFunctor +class eoBinOp: public eoOp, public eoBF { public: /// Ctor @@ -105,7 +105,7 @@ public: */ template -class eoQuadraticOp: public eoOp, public eoBinaryFunctor { +class eoQuadraticOp: public eoOp, public eoBF { public: /// Ctor eoQuadraticOp() @@ -129,7 +129,7 @@ class eoInserter; * eGeneralOp: General genetic operator; for objects used to transform sets * of EOs. Nary ("orgy") operators should be derived from this class - Derived from eoBinaryFunctor + Derived from eoB(inary)F(unction) Applies the genetic operator to a individuals dispensed by an eoIndividualSelector, and puts the results in the eoIndividualInserter. @@ -139,7 +139,7 @@ class eoInserter; template -class eoGeneralOp: public eoOp, public eoBinaryFunctor&, eoInserter&> +class eoGeneralOp: public eoOp, public eoBF&, eoInserter&, void> { public: /// Ctor that honors its superclass diff --git a/eo/src/eoReduce.h b/eo/src/eoReduce.h index e1fb6eb1..150963ef 100644 --- a/eo/src/eoReduce.h +++ b/eo/src/eoReduce.h @@ -38,7 +38,7 @@ * eoReduce: .reduce the new generation to the specified size */ -template class eoReduce: public eoBinaryFunctor&, unsigned> +template class eoReduce: public eoBF&, unsigned, void> {}; template class eoTruncate : public eoReduce diff --git a/eo/src/eoReplacement.h b/eo/src/eoReplacement.h index 43b8347d..3a57db63 100644 --- a/eo/src/eoReplacement.h +++ b/eo/src/eoReplacement.h @@ -41,7 +41,7 @@ so there is an implementation called eoMergeReduce that can be found below @see eoMerge, eoReduce, eoMergeReduce */ template -class eoReplacement : public eoBinaryFunctor&, eoPop&> +class eoReplacement : public eoBF&, eoPop&, void> {}; /** diff --git a/eo/src/eoSelect.h b/eo/src/eoSelect.h index 2ba9adb5..90bfd7dc 100644 --- a/eo/src/eoSelect.h +++ b/eo/src/eoSelect.h @@ -37,7 +37,7 @@ the population, the second argument is an eoPopRange, a simple struct that holds a begin and end iterator to the population */ template -class eoSelect : public eoBinaryFunctor&, eoPop&> +class eoSelect : public eoBF&, eoPop&, void> {}; #endif diff --git a/eo/src/eoSelectOne.h b/eo/src/eoSelectOne.h index 07d3a65f..b6965580 100644 --- a/eo/src/eoSelectOne.h +++ b/eo/src/eoSelectOne.h @@ -38,7 +38,7 @@ @see eoSelectMany, eoSelectRandom, eoDetTournament, eoStochTournament, eoProportional */ template -class eoSelectOne : public eoUnaryFunctor&> +class eoSelectOne : public eoUF&, const EOT&> { public : diff --git a/eo/src/eoTransform.h b/eo/src/eoTransform.h index f1044024..40bc8138 100644 --- a/eo/src/eoTransform.h +++ b/eo/src/eoTransform.h @@ -35,7 +35,7 @@ eoTransform transforms a population by applying genetic operators on it. */ template -class eoTransform : public eoUnaryFunctor&> +class eoTransform : public eoUF&, void> {}; #endif diff --git a/eo/src/utils/eoMonitor.h b/eo/src/utils/eoMonitor.h index e4e44e3f..1b3f7aca 100644 --- a/eo/src/utils/eoMonitor.h +++ b/eo/src/utils/eoMonitor.h @@ -41,7 +41,7 @@ class eoParam; will stream or pipe the current values of the parameters to wherever you want it streamed or piped to. */ -class eoMonitor : public eoProcedure +class eoMonitor : public eoF { public : diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index 0ae15e76..037ca409 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -36,7 +36,7 @@ over the (unsorted) population */ template -class eoStatBase : public eoUnaryFunctor&> +class eoStatBase : public eoUF&, void> {}; template @@ -50,7 +50,7 @@ public : Base class for statistics calculated over a sorted snapshot of the population */ template -class eoSortedStatBase : public eoUnaryFunctor&> +class eoSortedStatBase : public eoUF&, void> { }; diff --git a/eo/src/utils/eoUpdater.h b/eo/src/utils/eoUpdater.h index db096749..c75141c4 100644 --- a/eo/src/utils/eoUpdater.h +++ b/eo/src/utils/eoUpdater.h @@ -34,7 +34,7 @@ eoUpdater is a generic procudere for updating whatever you want. Yet again an empty name */ -class eoUpdater : public eoProcedure +class eoUpdater : public eoF {}; /** diff --git a/eo/test/t-eoBaseFunctions.cpp b/eo/test/t-eoBaseFunctions.cpp index 052c1f4f..636b0a38 100644 --- a/eo/test/t-eoBaseFunctions.cpp +++ b/eo/test/t-eoBaseFunctions.cpp @@ -5,12 +5,12 @@ using namespace std; -struct eo1 : public eoProcedure +struct eo1 : public eoF { void operator()(void) {} }; -struct eo2 : public eoProcedure +struct eo2 : public eoF { int operator()(void) { return 1; } };