Basic Examples#

Start here if you’re new to BAM Engine. These examples demonstrate fundamental concepts and basic usage patterns.

Examples in this section:

  1. Hello World: The simplest possible BAM Engine example - initialize, run, and visualize

  2. Configuration: Customize simulation parameters using keyword arguments

  3. YAML Configuration: Configure simulations using YAML files

  4. Logging: Configure logging levels globally and per-event

  5. BAM Operations: Comprehensive guide to the ops module for NumPy-free array operations

  6. Type System: Using Float, Int, Bool, Agent type aliases for custom roles

  7. Simulation Results: Comprehensive guide to SimulationResults for data collection

  8. Baseline Scenario: Simplified baseline scenario from section 3.9.1 of the original BAM book

These examples will teach you:

  • How to initialize and run a basic simulation

  • How to configure simulation parameters via kwargs and YAML files

  • How to collect and visualize simulation results

  • How to compare different economic scenarios

  • How to reproduce scenarios from the BAM literature

  • How to use type aliases for extending BAM Engine

  • How to configure and use the logging system

Note: The baseline scenario example is a simplified demonstration. For full validation with target bounds and statistical annotations, run:

python -m validation.scenarios.baseline

Hello BAM Engine

Hello BAM Engine

Configuring Your Simulation

Configuring Your Simulation

YAML Configuration

YAML Configuration

Logging

Logging

BAM Operations

BAM Operations

Type System

Type System

Simulation Results

Simulation Results

BAM Baseline Scenario

BAM Baseline Scenario