This project implements a simplified Beer Game supply chain simulator to study the bullwhip effect under two control modes:
- Mode A (baseline / reactive policy): agents order primarily from local inventory gaps and incoming demand.
- Mode B (stabilized policy): agents include smoothing and correction terms to reduce amplification.
The goal is to compare how local ordering policies affect system-wide inventory oscillations, order variance, and total operating cost.
Core components are organized around the following concepts:
Agent- Represents one echelon (e.g., retailer, wholesaler, distributor, factory).
- Tracks on-hand inventory, backlog, pipeline orders, and order decisions.
SupplyChain- Connects all agents and advances the simulation one period at a time.
- Applies demand, shipment/order delays, and state transitions across echelons.
- Policies
- Mode A policy: baseline ordering rule that tends to overreact to local signals.
- Mode B policy: damped ordering rule that uses stabilization terms to mitigate oscillations.
- Runner / experiment script
- Parses parameters, executes one or more simulation runs, and writes plots/CSV outputs.
- Python 3.10+ (3.11 recommended)
pipfor dependency installation
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtpython runner.py --mode A --periods 100 --seed 42
python runner.py --mode B --periods 100 --seed 42python runner.py --compare --periods 100 --seed 42 --save-plotsIf your runner entry point is exposed as a module, equivalent commands are typically:
python -m beergame.runner ...
| Parameter | Meaning | Typical effect |
|---|---|---|
initial_inventory |
Starting on-hand inventory per agent | Higher values reduce early stockouts but can increase holding cost |
initial_demand |
Base customer demand level before any shock | Sets baseline flow through all echelons |
shock_start |
Period when demand shock begins | Determines when system stress starts |
shock_magnitude |
Size of demand increase/decrease | Larger shocks create stronger transients |
shock_duration |
Number of periods shock persists | Longer shocks shift average inventory/order levels |
order_delay |
Delay between placing and receiving orders | Larger delays increase risk of over-ordering |
shipment_delay |
Transit delay for physical goods | Increases pipeline inventory and response lag |
alpha |
Responsiveness to inventory/backlog gap | Higher alpha usually increases oscillation amplitude |
beta |
Smoothing / damping gain (Mode B) | Higher beta typically reduces variance (up to stability limits) |
holding_cost |
Cost per unit inventory per period | Penalizes excess stock |
backlog_cost |
Cost per unit unmet demand per period | Penalizes stockouts and delayed fulfillment |
demand_noise_std |
Random demand noise scale | More noise can trigger stronger bullwhip under reactive policies |
Depending on CLI flags, the simulation can produce:
- Time-series plots for inventory, backlog, and orders by echelon
- Comparison plots (Mode A vs Mode B) for:
- order trajectories
- cumulative/period costs
- inventory oscillation profiles
When CSV export is enabled, each row is typically one period × agent observation with fields such as:
run_idmodeperiodagentdemandshipment_receivedorder_placedinventory_on_handbacklogpipelineholding_costbacklog_costtotal_cost
- Order variance: measures amplification of ordering signals; higher variance implies stronger bullwhip.
- Total cost: aggregate of holding + backlog costs over all periods/agents.
- Oscillation amplitude: peak-to-trough swing in inventory/orders; larger amplitude indicates less stable control.
In a typical demand-shock experiment:
- Mode A should exhibit stronger bullwhip oscillations and higher total system cost.
- Mode B should show damped oscillations, faster settling, and lower overall cost.
Use identical seeds and demand scenarios across both modes to make fair comparisons.