Python rewrite of the Urb/Homemaker stack
Two root causes found for ca/cb corpus parity failures: 1. _avg_path_len_from used unweighted BFS (hop count) but Perl's Graph::average_path_length uses weighted Dijkstra with centroid-to-centroid edge distances. This caused wrong edge removal in has_circulation, giving wrong stack corner counts (2 instead of 3 for lr in ca9e80c5). 2. Entrance corner logic used _public_access (any street boundary) but Perl's Entrances() picks the best entrance route — a stair only gets entrance corners if no higher-priority non-stair C leaf has public access. Also includes homemaker-py-hgg storey/building checks previously uncommitted: stair fit, circ connectivity, roof-garden, public-access tracking, has_circulation, corners_in_use, stack_corners_in_use, check_space_counts with failure stacking. All 4 debug corpus prefixes: ratio=1.000000. 39 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .beads | ||
| .claude | ||
| experiments | ||
| src/homemaker | ||
| tests | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| DESIGN.md | ||
| pyproject.toml | ||
| README.md | ||
homemaker-py
Programme-driven building-layout search over slicing trees. A clean-room Python successor to the Perl Urb project, intended to eventually be 100% Python.
Why a rewrite
Urb represents a building as a binary slicing tree where room sizes are derived top-down from division ratios. That makes room area an emergent property of every cut above it, which:
- gives the genome low locality (a cut near the root rescales every descendant),
- makes target room sizes nearly impossible to hit, so the gaussian size penalty dominates fitness, and
- defeats crossover (transplanted subtrees lose their proportions).
homemaker inverts this: leaves carry target dimensions from the programme and division ratios are solved bottom-up for a fixed topology. The evolutionary search then only explores topology + types + adjacency.
Phase plan
- Solver experiment (current): port Urb's geometry, re-solve ratios from programme targets, score the result against the original via the Perl oracle.
- Native Python fitness (retire the Perl oracle).
- Canonical slicing encoding (normalized Polish expression) + memetic search.
Layout
src/homemaker/dom.py— read/write Urb.domYAML into aNodetree.src/homemaker/geometry.py— faithful port of Urb's top-down geometry.src/homemaker/programme.py— parsepatterns.configspace requirements.src/homemaker/solver.py— bottom-up ratio solve (scipy).src/homemaker/oracle.py— Phase-1 scaffold: score a.domvia Urb'surb-fitness.pl.
The Perl oracle is the only throwaway component; everything else is permanent.