Skip to main content

A modular Python framework for the BAM agent-based macroeconomic model

Project description

BAM Engine

A Modular Python Framework for the BAM Agent-Based Macroeconomic Model

A Python implementation of the BAM (Bottom-Up Adaptive Macroeconomics) model from Macroeconomics from the Bottom-up (Delli Gatti et al., 2011). Simulate households, firms, and banks interacting across labor, credit, and goods markets, where macroeconomic dynamics emerge from individual agent decisions.

Traditional economics models economies from the top down, assuming markets automatically reach equilibrium. BAM Engine takes a different approach: it simulates individual workers, firms, and banks making decisions and interacting in markets, letting macroeconomic patterns emerge from the bottom up.

bamengine.orgDocumentationGetting StartedExamples

Python PyPI version DOI License

Tests Repo-Review codecov Benchmarks

pre-commit.ci status Ruff Type Checked

Model Validation

Note: This release is feature-complete for the core BAM model but APIs may change in future releases before v1.0.0.

Quick Start

pip install bamengine

Requirements: Python 3.11+. NumPy and PyYAML are installed automatically.

import bamengine as bam

# Initialize and run simulation
sim = bam.Simulation.init(n_firms=100, n_households=500, seed=42)
results = sim.run(n_periods=100)

# Access results
results["Economy.inflation"]  # 1D array (n_periods,)
results.Producer.price  # 2D array (n_periods, n_firms)

# Export to pandas DataFrame
df = results.to_dataframe()

# Add extensions with one call
from extensions.rnd import RND

sim = bam.Simulation.init(seed=42)
sim.use(RND)
results = sim.run(n_periods=1000)

See the Getting Started guide for a complete walkthrough.

Features

  • Complete BAM Model: Full Chapter 3 implementation: firms, households, and banks interacting across labor, credit, and goods markets
  • ECS Architecture: Entity-Component-System design separates data (Roles) from behavior (Events) for clean extensibility
  • Vectorized Performance: All agent operations use NumPy arrays; no Python loops over agents
  • Built-in Extensions: R&D / Growth+, buffer-stock consumption, and taxation modules
  • Validation Framework: Three scenario validators with scoring and robustness analysis
  • Calibration Pipeline: Morris screening, grid search, and tiered stability testing
  • Easy Configuration: All parameters configurable without code changes via YAML files

Architecture

BAM Engine uses an ECS (Entity-Component-System) architecture: agents are lightweight entities, state lives in Role components stored as NumPy arrays, and behavior is defined by Event systems executed via a YAML-configurable pipeline. Custom roles, events, and relationships can be added without modifying core code.

See the User Guide for a full walkthrough of the model and its architecture.

Documentation

Full documentation is available at bam-engine.readthedocs.io.

Section Description
Getting Started Installation, first simulation, data collection
User Guide Model overview, configuration, custom roles/events, pipelines, best practices
API Reference Complete reference for all components and operations
Examples 16 runnable examples: basic, advanced, and extensions
Extensions R&D / Growth+, buffer-stock consumption, taxation
Validation Scenario validation, scoring, robustness analysis
Calibration Morris screening, grid search, stability testing

Development

git clone https://github.com/kganitis/bam-engine.git
pip install -e ".[dev]"
pytest
ruff format . && ruff check --fix . && mypy

This project is part of ongoing MSc thesis research at the University of Piraeus, Greece. Code contributions will be welcome after thesis submission. In the meantime, bug reports, feedback, and documentation suggestions are appreciated via the issue tracker.

See the Development Guide for more on testing, linting, benchmarking, and contributing.

Citation

If you use BAM Engine in your research, please cite:

  1. This software - Use CITATION.cff or GitHub's "Cite this repository"
  2. The original BAM model - Delli Gatti, D., Desiderio, S., Gaffeo, E., Cirillo, P., & Gallegati, M. (2011). Macroeconomics from the Bottom-up. Springer. DOI: 10.1007/978-88-470-1971-3

License

MIT License - see LICENSE for details.

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

bamengine-0.9.1.tar.gz (278.7 kB view details)

Uploaded Source

Built Distribution

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

bamengine-0.9.1-py3-none-any.whl (332.8 kB view details)

Uploaded Python 3

File details

Details for the file bamengine-0.9.1.tar.gz.

File metadata

  • Download URL: bamengine-0.9.1.tar.gz
  • Upload date:
  • Size: 278.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bamengine-0.9.1.tar.gz
Algorithm Hash digest
SHA256 fc5055ee7b5e096f3f22ad54118a2a1ad9c9264fdfca3f09ee4ba402331f58f0
MD5 468d7ab221374a40594da0840e7377a9
BLAKE2b-256 80d8189b988e724bd288f655edf7433eb50ceff60773cfc660f836bba984a0ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for bamengine-0.9.1.tar.gz:

Publisher: publish.yml on kganitis/bam-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bamengine-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: bamengine-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 332.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bamengine-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d436f44a9f96c43dfd2ffa66a3eb7842f7864dabb64d892994c984b126bae423
MD5 4b711604d3245f5acbce6f2c46168670
BLAKE2b-256 b61f43e4e85d83fdc883f6a52c6c1da30f7fb22ff36f6a91a1cc6ed669d63125

See more details on using hashes here.

Provenance

The following attestation bundles were made for bamengine-0.9.1-py3-none-any.whl:

Publisher: publish.yml on kganitis/bam-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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