BREAKING CHANGE: set standard to C++11, feat: accessor to breeder ops
Give an access to the operators held by a breeder. This is needed to design algorithms that dynamically update their internal parameters during search. To simplify the interface, we use a returned tuple, and thus upgrade the C++ standard to C++11.
This commit is contained in:
parent
646f20934e
commit
e64417f2a5
2 changed files with 22 additions and 7 deletions
|
|
@ -15,6 +15,7 @@ project("ParadisEO")
|
||||||
|
|
||||||
## Language
|
## Language
|
||||||
enable_language(CXX)
|
enable_language(CXX)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
## Test the presence of a compiler
|
## Test the presence of a compiler
|
||||||
if("${CMAKE_CXX_COMPILER}" STREQUAL "" OR "${CMAKE_C_COMPILER}" STREQUAL "")
|
if("${CMAKE_CXX_COMPILER}" STREQUAL "" OR "${CMAKE_C_COMPILER}" STREQUAL "")
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@
|
||||||
* eoGeneralBreeder: transforms a population using the generalOp construct.
|
* eoGeneralBreeder: transforms a population using the generalOp construct.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
#include "eoOp.h"
|
#include "eoOp.h"
|
||||||
#include "eoGenOp.h"
|
#include "eoGenOp.h"
|
||||||
#include "eoPopulator.h"
|
#include "eoPopulator.h"
|
||||||
|
|
@ -58,9 +60,12 @@ class eoGeneralBreeder: public eoBreed<EOT>
|
||||||
eoGeneralBreeder(
|
eoGeneralBreeder(
|
||||||
eoSelectOne<EOT>& _select,
|
eoSelectOne<EOT>& _select,
|
||||||
eoGenOp<EOT>& _op,
|
eoGenOp<EOT>& _op,
|
||||||
double _rate=1.0,
|
double _rate=1.0,
|
||||||
bool _interpret_as_rate = true) :
|
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:
|
/** Ctor:
|
||||||
*
|
*
|
||||||
|
|
@ -71,8 +76,8 @@ class eoGeneralBreeder: public eoBreed<EOT>
|
||||||
eoGeneralBreeder(
|
eoGeneralBreeder(
|
||||||
eoSelectOne<EOT>& _select,
|
eoSelectOne<EOT>& _select,
|
||||||
eoGenOp<EOT>& _op,
|
eoGenOp<EOT>& _op,
|
||||||
eoHowMany _howMany ) :
|
eoHowMany& _howMany ) :
|
||||||
select( _select ), op(_op), howMany(_howMany) {}
|
select( _select ), op(_op), howMany(_howMany) {}
|
||||||
|
|
||||||
/** The breeder: simply calls the genOp on a selective populator!
|
/** The breeder: simply calls the genOp on a selective populator!
|
||||||
*
|
*
|
||||||
|
|
@ -82,7 +87,6 @@ class eoGeneralBreeder: public eoBreed<EOT>
|
||||||
void operator()(const eoPop<EOT>& _parents, eoPop<EOT>& _offspring)
|
void operator()(const eoPop<EOT>& _parents, eoPop<EOT>& _offspring)
|
||||||
{
|
{
|
||||||
unsigned target = howMany(_parents.size());
|
unsigned target = howMany(_parents.size());
|
||||||
|
|
||||||
_offspring.clear();
|
_offspring.clear();
|
||||||
eoSelectivePopulator<EOT> it(_parents, _offspring, select);
|
eoSelectivePopulator<EOT> it(_parents, _offspring, select);
|
||||||
|
|
||||||
|
|
@ -98,10 +102,20 @@ class eoGeneralBreeder: public eoBreed<EOT>
|
||||||
/// The class name.
|
/// The class name.
|
||||||
virtual std::string className() const { return "eoGeneralBreeder"; }
|
virtual std::string className() const { return "eoGeneralBreeder"; }
|
||||||
|
|
||||||
private:
|
virtual std::tuple
|
||||||
|
<eoSelectOne<EOT>&,eoGenOp<EOT>&,eoHowMany&>
|
||||||
|
operators()
|
||||||
|
{
|
||||||
|
return std::forward_as_tuple
|
||||||
|
<eoSelectOne<EOT>&,eoGenOp<EOT>&,eoHowMany&>
|
||||||
|
(select, op, howMany);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
eoSelectOne<EOT>& select;
|
eoSelectOne<EOT>& select;
|
||||||
eoGenOp<EOT>& op;
|
eoGenOp<EOT>& op;
|
||||||
eoHowMany howMany;
|
eoHowMany local_howMany;
|
||||||
|
eoHowMany& howMany;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue