|
GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
|
A container for a group of individuals in the genetic algorithm. More...
#include <Population.h>
Public Member Functions | |
| Population (std::size_t size, std::size_t num_genes) | |
| Constructs a population of a given size. | |
| void | initialize (GeneType lower, GeneType upper) |
| Randomly initializes all individuals within the specified bounds. | |
| std::size_t | size () const |
| Returns the total number of individuals in the population. | |
| bool | empty () const |
| Checks if the population is empty. | |
| std::size_t | getNumGenes () const |
| Returns the number of genes for individuals in this population. | |
| Individual< GeneType > & | operator[] (std::size_t index) |
| Accesses an individual by its index. | |
| const Individual< GeneType > & | operator[] (std::size_t index) const |
| Accesses an individual by its index (const version). | |
| std::vector< Individual< GeneType > >::iterator | begin () |
| Returns an iterator to the beginning. | |
| std::vector< Individual< GeneType > >::iterator | end () |
| Returns an iterator to the end. | |
| std::vector< Individual< GeneType > >::const_iterator | begin () const |
| Returns a constant iterator to the beginning. | |
| std::vector< Individual< GeneType > >::const_iterator | end () const |
| Returns a constant iterator to the end. | |
| const Individual< GeneType > & | getBestIndividual () const |
| Finds and returns the individual with the best fitness score. | |
A container for a group of individuals in the genetic algorithm.
Provides methods for initializing individuals with random values and retrieving the best performing member.
| GeneType | The type of the genes. |
Definition at line 24 of file Population.h.
|
inlineexplicit |
Constructs a population of a given size.
| size | Number of individuals in the population. Must be > 0. |
| num_genes | Number of genes each individual should have. |
| std::invalid_argument | if size is 0. |
Definition at line 35 of file Population.h.
References galib::Population< GeneType >::size().
|
inline |
Returns an iterator to the beginning.
Definition at line 97 of file Population.h.
|
inline |
Returns a constant iterator to the beginning.
Definition at line 103 of file Population.h.
|
inline |
Checks if the population is empty.
Definition at line 74 of file Population.h.
Referenced by galib::GridPopulation< GeneType >::empty(), galib::CellularGA< GeneType >::run(), galib::DifferentialEvolutionGA< GeneType >::run(), galib::IslandGA< GeneType >::run(), galib::StandardGA< GeneType >::run(), and galib::cuda::StandardGACUDA< GeneType >::run().
|
inline |
Returns an iterator to the end.
Definition at line 100 of file Population.h.
|
inline |
Returns a constant iterator to the end.
Definition at line 106 of file Population.h.
|
inline |
Finds and returns the individual with the best fitness score.
Definition at line 112 of file Population.h.
Referenced by galib::GridPopulation< GeneType >::getBestIndividual(), galib::utils::ConsoleLogger< GeneType >::log(), and galib::StandardGA< GeneType >::run().
|
inline |
Returns the number of genes for individuals in this population.
Definition at line 80 of file Population.h.
Referenced by galib::GridPopulation< GeneType >::getNumGenes(), galib::utils::FileLogger< GeneType >::log(), galib::CellularGA< GeneType >::run(), galib::DifferentialEvolutionGA< GeneType >::run(), galib::IslandGA< GeneType >::run(), galib::StandardGA< GeneType >::run(), and galib::cuda::StandardGACUDA< GeneType >::run().
|
inline |
Randomly initializes all individuals within the specified bounds.
Parallelized using OpenMP.
| lower | Lower bound for each gene. |
| upper | Upper bound for each gene. |
Definition at line 48 of file Population.h.
Referenced by galib::GridPopulation< GeneType >::initialize().
|
inline |
Accesses an individual by its index.
| index | Zero-based index. |
Definition at line 87 of file Population.h.
|
inline |
Accesses an individual by its index (const version).
| index | Zero-based index. |
Definition at line 94 of file Population.h.
|
inline |
Returns the total number of individuals in the population.
Definition at line 68 of file Population.h.
Referenced by galib::GridPopulation< GeneType >::linearAt(), galib::GridPopulation< GeneType >::linearAt(), galib::utils::FileLogger< GeneType >::log(), galib::Population< GeneType >::Population(), galib::WorstReplacer< GeneType >::replaceDeme(), galib::CellularGA< GeneType >::run(), galib::DifferentialEvolutionGA< GeneType >::run(), galib::IslandGA< GeneType >::run(), galib::StandardGA< GeneType >::run(), galib::cuda::StandardGACUDA< GeneType >::run(), galib::TournamentSelection< GeneType >::select(), galib::ElitismSelector< GeneType >::selectDeme(), and galib::GridPopulation< GeneType >::size().