feat(parallel): add GIL-free parallel DE with Rust objectives

- Implement RustObjective trait for GIL-free parallelization
- Add 5 benchmark functions: Sphere, Rosenbrock, Rastrigin, Ackley, Griewank
  * Each implements RustObjective with evaluate(), dimension(), global_optimum()
  * Exposed to Python with __call__ method

- Add parallel_differential_evolution_rust() function:
  * Uses Rayon for parallel population evaluation
  * Works with RustObjective implementations only
  * Eliminates Python GIL overhead for 10-100× speedup
  * Supports all DE strategies and adaptive parameters

- Create comprehensive examples:
  * parallel_de_benchmark.py: Performance benchmarks showing speedup
  * polaroid_optimizr_integration.py: 4 workflows combining Polaroid + OptimizR
    - Regime detection with HMM
    - Strategy parameter optimization
    - Portfolio risk analysis
    - Pairs trading pipeline

- Module integration:
  * Export benchmark functions in Python API
  * Export parallel_differential_evolution_rust
  * Update __init__.py and core.py with new functions

- Technical implementation:
  * RustObjective trait in src/rust_objectives.rs
  * Parallel evaluation uses par_iter() from Rayon
  * Per-thread RNG seeding for reproducibility
  * Maintains same API as standard DE for easy comparison

Part of Priority 2: Enable Rust parallelization (Enhancement Strategy)
Expected speedup: 10-100× on multi-core systems for pure Rust objectives
This commit is contained in:
Melvin Alvarez
2026-01-03 00:03:29 +01:00
parent 7f77f29203
commit f5f6005f80
7 changed files with 1377 additions and 0 deletions
+7
View File
@@ -11,6 +11,7 @@ try:
from optimizr._core import (
mcmc_sample as _rust_mcmc_sample,
differential_evolution as _rust_differential_evolution,
parallel_differential_evolution_rust,
grid_search as _rust_grid_search,
mutual_information as _rust_mutual_information,
shannon_entropy as _rust_shannon_entropy,
@@ -28,6 +29,12 @@ try:
return_statistics_py,
create_lagged_features_py,
rolling_correlation_py,
# Benchmark functions
Sphere,
Rosenbrock,
Rastrigin,
Ackley,
Griewank,
)
RUST_AVAILABLE = True
except ImportError: