Giter VIP home page Giter VIP logo

mfglib's Introduction

MFGLib: A Library for Mean-Field Games

Documentation Status Checked with mypy Ruff Code style: black Imports: isort Coverage Status 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

For developers who would like to contribute to this library, please refer to CONTRIBUTING.md for the installation steps using poetry that allows developers to test their changes in real time.

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.metrics 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.

mfglib's People

Contributors

anranhu avatar junziz avatar mahantajrobehkar avatar matteosantama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mfglib's Issues

CI Optimizations

Tracking issue for potential CI optimizations.

  1. Only run testing/linting when Python code is changed, ie. ignore changes to the docs folder.

README and doc

Add a new brief README:
[DONE] Add README based on draft intro and create a MWE with the latest signature.
[DONE] Add some additional badges for documentation, test coverage and CI/build passing, etc. Some good examples for these additional badges: https://github.com/cvxgrp/scs/blob/master/README.md and https://github.com/cvxgrp/pymde.
[DONE] Add references to arXiv once it's there. Add it to the citing parts (of README and doc) and also the end of the usage part.

Documentation:
[] Add intro to MFG and when and how to use MFG. Edit NE and exploitability part — currently Gamma is not defined.
[] Polish the explanations on MF-OMO, especially the "more on MF-OMO" part.
[] Show verbose printout examples. MF-OMO verbose printout should provide optimizer info?
[] Describe how to uninstall using poetry for developers when development is done. Also what happens when mistakenly installing using poetry again before uninstalling the old one in a new/updated mfglib local repo?
[] Some example notebooks/pages on doc may still be helpful like here. Maybe can add more on basic usage, performance comparisons, tuning example, multi-Nash and even some variants. Also some fancy visualizations, etc.?
[] Add details on the implemented env's input parameters for easier lookup. Also add details on returns. Optionally better display of the API. Explain the usage and creation of initial policies using Policy and directly from PyTorch. Also API for non-leaf functions, like mean_field.py.
[] More details for contributing and developers.

Citation version

@AnranHu I notice you put the version into the citation in README.md. Is that standard? It means we have to remember to update it every time we bump the version (I've already bumped from v0.1.0 to v0.1.1 to fix some metadata on PyPI).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.