29 #include "boost/smart_ptr.hpp"
36 void crossover(boost::shared_ptr<T> ind1, boost::shared_ptr<T> ind2,
41 const double alpha = 0.5;
43 for(
size_t i = 0; i < ind1->genes_m.size(); i++) {
45 double ming =
std::min(ind1->genes_m[i], ind2->genes_m[i]);
46 double maxg =
std::max(ind1->genes_m[i], ind2->genes_m[i]);
47 double gamma1 = (1 + 2 *
alpha) *
48 static_cast<double>(rand() / (RAND_MAX + 1.0)) -
alpha;
49 double gamma2 = (1 + 2 *
alpha) *
50 static_cast<double>(rand() / (RAND_MAX + 1.0)) -
alpha;
51 ind1->genes_m[i] = (1 - gamma1) * ming + gamma1 * maxg;
52 ind2->genes_m[i] = (1 - gamma2) * ming + gamma2 * maxg;
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
boost::shared_ptr< CmdArguments > CmdArguments_t
constexpr double alpha
The fine structure constant, no dimension.
void crossover(boost::shared_ptr< T > ind1, boost::shared_ptr< T > ind2, CmdArguments_t)