Files
optimiz-rs/src/mean_field/optimal_transport.rs
T
Melvin Alvarez 27e1b377ac feat(mean_field): Implement Mean Field Games module with PDE solvers
- Add complete mean_field module with 6 submodules
- Implement HJB and Fokker-Planck PDE solvers with rayon parallelization
- Add forward-backward fixed-point iteration algorithm
- Include Nash equilibrium and optimal transport utilities
- Add comprehensive Jupyter notebook tutorial with:
  * Mathematical formulation (HJB and FP equations)
  * Finite difference methods explanation
  * Complete congestion game example
  * 3D visualizations and convergence plots
  * Citations to Jiang, Chewi, Pooladian (2023) paper
- All tests passing (5 tests in mean_field module)
- Based on 'Numerical Methods for Mean Field Games' PDF algorithms
2026-01-04 13:30:57 +01:00

12 lines
407 B
Rust

//! Optimal Transport Methods for MFG
use ndarray::{Array1, Array2};
use crate::core::Result;
pub fn wasserstein_distance(m1: &Array1<f64>, m2: &Array1<f64>, dx: f64) -> f64 {
m1.iter().zip(m2.iter()).map(|(a, b)| (a - b).abs()).sum::<f64>() * dx
}
pub fn sinkhorn_divergence(m1: &Array1<f64>, m2: &Array1<f64>, eps: f64) -> Result<f64> {
Ok(wasserstein_distance(m1, m2, 1.0 / m1.len() as f64))
}