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

Abstract base class for all optimization algorithms. More...

#include <Algorithm.h>

Inheritance diagram for galib::Algorithm< GeneType >:
[legend]

Public Member Functions

virtual ~Algorithm ()=default
 
virtual void run (Population< GeneType > &population)=0
 Executes the optimization process on the given population.
 
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.
 

Protected Member Functions

void notifyLoggers (std::size_t gen, const Population< GeneType > &pop)
 Notifies all active loggers to record the current state.
 

Protected Attributes

std::unique_ptr< utils::ConsoleLogger< GeneType > > console_logger_m
 
std::unique_ptr< utils::FileLogger< GeneType > > file_logger_m
 

Detailed Description

template<typename GeneType>
class galib::Algorithm< GeneType >

Abstract base class for all optimization algorithms.

Defines the core interface for running an evolutionary process and provides common functionality for logging to console and files.

Template Parameters
GeneTypeThe type of the genes (e.g., double, int).

Definition at line 22 of file Algorithm.h.

Constructor & Destructor Documentation

◆ ~Algorithm()

template<typename GeneType >
virtual galib::Algorithm< GeneType >::~Algorithm ( )
virtualdefault

Member Function Documentation

◆ enableConsoleLogging()

template<typename GeneType >
virtual void galib::Algorithm< GeneType >::enableConsoleLogging ( const std::size_t  interval)
inlinevirtual

Enables logging of progress to the standard output.

Parameters
intervalThe frequency of logging (every N generations). 0 disables.

Definition at line 59 of file Algorithm.h.

References galib::Algorithm< GeneType >::console_logger_m.

◆ enableFileLogging()

template<typename GeneType >
virtual void galib::Algorithm< GeneType >::enableFileLogging ( const std::string &  path,
std::size_t  interval 
)
inlinevirtual

Enables logging of population snapshots to a CSV file.

Parameters
pathThe path where the CSV file will be created.
intervalThe frequency of logging (every N generations). 0 disables.

Definition at line 68 of file Algorithm.h.

References galib::Algorithm< GeneType >::file_logger_m.

◆ enableLogging()

template<typename GeneType >
virtual void galib::Algorithm< GeneType >::enableLogging ( const std::string &  )
inlinevirtual

Placeholder for generic logging configuration.

Definition at line 75 of file Algorithm.h.

◆ notifyLoggers()

template<typename GeneType >
void galib::Algorithm< GeneType >::notifyLoggers ( std::size_t  gen,
const Population< GeneType > &  pop 
)
inlineprotected

Notifies all active loggers to record the current state.

Parameters
genThe current generation index.
popThe current population.

Definition at line 32 of file Algorithm.h.

References galib::Algorithm< GeneType >::console_logger_m, and galib::Algorithm< GeneType >::file_logger_m.

Referenced by galib::CellularGA< GeneType >::run(), galib::DifferentialEvolutionGA< GeneType >::run(), galib::IslandGA< GeneType >::run(), and galib::StandardGA< GeneType >::run().

◆ run()

template<typename GeneType >
virtual void galib::Algorithm< GeneType >::run ( Population< GeneType > &  population)
pure virtual

Executes the optimization process on the given population.

This is a pure-virtual method that must be implemented by concrete algorithms (e.g., StandardGA, IslandGA).

Parameters
populationThe population to optimize. Modified in-place.
Note
The population must be initialized before calling this method.

Implemented in galib::CellularGA< GeneType >, galib::DifferentialEvolutionGA< GeneType >, galib::IslandGA< GeneType >, galib::StandardGA< GeneType >, and galib::cuda::StandardGACUDA< GeneType >.

Member Data Documentation

◆ console_logger_m

template<typename GeneType >
std::unique_ptr<utils::ConsoleLogger<GeneType> > galib::Algorithm< GeneType >::console_logger_m
protected

◆ file_logger_m

template<typename GeneType >
std::unique_ptr<utils::FileLogger<GeneType> > galib::Algorithm< GeneType >::file_logger_m
protected

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