diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bb3a2c4e..b125b0966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ project("ParadisEO") ## Language enable_language(CXX) +set(CMAKE_CXX_STANDARD 11) ## Test the presence of a compiler if("${CMAKE_CXX_COMPILER}" STREQUAL "" OR "${CMAKE_C_COMPILER}" STREQUAL "") diff --git a/eo/src/eoGeneralBreeder.h b/eo/src/eoGeneralBreeder.h index 1fdbd5c40..fb1bc88b8 100644 --- a/eo/src/eoGeneralBreeder.h +++ b/eo/src/eoGeneralBreeder.h @@ -32,6 +32,8 @@ * eoGeneralBreeder: transforms a population using the generalOp construct. *****************************************************************************/ +#include + #include "eoOp.h" #include "eoGenOp.h" #include "eoPopulator.h" @@ -58,9 +60,12 @@ class eoGeneralBreeder: public eoBreed eoGeneralBreeder( eoSelectOne& _select, eoGenOp& _op, - double _rate=1.0, + double _rate=1.0, bool _interpret_as_rate = true) : - select( _select ), op(_op), howMany(_rate, _interpret_as_rate) {} + select( _select ), op(_op), + local_howMany(_rate, _interpret_as_rate), + howMany(local_howMany) + {} /** Ctor: * @@ -71,8 +76,8 @@ class eoGeneralBreeder: public eoBreed eoGeneralBreeder( eoSelectOne& _select, eoGenOp& _op, - eoHowMany _howMany ) : - select( _select ), op(_op), howMany(_howMany) {} + eoHowMany& _howMany ) : + select( _select ), op(_op), howMany(_howMany) {} /** The breeder: simply calls the genOp on a selective populator! * @@ -82,7 +87,6 @@ class eoGeneralBreeder: public eoBreed void operator()(const eoPop& _parents, eoPop& _offspring) { unsigned target = howMany(_parents.size()); - _offspring.clear(); eoSelectivePopulator it(_parents, _offspring, select); @@ -98,10 +102,20 @@ class eoGeneralBreeder: public eoBreed /// The class name. virtual std::string className() const { return "eoGeneralBreeder"; } - private: + virtual std::tuple + &,eoGenOp&,eoHowMany&> + operators() + { + return std::forward_as_tuple + &,eoGenOp&,eoHowMany&> + (select, op, howMany); + } + + protected: eoSelectOne& select; eoGenOp& op; - eoHowMany howMany; + eoHowMany local_howMany; + eoHowMany& howMany; }; #endif