PaGMO  1.1.5
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
pagmo::population Class Reference

Population class. More...

#include <population.h>

Data Structures

struct  champion_type
 Population champion. More...
 
struct  individual_type
 Individuals stored in the population. More...
 

Public Types

typedef std::vector< individual_typecontainer_type
 Underlying container type.
 
typedef container_type::size_type size_type
 Population size type.
 
typedef container_type::const_iterator const_iterator
 Const iterator.
 

Public Member Functions

 population (const problem::base &, int=0, const boost::uint32_t &seed=getSeed())
 Constructor from problem::base and number of individuals. More...
 
 population (const population &)
 Copy constructor. More...
 
populationoperator= (const population &)
 Assignment operator. More...
 
const individual_typeget_individual (const size_type &) const
 Get constant reference to individual at position n. More...
 
const std::vector< size_type > & get_domination_list (const size_type &) const
 Get domination list. More...
 
size_type get_domination_count (const size_type &) const
 Get domination count. More...
 
size_type get_pareto_rank (const size_type &) const
 Get Pareto rank. More...
 
double get_crowding_d (const size_type &) const
 Get Crowding Distance. More...
 
void update_pareto_information () const
 Update Pareto Information. More...
 
size_type n_dominated (const individual_type &) const
 
std::vector< std::vector< size_type > > compute_pareto_fronts () const
 Computes and returns the population Pareto fronts. More...
 
fitness_vector compute_ideal () const
 Compute and return the ideal objective vector. More...
 
fitness_vector compute_nadir () const
 Compute and return the nadir objective vector. More...
 
const problem::baseproblem () const
 
const champion_typechampion () const
 
std::string human_readable_terse () const
 
std::string human_readable () const
 
size_type get_best_idx () const
 
std::vector< size_typeget_best_idx (const size_type &N) const
 
size_type get_worst_idx () const
 
void set_x (const size_type &, const decision_vector &)
 
void set_v (const size_type &, const decision_vector &)
 
void push_back (const decision_vector &)
 
void erase (const size_type &)
 
size_type size () const
 
const_iterator begin () const
 
const_iterator end () const
 
void reinit (const size_type &)
 Re-initialise individual at position idx. More...
 
void reinit ()
 Re-initialise all individuals. More...
 
void clear ()
 
double mean_velocity () const
 Computes the mean curent velocity of all individuals in the population.
 
void repair (const size_type &, const algorithm::base_ptr &)
 
std::pair< std::vector< population::size_type >, unsigned int > race (const size_type n_final, const unsigned int min_trials=0, const unsigned int max_count=1000, double delta=0.05, const std::vector< size_type > &=std::vector< size_type >(), const bool race_best=true, const bool screen_output=false) const
 

Static Public Member Functions

static boost::uint32_t getSeed ()
 

Protected Member Functions

void update_dom (const size_type &)
 

Protected Attributes

container_type m_container
 
std::vector< std::vector< size_type > > m_dom_list
 
std::vector< size_typem_dom_count
 

Friends

class base_island
 
struct population_access
 
class boost::serialization::access
 

Detailed Description

Population class.

This class contains an instance of an optimisation problem and a group of candidate solutions represented by the class individual_type. On creation, the population is associated to a problem and initialised with random decision vectors. An instance of champion_type automatically keeps track of the best solution ever appeared in the population. This is only meaningful in single objective optimization problems.

Methods are offered to get and manipulate the single individuals.

Additionally, the population class keeps for each individual I a "domination list", constituted by the list of individuals (identified by their positional index in the population) which I dominates, and a 'domination count' containing the number of individuals that dominate I. Individual I1 is dominated by individual I2 if problem::base::compare_fc on the fitness and constraints vectors of I1 and I2 respectively returns true. The best/worst individuals in the population are computed according to the crowding distance operator (in case of multi-objective problems)

Author
Francesco Biscani (blues.nosp@m.carn.nosp@m.i@gma.nosp@m.il.c.nosp@m.om)
Dario Izzo (dario.nosp@m..izz.nosp@m.o@goo.nosp@m.glem.nosp@m.ail.c.nosp@m.om)

Definition at line 70 of file population.h.

Constructor & Destructor Documentation

pagmo::population::population ( const problem::base p,
int  n = 0,
const boost::uint32_t &  seed = getSeed() 
)
explicit

Constructor from problem::base and number of individuals.

Will store a copy of the problem and will initialise the population to n randomly-generated individuals. Will fail if n is negative.

Parameters
[in]pproblem::base that will be associated to the population.
[in]ninteger number of individuals in the population.
[in]seedrng seed (used to initialize the pop and in race)
Exceptions
value_errorif n is negative.

Definition at line 69 of file population.cpp.

pagmo::population::population ( const population p)

Copy constructor.

Will perform a deep copy of all the elements.

Parameters
[in]ppopulation used to initialise this.

Definition at line 103 of file population.cpp.

Member Function Documentation

fitness_vector pagmo::population::compute_ideal ( ) const

Compute and return the ideal objective vector.

This method returns the ideal objective vector for the current optimal pareto set. The components of the ideal objective vector are defined as:

\[ z_i^{\mbox{ideal}} = \mbox{min}_{x \in X : x \mbox{ is Pareto Optimal}} f_i(x) \]

Returns
the ideal objective vector for the current optimal pareto set

Definition at line 499 of file population.cpp.

fitness_vector pagmo::population::compute_nadir ( ) const

Compute and return the nadir objective vector.

This method returns the nadir objective vector for the current optimal pareto set. The components of the nadir objective vector are defined as:

\[ z_i^{\mbox{nadir}} = \mbox{max}_{x \in X : x \mbox{ is Pareto Optimal}} f_i(x) \]

Returns
the nadir objective vector for the current optimal pareto set

Definition at line 523 of file population.cpp.

std::vector< std::vector< population::size_type > > pagmo::population::compute_pareto_fronts ( ) const

Computes and returns the population Pareto fronts.

This method computes all Pareto Fronts of the population, returning the positional indices of the individuals belonging to each Pareto front.

Returns
a vector containing, for each Pareto front, a vector of the individuals idx that belong to each front

Definition at line 475 of file population.cpp.

double pagmo::population::get_crowding_d ( const size_type idx) const

Get Crowding Distance.

Will return the crowding distance for the requested individual idx. A call to population::update_pareto_information() is needed if the population has changed since the last time the Crowding Distance was computed. The crowding distance is computed as defined in Deb's work

See also
Deb, K. and Pratap, A. and Agarwal, S. and Meyarivan, T., "A fast and elitist multiobjective genetic algorithm: NSGA-II"
Parameters
[in]idxposition of the individual whose Crowding Distance will be returned
Returns
the Crowding Distance of indiviual idx
Exceptions
index_errorif idx is not smaller than m_crowding_distance.size().

Definition at line 356 of file population.cpp.

population::size_type pagmo::population::get_domination_count ( const size_type idx) const

Get domination count.

Will return the domination count for the requested individual idx. That is the number of population individuals that dominate idx.

Parameters
[in]idxposition of the individual whose domination count will be retrieved.
Returns
the domination count
Exceptions
index_errorif idx is not smaller than size().

Definition at line 314 of file population.cpp.

const std::vector< population::size_type > & pagmo::population::get_domination_list ( const size_type idx) const

Get domination list.

Will return a vector containing the indices of the individuals dominated by the individual in position idx. Will fail if idx is not smaller than size().

Parameters
[in]idxposition of the individual whose domination list will be retrieved.
Returns
const reference to the vector containing the indices of the individuals dominated by the individual at position idx.
Exceptions
index_errorif idx is not smaller than size().

Definition at line 296 of file population.cpp.

const population::individual_type & pagmo::population::get_individual ( const size_type idx) const

Get constant reference to individual at position n.

Will fail if idx is greater than size().

Parameters
idxpositional index of the individual to get.
Returns
const reference to the individual at position idx.
Exceptions
index_errorif idx is not smaller than size().

Definition at line 277 of file population.cpp.

population::size_type pagmo::population::get_pareto_rank ( const size_type idx) const

Get Pareto rank.

Will return the Pareto rank for the requested individual idx (that is the Pareto front it belongs to, starting from 0,1,2....N). A call to population::update_pareto_information() is needed if the population has changed since the last time the Pareto rank was computed

Parameters
[in]idxposition of the individual whose Pareto rank will be returned
Returns
the Pareto rank of indiviual idx
Exceptions
index_errorif idx is not smaller than m_pareto_rank.size().

Definition at line 334 of file population.cpp.

population & pagmo::population::operator= ( const population p)

Assignment operator.

Performs a deep copy of all the elements of p into this.

Parameters
[in]ppopulation to be assigned to this.
Returns
reference to this.

Definition at line 115 of file population.cpp.

void pagmo::population::reinit ( const size_type idx)

Re-initialise individual at position idx.

The continuous and integer parts of the chromosome will be picked randomly within the problem's bounds, the velocities will be initialised randomly so that in one tick the particles travel at most half the bounds distance. Fitness and constraints will be evaluated, best_x and best_f are erasred and reset to the new values, the champion is updated.

Parameters
[in]idxposition of the individual to be re-initialised.
Exceptions
index_errorif idx is not smaller than size().

Definition at line 236 of file population.cpp.

void pagmo::population::reinit ( )

Re-initialise all individuals.

See also
population::reinit(const size_type &).

Definition at line 218 of file population.cpp.

void pagmo::population::update_pareto_information ( ) const

Update Pareto Information.

Computes all pareto fronts, updates the pareto rank and the crowding distance of each individual. Member variables for rank and crowding distance are set to zero and domination lists and domination count are used to for the computation.

Definition at line 384 of file population.cpp.


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