Skip to content

Commit 8c0443b

Browse files
committed
ops: sweep_n4_post.sh — single-command post-N4-sweep update
1 parent 5bc09f7 commit 8c0443b

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

scripts/sweep_n4_post.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bash
2+
# Post-N=4-sweep automation: when configs/sweeps/maze-camera-only-n4.yaml
3+
# completes, this script:
4+
#
5+
# 1. Refuses to run while the sweep is still in flight.
6+
# 2. Re-runs sweep_finalize_camera.sh (analyze_sweep with N=4 data).
7+
# 3. Prints a side-by-side N=2 vs N=4 summary for the operator to
8+
# copy-paste into the article narrative.
9+
#
10+
# Usage: bash scripts/sweep_n4_post.sh
11+
set -euo pipefail
12+
13+
cd "$(dirname "$0")/.."
14+
15+
if pgrep -f "multi_seed_sweep.*camera-only-n4" > /dev/null 2>&1; then
16+
echo "ERROR: N=4 sweep is still running. Wait for it to finish." >&2
17+
exit 1
18+
fi
19+
if pgrep -f "multi_seed_sweep" > /dev/null 2>&1; then
20+
echo "ERROR: A multi_seed_sweep process is running. Wait for it." >&2
21+
exit 1
22+
fi
23+
24+
echo "=== Step 1: Re-running analyze_sweep over camera-only evidence ==="
25+
bash scripts/sweep_finalize_camera.sh
26+
27+
echo
28+
echo "=== Step 2: Side-by-side N=2 vs N=4 summary ==="
29+
cd python
30+
PYTHONPATH=. .venv/bin/python <<'EOF'
31+
import json
32+
from pathlib import Path
33+
import statistics
34+
35+
evidence = Path("../docs/report/master-thesis/sprint-4-bc-variance-2026-06/sweeps-camera-only")
36+
37+
def summarize(branch_dir, metric_key):
38+
vals = []
39+
for seed_dir in sorted(branch_dir.glob("seed-*")):
40+
e = seed_dir / "eval_full.json"
41+
if not e.exists():
42+
continue
43+
try:
44+
data = json.loads(e.read_text())
45+
except Exception:
46+
continue
47+
v = data.get(metric_key)
48+
if v is None:
49+
continue
50+
vals.append(float(v))
51+
return vals
52+
53+
for branch_dir in sorted(evidence.iterdir()):
54+
if not branch_dir.is_dir():
55+
continue
56+
rewards = summarize(branch_dir, "avgReward")
57+
progresses = summarize(branch_dir, "avgProgress")
58+
if not rewards:
59+
continue
60+
mean_r = statistics.fmean(rewards)
61+
std_r = statistics.pstdev(rewards) if len(rewards) > 1 else 0.0
62+
mean_p = statistics.fmean(progresses) if progresses else 0.0
63+
std_p = statistics.pstdev(progresses) if len(progresses) > 1 else 0.0
64+
cv = (std_r / mean_r * 100) if mean_r != 0 else 0.0
65+
print(f"{branch_dir.name:18s} N={len(rewards)} reward {mean_r:7.2f} ± {std_r:6.2f} (CV {cv:5.1f} %) progress {mean_p:.3f} ± {std_p:.3f}")
66+
EOF
67+
cd ..
68+
69+
echo
70+
echo "=== Step 3: Copy these tables into article §4.5 Tables 3, 3a ==="
71+
echo
72+
echo "Mean reward (replace existing Table 3 in article.md §4.5):"
73+
cat docs/report/master-thesis/sprint-4-bc-variance-2026-06/analysis-camera-only/variance-table-mean-reward.md
74+
echo
75+
echo "Mean progress (replace existing Table 3а in article.md §4.5):"
76+
cat docs/report/master-thesis/sprint-4-bc-variance-2026-06/analysis-camera-only/variance-table-avgProgress.md
77+
78+
echo
79+
echo "=== Step 4: Commit + push ==="
80+
echo "After manually editing article §4.5 narrative numbers, run:"
81+
echo " git add docs/report/master-thesis/articles/2026-occupancy-variance/article.md \\"
82+
echo " docs/report/master-thesis/sprint-4-bc-variance-2026-06/CHAPTER_OCCUPANCY.md \\"
83+
echo " docs/report/master-thesis/sprint-4-bc-variance-2026-06/analysis-camera-only/"
84+
echo " git commit -m 'doc: N=4 variance numbers for camera-only experiment'"
85+
echo " git push origin develop"

0 commit comments

Comments
 (0)