experiments/benchmark_vs_urbevolve.py (homemaker-py-way): 3 seed designs (init from scratch, c964435 weak, 2f45907 strong) x 2000-eval runs, the 1000-eval tier read from each run's best-so-far log; urb-evolve gets two population sizes (default 128 = ~16 generations at this budget, and 16 = ~130) and credit for its better one. Counts via the MAX_EVALS counter patch in urb-evolve.pl (committed in the urb repo); both systems under URB_NO_OCCLUSION=1; all finals re-scored through urb-fitness.pl as the common deterministic yardstick. run_search.py generalised to (budget, rng-seed, seed.dom, out.dom); innerloop.optimise now handles 0-DOF topologies (an undivided plot like init.dom scores once instead of crashing CMA). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
57 lines
2.3 KiB
Python
57 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""End-to-end memetic search on programme-house (homemaker-py-b39 acceptance).
|
|
|
|
Runs driver.search from a corpus seed within a stated oracle-evaluation
|
|
budget, logs every improvement, writes the best design to
|
|
scratch/search_best.dom and independently re-scores it through the oracle to
|
|
prove the output is a valid .dom whose recorded fitness is reproducible.
|
|
|
|
The interesting bar: the seed's geometry-only optimum (inner loop alone,
|
|
DESIGN §4.7 reference: c964435 -> 0.00674). Anything above that is value
|
|
added by *topology* search.
|
|
|
|
Run under the go-forward fitness:
|
|
URB_NO_OCCLUSION=1 python3 experiments/run_search.py [budget] [rng-seed] [seed.dom] [out.dom]
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import math
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
from homemaker import dom, driver, oracle # noqa: E402
|
|
|
|
URB = Path("/home/bruno/src/urb")
|
|
EX = URB / "examples" / "programme-house"
|
|
SEED_FILE = EX / "c964435454c459f86c3ed9a5a7621132.dom"
|
|
OUT = Path(__file__).resolve().parents[1] / "scratch" / "search_best.dom"
|
|
|
|
|
|
def main() -> int:
|
|
budget = int(sys.argv[1]) if len(sys.argv) > 1 else 2000
|
|
rng_seed = int(sys.argv[2]) if len(sys.argv) > 2 else 0
|
|
seed_file = Path(sys.argv[3]) if len(sys.argv) > 3 else SEED_FILE
|
|
out = Path(sys.argv[4]) if len(sys.argv) > 4 else OUT
|
|
print(f"seed={seed_file.name} budget={budget} oracle evals, rng seed {rng_seed}",
|
|
flush=True)
|
|
|
|
r = driver.search(dom.load(str(seed_file)), EX, budget=budget,
|
|
urb_root=URB, seed=rng_seed, log=lambda m: print(m, flush=True))
|
|
|
|
print(f"\ndone: {r.n_evals} oracle evals across {r.n_topologies} topologies")
|
|
print(f"best: {r.best.fitness:.6g} (fails {r.best.n_fails}) via {r.best.lineage}")
|
|
print("population: " + ", ".join(f"{p.fitness:.4g}/{p.n_fails}f" for p in r.population))
|
|
|
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
dom.dump(r.best.root, str(out))
|
|
s = oracle.score(out, URB)
|
|
ok = math.isclose(s.fitness, r.best.fitness, rel_tol=1e-9)
|
|
print(f"\n{out} re-scored standalone: {s.fitness:.6g} ({s.n_fails} fails) "
|
|
f"-> {'MATCHES search record' if ok else 'MISMATCH'}")
|
|
return 0 if ok else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|