Skip to main content
The Real Business Cycle (RBC) simulation implements a many-agent macroeconomic environment with heterogeneous consumers, firms, and a government. The simulation core is written in CUDA C for high-throughput GPU execution, and training is powered by PyTorch policy networks.
A GPU is required to run these experiments. The CUDA simulation code does not fall back to CPU.

What the simulation models

The RBC simulation extends classical real business cycle theory to a multi-agent setting with strategic interactions:
  • Consumers choose how much to work and how much of each firm’s good to consume, subject to a budget constraint. Each consumer has a private theta parameter (disutility of work).
  • Firms set prices, wages, and capital investment. Production follows a Cobb-Douglas function parameterized by a firm-specific alpha.
  • Government sets income and corporate tax rates to influence economic outcomes.
Agents observe a shared global state plus agent-type-specific private state variables.

Global state layout

The global state has dimension 4 * num_firms + 2 * num_governments + 1: Per-agent private state extensions:

Directory structure

Dependencies

Running experiments

1

Single experiment

Train one configuration defined in constants.py:
2

Hyperparameter sweep

Launch a Cartesian-product sweep over the parameter grids defined in train_multi_exps.py:
Parameter sweeps are defined as *_param_sweeps dictionaries in the file. Each hyperparameter takes a list of one or more values; all combinations are run.
3

Approximate best-response training

Train one agent type against fixed checkpointed policies from a previous run:
--ep-strs specifies which saved episode checkpoints to load (e.g. policies saved at episodes 0, 10000, and 200000). --agent-type can target a single agent type or all.

Configuration dictionaries

Experiment configuration is managed through Python dictionaries with three top-level keys:
The configuration is written to hparams.yaml in the job output directory at the start of training.

Action discretizations

Actions are discrete indices mapped to real-valued choices at runtime: Action arrays are saved to action_arrays.pickle in each run directory so that index-to-value mappings are preserved alongside saved policies.

Output files

Each training run produces a rollout-XXXXXX-XXXXX/ directory:
Each .npz rollout file has keys states, actions, rewards, action_array, and aux_array. Array shapes:

Saving frequency

The default configuration saves dense rollouts frequently. To reduce disk usage, set train.save_dense_every in the configuration dictionary to a larger integer before starting the run.

Reference

For details on the model and results, see:
Finding General Equilibria in Many-Agent Economic Simulations using Deep Reinforcement Learning
(ArXiv link forthcoming as of this writing)