29 #include "../population.h"
31 #include "base_s_policy.h"
32 #include "hv_greedy_s_policy.h"
33 #include "best_s_policy.h"
34 #include "../exceptions.h"
35 #include "../util/hypervolume.h"
39 namespace pagmo {
namespace migration {
49 hv_greedy_s_policy::hv_greedy_s_policy(
const double &rate,
rate_type type,
const double nadir_eps):
base_s_policy(rate,type), m_nadir_eps(nadir_eps) { }
67 std::vector<population::individual_type> result;
73 std::vector< std::vector< fitness_vector> > fronts_f (fronts_i.size());
78 for (
unsigned int f_idx = 0 ; f_idx < fronts_i.size() ; ++f_idx) {
79 fronts_f[f_idx].resize(fronts_i[f_idx].size());
80 for (
unsigned int p_idx = 0 ; p_idx < fronts_i[f_idx].size() ; ++p_idx) {
84 for (
unsigned int d_idx = 0 ; d_idx < fronts_f[f_idx][p_idx].size() ; ++d_idx) {
85 refpoint[d_idx] = std::max(refpoint[d_idx], fronts_f[f_idx][p_idx][d_idx]);
91 for (
unsigned int d_idx = 0 ; d_idx < refpoint.size() ; ++d_idx) {
92 refpoint[d_idx] += m_nadir_eps;
96 unsigned int front_idx = 0;
97 unsigned int processed_individuals = 0;
100 std::vector<unsigned int> orig_indices;
102 while (processed_individuals < migration_rate) {
104 if (fronts_f[front_idx].size() <= (migration_rate - processed_individuals)) {
105 for(
unsigned int i = 0 ; i < fronts_i[front_idx].size() ; ++i) {
109 processed_individuals += fronts_f[front_idx].size();
113 if (orig_indices.size() == 0) {
114 orig_indices.resize(fronts_i[front_idx].size());
115 iota(orig_indices.begin(), orig_indices.end(), 0);
122 result.push_back(pop.
get_individual(fronts_i[front_idx][orig_indices[gc_idx]]));
125 orig_indices.erase(orig_indices.begin() + gc_idx);
126 fronts_f[front_idx].erase(fronts_f[front_idx].begin() + gc_idx);
127 ++processed_individuals;
hv_greedy_s_policy(const double &rate=1, rate_type type=absolute, double nadir_eps=1.0)
Constructor from migration rate and type.
fitness_vector cur_f
Current fitness vector.
Base class for migration selection policies.
const individual_type & get_individual(const size_type &) const
Get constant reference to individual at position n.
"Choose best" migration selection policy.
base_s_policy_ptr clone() const
Clone method.
population::size_type get_n_individuals(const population &) const
Get number of individuals to migrate from/to input population.
std::vector< double > fitness_vector
Fitness vector type.
Choose 'n' successive greatest contributors migration policy.
boost::shared_ptr< base_s_policy > base_s_policy_ptr
Shared pointer to base selection policy.
static void iota(ForwardIterator first, ForwardIterator last, T value)
Iota function, usefull to fill iterator range with increasing values.
container_type::size_type size_type
Population size type.
unsigned int greatest_contributor(const fitness_vector &, const hv_algorithm::base_ptr) const
Find the most contributing individual.
rate_type m_type
Migration rate type.
f_size_type get_f_dimension() const
Return fitness dimension.
std::vector< population::individual_type > select(population &) const
Select individuals to emigrate from the given population.
std::vector< population::individual_type > select(population &) const
Select individuals to emigrate from the given population.
double m_rate
Migration rate.
void set_copy_points(const bool)
Setter for 'copy_points' flag.
std::vector< std::vector< size_type > > compute_pareto_fronts() const
Computes and returns the population Pareto fronts.
rate_type
Type of migration rate.