Skip to main content

A benchmark suite for Mean Field Game algorithms

Project description

BenchMFG icon

BenchMFG

Benchmark suite for Mean Field Game algorithms.

Python JAX Hydra uv

License: MIT Unit tests ruff pre-commit

Contents

Install

uv add bench-mfg-suite
# or
pip install bench-mfg-suite

For local development:

uv sync --extra dev

CUDA is optional. The default install uses CPU-compatible JAX.

# Linux/NVIDIA, pip-managed CUDA runtime components:
uv add "bench-mfg-suite[cuda12]"
pip install "bench-mfg-suite[cuda12]"

# Linux/NVIDIA, local CUDA installation:
pip install "bench-mfg-suite[cuda12-local]"

If GPU initialization fails, check nvidia-smi and the official JAX install matrix: https://docs.jax.dev/en/latest/installation.html

Quick Start

List registered configs:

benchmfg env list
benchmfg algo list

Run one experiment:

benchmfg train algorithm=pso environment=kinetic_congestion device=cpu

Registered Configs

Environments: contraction_game, four_rooms_obstacles, kinetic_congestion, lasry_lions_chain, mf_garnet, multiple_equilibria, no_interaction_game, potential_game2d, rock_paper_scissors, sis_epidemic.

Algorithms: damped_fixed_point, omd, pi, pso.

Use benchmfg env list and benchmfg algo list for the installed package’s authoritative list.

Sweep

Run a sweep:

benchmfg sweep \
  algorithm=omd \
  environment=lasry_lions_chain \
  experiment.name=omd_sweep \
  experiment.random_seed=42,10,111,1032 \
  algorithm.omd.learning_rate=0.5,0.05,0.005 \
  algorithm.omd.temperature=0.2,0.5,0.8

Python API

import benchmfg

cfg = benchmfg.load_config(["algorithm=omd", "environment=lasry_lions_chain"])
environment, initial_policy = benchmfg.make_environment(cfg)
solver = benchmfg.make_solver(
    cfg,
    environment=environment,
    initial_policy=initial_policy,
)

Outputs And Plots

Runs write artifacts under:

outputs/<Env>/<Algorithm>/seed_<seed>/<Experiment>/<run_id>/

Important files: exploitabilities.npz, final_mean_field.npz, final_policy.npz, metrics.npz, config.yaml.

Plot commands:

benchmfg plot single-run <run_dir>
benchmfg plot sweep <environment> <algorithm>
benchmfg plot compare <environment>

Plot discovery defaults:

  • single-run <run_dir> plots exactly that timestamped run.
  • sweep <environment> <algorithm> scans outputs/ by default. For each seed and hyperparameter version, it selects the latest timestamped run containing exploitabilities.npz.
  • compare <environment> reads the results/<environment>/<algorithm>/best_model.yaml files written by plot sweep; rerun plot sweep first if new runs were added.
  • Use --outputs-dir <path> on sweep/compare commands when artifacts are not under outputs/.

Repository Layout

src/benchmfg/
├── config/      # packaged Hydra configs
├── envs/        # MFG environments
├── learner/     # solvers
├── utility/     # training, saving, plotting helpers
├── cli.py       # benchmfg command
└── train.py     # Hydra train entrypoint

See EXPERIMENTS.md for batch-run scripts.

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

bench_mfg_suite-0.1.0.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

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

bench_mfg_suite-0.1.0-py3-none-any.whl (126.4 kB view details)

Uploaded Python 3

File details

Details for the file bench_mfg_suite-0.1.0.tar.gz.

File metadata

  • Download URL: bench_mfg_suite-0.1.0.tar.gz
  • Upload date:
  • Size: 89.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bench_mfg_suite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ffa866e883436ee746a96fd47f8ea8b3351ab2746a00bfbfd6321e66822beab
MD5 1e31fd272e242fd5a4b7da50feb41e33
BLAKE2b-256 3eae8064638b38b456dea575df64d61f58bd623b39bf222d19f9470d978ec9ad

See more details on using hashes here.

File details

Details for the file bench_mfg_suite-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bench_mfg_suite-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 126.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bench_mfg_suite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb1a3de27985986b79dab6afb4a622456c2a3255fd17f73fcb02086d5b564df0
MD5 0ce9b5549217fbdec724511abd2941dc
BLAKE2b-256 e0cf98a88f30e682068e3e9889918190680742f9204d8bc167903d48e4dcfba3

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