homemaker-layout/experiments/run_sharefactor_sweep.sh
Bruno Postle 34a7b2ecf9 erc.7: leaf-sharing × depth-balancing synergy CONFIRMED end-to-end (§13.5)
Synergy A/B: bal+share vs share-alone, factor 3, seeds 0/1/2, staged 20k.
maple 86.3->82.3 (-4.6%), harbor 50.7->40.0 (-21.1%, non-overlapping arms).
Control reproduces §13.3. Adds run_synergy_ab.sh + run_sharefactor_sweep.sh
(factor 2/4 sweep under bal+share, running).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 16:47:14 +01:00

46 lines
2.2 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# leaf_share_factor sweep under the winning bal+share stack (erc.7 second half,
# DESIGN.md §13.5). The §13.5 synergy A/B fixed factor 3 (the §13.3 winner) and
# showed depth-balancing × leaf-sharing survives to convergence (harbor 21 %,
# non-overlapping). This sweep asks whether factor 3 is still the construction
# optimum once depth-balancing is stacked on top: does collapsing FEWER (factor
# 2) or MORE (factor 4) same-code rooms per shared leaf do better?
#
# Both knobs ON in every run (DEPTHBAL=1 LEAFSHARE=1); only LEAFSHAREFAC varies.
# factor 3 bal+share is already known from run_synergy_ab.sh (maple 82.3, harbor
# 40.0), so we only run 2 and 4 here. leaf_share_max (scoring cap, default 4)
# already covers all multiplicities at factor ≤4, so no missing-fail leak — the
# final native re-score (MISMATCH guard) verifies this per run.
set -u
cd "$(dirname "$0")/.."
BUDGET="${1:-20000}"
OUT=scratch/sharefactor_sweep; mkdir -p "$OUT"
TSV=scratch/sharefactor_results.tsv
[ -f "$TSV" ] || printf 'programme\tseed\tfactor\tfails\ttopologies\telapsed_s\n' > "$TSV"
run() { # programme seed factor
local prog="$1" seed="$2" fac="$3"
local tag="bal_sh1f${fac}"
local log="$OUT/${prog}_${tag}_s${seed}.log"
echo ">>> $prog seed=$seed bal+share factor=$fac"
local t0; t0=$(date +%s)
env URB_NO_OCCLUSION=1 LEAFSHARE=1 LEAFSHAREFAC="$fac" DEPTHBAL=1 \
python3 experiments/run_staged_search.py "examples/$prog" "$BUDGET" "$seed" \
"examples/$prog/init.dom" "$OUT/${prog}_${tag}_s${seed}.dom" > "$log" 2>&1
local t1; t1=$(date +%s)
local fails topos
fails=$(grep 're-scored (native)' "$log" | tail -1 | sed -n 's/.*(\([0-9]*\) fails).*/\1/p')
topos=$(grep -m1 '^evals' "$log" | sed -n 's/.*across \([0-9]*\) topologies.*/\1/p')
printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$prog" "$seed" "$fac" "${fails:-ERR}" "${topos:-?}" "$((t1-t0))" >> "$TSV"
echo " -> ${fails:-ERR} fails, ${topos:-?} topologies, $((t1-t0))s"
}
# factor 2 then factor 4, seeds 0/1/2 (factor 3 bal+share is in synergy_results.tsv)
for prog in maple-court harbor-house; do
for fac in 2 4; do
for seed in 0 1 2; do run "$prog" "$seed" "$fac"; done
done
done
echo "=== leaf_share_factor sweep (bal+share) complete ==="
column -t -s $'\t' "$TSV"