Optimiz-rs Documentation¶
High-performance optimization algorithms in Rust with Python bindings
Optimiz-rs provides blazingly fast, production-ready implementations of advanced optimization and statistical inference algorithms. Built with Rust for maximum performance and exposed to Python through PyO3, it delivers 50-100Ă— speedup over pure Python implementations.
🚀 Quick Integration with Polarway — Combine Optimiz-rs algorithms with Polarway’s high-performance DataFrame engine for streaming time-series analytics:
🔄 Time-Series Regime Detection
Polarway streams OHLCV data → Optimiz-rs HMM classifies market regimes
📊 Bayesian Inference at Scale
Polarway distributed storage → Optimiz-rs MCMC for probabilistic modeling
⚡ Strategy Optimization
Polarway hybrid storage → Optimiz-rs Differential Evolution (74-88× speedup)
đź§ Mean Field Games
Polarway time-series → Optimiz-rs MFG for agent population dynamics
Getting Started
Algorithms
- Differential Evolution
- Mathematical Foundations
- Mutation Strategies
- Crossover
- Selection
- Complete Algorithm
- Parameter Selection Guidelines
- Python API
- Adaptive Control (jDE)
- Parallel Evaluation (Rust Backend)
- Convergence Analysis
- Performance Comparison
- Practical Tips
- Troubleshooting
- Benchmark Results
- Advantages & Limitations
- References
- Related Topics
- Mean Field Games
- Hidden Markov Models
- MCMC Sampling
- Sparse Optimization
- Optimal Control
- Risk Metrics
- Grid Search
- Point Processes & Fractional Brownian Motion
v1.1 Numerical Primitives
v2.0 Generic Stochastic Control & PDE
- BSDE — θ-scheme and deep-BSDE bridge
- 10 — BSDE θ-scheme
- PDE — Fokker–Planck, HJB, elliptic Poisson
- 11 — PDE solvers
- Stochastic control — switching, Pontryagin, two-sided intensities
- 12 — Stochastic control
- Quadratic-impact control — closed-form Riccati
- 13 — Quadratic-impact controlled SDE
- McKean–Vlasov — propagation of chaos
- 14 — McKean–Vlasov mean-reverting dynamics
- Agent-based — bounded-confidence consensus
- 15 — Agent-based dynamics
- Inference — Huber-IRLS robust drift estimator
- 16 — Robust drift estimation
- Generative calibration — Gaussian-MMD loss
- 17 — MMD calibration loss
API Reference
Advanced
Features¶
✨ Algorithms Included:
Mean Field Games: 1D MFG solver, HJB-Fokker-Planck coupling, agent population dynamics
Differential Evolution: 5 strategies (rand/1, best/1, current-to-best/1, rand/2, best/2), adaptive jDE
Optimal Control: HJB solvers, regime switching, jump diffusion, MRSJD framework
Hidden Markov Models: Baum-Welch training, Viterbi decoding, Gaussian emissions
MCMC Sampling: Metropolis-Hastings, adaptive proposals, Bayesian inference
Sparse Optimization: Sparse PCA, Box-Tao decomposition, Elastic Net, ADMM
Risk Metrics: Hurst exponent, half-life estimation, time series analysis
Information Theory: Mutual information, Shannon entropy, feature selection
Time-Series Helpers: Rolling Hurst/half-life, feature prep for HMM, lagged feature builders
Parallelization: Rust-native population evaluation with Rayon for built-in objectives
🚀 Performance:
50-100Ă— faster than pure Python implementations
95% memory reduction vs NumPy/SciPy
Parallel-ready with Rayon infrastructure
Production-tested on multi-dimensional problems
Quick Example¶
import numpy as np
from optimizr import DifferentialEvolution
# Define objective function
def sphere(x):
return np.sum(x**2)
# Optimize
de = DifferentialEvolution(
bounds=[(-5, 5)] * 10,
strategy="best/1/bin",
population_size=50
)
result = de.optimize(sphere, max_iterations=100)
print(f"Best fitness: {result.best_fitness:.6f}")
print(f"Best solution: {result.best_solution}")
Installation¶
From PyPI:
pip install optimiz-rs
From source:
# Clone repository
git clone https://github.com/ThotDjehuty/optimiz-r.git
cd optimiz-r
# Build and install
pip install maturin
maturin develop --release