|
GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
|
Cellular genetic algorithm that evolves individuals on a local 2D neighbourhood. More...
#include <CellularGA.h>
Public Member Functions | |
| CellularGA (FitnessFunction< GeneType > &ff, std::unique_ptr< LocalSelection< GeneType > > local_sel, std::unique_ptr< Mutation< GeneType > > mu, std::unique_ptr< Crossover< GeneType > > cs, double m_rate, double c_rate, std::size_t max_gen, std::size_t threads, bool elitism=false) | |
| Constructs the cellular genetic algorithm with all required operators. | |
| void | run (Population< GeneType > &population) override |
| Runs the cellular evolutionary optimisation loop. | |
Public Member Functions inherited from galib::Algorithm< GeneType > | |
| virtual | ~Algorithm ()=default |
| virtual void | enableConsoleLogging (const std::size_t interval) |
| Enables logging of progress to the standard output. | |
| virtual void | enableFileLogging (const std::string &path, std::size_t interval) |
| Enables logging of population snapshots to a CSV file. | |
| virtual void | enableLogging (const std::string &) |
| Placeholder for generic logging configuration. | |
Additional Inherited Members | |
Protected Member Functions inherited from galib::Algorithm< GeneType > | |
| void | notifyLoggers (std::size_t gen, const Population< GeneType > &pop) |
| Notifies all active loggers to record the current state. | |
Protected Attributes inherited from galib::Algorithm< GeneType > | |
| std::unique_ptr< utils::ConsoleLogger< GeneType > > | console_logger_m |
| std::unique_ptr< utils::FileLogger< GeneType > > | file_logger_m |
Cellular genetic algorithm that evolves individuals on a local 2D neighbourhood.
The algorithm accepts a regular Population and interprets it as a 2D toroidal grid. Grid dimensions are inferred automatically from the population size by choosing a factorisation close to a square. Each cell evolves using only its local neighbourhood, which preserves spatial diversity better than fully mixing the whole population.
The evolutionary loop is:
population.size().| GeneType | Numeric type of each gene (default: double). |
threads is 0, TBB chooses the level of parallelism automatically. Definition at line 50 of file CellularGA.h.
|
inline |
Constructs the cellular genetic algorithm with all required operators.
| ff | Fitness function used to evaluate individuals. Must outlive this object. |
| local_sel | Local neighbourhood selection strategy. Ownership is transferred. |
| mu | Mutation operator applied to produced offspring. Ownership is transferred. |
| cs | Crossover operator used to combine the current cell with a neighbour. Ownership is transferred. |
| m_rate | Mutation probability in the range [0, 1]. |
| c_rate | Crossover probability in the range [0, 1]. |
| max_gen | Number of generations to run. |
| threads | Maximum number of TBB worker threads. If 0, TBB decides automatically. |
| elitism | If true, the current individual competes with both children and the best one survives in the next generation. |
Definition at line 156 of file CellularGA.h.
|
inlineoverridevirtual |
Runs the cellular evolutionary optimisation loop.
The input population is interpreted as a 2D grid whose shape is inferred from population.size(). The population is evolved in place and overwritten with the final generation.
| population | In/out population to evolve. |
Implements galib::Algorithm< GeneType >.
Definition at line 190 of file CellularGA.h.
References galib::Population< GeneType >::empty(), galib::Population< GeneType >::getNumGenes(), galib::Algorithm< GeneType >::notifyLoggers(), and galib::Population< GeneType >::size().