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
+8
View File
@@ -34,6 +34,7 @@ pub mod core;
pub mod functional;
pub mod maths_toolkit; // Mathematical utilities
pub mod timeseries_utils; // Time-series integration helpers
pub mod rust_objectives; // Rust-native objectives for parallel evaluation
// Modular structure (trait-based, generic)
pub mod de;
@@ -77,6 +78,10 @@ fn _core(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
differential_evolution::differential_evolution,
m
)?)?;
m.add_function(wrap_pyfunction!(
differential_evolution::parallel_differential_evolution_rust,
m
)?)?;
m.add_function(wrap_pyfunction!(grid_search::grid_search, m)?)?;
// Information theory functions
@@ -102,5 +107,8 @@ fn _core(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
// Time-series utility functions
timeseries_utils::python_bindings::register_python_functions(m)?;
// Rust-native benchmark functions
rust_objectives::register_benchmark_functions(m)?;
Ok(())
}