25 #include <boost/numeric/conversion/cast.hpp>
32 #include "../exceptions.h"
33 #include "../population.h"
37 namespace pagmo {
namespace migration {
53 if (m_rate < 0 || m_rate > INT_MAX) {
54 pagmo_throw(value_error,
"invalid absolute migration rate");
60 if (m_rate < 0 || m_rate > 1) {
61 pagmo_throw(value_error,
"invalid fractional migration rate");
65 pagmo_throw(value_error,
"invalid type for migration rate");
81 if (retval > pop.size()) {
82 pagmo_throw(value_error,
"absolute migration rate is higher than population size");
87 pagmo_assert(retval <= pop.size());
104 std::ostringstream oss;
105 oss <<
"Policy name: " <<
typeid(*this).name() <<
'\n';
106 oss <<
"\tMigration type: " << ((
m_type) ?
"fractional" :
"absolute") <<
'\n';
120 return std::string();
std::ostream & operator<<(std::ostream &s, const base &p)
Overload stream operator for migration::base.
base(const double &, rate_type)
Constructor from migration rate and type.
Migration rate is interpreted as the fraction of individuals to migrate with respect to the orign/des...
population::size_type get_n_individuals(const population &) const
Get number of individuals to migrate from/to input population.
virtual ~base()
Destructor.
virtual std::string human_readable_extra() const
Return extra information in human readable representation.
container_type::size_type size_type
Population size type.
rate_type m_type
Migration rate type.
std::string human_readable() const
Return human readable representation.
double m_rate
Migration rate.
Migration rate is interpreted as the absolute number of individuals to migrate.
rate_type
Type of migration rate.