Skip to content

Phase 6: the CP-SAT backend over reachable placements - #7

Merged
madeline-v-brandt merged 2 commits into
phase-5-rust-contact-dfsfrom
phase-6-cp-sat
Nov 11, 2026
Merged

madeline-v-brandt merged 2 commits into
phase-5-rust-contact-dfsfrom
phase-6-cp-sat

Conversation

@kuvychko

Copy link
Copy Markdown
Member

Phase 6 of the roadmap, chained on #6 (phase 5).

What it adds

cp_sat.placements: OR-Tools CP-SAT choosing an assembly from a finite list of placements. The solver knows no geometry. Rust builds the list and what its members exclude among themselves in one call; CP-SAT runs with one worker and no objective.

  • The list is the placements the corner search of rust.contact_dfs puts down anywhere in its tree (tiling-search::enumerate). A list built without a search, by closing contacts under contacts, was tried first and does not stay small.
  • The model: one Boolean per placement; each class of congruent pieces takes as many placements as it has members; overlaps stated as "at most one" over a grid of probe points, the rest as pairs (tiling-geometry::conflict); coverage stated as "at least one" per probe point of the target.
  • Tray rotations are removed from the choices using the images Rust reports, so the solver still crosses into Rust once per solve.
  • Switches: the listing search's anchor, cavity_pruning, closure_pruning, tray_rotations; coverage; targeted_probes (off: fewer pairs, slower).
  • OR-Tools is the optional extra cp-sat; importing the package does not load it.

Exit criterion

tests/corpus/test_cp_sat.py: on all 20 fixtures, in their own regimes, CP-SAT and the Rust search both run to the end and return the same assemblies, compared as placed polygons up to the tray's rotations. Every one passes the validator.

Also: the model's exclusions against Shapely pair by pair, hand-countable unit puzzles, every switch on and off, limits, and architecture tests for the new solver. The solver was broken by hand seven ways and the tests watched to fail.

Findings

Relative to the listed placements, in f64 with tolerances. Tables in docs/algorithms.md.

  • Once the placements are listed, the choice is easy: new1-flat takes 297 conflicts and new2-flat none, where the search takes about a million nodes each. The search's trouble is meeting the same dead ends again, not the number of combinations.
  • Coverage is what makes it so. Without it CP-SAT does not finish rat1-flat in a minute; with it, 19 conflicts.
  • In relief there is no branch and no conflict on any fixture.
  • The solver cannot be quicker than the search that builds its list. It is a check and a measurement.

Notes

  • The roadmap row for phase 6 is not ticked; that waits for CI on both platforms.
  • The exit test adds a few minutes to the pytest job (the three largest footprints).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jfg9fgTR9LYn4D2rTtfifs

kuvychko and others added 2 commits November 11, 2026 06:47
cp_sat.placements hands OR-Tools CP-SAT a finite list of placements and
what they exclude among themselves, and chooses an assembly from it. The
list is the placements the corner search of rust.contact_dfs puts down
anywhere in its tree, built in one Rust call (tiling-search::enumerate)
together with their conflicts (tiling-geometry::conflict).

The model: one Boolean per placement; each class of congruent pieces
takes as many placements as it has members; overlaps stated as "at most
one" over a grid of probe points and the rest as pairs; coverage stated
as "at least one" per probe point of the target. One worker, no
objective. Tray rotations are removed from the choices using the images
Rust reports, so the solver still crosses into Rust once.

Switches: the listing search's anchor, cavity_pruning, closure_pruning
and tray_rotations; coverage; targeted_probes (off: fewer pairs, slower).

The exit test, tests/corpus/test_cp_sat.py, runs both solvers to the end
on all 20 fixtures and compares the assemblies as placed polygons. The
model's exclusions are also checked pair by pair against Shapely.

Findings are in docs/algorithms.md: once the placements are listed the
choice takes none to a few hundred conflicts where the search takes up
to a million nodes, and the coverage constraints are what make it so.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jfg9fgTR9LYn4D2rTtfifs
@madeline-v-brandt
madeline-v-brandt merged commit 280aaa5 into phase-5-rust-contact-dfs Nov 11, 2026
2 checks passed
@kuvychko
kuvychko deleted the phase-6-cp-sat branch November 11, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants