Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ cargo test -p tiling-search # the search, on random tili
uv run maxplus-solve new5-flat --max-solutions all --validate # run a solver from the command line
uv run maxplus-solve new5 --mode relief --option lookahead=true --option order=random --seed 3
uv run maxplus-solve rat1-flat --solver cp_sat.placements --max-solutions all --option coverage=false # CP-SAT, needs the cp-sat extra
uv run maxplus-solve new1-flat --assume edge-to-edge --max-solutions all --validate # assume no T between pieces
uv run maxplus-bench run benchmarks/manifests/corpus.toml --no-times # every solver on the corpus: the table in benchmarks/results/corpus.md
uv run maxplus-bench run benchmarks/manifests/edge_to_edge.toml --no-times # the table in benchmarks/results/edge_to_edge.md
uv run maxplus-bench run benchmarks/manifests/tolerance.toml # an experiment; records go to benchmarks/results/<name>.jsonl
uv run maxplus-bench proxies --results benchmarks/results/corpus.jsonl # difficulty proxies against what the searches cost
uv run python scripts/import_fixtures.py --source ../tropical-puzzle-lab # regenerate fixtures and keys
Expand Down Expand Up @@ -85,6 +87,7 @@ Rules:
## Invariants that are easy to break

- **Solver instances carry no answer.** The source `puzzle.json` leaks the solution three ways: `reference.poses`; local polygons stored in their solved orientation (every reference `theta` is 0); and piece ids and order that encode the tropical construction. Instances must be sanitized: seeded random rotation per piece (roof gradient rotated with it), random starting vertex, shuffled order, opaque ids, no `reference`, `tropical` or `provenance`. The sanitizer seed is part of the answer, since the rotations can be recomputed from it: it is recorded in the answer key and never in an instance. Answer keys live under `tests/` and only tests load them.
- **An assumption is not a rule.** A pruning rule leaves what a whole search finds unchanged; an assumption (`SolverConfig.assumptions`, today only `edge-to-edge`) narrows it. A solver declares the assumptions it can make, a result records them and names a candidate set that says so, and results under different assumptions are not compared. Rules that follow from an assumption are options, tested not to change what the search finds under it.
- **Three information regimes stay separate:** footprint (polygons only), relief (polygons and roof planes), tropical-aware (construction data as well). A solver declares which one it uses; results from different regimes are not comparable.
- **The validator is independent of the search.** `validation.py` must not import `_native` or reuse the Rust geometry, so one bug cannot affect both. It follows the browser's completion rules and may only depart from them on the stricter side; the three places it does are listed in its module docstring.
- **Solvers never call the validator.** `api.solve(..., validate=True)` is the only place the two meet, after the search has returned. A search that consulted the validator would be checking its answer with its own oracle.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Python owns orchestration and analysis. Rust owns the geometry and the search.

## Status

**Contracts and fixtures.** The instance format, the sanitizing importer and the benchmark corpus exist: 16 puzzles from Tropical Puzzle Lab and 4 synthetic ones with known solution counts, each with an answer key that only tests read. An independent validator checks an assembly against the browser player's completion rules. The Rust geometry kernel (separating-axis depth, convex clipping, containment, edge signatures, roof continuity) is in place and agrees with the validator on random poses of every fixture's pieces. Three solvers exist. `python.contact_dfs` is a Python prototype of the contact search. `rust.contact_dfs` is that search in Rust with roofs, pruning and symmetry handling: it solves all 16 corpus puzzles, runs every search to its end, and returns assemblies that pass the validator. `cp_sat.placements` hands the placements that search reaches to OR-Tools CP-SAT as a plain choice problem, and returns the same assemblies by other means. `maxplus-bench` runs experiment manifests over the corpus and writes the results table; [docs/experiments.md](docs/experiments.md) has what the first experiments found about tolerance, heuristics and difficulty proxies. Each rule of either can be switched off, because the question here is what makes a puzzle hard and what helps, not how fast one solver is; [docs/algorithms.md](docs/algorithms.md) has the measurements. The work is laid out in [docs/roadmap.md](docs/roadmap.md), and the design in [docs/architecture.md](docs/architecture.md).
**Contracts and fixtures.** The instance format, the sanitizing importer and the benchmark corpus exist: 18 puzzles from Tropical Puzzle Lab (nine constructions, each with its roofs and without) and 4 synthetic ones with known solution counts, each with an answer key that only tests read. An independent validator checks an assembly against the browser player's completion rules. The Rust geometry kernel (separating-axis depth, convex clipping, containment, edge signatures, roof continuity) is in place and agrees with the validator on random poses of every fixture's pieces. Three solvers exist. `python.contact_dfs` is a Python prototype of the contact search. `rust.contact_dfs` is that search in Rust with roofs, pruning and symmetry handling: it runs the search to its end on 17 of the 18 corpus puzzles, and every assembly it returns passes the validator. The eighteenth, `cor1-flat`, was built to be hard and has not been seen to end without roofs. `cp_sat.placements` hands the placements that search reaches to OR-Tools CP-SAT as a plain choice problem, and returns the same assemblies by other means. `maxplus-bench` runs experiment manifests over the corpus and writes the results table; [docs/experiments.md](docs/experiments.md) has what the first experiments found about tolerance, heuristics and difficulty proxies. Each rule of either can be switched off, because the question here is what makes a puzzle hard and what helps, not how fast one solver is; [docs/algorithms.md](docs/algorithms.md) has the measurements. `rust.contact_dfs` can also be told to assume that the pieces meet edge to edge, as every tropical cut does (`--assume edge-to-edge`); then the footprint puzzles that took a million nodes take about fifty. The work is laid out in [docs/roadmap.md](docs/roadmap.md), and the design in [docs/architecture.md](docs/architecture.md).

```python
from maxplus_solvers import load_puzzle
Expand Down
280 changes: 280 additions & 0 deletions benchmarks/fixtures/cor1-flat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
{
"formatVersion": 1,
"id": "cor1-flat",
"regime": "footprint",
"units": "mm",
"spanMm": 144.0,
"target": {
"vertices": [
[-72.0, -72.0],
[72.0, -72.0],
[72.0, 72.0],
[-72.0, 72.0]
]
},
"pieces": [
{
"id": "p00",
"polygon": [
[15.811873776259539, 5.414209046770245],
[-3.2015020654401622, 16.40363973158016],
[-15.811873776259539, -5.414209046770245],
[3.2015020654401622, -16.40363973158016]
]
},
{
"id": "p01",
"polygon": [
[-10.172575805661928, -18.07094292765794],
[20.10305969758872, -5.089918232328805],
[10.172575805661928, 18.07094292765794],
[-20.10305969758872, 5.089918232328805]
]
},
{
"id": "p02",
"polygon": [
[-19.33920159602142, 12.63786209946332],
[-12.31580348208042, -19.54587581581815],
[19.33920159602142, -12.63786209946332],
[12.31580348208042, 19.54587581581815]
]
},
{
"id": "p03",
"polygon": [
[-3.960665521198517, -17.670374657818726],
[18.08850691930801, 0.857280204273442],
[3.960665521198517, 17.670374657818726],
[-18.08850691930801, -0.857280204273442]
]
},
{
"id": "p04",
"polygon": [
[-5.684983804332803, -13.520671798842406],
[15.509811472086938, -13.852048250073873],
[15.921784169227195, 12.497672567182047],
[-16.4742565141312, 13.004178285005379],
[-16.798664577975522, -7.744919828781215]
]
},
{
"id": "p05",
"polygon": [
[-17.18946261113986, 2.7094994110938195],
[-6.1540056909537535, -16.2771995710012],
[17.18946261113986, -2.7094994110938195],
[6.1540056909537535, 16.2771995710012]
]
},
{
"id": "p06",
"polygon": [
[-3.5788798818224112, -25.064470201172384],
[19.83218831002089, -15.739134490493505],
[3.5788798818224112, 25.064470201172384],
[-19.83218831002089, 15.739134490493505]
]
},
{
"id": "p07",
"polygon": [
[18.459899557293806, 11.741907219495175],
[-14.101968516293422, 16.72646886769823],
[-18.459899557293806, -11.741907219495175],
[14.101968516293422, -16.72646886769823]
]
},
{
"id": "p08",
"polygon": [
[-13.039000219794794, -8.793508295730668],
[12.1317101991555, -10.008142810861521],
[13.039000219794794, 8.793508295730668],
[-12.1317101991555, 10.008142810861521]
]
},
{
"id": "p09",
"polygon": [
[-25.87911542288911, -6.82916046104896],
[15.37207303401124, -21.910395211200456],
[25.87911542288911, 6.82916046104896],
[-15.37207303401124, 21.910395211200456]
]
},
{
"id": "p10",
"polygon": [
[23.146056328376815, -11.348397425080744],
[-0.32427273530226763, 25.776363103958463],
[-23.146056328376815, 11.348397425080744],
[0.32427273530226763, -25.776363103958463]
]
},
{
"id": "p11",
"polygon": [
[11.723840254429945, 14.738065734929428],
[-17.715303448070415, 6.389603717076468],
[-11.723840254429945, -14.738065734929428],
[17.715303448070415, -6.389603717076468]
]
},
{
"id": "p12",
"polygon": [
[-8.778487752024896, -15.978658577933839],
[16.35513458018583, -8.055367777242665],
[8.778487752024896, 15.978658577933839],
[-16.35513458018583, 8.055367777242665]
]
},
{
"id": "p13",
"polygon": [
[-17.16582795880929, 1.129453570295814],
[5.855168004089374, -16.17585616042566],
[17.16582795880929, -1.129453570295814],
[-5.855168004089374, 16.17585616042566]
]
},
{
"id": "p14",
"polygon": [
[3.1470773247262347, -19.2633143948497],
[18.908906767083145, 4.840725362627694],
[-3.1470773247262347, 19.2633143948497],
[-18.908906767083145, -4.840725362627694]
]
},
{
"id": "p15",
"polygon": [
[13.099432656491729, -5.985862125702378],
[6.602929697437574, 14.191466896365334],
[-13.179317421789484, 3.977001493436167],
[-7.804558930258247, -12.716328930839882]
]
},
{
"id": "p16",
"polygon": [
[4.961693795127983, -17.264208917940064],
[17.64663124953175, -3.356742531375059],
[-4.961693795127983, 17.264208917940064],
[-17.64663124953175, 3.356742531375059]
]
},
{
"id": "p17",
"polygon": [
[14.785265230853653, -22.937131026509864],
[17.550459823610836, 20.897306229602737],
[-14.785265230853653, 22.937131026509864],
[-17.550459823610836, -20.897306229602737]
]
},
{
"id": "p18",
"polygon": [
[1.6170516557415997, -22.422208204351158],
[22.480411007273133, -0.0373866377435359],
[-1.6170516557415997, 22.422208204351158],
[-22.480411007273133, 0.0373866377435359]
]
},
{
"id": "p19",
"polygon": [
[-11.72687143372898, 6.390624815450257],
[-11.86661177893315, -8.47146334487267],
[10.127614611567893, -5.017970904285675],
[15.834001816966614, 6.1314845182972295]
]
},
{
"id": "p20",
"polygon": [
[10.23693773557185, 5.523998387739964],
[-2.4387564155430637, 12.356770723138766],
[-11.370484958548033, -4.212764114919944],
[4.06679833224333, -12.534157874152907]
]
},
{
"id": "p21",
"polygon": [
[3.894743686739261, -19.81263104126341],
[19.01583749008507, 6.790235762718771],
[-3.894743686739261, 19.81263104126341],
[-19.01583749008507, -6.790235762718771]
]
},
{
"id": "p22",
"polygon": [
[-10.544243883036525, -15.642515721509648],
[15.38219347927097, -10.920508272461651],
[10.544243883036525, 15.642515721509648],
[-15.38219347927097, 10.920508272461651]
]
},
{
"id": "p23",
"polygon": [
[-13.348240166183128, -0.32075630215115236],
[2.0658695197996133, -11.571216311588142],
[12.682590341572308, -1.169945675659716],
[-0.49052286488057817, 12.27603320151942]
]
},
{
"id": "p24",
"polygon": [
[-25.835304128377956, 4.708833004916235],
[5.9804607587122085, -25.570884552308215],
[25.835304128377956, -4.708833004916235],
[-5.9804607587122085, 25.570884552308215]
]
},
{
"id": "p25",
"polygon": [
[5.754156472129492, 20.50414494951836],
[-21.234763162509214, 1.617130251015869],
[-5.754156472129492, -20.50414494951836],
[21.234763162509214, -1.617130251015869]
]
},
{
"id": "p26",
"polygon": [
[12.72010748714181, 10.441751787628913],
[-5.398037716497224, 15.546462738840827],
[-12.72010748714181, -10.441751787628913],
[5.398037716497224, -15.546462738840827]
]
}
],
"rules": {
"translate": true,
"rotate": "continuous-z",
"flip": false
},
"validation": {
"contactNoise": 1e-06,
"overlapDepth": 0.006,
"outsideDepth": 0.006,
"areaError": 0.012,
"edgeAngleDeg": 3.0,
"edgeMinOverlap": 0.02
},
"source": {
"repository": "https://github.com/maxpluslab/tropical-puzzle-lab",
"commit": "b1a17926b6cb32eacfb9f24a4e3ac36241e73f7c",
"puzzleId": "cor1-flat",
"geometryHash": "049804fdb45e2f37430c7616cd461063ac9d71eedc67e963f2c77ac1ce95bcf5"
}
}
Loading
Loading