Table of Contents
Fetching ...

BeforeIT.jl: High-Performance Agent-Based Macroeconomics Made Easy

Aldo Glielmo, Mitja Devetak, Adriano Meligrana, Sebastian Poledna

TL;DR

The paper addresses the need for an open, high-performance platform to build macroeconomic ABMs by introducing BeforeIT.jl, a Julia-based implementation of the Poledna 2023 base model. It emphasizes modular design, strong documentation, comprehensive testing, and the ability to run shock implementations and Monte Carlo ensembles, achieving substantial speedups over Matlab and Matlab-generated C code. Key contributions include a transparent, extensible framework with six macro agent classes, a flexible shock mechanism, and cross-language interoperability potential, enabling rapid experimentation and policy analysis. The work aims to foster collaboration, reproducibility, and scalable calibration in macro ABM research, with practical impact for forecasting and scenario analysis. Overall, BeforeIT.jl demonstrates that high performance and usability can coexist in open-source macro ABM tooling, accelerating methodological innovation.

Abstract

BeforeIT is an open-source software for building and simulating state-of-the-art macroeconomic agent-based models (macro ABMs) based on the recently introduced macro ABM developed in [1] and here referred to as the base model. Written in Julia, it combines extraordinary computational efficiency with user-friendliness and extensibility. We present the main structure of the software, demonstrate its ease of use with illustrative examples, and benchmark its performance. Our benchmarks show that the base model built with BeforeIT is orders of magnitude faster than a Matlab version, and significantly faster than Matlab-generated C code. BeforeIT is designed to facilitate reproducibility, extensibility, and experimentation. As the first open-source, industry-grade software to build macro ABMs of the type of the base model, BeforeIT can significantly foster collaboration and innovation in the field of agent-based macroeconomic modelling. The package, along with its documentation, is freely available at https://github.com/bancaditalia/BeforeIT.jl under the AGPL-3.0.

BeforeIT.jl: High-Performance Agent-Based Macroeconomics Made Easy

TL;DR

The paper addresses the need for an open, high-performance platform to build macroeconomic ABMs by introducing BeforeIT.jl, a Julia-based implementation of the Poledna 2023 base model. It emphasizes modular design, strong documentation, comprehensive testing, and the ability to run shock implementations and Monte Carlo ensembles, achieving substantial speedups over Matlab and Matlab-generated C code. Key contributions include a transparent, extensible framework with six macro agent classes, a flexible shock mechanism, and cross-language interoperability potential, enabling rapid experimentation and policy analysis. The work aims to foster collaboration, reproducibility, and scalable calibration in macro ABM research, with practical impact for forecasting and scenario analysis. Overall, BeforeIT.jl demonstrates that high performance and usability can coexist in open-source macro ABM tooling, accelerating methodological innovation.

Abstract

BeforeIT is an open-source software for building and simulating state-of-the-art macroeconomic agent-based models (macro ABMs) based on the recently introduced macro ABM developed in [1] and here referred to as the base model. Written in Julia, it combines extraordinary computational efficiency with user-friendliness and extensibility. We present the main structure of the software, demonstrate its ease of use with illustrative examples, and benchmark its performance. Our benchmarks show that the base model built with BeforeIT is orders of magnitude faster than a Matlab version, and significantly faster than Matlab-generated C code. BeforeIT is designed to facilitate reproducibility, extensibility, and experimentation. As the first open-source, industry-grade software to build macro ABMs of the type of the base model, BeforeIT can significantly foster collaboration and innovation in the field of agent-based macroeconomic modelling. The package, along with its documentation, is freely available at https://github.com/bancaditalia/BeforeIT.jl under the AGPL-3.0.

Paper Structure

This paper contains 5 sections, 5 figures.

Figures (5)

  • Figure 1: Logo of the package. BeforeIT stands for Behavioural economic forecasting by the IT research unit of the Bank of Italy. The agents in the 'it' monogram exemplify the agent-based nature of the simulation method. The name of the package also refers to the forecasting possibilities offered by the package, as in predicting a phenomenon before it happens.
  • Figure 2: Illustration of the workflow and main objects of the software. The left-hand side illustrates the typical workflow of a simulation run. The function init_model takes as input the two dictionaries parameters and initial_conditions and the number of simulation steps T, returning an object named model. This model object is composed of distinct objects representing the different agents of the economy, such as gov and firms and two other objects that do not represent agents but store properties and aggregate variables, i.e., prop and agg. The model object serves as input for run! or ensemblerun, where the second function performs multiple independent Monte Carlo runs. Simulation results are stored in a data object for a single run or in a data_vector object for multiple runs, both of which allow easy inspection and visualization of attributes for any agent type. Similarly, we can inspect any attribute of any of the agent classes. The right-hand side illustrates the fact that a simulation run is essentially a for loop over the function step! and that a run over one step consists of a series of well-defined function calls taking the different agent types as input and updating specific attributes of the same agent type, making up modular and transparent simulation process.
  • Figure 3: A benchmark of the computational efficiency of different implementations. The figure shows the mean time to run one step of the model calibrated on the Austrian economy with around 8 thousand agents and 8 million agents using the original Matlab code, the C code generated by the Matlab Coder toolkit, the HPC implementation and BeforeIT. The benchmarks were executed on Linux x86_64 with an AMD Ryzen 5 5600H CPU and 16 GB of RAM, except for the HPC results, which were only estimated by using the timings in gill2021high.
  • Figure 4: A simple script and its resulting graphs. The left panel shows how to run the model with just a few lines of code. We import the package, load the original parametrisation for Austria in the first quarter of 2010, and specify a given number of quarters to simulate. Then we call the init_model function and then the ensemblerun function, specifying 8 Monte Carlo runs. Some of the results contained in the resulting data_vector are provided on the right panel.
  • Figure 5: Scripts for shocks and for extensions. The left-hand side script illustrates the usage of the interface to run simulations with shocks. In essence, one simply needs to define a callable struct and pass it to the function ensemblerun as the shock keyword argument. The effect of the simulated consumption shock on the GDP (ratio of shocked over baseline) is presented in the graph at the bottom. The right-hand side script illustrates the usage of macros to extend the model without needing to copy-paste code. In essence, one can create a new mutable struct for a custom central bank as a subtype of AbstractCentralBank and inherit all standard attributes using the @centralBank macro. Then, one can modify specific behaviours by re-defining some functions for cb::NewCentralBank, the other functions will remain unchanged.