OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Population< Individual_t > Class Template Reference

#include <Population.h>

Inheritance diagram for Population< Individual_t >:
Collaboration diagram for Population< Individual_t >:

Public Types

typedef Individual_t::genes_t genes_t
typedef std::shared_ptr< Individual_t > individual
typedef std::pair< unsigned int, individualind_t
typedef std::map< unsignedint, individual >::iterator indItr_t
 population iterator type

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
double computeHypervolume (size_t island_id, const std::vector< double > &referencePoint)
void commit_individuals ()
indItr_t stagingBegin ()
 iterator begin on staging area
indItr_t stagingEnd ()
 iterator end on staging area
unsigned int size () const
indItr_t begin ()
 iterator begin on population container
indItr_t end ()
 iterator end on population container
indItr_t erase (indItr_t it)
 erase individual

Private Member Functions

unsigned int getFreeID ()

Private Attributes

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

Detailed Description

template<class Individual_t>
class Population< Individual_t >

Definition at line 44 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 53 of file Population.h.

◆ ind_t

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

Definition at line 55 of file Population.h.

◆ indItr_t

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

population iterator type

Definition at line 58 of file Population.h.

◆ individual

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

Definition at line 54 of file Population.h.

Constructor & Destructor Documentation

◆ Population()

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

Definition at line 47 of file Population.h.

References last_identity.

◆ ~Population()

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

Definition at line 51 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 65 of file Population.h.

References getFreeID(), and 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 225 of file Population.h.

References individuals.

◆ commit_individuals() [1/2]

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

Definition at line 206 of file Population.h.

References individuals, and stagingArea.

◆ commit_individuals() [2/2]

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

Definition at line 131 of file Population.h.

References get_staging(), individuals, and 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 176 of file Population.h.

References Hypervolume::FromFile(), and 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 227 of file Population.h.

References individuals.

◆ erase()

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

erase individual

Definition at line 229 of file Population.h.

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

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

References stagingArea.

Referenced by 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 249 of file Population.h.

References freeids, and last_identity.

Referenced by 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 165 of file Population.h.

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

References freeids, individuals, and last_identity.

◆ remove_individual()

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

Definition at line 74 of file Population.h.

References freeids, last_identity, and stagingArea.

◆ size()

template<class Individual_t>
unsigned int Population< Individual_t >::size ( ) const
inline

Size of population

Returns
total number of individuals in population

Definition at line 222 of file Population.h.

References individuals.

◆ stagingBegin()

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

iterator begin on staging area

Definition at line 213 of file Population.h.

References stagingArea.

◆ stagingEnd()

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

iterator end on staging area

Definition at line 215 of file Population.h.

References stagingArea.

Member Data Documentation

◆ freeids

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

queue to handle free individual IDs

Definition at line 240 of file Population.h.

Referenced by getFreeID(), keepSurvivors(), and remove_individual().

◆ individuals

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

population container holding all individuals

Definition at line 234 of file Population.h.

Referenced by begin(), commit_individuals(), commit_individuals(), computeHypervolume(), end(), erase(), get_individual(), isRepresentedInPopulation(), keepSurvivors(), and size().

◆ last_identity

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

last used (= next free) ID

Definition at line 243 of file Population.h.

Referenced by getFreeID(), keepSurvivors(), Population(), and remove_individual().

◆ stagingArea

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

staging area for individuals probably joining population

Definition at line 237 of file Population.h.

Referenced by add_individual(), commit_individuals(), commit_individuals(), get_staging(), remove_individual(), stagingBegin(), and stagingEnd().


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