|
GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
|
Generational GA with the same interface as StandardGA, built for CUDA-enabled builds. More...
#include <StandardGACUDA.h>
Public Member Functions | |
| StandardGACUDA (FitnessFunction< GeneType > &ff, std::unique_ptr< Selection< GeneType > > sel, std::unique_ptr< Mutation< GeneType > > mu, std::unique_ptr< Crossover< GeneType > > cs, double m_rate, double c_rate, std::size_t max_gen, bool elitism=true) | |
| Constructs the algorithm with all required operators and parameters. | |
| void | run (Population< GeneType > &population) override |
| Runs the 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 |
Generational GA with the same interface as StandardGA, built for CUDA-enabled builds.
Drop-in replacement for galib::StandardGA. The evolution loop (selection, crossover, mutation) runs on the CPU using OpenMP, making it fully compatible with any pluggable operator. When the library is compiled with CUDA support, the CUDA runtime is linked and GPU-accelerated fitness evaluation can be added in future iterations.
The algorithm follows a generational model:
| GeneType | Numeric type of each gene (default: double). |
algorithm.standard.use_cuda: true rather than instantiating directly. Definition at line 45 of file StandardGACUDA.h.
|
inline |
Constructs the algorithm with all required operators and parameters.
| ff | Fitness function used to evaluate individuals. Must outlive this object. |
| sel | Selection operator (e.g. TournamentSelection). Ownership is transferred. |
| mu | Mutation operator (e.g. GaussianMutation). Ownership is transferred. |
| cs | Crossover operator (e.g. SinglePointCrossover). Ownership is transferred. |
| m_rate | Probability [0, 1] that any individual gene is mutated. |
| c_rate | Probability [0, 1] that two parents produce children via crossover; otherwise parents are copied unchanged. |
| max_gen | Number of generations to run. |
| elitism | If true, the best individual is always copied to the next generation. |
Definition at line 60 of file StandardGACUDA.h.
|
inlineoverridevirtual |
Runs the evolutionary optimisation loop.
Evolves population in-place for max_gen generations. The population must be initialised with valid gene values before calling this method.
Progress is printed to stdout every 50 generations unless a ConsoleLogger is attached via enableConsoleLogging(), in which case that logger is used instead.
| population | In/out: the population to evolve. Modified in place. |
Implements galib::Algorithm< GeneType >.
Definition at line 90 of file StandardGACUDA.h.
References galib::cuda::internal::CUDARunParams::crossover_rate, galib::cuda::internal::CUDARunParams::dims, galib::Population< GeneType >::empty(), galib::cuda::internal::CUDARunParams::fitness_callback, galib::Population< GeneType >::getNumGenes(), galib::cuda::internal::CUDARunParams::max_generations, galib::cuda::internal::CUDARunParams::mutation_rate, galib::cuda::internal::CUDARunParams::pop_size, galib::cuda::internal::CUDARunParams::problem_name, galib::cuda::internal::CUDARunParams::progress_callback, galib::cuda::internal::runCUDAEvolution(), galib::cuda::internal::CUDARunParams::sigma, galib::Population< GeneType >::size(), galib::cuda::internal::CUDARunParams::tournament_size, and galib::cuda::internal::CUDARunParams::use_elitism.