Monte Carlo Integration Library 1.0
High-performance Monte Carlo methods for numerical integration and optimization
Functions
ga_benchmarks.cpp File Reference

Genetic Algorithm benchmark suite with visualization. More...

#include "apps/benchmarks.hpp"
#include <cmath>
#include <cstdint>
#include <sstream>
#include <filesystem>
Include dependency graph for ga_benchmarks.cpp:

Go to the source code of this file.

Functions

static std::string makeFrameName (const std::string &baseName, size_t iter)
 Generate frame filename for GA population evolution.
 
static void savePopulationFrame2D (const std::string &baseName, size_t iter, const std::vector< opt::GA::Individual > &pop)
 Save population snapshot for 2D visualization.
 
static void savePopulationFrame3D (const std::string &baseName, size_t iter, const std::vector< opt::GA::Individual > &pop)
 
void runSphereTest (opt::GA &ga, const opt::Coordinates &lower, const opt::Coordinates &upper)
 
void runBoundaryTest (opt::GA &ga, const opt::Coordinates &lower, const opt::Coordinates &upper)
 
void runRastriginTest (opt::GA &, int dim)
 
void runVisualGABenchmark ()
 
void runVisualGA3DBenchmark ()
 
void runOptimizationBenchmarksGA ()
 

Detailed Description

Genetic Algorithm benchmark suite with visualization.

Comprehensive testing of GA performance with frame-based animation support:

Features:

Test Problems:

  1. Sphere: f(x,y) = x² + y², easy unimodal problem
  2. Rastrigin: Highly multimodal, 25+ local minima in [-5.12, 5.12]²
  3. Rosenbrock: Long narrow valley, requires fine-tuning
  4. Ackley: Many local minima with large global basin

Visualization:

See also
GA, Optimizer, OptimizationMode

Definition in file ga_benchmarks.cpp.

Function Documentation

◆ makeFrameName()

static std::string makeFrameName ( const std::string &  baseName,
size_t  iter 
)
static

Generate frame filename for GA population evolution.

Parameters
baseNameBase name for output files
iterIteration/generation number
Returns
Filename formatted as: baseName_iter_N.dat

Definition at line 48 of file ga_benchmarks.cpp.

◆ runBoundaryTest()

void runBoundaryTest ( opt::GA ga,
const opt::Coordinates lower,
const opt::Coordinates upper 
)

Definition at line 146 of file ga_benchmarks.cpp.

Here is the call graph for this function:

◆ runOptimizationBenchmarksGA()

void runOptimizationBenchmarksGA ( )

Definition at line 352 of file ga_benchmarks.cpp.

Here is the call graph for this function:

◆ runRastriginTest()

void runRastriginTest ( opt::GA ,
int  dim 
)

Definition at line 191 of file ga_benchmarks.cpp.

Here is the call graph for this function:

◆ runSphereTest()

void runSphereTest ( opt::GA ga,
const opt::Coordinates lower,
const opt::Coordinates upper 
)

Definition at line 109 of file ga_benchmarks.cpp.

Here is the call graph for this function:

◆ runVisualGA3DBenchmark()

void runVisualGA3DBenchmark ( )

Definition at line 299 of file ga_benchmarks.cpp.

Here is the call graph for this function:

◆ runVisualGABenchmark()

void runVisualGABenchmark ( )

Definition at line 251 of file ga_benchmarks.cpp.

Here is the call graph for this function:

◆ savePopulationFrame2D()

static void savePopulationFrame2D ( const std::string &  baseName,
size_t  iter,
const std::vector< opt::GA::Individual > &  pop 
)
static

Save population snapshot for 2D visualization.

Parameters
baseNameBase filename for frame output
iterCurrent iteration/generation
popVector of individuals (genome + fitness)

Saves population positions to ga_frames/baseName_iter_N.dat for gnuplot animation or analysis. Each line: x y (first two coordinates).

Definition at line 63 of file ga_benchmarks.cpp.

Here is the call graph for this function:

◆ savePopulationFrame3D()

static void savePopulationFrame3D ( const std::string &  baseName,
size_t  iter,
const std::vector< opt::GA::Individual > &  pop 
)
static

Definition at line 85 of file ga_benchmarks.cpp.

Here is the call graph for this function: