BAM Engine
Agent-based macroeconomic simulation in Python
BAM Engine 0.9.0: Results API Redesign
2026-03-19

What is BAM Engine?#

Imagine a virtual economy where thousands of workers look for jobs, companies compete for customers, and banks decide who gets a loan. BAM Engine creates exactly that: a computer simulation where economic patterns like unemployment, inflation, and business cycles emerge naturally from these individual decisions, just as they do in the real world. It is a Python framework that implements the BAM model from Macroeconomics from the Bottom-up (Delli Gatti et al., 2011), designed for researchers in computational economics and agent-based modeling.

Complete BAM Model
Full implementation of the BAM model from Delli Gatti et al. (2011). Firms, households, and banks interact across labor, credit, and goods markets. Macroeconomic dynamics emerge from the bottom up.
ECS Architecture
Entity-Component-System design separates agent data (Roles) from behavior (Events). Extend or override any aspect of the model without forking the core.
Vectorized Performance
All agent operations use NumPy arrays, with no Python loops over agents. Simulate economies of 100+ firms and 500+ households at interactive speed.
Built-in Extensions
Activate R&D/Growth+, buffer-stock consumption, or taxation with a single sim.use(EXTENSION) call. Extensible design for custom model components.
Validation Framework
Three scenario validators check unemployment, inflation, and firm-size distributions against stylized facts. Robustness analysis and sensitivity sweeps are built in.
Calibration Pipeline
Morris screening, grid search, and tiered stability testing, all accessible from the same high-level API. Reproducible parameter estimation out of the box.

Model Validation

Try BAM Engine

Use the interactive shell to try BAM Engine in the browser

To try the examples in the browser:
1. Type code in the input cell and press
   Shift + Enter to execute
2. Or copy paste the code, and click on
   the "Run" button in the toolbar
# Baseline: GDP fluctuates but stays flat
import bamengine as bam
from bamengine import ops

sim = bam.Simulation.init(seed=42, log_level="ERROR")
results = sim.run(n_periods=100)

# Business cycles emerge from agent interactions
gdp = ops.sum(results.Producer.production, axis=1)
print(f"Baseline GDP: {gdp[-1]:.0f}")
# With R&D: GDP now grows over time
from extensions.rnd import RND
import matplotlib.pyplot as plt

sim = bam.Simulation.init(seed=42, log_level="ERROR")
sim.use(RND)
results = sim.run(n_periods=100)

gdp = ops.sum(results.Producer.production, axis=1)
plt.plot(gdp)
plt.title("GDP with R&D")
plt.show()
BAM Engine 0.9.0: Results API Redesign

BAM Engine 0.9.0 redesigns the results collection API, making simulation data easier to access and explore. A follow-up patch (0.9.1) adds a log_level convenience parameter.

Read more...

Browse all news  ⟶