OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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, individualind_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, individualindividuals
 population container holding all individuals More...
 
std::map< unsigned int, individualstagingArea
 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 >

Definition at line 45 of file Population.h.

Member Typedef Documentation

◆ genes_t

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

Definition at line 54 of file Population.h.

◆ ind_t

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

Definition at line 56 of file Population.h.

◆ indItr_t

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

population iterator type

Definition at line 59 of file Population.h.

◆ individual

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

Definition at line 55 of file Population.h.

Constructor & Destructor Documentation

◆ Population()

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

Definition at line 48 of file Population.h.

References Population< Individual_t >::last_identity.

◆ ~Population()

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

Definition at line 52 of file Population.h.

Member Function Documentation

◆ add_individual()

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 66 of file Population.h.

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

Here is the call graph for this function:

◆ begin()

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

iterator begin on population container

Definition at line 226 of file Population.h.

References Population< Individual_t >::individuals.

◆ commit_individuals() [1/2]

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

◆ commit_individuals() [2/2]

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

Definition at line 132 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:

◆ computeHypervolume()

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

Definition at line 177 of file Population.h.

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

Here is the call graph for this function:

◆ end()

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

iterator end on population container

Definition at line 228 of file Population.h.

References Population< Individual_t >::individuals.

◆ erase()

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

erase individual

Definition at line 230 of file Population.h.

References Population< Individual_t >::individuals.

◆ get_individual()

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 99 of file Population.h.

References Population< Individual_t >::individuals.

◆ get_staging()

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 118 of file Population.h.

References Population< Individual_t >::stagingArea.

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

◆ getFreeID()

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

Manages free individual IDs

Returns
lowest free ID

Definition at line 250 of file Population.h.

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

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

◆ isRepresentedInPopulation()

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 166 of file Population.h.

References Population< Individual_t >::individuals.

◆ keepSurvivors()

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 147 of file Population.h.

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

◆ remove_individual()

template<class Individual_t >
void Population< Individual_t >::remove_individual ( individual  ind)
inline

◆ size()

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 223 of file Population.h.

References Population< Individual_t >::individuals.

◆ stagingBegin()

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

iterator begin on staging area

Definition at line 214 of file Population.h.

References Population< Individual_t >::stagingArea.

◆ stagingEnd()

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

iterator end on staging area

Definition at line 216 of file Population.h.

References Population< Individual_t >::stagingArea.

Member Data Documentation

◆ freeids

template<class Individual_t >
std::queue<unsigned int> Population< Individual_t >::freeids
private

◆ individuals

template<class Individual_t >
std::map<unsigned int, individual > Population< Individual_t >::individuals
private

◆ last_identity

template<class Individual_t >
unsigned int Population< Individual_t >::last_identity
private

◆ stagingArea

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: