|
GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
|
A header-only C++ library for continuous optimization using various evolutionary algorithms (Standard GA, Cellular GA, Island GA, Differential Evolution), accelerated with OpenMP, TBB, MPI, and CUDA. The project includes Python tools for 3D visualization of the optimization process and performance benchmarking.
C++ Core:
Python Analytics:
numpy, matplotlib, pandas, pyyamlffmpeg (for MP4 animation generation)include/ - Core header-only C++ library files.examples/ - Example source files for different algorithms (standard_ga_example.cpp, island_ga_example.cpp, cellular_ga_example.cpp, differential_evolution_example.cpp).configs/ - YAML configuration files for different algorithms and benchmarking (e.g., Sphere, Rastrigin).scripts/ - Python scripts for data visualization (visualization.py, visualization_standard.py, visualization_de.py, visualization_cellular.py, visualization_island.py) and performance testing.build/ - Compilation output and generated CSV logs.src/ - Source files for CUDA implementations.cmake/ - CMake configuration files.island_example is only available when MPI is found. ga_cuda and test_ga_cuda are only available when CUDA is found.
Install into a local folder inside the repository:
This creates:
install/include/ - public headersinstall/lib/cmake/GALib/ - CMake package files for find_package(GALib)install/share/GALib/examples/ - installed example sourcesinstall/share/GALib/configs/ - installed sample configsIf you want find_package(GALib) to work without extra path flags, install into a standard system prefix:
To build and install the CUDA-enabled package variant of GALib:
You can control the CUDA architecture set with:
Examples of explicit architecture values:
To use GALib in another CMake project, the workflow is:
find_package(GALib REQUIRED).GALib::ga_lib.GALib::ga_cuda or GALib::ga_island if those targets are available.Clone the repository and install it either locally or system-wide:
If you want a system-wide install instead:
If you want the CUDA-enabled package variant in /usr/local:
In your own CMakeLists.txt:
If GALib was installed into a local prefix such as ./install, configure your project with:
If GALib was installed into /usr/local, no extra path is usually needed:
GALib exports up to three targets, depending on how it was built:
GALib::ga_lib - base library, always availableGALib::ga_cuda - optional CUDA backend, available only when GALib was built with CUDA supportGALib::ga_island - optional island/MPI backend, available only when GALib was built in an environment with working MPI supportThe recommended usage pattern is:
Your own project can look like this:
Then build it like this:
If GALib was installed into a local prefix instead of /usr/local, configure with:
Run the example executables from the project root:
Standard GA
Cellular GA
Differential Evolution
Island GA
Each run can generate console output and file logs depending on the selected example and YAML configuration.
Configuration files are in YAML format. The library uses a hierarchical structure to define algorithm parameters, genetic operators, and logging options.
| Parameter | Description | Type | Allowed Values |
|---|---|---|---|
algorithm.type | Evolutionary algorithm variant to execute. | String | standard, cellular, island, differential_evolution |
algorithm.max_generations | Maximum number of generations (iterations) to run. | Integer | Positive integers |
algorithm.mutation_rate | Probability of mutation for each gene. | Float | 0.0 to 1.0 |
algorithm.crossover_rate | Probability of crossover (used as CR in Differential Evolution). | Float | 0.0 to 1.0 |
algorithm.use_elitism | If true, the best individuals are preserved for the next generation. | Boolean | true, false |
algorithm.threads | Number of worker threads for parallelization (0 for auto-detection). | Integer | >= 0 |
algorithm.standard.use_cuda | Enable CUDA-accelerated evaluation (Standard GA only). | Boolean | true, false |
algorithm.differential_evolution.f_weight | Differential weight factor (Scaling Factor) for DE mutation. | Float | 0.0 to 2.0 |
algorithm.cellular.rows | Number of rows in the grid population (Cellular GA). | Integer | Positive integers |
algorithm.cellular.cols | Number of columns in the grid population (Cellular GA). | Integer | Positive integers |
algorithm.cellular.use_local_elitism | If true, elitism is applied within local neighborhoods. | Boolean | true, false |
algorithm.island.topology | Communication topology between islands in the archipelago. | String | fully_connected, one_way_ring, bidirectional_ring |
algorithm.island.migration_interval | Number of generations between migration events. | Integer | Positive integers |
algorithm.island.migration_size | Number of individuals sent during each migration event. | Integer | Positive integers |
algorithm.island.immigration_quota | Max fraction of population that can be replaced by immigrants. | Float | 0.0 to 1.0 |
algorithm.island.buffer_capacity | Capacity of the asynchronous migration receiving buffer. | Integer | Positive integers |
algorithm.island.replacer.type | Strategy for integrating incoming migrants. | String | worst |
algorithm.island.selector.type | Strategy for selecting individuals for emigration. | String | elitism |
algorithm.selection.type | Selection operator type. | String | tournament, best_neighbor (Cellular GA) |
algorithm.selection.tournament_size | Number of individuals in each tournament. | Integer | >= 1 |
algorithm.mutation.type | Mutation operator type. | String | gaussian, uniform, boundary |
algorithm.mutation.sigma | Standard deviation for Gaussian mutation. | Float | Positive floats |
algorithm.crossover.type | Crossover operator type. | String | single_point, arithmetic, uniform |
output.console.enabled | Enable logging of progress to the console. | Boolean | true, false |
output.console.interval | Generations between console status updates. | Integer | Positive integers |
output.file.enabled | Enable logging of evolution data to a CSV file. | Boolean | true, false |
output.file.interval | Generations between CSV log entries. | Integer | Positive integers |
output.file.path | Path to the output CSV log file. | String | File path string |
The sample configuration are available in the repository: configs/config_example.yaml
View the full documentation at Documentation Page