PaGMO
1.1.5
|
Archipelago class. More...
#include <archipelago.h>
Public Types | |
enum | distribution_type { point_to_point = 0, broadcast = 1 } |
Distribution type for migrating individuals. More... | |
enum | migration_direction { source = 0, destination = 1 } |
Migration direction. More... | |
typedef std::vector< base_island_ptr > | container_type |
Internal container of islands. | |
typedef container_type::size_type | size_type |
Archipelago size type. | |
typedef population::individual_type | individual_type |
Individual type. | |
Public Member Functions | |
archipelago (distribution_type=point_to_point, migration_direction=destination) | |
Default constructor. More... | |
archipelago (const topology::base &, distribution_type=point_to_point, migration_direction=destination) | |
Constructor from topology. More... | |
archipelago (const algorithm::base &, const problem::base &, int, int, const topology::base &=topology::unconnected(), distribution_type=point_to_point, migration_direction=destination) | |
Constructor from problem, algorithm, archipelago size, island sizes, topology and migration attributes. More... | |
archipelago (const archipelago &) | |
Copy constructor. More... | |
archipelago & | operator= (const archipelago &) |
Assignment operator. More... | |
~archipelago () | |
Destructor. More... | |
void | join () const |
Wait until evolution on each island has terminated. More... | |
void | set_algorithm (const size_type &, const algorithm::base &) |
Set island algorithm. More... | |
void | push_back (const base_island &) |
Add an island to the archipelago. More... | |
size_type | get_size () const |
Get the size of the archipelago. More... | |
std::string | human_readable () const |
Return human readable representation of the archipelago. More... | |
bool | check_island (const base_island &) const |
Check whether an island is compatible with the archipelago. More... | |
topology::base_ptr | get_topology () const |
Return a copy of the topology. More... | |
void | set_topology (const topology::base &) |
Set topology. More... | |
distribution_type | get_distribution_type () const |
Return a copy of the distribution type. More... | |
void | set_distribution_type (const distribution_type &) |
Set distribution type. More... | |
void | evolve (int=1) |
Run the evolution for the given number of iterations. More... | |
void | evolve_batch (int, unsigned int, bool=true) |
Run the evolution for the given number of iterations in batches. More... | |
void | evolve_t (int) |
Run the evolution for a minimum amount of time. More... | |
bool | busy () const |
Query the status of the archipelago. More... | |
void | interrupt () |
Interrupt ongoing evolution. More... | |
std::string | dump_migr_history () const |
Dumps the archipelago migration history. More... | |
void | clear_migr_history () |
Clears the archipelago migration history. More... | |
void | set_island (const size_type &, const base_island &) |
Island setter. More... | |
std::vector< base_island_ptr > | get_islands () const |
Get vector of islands in the archipelago. More... | |
base_island_ptr | get_island (const size_type &) const |
Island getter. More... | |
void | set_seeds (unsigned int) |
Sets the seed of the random number generators of the archipelago. More... | |
Friends | |
class | base_island |
Base island class must have access to internal archipelago methods. | |
class | boost::serialization::access |
Archipelago class.
Definition at line 57 of file archipelago.h.
Distribution type for migrating individuals.
Definition at line 69 of file archipelago.h.
Migration direction.
This parameters controls how islands migrate individuals to/from their neighbours. It is a fine tuning parameter for which the default value is appropriate for most uses.
Definition at line 87 of file archipelago.h.
|
explicit |
Default constructor.
Will construct an empty archipelago with topology::unconnected topology, with point_to_point distribution_type and destination migration_direction.
[in] | dt | distribution type. |
[in] | md | migration direction. |
Definition at line 68 of file archipelago.cpp.
|
explicit |
Constructor from topology.
Will construct an empty archipelago with provided topology (which will be deep-copied internally), with point_to_point distribution_type and destination migration_direction.
[in] | t | topology that will be associated to the archipelago. |
[in] | dt | distribution type. |
[in] | md | migration direction. |
Definition at line 84 of file archipelago.cpp.
|
explicit |
Constructor from problem, algorithm, archipelago size, island sizes, topology and migration attributes.
Constructs n islands of m individuals each, with assigned problem p and algorithm a, and inserts them with push_back() into the archipelago, whose topology is set to t, with point_to_point distribution_type and destination migration_direction.
[in] | a | algorithm which will be assigned to all islands. |
[in] | p | problem which will be assigned to all islands. |
[in] | n | number of islands. |
[in] | m | number of individuals on each island. |
[in] | t | topology. |
[in] | dt | distribution type. |
[in] | md | migration direction. |
Definition at line 107 of file archipelago.cpp.
pagmo::archipelago::archipelago | ( | const archipelago & | a | ) |
Copy constructor.
Will synchronise input archipelago before deep-copying all its elements.
[in] | a | archipelago to be copied. |
Definition at line 126 of file archipelago.cpp.
pagmo::archipelago::~archipelago | ( | ) |
Destructor.
Will call join() before returning. No other side effects.
Definition at line 177 of file archipelago.cpp.
bool pagmo::archipelago::busy | ( | ) | const |
Query the status of the archipelago.
Definition at line 677 of file archipelago.cpp.
bool pagmo::archipelago::check_island | ( | const base_island & | isl | ) | const |
Check whether an island is compatible with the archipelago.
Will return true if any of these conditions holds:
Otherwise, false will be returned.
[in] | isl | island which will be checked. |
Definition at line 351 of file archipelago.cpp.
void pagmo::archipelago::clear_migr_history | ( | ) |
Clears the archipelago migration history.
Definition at line 788 of file archipelago.cpp.
std::string pagmo::archipelago::dump_migr_history | ( | ) | const |
Dumps the archipelago migration history.
Definition at line 770 of file archipelago.cpp.
void pagmo::archipelago::evolve | ( | int | n = 1 | ) |
Run the evolution for the given number of iterations.
Will iteratively call island::evolve(n) on each island of the archipelago and then return.
[in] | n | number of time each island will be evolved. |
Definition at line 603 of file archipelago.cpp.
void pagmo::archipelago::evolve_batch | ( | int | n, |
unsigned int | b, | ||
bool | randomize = true |
||
) |
Run the evolution for the given number of iterations in batches.
Will iteratively call island::evolve(n) on batches of b islands of the archipelago and then return. Each batch will wait to complete the n evolves before ending. It is typically called with n=1 as for n>1 this set-up creates a strange effect on the migration flux (the first batch that evolves does not make use of the islands in the remaining batches).
[in] | n | number of time each island will be evolved. |
[in] | b | the size of the batch of islands to evolve at the same time. |
[in] | randomize | determines whether evolve populations in index-order (randomize=false) or in random order (randomize=true) |
Definition at line 625 of file archipelago.cpp.
void pagmo::archipelago::evolve_t | ( | int | t | ) |
Run the evolution for a minimum amount of time.
Will iteratively call island::evolve_t(n) on each island of the archipelago and then return.
[in] | t | amount of time to evolve each island (in milliseconds). |
Definition at line 663 of file archipelago.cpp.
archipelago::distribution_type pagmo::archipelago::get_distribution_type | ( | ) | const |
Return a copy of the distribution type.
Definition at line 323 of file archipelago.cpp.
base_island_ptr pagmo::archipelago::get_island | ( | const size_type & | idx | ) | const |
Island getter.
[in] | idx | index of the desired island. |
index_error | if idx is not less than the size of the archipelago. |
Definition at line 708 of file archipelago.cpp.
std::vector< base_island_ptr > pagmo::archipelago::get_islands | ( | ) | const |
Get vector of islands in the archipelago.
Definition at line 746 of file archipelago.cpp.
archipelago::size_type pagmo::archipelago::get_size | ( | ) | const |
Get the size of the archipelago.
Definition at line 254 of file archipelago.cpp.
topology::base_ptr pagmo::archipelago::get_topology | ( | ) | const |
Return a copy of the topology.
Definition at line 287 of file archipelago.cpp.
std::string pagmo::archipelago::human_readable | ( | ) | const |
Return human readable representation of the archipelago.
Will return a formatted string containing:
Definition at line 269 of file archipelago.cpp.
void pagmo::archipelago::interrupt | ( | ) |
Interrupt ongoing evolution.
Will iteratively called island::interrupt() on all the islands of the archipelago.
Definition at line 692 of file archipelago.cpp.
void pagmo::archipelago::join | ( | ) | const |
Wait until evolution on each island has terminated.
Will call iteratively island::join() on all islands of the archipelago.
Definition at line 187 of file archipelago.cpp.
archipelago & pagmo::archipelago::operator= | ( | const archipelago & | a | ) |
Assignment operator.
Will synchronise this and the input archipelago before deep-copying all the elements into this.
[in] | a | archipelago used for assignment. |
Definition at line 151 of file archipelago.cpp.
void pagmo::archipelago::push_back | ( | const base_island & | isl | ) |
Add an island to the archipelago.
Both the island and the archipelago will be synchronised before any operation takes place. The island will then be appended to the archipelago and connected to the existing islands via topology::base::push_back().
Will fail if check_island() returns false on isl.
[in] | isl | island to be added to the archipelago. |
Definition at line 219 of file archipelago.cpp.
void pagmo::archipelago::set_algorithm | ( | const size_type & | idx, |
const algorithm::base & | a | ||
) |
Set island algorithm.
Set algorithm of island number idx to a.
[in] | idx | island index. |
[in] | a | algorithm to be set. |
pagmo::index_error | if index is not smaller than archipelago size. |
Definition at line 241 of file archipelago.cpp.
void pagmo::archipelago::set_distribution_type | ( | const distribution_type & | dt | ) |
Set distribution type.
Change the current distribution type in the archipelago to be dt.
[in] | dt | new distribution type for the archipelago. |
Definition at line 334 of file archipelago.cpp.
void pagmo::archipelago::set_island | ( | const size_type & | idx, |
const base_island & | isl | ||
) |
Island setter.
[in] | idx | index of the island to be set. |
[in] | isl | pagmo::island to be copied in the archipelago at the specified position. |
index_error | if idx is not less than the size of the archipelago. |
value_error | if archipelago::check_island(isl) returns false. |
Definition at line 728 of file archipelago.cpp.
void pagmo::archipelago::set_seeds | ( | unsigned int | seed | ) |
Sets the seed of the random number generators of the archipelago.
Sets the seed of the random number generators of the archipelago. These are used during migration
[in] | seed | Seed for generating pseudo-random sequences |
Definition at line 427 of file archipelago.cpp.
void pagmo::archipelago::set_topology | ( | const topology::base & | tp | ) |
Set topology.
A valid topology must contain only island indices smaller than the size of the archipelago. If this condition is satisfied, then the incoming topology will become the new archipelago topology (after calling push_back() a number of times necessary to fill in the island indices missing in the topology). Otherwise, a value_error exception will be raised.
[in] | tp | new topology for the archipelago. |
Definition at line 301 of file archipelago.cpp.