26 #include <boost/numeric/conversion/cast.hpp>
30 #include "../population.h"
32 #include "base_r_policy.h"
33 #include "fair_r_policy.h"
35 namespace pagmo {
namespace migration {
52 template <
class Container>
53 struct indirect_individual_sorter
55 indirect_individual_sorter(
const Container &container,
const population &pop):
56 m_container(container),m_pop(pop) {}
58 bool operator()(
const Idx &idx1,
const Idx &idx2)
const
60 typedef typename Container::const_iterator::difference_type diff_type;
61 return m_pop.n_dominated(*(m_container.begin() + boost::numeric_cast<diff_type>(idx1))) >
62 m_pop.n_dominated(*(m_container.begin() + boost::numeric_cast<diff_type>(idx2)));
65 const Container &m_container;
66 const population &m_pop;
70 std::vector<std::pair<population::size_type,std::vector<population::individual_type>::size_type> >
77 std::vector<std::pair<population::size_type,std::vector<population::individual_type>::size_type> > result;
84 pop_copy.push_back(immigrants[i].cur_x);
88 std::vector<population::size_type> best_idx(pop_copy.get_best_idx(pop_copy.size()));
90 std::vector<population::size_type>::iterator left = best_idx.begin();
91 std::vector<population::size_type>::iterator right = best_idx.end() - 1;
95 while (left < right) {
97 if (*left >= dest.size()) {
99 while (*right >= dest.size()) {
103 result.push_back(std::make_pair(*right,*left-dest.size()));
Base class for migration replacement policies.
boost::shared_ptr< base_r_policy > base_r_policy_ptr
Shared pointer to base replacement policy.
std::vector< std::pair< population::size_type, std::vector< population::individual_type >::size_type > > select(const std::vector< population::individual_type > &, const population &) const
Assign pairs of individuals for replacement during migration.
population::size_type get_n_individuals(const population &) const
Get number of individuals to migrate from/to input population.
fair_r_policy(const double &rate=1, rate_type type=absolute)
Constructor from rate and rate type.
container_type::size_type size_type
Population size type.
base_r_policy_ptr clone() const
Clone method.
rate_type
Type of migration rate.