PaGMO  1.1.5
Public Types | Public Member Functions | Friends
pagmo::archipelago Class Reference

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_ptrcontainer_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...
 
archipelagooperator= (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_ptrget_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
 

Detailed Description

Archipelago class.

Author
Francesco Biscani (blues.nosp@m.carn.nosp@m.i@gma.nosp@m.il.c.nosp@m.om)
Marek RuciƄski (marek.nosp@m..ruc.nosp@m.inski.nosp@m.@gma.nosp@m.il.co.nosp@m.m)

Definition at line 57 of file archipelago.h.

Member Enumeration Documentation

Distribution type for migrating individuals.

Enumerator
point_to_point 

Individuals migrate to one of the island's neighbours.

The destination will be chosen randomly among all the possible choices.

broadcast 

Individuals migrate to all the island's neighbours.

Note that in case of highly-connected topologies this options can result in high memory usage.

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.

Enumerator
source 

Immigrants flow is initiated by the source island.

With this strategy, the internal migration database stores for each island the individuals that are meant to migrate to that island. Before each evolution, an island will check if individuals destined to it are available in the database, and, in such case will, migrate over incoming individuals before starting evolution.

After each evolution, the island will place its candidate individuals for emigration in the database slots of the island(s) to which it connects.

destination 

Immigrants flow is initiated by the destination island.

With this strategy, the internal migration database stores for each island its best individuals. Before each evolution, the island will get migrating individuals from those made available by the islands connecting to it.

After each evolution, the island will update its list of best individuals in the database.

Definition at line 87 of file archipelago.h.

Constructor & Destructor Documentation

pagmo::archipelago::archipelago ( distribution_type  dt = point_to_point,
migration_direction  md = destination 
)
explicit

Default constructor.

Will construct an empty archipelago with topology::unconnected topology, with point_to_point distribution_type and destination migration_direction.

Parameters
[in]dtdistribution type.
[in]mdmigration direction.

Definition at line 68 of file archipelago.cpp.

pagmo::archipelago::archipelago ( const topology::base t,
distribution_type  dt = point_to_point,
migration_direction  md = destination 
)
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.

Parameters
[in]ttopology that will be associated to the archipelago.
[in]dtdistribution type.
[in]mdmigration direction.

Definition at line 84 of file archipelago.cpp.

pagmo::archipelago::archipelago ( const algorithm::base a,
const problem::base p,
int  n,
int  m,
const topology::base t = topology::unconnected(),
distribution_type  dt = point_to_point,
migration_direction  md = destination 
)
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.

Parameters
[in]aalgorithm which will be assigned to all islands.
[in]pproblem which will be assigned to all islands.
[in]nnumber of islands.
[in]mnumber of individuals on each island.
[in]ttopology.
[in]dtdistribution type.
[in]mdmigration 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.

Parameters
[in]aarchipelago 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.

Member Function Documentation

bool pagmo::archipelago::busy ( ) const

Query the status of the archipelago.

Returns
true if at least one island is evolving, false otherwise.

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:

  • archipelago is empty,
  • the problem of the incoming island is compatible with the problems of the islands already present in the archipelago (via problem::base::is_compatible()).

Otherwise, false will be returned.

Parameters
[in]islisland which will be checked.
Returns
true if isl is compatible with the archipelago, false otherwise.

Definition at line 351 of file archipelago.cpp.

void pagmo::archipelago::clear_migr_history ( )

Clears the archipelago migration history.

Returns
Empties the migration history. If dump_migr_history is called immediately after, it will return an empty string

Definition at line 788 of file archipelago.cpp.

std::string pagmo::archipelago::dump_migr_history ( ) const

Dumps the archipelago migration history.

Returns
A string formatted as follows: (x1,y1,z1)
(x2,y2,z2)..... where x is the number of individuals accepted in island z and coming from island y

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.

Parameters
[in]nnumber 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).

Parameters
[in]nnumber of time each island will be evolved.
[in]bthe size of the batch of islands to evolve at the same time.
[in]randomizedetermines 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.

Parameters
[in]tamount 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.

Returns
a archipelago::distribution_type corresponding to the current distribution type in the archipelago.

Definition at line 323 of file archipelago.cpp.

base_island_ptr pagmo::archipelago::get_island ( const size_type idx) const

Island getter.

Parameters
[in]idxindex of the desired island.
Returns
a copy of the island at position idx.
Exceptions
index_errorif 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.

Returns
vector of pagmo::base_island_ptr to copies of the islands contained 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.

Returns
the number of islands contained in the archipelago.

Definition at line 254 of file archipelago.cpp.

topology::base_ptr pagmo::archipelago::get_topology ( ) const

Return a copy of the topology.

Returns
a topology::base_ptr to a clone of the internal 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:

Returns
formatted string containing the human readable representation of the archipelago.

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.

Parameters
[in]aarchipelago used for assignment.
Returns
reference to this.

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.

Parameters
[in]islisland 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.

Parameters
[in]idxisland index.
[in]aalgorithm to be set.
Exceptions
pagmo::index_errorif 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.

Parameters
[in]dtnew 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.

Parameters
[in]idxindex of the island to be set.
[in]islpagmo::island to be copied in the archipelago at the specified position.
Exceptions
index_errorif idx is not less than the size of the archipelago.
value_errorif 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

Parameters
[in]seedSeed 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.

Parameters
[in]tpnew topology for the archipelago.

Definition at line 301 of file archipelago.cpp.


The documentation for this class was generated from the following files: