5 #ifndef ROCKY_ZAGROS_DE_STRATEGY
6 #define ROCKY_ZAGROS_DE_STRATEGY
8 #include <rocky/zagros/strategies/strategy.h>
13 template<
typename T_e,
int T_dim>
29 this->problem_ = problem;
30 this->container_ = container;
31 this->candidates_ = candidates;
34 this->n_crossovers_ = candidates->n_particles();
42 static std::uniform_real_distribution<T_e> dist(0.0, 1.0);
43 return dist(rocky::utils::random::prng());
47 if(container_->n_particles() < 4){
48 spdlog::warn(
"For using differential evolution the number of particles must be at least 4!");
51 tbb::parallel_for(0, n_crossovers_, [
this](
int p){
54 auto& [x, a, b, c] = parents;
56 std::copy(this->container_->
particle(x),
57 this->container_->particle(x) + T_dim,
58 this->candidates_->particle(p));
59 for(
int d=0; d<T_dim; d++){
64 this->candidates_->particles[p][d] = this->container_->particles[a][d] +
65 this->DW_ * (this->container_->particles[b][d] -
66 this->container_->particles[c][d]);