PaGMO
1.1.5
|
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_type > | container_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... | |
population & | operator= (const population &) |
Assignment operator. More... | |
const individual_type & | get_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::base & | problem () const |
const champion_type & | champion () const |
std::string | human_readable_terse () const |
std::string | human_readable () const |
size_type | get_best_idx () const |
std::vector< size_type > | get_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_type > | m_dom_count |
Friends | |
class | base_island |
struct | population_access |
class | boost::serialization::access |
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)
Definition at line 70 of file population.h.
|
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.
[in] | p | problem::base that will be associated to the population. |
[in] | n | integer number of individuals in the population. |
[in] | seed | rng seed (used to initialize the pop and in race) |
value_error | if 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.
[in] | p | population used to initialise this. |
Definition at line 103 of file population.cpp.
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:
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:
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.
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
[in] | idx | position of the individual whose Crowding Distance will be returned |
index_error | if 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.
[in] | idx | position of the individual whose domination count will be retrieved. |
index_error | if 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().
[in] | idx | position of the individual whose domination list will be retrieved. |
index_error | if 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().
idx | positional index of the individual to get. |
index_error | if 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
[in] | idx | position of the individual whose Pareto rank will be returned |
index_error | if 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.
[in] | p | population to be assigned 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.
[in] | idx | position of the individual to be re-initialised. |
index_error | if idx is not smaller than size(). |
Definition at line 236 of file population.cpp.
void pagmo::population::reinit | ( | ) |
Re-initialise all individuals.
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.