GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
Public Member Functions | List of all members
galib::cuda::StandardGACUDA< GeneType > Class Template Reference

Generational GA with the same interface as StandardGA, built for CUDA-enabled builds. More...

#include <StandardGACUDA.h>

Inheritance diagram for galib::cuda::StandardGACUDA< GeneType >:
[legend]

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
 

Detailed Description

template<typename GeneType = double>
class galib::cuda::StandardGACUDA< GeneType >

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:

  1. Evaluate the initial population.
  2. For each generation: optionally copy the elite individual, then fill the rest of the population via selection → crossover → mutation.
  3. Evaluate the new population and repeat.
Template Parameters
GeneTypeNumeric type of each gene (default: double).
Note
Prefer constructing through galib::utils::AlgorithmBuilder with algorithm.standard.use_cuda: true rather than instantiating directly.
Fitness is minimised — lower values are considered better.

Definition at line 45 of file StandardGACUDA.h.

Constructor & Destructor Documentation

◆ StandardGACUDA()

template<typename GeneType = double>
galib::cuda::StandardGACUDA< GeneType >::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 
)
inline

Constructs the algorithm with all required operators and parameters.

Parameters
ffFitness function used to evaluate individuals. Must outlive this object.
selSelection operator (e.g. TournamentSelection). Ownership is transferred.
muMutation operator (e.g. GaussianMutation). Ownership is transferred.
csCrossover operator (e.g. SinglePointCrossover). Ownership is transferred.
m_rateProbability [0, 1] that any individual gene is mutated.
c_rateProbability [0, 1] that two parents produce children via crossover; otherwise parents are copied unchanged.
max_genNumber of generations to run.
elitismIf true, the best individual is always copied to the next generation.

Definition at line 60 of file StandardGACUDA.h.

Member Function Documentation

◆ run()

template<typename GeneType = double>
void galib::cuda::StandardGACUDA< GeneType >::run ( Population< GeneType > &  population)
inlineoverridevirtual

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