Gaotax2006 [ tscircuit ] Fix #12: Add LayoutConstraintSolver for layout quality improvement#113
Gaotax2006 [ tscircuit ] Fix #12: Add LayoutConstraintSolver for layout quality improvement#113Gaotax2006 wants to merge 1 commit into
Conversation
…ution (tscircuit#12) - New solver detects overlapping chips and spacing violations - Runs as final phase after partition packing - Force-directed displacement resolves collisions - Integrated into LayoutPipelineSolver pipeline
|
@Gaotax2006 is attempting to deploy a commit to the tscircuit Team on Vercel. A member of the Team first needs to authorize it. |
|
0x6e154f0e2c6190c18c27691537cf12a5f47d0558 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9af51c32b3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else { | ||
| const gapX = Math.max(ba.minX, bb.minX) - Math.min(ba.maxX, bb.maxX) | ||
| const gapY = Math.max(ba.minY, bb.minY) - Math.min(ba.maxY, bb.maxY) | ||
| const minGap = Math.max(gapX > 0 ? gapX : Infinity, gapY > 0 ? gapY : Infinity) |
There was a problem hiding this comment.
Compute spacing gap from nearest axis separation
The spacing check uses Math.max(gapX > 0 ? gapX : Infinity, gapY > 0 ? gapY : Infinity), which turns minGap into Infinity whenever chips overlap on one axis (the most common near-miss case). That means two chips that are too close vertically or horizontally are not reported as spacing violations, so the new minimum-gap constraint is silently skipped for valid layouts that are non-overlapping but too tight.
Useful? React with 👍 / 👎.
| const displacements = new Map<ChipId, { dx: number; dy: number }>() | ||
|
|
||
| for (const v of this.violations) { | ||
| if ("overlapX" in v && "overlapY" in v) { |
There was a problem hiding this comment.
Handle spacing violations in the resolver loop
resolveViolations() only applies displacements for overlap violations ("overlapX" in v && "overlapY" in v) and ignores SpacingViolation entries entirely. As a result, even spacing violations that are successfully detected are never corrected, so the pipeline can complete while still violating the advertised minimum chip gap constraint.
Useful? React with 👍 / 👎.
Fixes #12
Adds a ConstraintSatisfactionSolver phase after partition packing to detect and resolve chip overlaps and minimum spacing violations using force-directed displacement.
Files changed
Acceptance checklist