PaGMO  1.1.5
migration/base.h
1 /*****************************************************************************
2  * Copyright (C) 2004-2015 The PaGMO development team, *
3  * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4  * *
5  * https://github.com/esa/pagmo *
6  * *
7  * act@esa.int *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  *****************************************************************************/
24 
25 #ifndef PAGMO_MIGRATION_BASE_POLICY_H
26 #define PAGMO_MIGRATION_BASE_POLICY_H
27 
28 #include <iostream>
29 #include <string>
30 
31 #include "../config.h"
32 #include "../population.h"
33 #include "../serialization.h"
34 
35 namespace pagmo {
36 
38 
41 namespace migration {
42 
44 
48 {
50  absolute = 0,
53 };
54 
56 
69 class __PAGMO_VISIBLE base
70 {
71  public:
72  base(const double &, rate_type);
73  population::size_type get_n_individuals(const population &) const;
74  std::string human_readable() const;
75  virtual ~base();
76  protected:
77  virtual std::string human_readable_extra() const;
78  protected:
80 
87  template <class ForwardIterator, class T>
88  static void iota(ForwardIterator first, ForwardIterator last, T value)
89  {
90  for (; first != last; ++first, ++value)
91  *first = value;
92  }
94 
98  double m_rate;
101  private:
102  friend class boost::serialization::access;
103  template <class Archive>
104  void serialize(Archive &ar, const unsigned int)
105  {
106  ar & m_rate;
107  ar & m_type;
108  }
109 };
110 
111 std::ostream __PAGMO_VISIBLE_FUNC &operator<<(std::ostream &, const base &);
112 
113 } }
114 
115 #endif
Root PaGMO namespace.
Population class.
Definition: population.h:70
std::ostream & operator<<(std::ostream &s, const base &p)
Overload stream operator for migration::base.
Migration rate is interpreted as the fraction of individuals to migrate with respect to the orign/des...
Base migration class.
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.
Definition: population.h:192
rate_type m_type
Migration rate type.
double m_rate
Migration rate.
Migration rate is interpreted as the absolute number of individuals to migrate.
rate_type
Type of migration rate.