Skip to main content

A Library for Mean-Field Games.

Project description

MFGLib: A Library for Mean-Field Games

Documentation Status Checked with mypy Ruff Code style: black Imports: isort Code coverage badge PyPI Version License: MIT

Overview

MFGLib is an open-source Python library dedicated to solving Nash equilibria (NEs) for generic mean-field games (MFGs) with a user-friendly and customizable interface, aiming at promoting both applications and research of MFGs. On one hand, it facilitates the creation and analysis of arbitrary user-defined MFG environments with minimal prior knowledge on MFGs. On the other hand, it serves as a modular and extensible code base for the community to easily prototype and implement new algorithms and environments of MFGs as well as their variants and generalizations.

The official documentation for MFGLib is available at https://mfglib.readthedocs.io/en/latest/. A companion introductory paper can be found at https://arxiv.org/abs/2304.08630.

Installation

MFGLib supports all major platforms and can be installed with pip:

$ pip install mfglib

Developers who would like to contribute to the library should refer to the Contributing section on the project's documentation site.

Usage

Here is an example that shows how to use MFGLib to define an environment called rock paper scissors, and solve it using MF-OMO with default hyperparameters and tolerances, and plot the exploitability scores over iterations.

from mfglib.env import Environment
from mfglib.alg import MFOMO
from mfglib.scoring import exploitability_score
import matplotlib.pyplot as plt

# Environment
rock_paper_scissors_instance = Environment.rock_paper_scissors()

# Run the MF-OMO algorithm with default hyperparameters and default tolerances and plot exploitability scores
solns, expls, runtimes = MFOMO().solve(rock_paper_scissors_instance, max_iter=300, verbose=True)

plt.semilogy(runtimes, exploitability_score(rock_paper_scissors_instance, solns)) 
plt.grid(True)
plt.xlabel("Runtime (seconds)")
plt.ylabel("Exploitability")
plt.title("Rock Paper Scissors Environment - MFOMO Algorithm")
plt.show()
“”

Please refer to the documentation for more info on how to use the library.

Citing

If you wish to cite MFGLib, please use the following:

@article{mfglib,
    author  = {Guo, X. and Hu, A. and Santamaria, M. and Tajrobehkar, M. and Zhang, J.},
    title   = {{MFGLib}: A Library for Mean Field Games},
    journal = {arXiv preprint arXiv:2304.08630},
    year    = {2023}
}

If you find MFGLib to be helpful and would like to send virtual kudos, please consider leaving a star on the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mfglib-0.2.0.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mfglib-0.2.0-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

Details for the file mfglib-0.2.0.tar.gz.

File metadata

  • Download URL: mfglib-0.2.0.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for mfglib-0.2.0.tar.gz
Algorithm Hash digest
SHA256 befda3f4f3ab088b608f228264f3adfc065cc36b4956ccfe2f6661af0b8caf89
MD5 ae034c63e22632293c71516592836581
BLAKE2b-256 6186a8fc33194ebbd64f8e8795d8a2e31cbc17d56bb35962ff248fd83efb69ae

See more details on using hashes here.

File details

Details for the file mfglib-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mfglib-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for mfglib-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c40dbf4702517fdbbe4e3492aed1094e04809726ef30827958f0ea13f8e48214
MD5 642925dad006395fb884a034751bae25
BLAKE2b-256 0128e3e083e21d1f1cd2afe992aa0bd8f740f47d6247eadb4f1c1499eb84db02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page