25 #ifndef PAGMO_ARCHIPELAGO_H
26 #define PAGMO_ARCHIPELAGO_H
28 #include <boost/scoped_ptr.hpp>
29 #include <boost/thread/barrier.hpp>
30 #include <boost/thread/locks.hpp>
31 #include <boost/thread/mutex.hpp>
32 #include <boost/tuple/tuple.hpp>
33 #include <boost/serialization/map.hpp>
34 #include <boost/unordered_map.hpp>
40 #include "algorithm/base.h"
41 #include "base_island.h"
43 #include "population.h"
44 #include "problem/base.h"
46 #include "serialization.h"
47 #include "topology/base.h"
48 #include "topology/unconnected.h"
110 typedef container_type::iterator iterator;
111 typedef container_type::const_iterator const_iterator;
116 typedef boost::unordered_map<size_type,boost::unordered_map<size_type,std::vector<individual_type> > > migration_map_type;
118 typedef boost::lock_guard<boost::mutex> lock_type;
120 typedef boost::tuple<population::size_type,size_type,size_type> migr_hist_item;
122 typedef std::vector<migr_hist_item> migr_hist_type;
124 explicit archipelago(distribution_type = point_to_point, migration_direction = destination);
127 distribution_type = point_to_point, migration_direction = destination);
134 size_type get_size()
const;
135 std::string human_readable()
const;
139 distribution_type get_distribution_type()
const;
140 void set_distribution_type(
const distribution_type &);
141 void evolve(
int = 1);
142 void evolve_batch(
int,
unsigned int,
bool =
true);
146 std::string dump_migr_history()
const;
147 void clear_migr_history();
148 void set_island(
const size_type &,
const base_island &);
149 std::vector<base_island_ptr> get_islands()
const;
151 void set_seeds(
unsigned int);
155 void reset_barrier(
const size_type &);
156 void build_immigrants_vector(std::vector<std::pair<population::size_type, individual_type > > &,
158 const std::vector<individual_type> &)
const;
159 void check_migr_attributes()
const;
160 void sync_island_start()
const;
161 size_type locate_island(
const base_island &)
const;
162 bool destruction_checks()
const;
163 void reevaluate_immigrants(std::vector<std::pair<population::size_type, individual_type> > &,
166 friend class boost::serialization::access;
167 template <
class Archive>
168 void serialize(Archive &ar,
const unsigned int version)
180 boost::serialization::split_member(ar, *
this, version);
183 template <
class Archive>
184 void save(Archive &,
const unsigned int)
const
186 template <
class Archive>
187 void load(Archive &,
const unsigned int)
191 for (size_type i = 0; i < m_container.size(); ++i) {
192 m_container[i]->m_archi =
this;
198 container_type m_container;
200 boost::scoped_ptr<boost::barrier> m_islands_sync_point;
204 distribution_type m_dist_type;
206 migration_direction m_migr_dir;
208 migration_map_type m_migr_map;
213 boost::mutex m_migr_mutex;
215 migr_hist_type m_migr_hist;
219 std::ostream __PAGMO_VISIBLE_FUNC &
operator<<(std::ostream &,
const archipelago &);
migration_direction
Migration direction.
container_type::size_type size_type
Archipelago size type.
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base topology.
std::ostream & operator<<(std::ostream &s, const archipelago &a)
Overload stream operator for pagmo::archipelago.
Individuals stored in the population.
distribution_type
Distribution type for migrating individuals.
population::individual_type individual_type
Individual type.
boost::shared_ptr< base_island > base_island_ptr
Alias for the shared pointer to a pagmo::base_island.
std::vector< base_island_ptr > container_type
Internal container of islands.