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

Test suite for RNG reproducibility and optimizer determinism. More...

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <omp.h>
#include "montecarlo/rng/rng_global.hpp"
#include "montecarlo/rng/rng_factory.hpp"
#include "montecarlo/optimizers/PSO.hpp"
#include "montecarlo/optimizers/GA.hpp"
Include dependency graph for test_rng_reproducibility.cpp:

Go to the source code of this file.

Functions

double rosenbrock (const std::vector< double > &x)
 Rosenbrock function benchmark.
 
double run_pso_test ()
 Run PSO on Rosenbrock function and return best value found.
 
double run_ga_test ()
 Run GA on Rosenbrock function and return best value found.
 
std::vector< double > generate_samples (int n_samples, std::uint64_t stream_id)
 
int main ()
 

Detailed Description

Test suite for RNG reproducibility and optimizer determinism.

Validates that:

Test Functions:

Verification:

Definition in file test_rng_reproducibility.cpp.

Function Documentation

◆ generate_samples()

std::vector< double > generate_samples ( int  n_samples,
std::uint64_t  stream_id 
)

Definition at line 104 of file test_rng_reproducibility.cpp.

Here is the call graph for this function:

◆ main()

int main ( )

Definition at line 118 of file test_rng_reproducibility.cpp.

Here is the call graph for this function:

◆ rosenbrock()

double rosenbrock ( const std::vector< double > &  x)

Rosenbrock function benchmark.

Parameters
xVector of two coordinates [x0, x1]
Returns
(1-x0)² + 100(x1-x0²)²

Classic benchmark function with global minimum at (1,1) = 0. Used to test optimizer reproducibility and convergence.

Definition at line 39 of file test_rng_reproducibility.cpp.

◆ run_ga_test()

double run_ga_test ( )

Run GA on Rosenbrock function and return best value found.

Returns
Best objective value found by GA

Configuration:

  • Population: 20 individuals
  • Generations: 30
  • Tournament k: 3
  • Crossover rate: 0.9
  • Mutation rate: 0.1
  • Domain: [-5, 5] × [-5, 5]

Definition at line 85 of file test_rng_reproducibility.cpp.

Here is the call graph for this function:

◆ run_pso_test()

double run_pso_test ( )

Run PSO on Rosenbrock function and return best value found.

Returns
Best objective value found by PSO

Configuration:

  • Population: 20 particles
  • Iterations: 30
  • Inertia: 0.7
  • Cognitive coeff: 1.5
  • Social coeff: 1.5
  • Domain: [-5, 5] × [-5, 5]

Definition at line 56 of file test_rng_reproducibility.cpp.

Here is the call graph for this function: