mean-field-tools 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Felipe José Pinto Antunes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: mean-field-tools
3
+ Version: 0.1.0
4
+ Summary: Tools for numerical simulations of mean field games
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: mean-field-games,mckean-vlasov,fbsde,deep-bsde,elicitability,stochastic-control
8
+ Author: Felipe José Pinto Antunes
9
+ Author-email: fjpantunes2@gmail.com
10
+ Requires-Python: >=3.10,<4.0
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
22
+ Requires-Dist: matplotlib (>=3.8.4,<4.0.0)
23
+ Requires-Dist: numpy (>=1.26.4,<2.0.0)
24
+ Requires-Dist: scipy (>=1.13.0,<2.0.0)
25
+ Requires-Dist: torch (>=2.3.0,<3.0.0)
26
+ Requires-Dist: tqdm (>=4.66.4,<5.0.0)
27
+ Project-URL: Homepage, https://github.com/fjpAntunes/mean-field-tools
28
+ Project-URL: Paper, https://arxiv.org/abs/2512.14967
29
+ Project-URL: Repository, https://github.com/fjpAntunes/mean-field-tools
30
+ Description-Content-Type: text/markdown
31
+
32
+ # Mean Field Tools
33
+
34
+ A Python library for numerically solving McKean-Vlasov forward-backward stochastic differential equations (MV-FBSDEs) under common noise using elicitability, deep learning and Picard iterations.
35
+
36
+ It accompanies the paper [*Deep Learning and Elicitability for McKean-Vlasov FBSDEs With Common Noise*](https://arxiv.org/abs/2512.14967) — see [How to cite this work](#how-to-cite-this-work).
37
+
38
+ ## Features
39
+
40
+ - Deep BSDE (Backward Stochastic Differential Equation) solvers
41
+ - Forward-Backward SDE implementations with Picard iteration
42
+ - Neural-network function approximators (including ResNet architectures)
43
+ - Mean field flow measure approximations (with common-noise support)
44
+ - Filtration tools for Brownian motion and stochastic state tracking
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ # Clone the repository
50
+ git clone https://github.com/fjpAntunes/mean-field-tools.git
51
+ cd mean-field-tools
52
+
53
+ # Install with Poetry
54
+ poetry install
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ See `mean_field_tools/deep_bsde/README.md` for a detailed overview of the components, and `mean_field_tools/deep_bsde/script/experiments/` for runnable examples (systemic risk, portfolio hedging, economic growth, and more).
60
+
61
+ ## Testing
62
+
63
+ The project uses pytest for testing. Tests are organized into unit and integration tests within the `mean_field_tools/deep_bsde/test/` directory.
64
+
65
+ ```bash
66
+ # Run all tests
67
+ pytest
68
+
69
+ # Run specific test categories
70
+ pytest mean_field_tools/deep_bsde/test/unit/
71
+ pytest mean_field_tools/deep_bsde/test/integration/
72
+
73
+ # Run a specific test file
74
+ pytest mean_field_tools/deep_bsde/test/unit/test_function_approximator.py
75
+ ```
76
+
77
+ ## Structure
78
+
79
+ - `mean_field_tools/deep_bsde/`: Core library — the Deep BSDE solver and its components
80
+ - `filtration.py`: Brownian motion generation and stochastic state tracking
81
+ - `forward_backward_sde.py`: Forward/Backward SDE classes and Picard iteration
82
+ - `function_approximator.py`: Neural-network approximators
83
+ - `measure_flow.py`: Mean field flow measure approximations
84
+ - `artist.py`: Plotting and diagnostics
85
+ - `script/experiments/`: Example applications
86
+ - `test/`: Unit and integration tests
87
+
88
+ ## How to cite this work
89
+
90
+ If you use this library in your research, please cite:
91
+
92
+ > Felipe J. P. Antunes, Yuri F. Saporito, and Sebastian Jaimungal.
93
+ > *Deep Learning and Elicitability for McKean-Vlasov FBSDEs With Common Noise*, 2026.
94
+ > arXiv:[2512.14967](https://arxiv.org/abs/2512.14967).
95
+
96
+ ```bibtex
97
+ @misc{antunes2026deeplearningelicitabilitymckeanvlasov,
98
+ title={Deep Learning and Elicitability for McKean-Vlasov FBSDEs With Common Noise},
99
+ author={Felipe J. P. Antunes and Yuri F. Saporito and Sebastian Jaimungal},
100
+ year={2026},
101
+ eprint={2512.14967},
102
+ archivePrefix={arXiv},
103
+ primaryClass={cs.LG},
104
+ url={https://arxiv.org/abs/2512.14967},
105
+ }
106
+ ```
107
+
108
+ ## License
109
+
110
+ MIT
111
+
@@ -0,0 +1,79 @@
1
+ # Mean Field Tools
2
+
3
+ A Python library for numerically solving McKean-Vlasov forward-backward stochastic differential equations (MV-FBSDEs) under common noise using elicitability, deep learning and Picard iterations.
4
+
5
+ It accompanies the paper [*Deep Learning and Elicitability for McKean-Vlasov FBSDEs With Common Noise*](https://arxiv.org/abs/2512.14967) — see [How to cite this work](#how-to-cite-this-work).
6
+
7
+ ## Features
8
+
9
+ - Deep BSDE (Backward Stochastic Differential Equation) solvers
10
+ - Forward-Backward SDE implementations with Picard iteration
11
+ - Neural-network function approximators (including ResNet architectures)
12
+ - Mean field flow measure approximations (with common-noise support)
13
+ - Filtration tools for Brownian motion and stochastic state tracking
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ # Clone the repository
19
+ git clone https://github.com/fjpAntunes/mean-field-tools.git
20
+ cd mean-field-tools
21
+
22
+ # Install with Poetry
23
+ poetry install
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ See `mean_field_tools/deep_bsde/README.md` for a detailed overview of the components, and `mean_field_tools/deep_bsde/script/experiments/` for runnable examples (systemic risk, portfolio hedging, economic growth, and more).
29
+
30
+ ## Testing
31
+
32
+ The project uses pytest for testing. Tests are organized into unit and integration tests within the `mean_field_tools/deep_bsde/test/` directory.
33
+
34
+ ```bash
35
+ # Run all tests
36
+ pytest
37
+
38
+ # Run specific test categories
39
+ pytest mean_field_tools/deep_bsde/test/unit/
40
+ pytest mean_field_tools/deep_bsde/test/integration/
41
+
42
+ # Run a specific test file
43
+ pytest mean_field_tools/deep_bsde/test/unit/test_function_approximator.py
44
+ ```
45
+
46
+ ## Structure
47
+
48
+ - `mean_field_tools/deep_bsde/`: Core library — the Deep BSDE solver and its components
49
+ - `filtration.py`: Brownian motion generation and stochastic state tracking
50
+ - `forward_backward_sde.py`: Forward/Backward SDE classes and Picard iteration
51
+ - `function_approximator.py`: Neural-network approximators
52
+ - `measure_flow.py`: Mean field flow measure approximations
53
+ - `artist.py`: Plotting and diagnostics
54
+ - `script/experiments/`: Example applications
55
+ - `test/`: Unit and integration tests
56
+
57
+ ## How to cite this work
58
+
59
+ If you use this library in your research, please cite:
60
+
61
+ > Felipe J. P. Antunes, Yuri F. Saporito, and Sebastian Jaimungal.
62
+ > *Deep Learning and Elicitability for McKean-Vlasov FBSDEs With Common Noise*, 2026.
63
+ > arXiv:[2512.14967](https://arxiv.org/abs/2512.14967).
64
+
65
+ ```bibtex
66
+ @misc{antunes2026deeplearningelicitabilitymckeanvlasov,
67
+ title={Deep Learning and Elicitability for McKean-Vlasov FBSDEs With Common Noise},
68
+ author={Felipe J. P. Antunes and Yuri F. Saporito and Sebastian Jaimungal},
69
+ year={2026},
70
+ eprint={2512.14967},
71
+ archivePrefix={arXiv},
72
+ primaryClass={cs.LG},
73
+ url={https://arxiv.org/abs/2512.14967},
74
+ }
75
+ ```
76
+
77
+ ## License
78
+
79
+ MIT
@@ -0,0 +1,10 @@
1
+ """Tools for numerical simulations of mean field games."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("mean-field-tools")
7
+ except PackageNotFoundError: # running from a source tree with no install
8
+ __version__ = "0.0.0.dev0"
9
+
10
+ __all__ = ["__version__"]
@@ -0,0 +1,85 @@
1
+ Mean Field Tools: Deep Backward Stochastic Differential Equation (BSDE) Solver
2
+ Project Overview
3
+ This project provides a sophisticated computational framework for solving forward-backward stochastic differential equations (FBSDEs) with advanced numerical methods, particularly focusing on mean-field interaction scenarios and systemic risk modeling.
4
+ Key Components
5
+ 1. Filtration Module (filtration.py)
6
+
7
+ Manages stochastic process state tracking
8
+ Generates Brownian motion and increments
9
+ Supports common noise filtration
10
+ Tracks time-dependent system states
11
+
12
+ 2. Forward-Backward SDE Module (forward_backward_sde.py)
13
+
14
+ Implements numerical solution strategies for SDEs
15
+ Supports Forward and Backward SDE classes
16
+ Uses Picard iterations for numerical convergence
17
+ Handles complex stochastic process interactions
18
+
19
+ 3. Function Approximator (function_approximator.py)
20
+
21
+ Neural network-based function approximation
22
+ Implements stochastic gradient descent training
23
+ Enables flexible function representation
24
+
25
+ 4. Measure Flow Module (measure_flow.py)
26
+
27
+ Calculates conditional mean and flow of stochastic processes
28
+ Supports common noise measure flow
29
+ Parametrizes process mean fields
30
+
31
+ 5. Systemic Risk Example (systemic_risk_common_noise.py)
32
+
33
+ Demonstrates practical application of the framework
34
+ Models a specific systemic risk scenario with common noise
35
+ Provides analytical and numerical solution comparisons
36
+
37
+ Methodology
38
+
39
+ Picard Iterations
40
+
41
+ Iteratively refine forward and backward processes
42
+ Uses neural network approximation
43
+ Converges to solution through damped updates
44
+
45
+
46
+ Common Noise Modeling
47
+
48
+ Introduces correlated noise components
49
+ Enables modeling of systemic interactions
50
+ Separates common and idiosyncratic noise sources
51
+
52
+
53
+ Stochastic Differential Equation Solving
54
+
55
+ Numerical approximation of SDEs
56
+ Supports complex drift and volatility functions
57
+ Handles multi-dimensional processes
58
+
59
+
60
+
61
+ Key Features
62
+
63
+ Flexible stochastic process modeling
64
+ Neural network-based function approximation
65
+ Supports multiple noise generation strategies
66
+ Comprehensive plotting and visualization tools
67
+
68
+ Use Cases
69
+
70
+ Financial risk modeling
71
+ Systemic risk assessment
72
+ Complex stochastic process simulation
73
+ Machine learning-enhanced SDE solving
74
+
75
+ Dependencies
76
+
77
+ PyTorch
78
+ NumPy
79
+ Matplotlib
80
+ tqdm
81
+
82
+ Usage Example
83
+ The systemic_risk_common_noise.py script provides a comprehensive example of setting up and solving a mean-field BSDE with common noise, demonstrating the framework's capabilities.
84
+ Note
85
+ This framework is particularly powerful for modeling complex stochastic systems with intricate interactions and mean-field effects.
@@ -0,0 +1,61 @@
1
+ """Deep BSDE solvers for mean field problems.
2
+
3
+ The names re-exported here are the supported public API. Anything reachable
4
+ through a module path but absent from this list is an implementation detail and
5
+ may change without a major version bump.
6
+ """
7
+
8
+ from mean_field_tools.deep_bsde.artist import (
9
+ FunctionApproximatorArtist,
10
+ PicardIterationsArtist,
11
+ )
12
+ from mean_field_tools.deep_bsde.filtration import CommonNoiseFiltration, Filtration
13
+ from mean_field_tools.deep_bsde.forward_backward_sde import (
14
+ AnalyticForwardSDE,
15
+ BackwardSDE,
16
+ CommonNoiseBackwardSDE,
17
+ ForwardBackwardSDE,
18
+ NumericalForwardSDE,
19
+ )
20
+ from mean_field_tools.deep_bsde.function_approximator import (
21
+ FunctionApproximator,
22
+ HybridApproximator,
23
+ PathDependentApproximator,
24
+ )
25
+ from mean_field_tools.deep_bsde.measure_flow import (
26
+ CommonNoiseMeasureFlow,
27
+ MeasureFlow,
28
+ )
29
+ from mean_field_tools.deep_bsde.utils import (
30
+ IDENTITY_TERMINAL,
31
+ L_2_norm,
32
+ L_inf_norm,
33
+ QUADRATIC_TERMINAL,
34
+ )
35
+
36
+ __all__ = [
37
+ # Filtration
38
+ "Filtration",
39
+ "CommonNoiseFiltration",
40
+ # Forward / backward SDEs
41
+ "NumericalForwardSDE",
42
+ "AnalyticForwardSDE",
43
+ "BackwardSDE",
44
+ "CommonNoiseBackwardSDE",
45
+ "ForwardBackwardSDE",
46
+ # Measure flow
47
+ "MeasureFlow",
48
+ "CommonNoiseMeasureFlow",
49
+ # Function approximators
50
+ "FunctionApproximator",
51
+ "PathDependentApproximator",
52
+ "HybridApproximator",
53
+ # Plotting and diagnostics
54
+ "FunctionApproximatorArtist",
55
+ "PicardIterationsArtist",
56
+ # Terminal conditions and norms
57
+ "IDENTITY_TERMINAL",
58
+ "QUADRATIC_TERMINAL",
59
+ "L_2_norm",
60
+ "L_inf_norm",
61
+ ]