#!/usr/bin/env bash # Reproduce the structural-sensitivity pilot (capital adjustment speed) from Econ-ARK's rebuild. # # Usage: bash reproduce.sh ECONARK_DIR OUT_DIR # ECONARK_DIR a clone of https://github.com/econ-ark/econ-scenarios at commit 87170fa, # with its environment built (`uv sync`); its .venv/bin/python is used. # OUT_DIR a new folder for the patched package, logs and results. # The scripts in this folder (*.py, capital_adjustment.patch) must sit next to this file. # Files downloaded from the web page end in .txt: drop that suffix first. set -euo pipefail ECONARK="$1" OUT="$2" HERE="$(cd "$(dirname "$0")" && pwd)" PY="$ECONARK/.venv/bin/python" [ -e "$OUT" ] && { echo "STOP: $OUT exists" >&2; exit 1; } [ "$(git -C "$ECONARK" rev-parse --short=7 HEAD)" = "87170fa" ] || echo "WARNING: Econ-ARK is not at 87170fa" >&2 mkdir -p "$OUT/pkg/code" cp -R "$ECONARK/code/econ_scenarios" "$OUT/pkg/code/econ_scenarios" patch -s -d "$OUT/pkg" -p1 < "$HERE/capital_adjustment.patch" mv "$OUT/pkg/code/econ_scenarios" "$OUT/pkg/econ_scenarios" rmdir "$OUT/pkg/code" # 1. Switch off: every series of the 14 printed runs equals the unmodified rebuild, bit for bit. "$PY" -I "$HERE/dump_series.py" "$ECONARK/code" "$OUT/series_original.json" "$PY" -I "$HERE/dump_series.py" "$OUT/pkg" "$OUT/series_variant_off.json" --half-life 0 "$PY" -I "$HERE/compare_series.py" "$OUT/series_original.json" "$OUT/series_variant_off.json" > "$OUT/check1_switch_off.log" # 2. Switch off: Econ-ARK's validator, every published number it checks. "$PY" -I "$HERE/validate_published.py" "$OUT/pkg" "$ECONARK/code" > "$OUT/check2_published.log" # 3. Frozen stock (infinite half-life) equals eps = 0 in the paper's rule. "$PY" -I "$HERE/frozen_check.py" "$OUT/pkg" > "$OUT/check3_frozen.log" # The pilot grid and the wage decomposition. "$PY" -I "$HERE/run_grid.py" "$OUT/pkg" "$OUT/grid_results.json" > "$OUT/run_grid.log" "$PY" -I "$HERE/mechanism_check.py" "$OUT/pkg" > "$OUT/mechanism_check.log" cat "$OUT"/check*.log echo "Results: $OUT/grid_results.json and $OUT/run_grid.log"