OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Population< Individual_t > Class Template Reference

#include <Population.h>

Public Types

typedef Individual_t::genes_t genes_t
 
typedef boost::shared_ptr
< Individual_t > 
individual
 
typedef std::pair< unsigned
int, individual
ind_t
 
typedef std::map< unsigned int,
individual >::iterator 
indItr_t
 population iterator type More...
 

Public Member Functions

 Population ()
 
 ~Population ()
 
unsigned int add_individual (individual ind)
 
void remove_individual (individual ind)
 
individual get_individual (int identity)
 
individual get_staging (int identity)
 
void commit_individuals (std::set< unsigned int > ids)
 
void keepSurvivors (std::set< unsigned int > survivors)
 
bool isRepresentedInPopulation (genes_t ind_genes)
 check if a gene set is already represented in the population More...
 
double computeHypervolume (size_t island_id, const std::vector< double > &referencePoint)
 
void commit_individuals ()
 
indItr_t stagingBegin ()
 iterator begin on staging area More...
 
indItr_t stagingEnd ()
 iterator end on staging area More...
 
unsigned int size () const
 
indItr_t begin ()
 iterator begin on population container More...
 
indItr_t end ()
 iterator end on population container More...
 
indItr_t erase (indItr_t it)
 erase individual More...
 

Private Member Functions

unsigned int getFreeID ()
 

Private Attributes

std::map< unsigned int,
individual
individuals
 population container holding all individuals More...
 
std::map< unsigned int,
individual
stagingArea
 staging area for individuals probably joining population More...
 
std::queue< unsigned int > freeids
 queue to handle free individual IDs More...
 
unsigned int last_identity
 last used (= next free) ID More...
 

Detailed Description

template<class Individual_t>
class Population< Individual_t >

Managing a population of individuals. We maintain two sets: a set of all (evaluated) individuals in the population and a set of new potential individuals (the selector decides which individuals join the population), called 'stagingArea'. Most operations work on the 'stagingArea', population is kept for visualization purposes.

Definition at line 29 of file Population.h.

Member Typedef Documentation

template<class Individual_t >
typedef Individual_t::genes_t Population< Individual_t >::genes_t

Definition at line 38 of file Population.h.

template<class Individual_t >
typedef std::pair< unsigned int, individual > Population< Individual_t >::ind_t

Definition at line 40 of file Population.h.

template<class Individual_t >
typedef std::map<unsigned int, individual>::iterator Population< Individual_t >::indItr_t

population iterator type

Definition at line 43 of file Population.h.

template<class Individual_t >
typedef boost::shared_ptr<Individual_t> Population< Individual_t >::individual

Definition at line 39 of file Population.h.

Constructor & Destructor Documentation

template<class Individual_t >
Population< Individual_t >::Population ( )
inline

Definition at line 32 of file Population.h.

References Population< Individual_t >::last_identity.

template<class Individual_t >
Population< Individual_t >::~Population ( )
inline

Definition at line 36 of file Population.h.

Member Function Documentation

template<class Individual_t >
unsigned int Population< Individual_t >::add_individual ( individual  ind)
inline

Adds an individual to the population

Parameters
indan individual that will be added to the population
Returns
individual id if successful, -1 otherwise

Definition at line 50 of file Population.h.

References Population< Individual_t >::getFreeID(), and Population< Individual_t >::stagingArea.

Here is the call graph for this function:

template<class Individual_t >
indItr_t Population< Individual_t >::begin ( )
inline

iterator begin on population container

Definition at line 210 of file Population.h.

References Population< Individual_t >::individuals.

template<class Individual_t >
void Population< Individual_t >::commit_individuals ( std::set< unsigned int >  ids)
inline

Definition at line 116 of file Population.h.

References Population< Individual_t >::get_staging(), Population< Individual_t >::individuals, and Population< Individual_t >::stagingArea.

Here is the call graph for this function:

template<class Individual_t >
void Population< Individual_t >::commit_individuals ( )
inline
template<class Individual_t >
double Population< Individual_t >::computeHypervolume ( size_t  island_id,
const std::vector< double > &  referencePoint 
)
inline

Definition at line 161 of file Population.h.

References endl(), Inform::flush(), Hypervolume::FromFile(), and Population< Individual_t >::individuals.

Here is the call graph for this function:

template<class Individual_t >
indItr_t Population< Individual_t >::end ( )
inline

iterator end on population container

Definition at line 212 of file Population.h.

References Population< Individual_t >::individuals.

template<class Individual_t >
indItr_t Population< Individual_t >::erase ( indItr_t  it)
inline

erase individual

Definition at line 214 of file Population.h.

References Population< Individual_t >::individuals.

template<class Individual_t >
individual Population< Individual_t >::get_individual ( int  identity)
inline

Get an individual of the current population with a specific ID

Parameters
identityan ID of the individual in the population
Returns
the individual with the specified ID in the population, empty pointer if none found

Definition at line 83 of file Population.h.

References Population< Individual_t >::individuals.

template<class Individual_t >
individual Population< Individual_t >::get_staging ( int  identity)
inline

Get an individual of the 'stagingArea' with a specific ID

Parameters
identityan ID of the individual in the stagingArea
Returns
the individual with the specified ID, empty pointer if none found

Definition at line 102 of file Population.h.

References Population< Individual_t >::stagingArea.

Referenced by Population< Individual_t >::commit_individuals().

template<class Individual_t >
unsigned int Population< Individual_t >::getFreeID ( )
inlineprivate

Manages free individual IDs

Returns
lowest free ID

Definition at line 234 of file Population.h.

References Population< Individual_t >::freeids, and Population< Individual_t >::last_identity.

Referenced by Population< Individual_t >::add_individual().

template<class Individual_t >
bool Population< Individual_t >::isRepresentedInPopulation ( genes_t  ind_genes)
inline

check if a gene set is already represented in the population

Definition at line 150 of file Population.h.

References Population< Individual_t >::individuals.

template<class Individual_t >
void Population< Individual_t >::keepSurvivors ( std::set< unsigned int >  survivors)
inline

Remove all non-surviving individuals from the population and put IDs back in pool of free IDs.

Parameters
survivorsto keep for next generation

Definition at line 131 of file Population.h.

References Population< Individual_t >::freeids, Population< Individual_t >::individuals, and Population< Individual_t >::last_identity.

template<class Individual_t >
void Population< Individual_t >::remove_individual ( individual  ind)
inline
template<class Individual_t >
unsigned int Population< Individual_t >::size ( void  ) const
inline

Size of population

Returns
total number of individuals in population

Definition at line 207 of file Population.h.

References Population< Individual_t >::individuals.

template<class Individual_t >
indItr_t Population< Individual_t >::stagingBegin ( )
inline

iterator begin on staging area

Definition at line 198 of file Population.h.

References Population< Individual_t >::stagingArea.

template<class Individual_t >
indItr_t Population< Individual_t >::stagingEnd ( )
inline

iterator end on staging area

Definition at line 200 of file Population.h.

References Population< Individual_t >::stagingArea.

Member Data Documentation

template<class Individual_t >
std::queue<unsigned int> Population< Individual_t >::freeids
private
template<class Individual_t >
std::map<unsigned int, individual > Population< Individual_t >::individuals
private
template<class Individual_t >
unsigned int Population< Individual_t >::last_identity
private
template<class Individual_t >
std::map<unsigned int, individual > Population< Individual_t >::stagingArea
private

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