Skip to content

Pass schLayout.packPlacementStrategy through to the schematic packer#2361

Closed
matthewhardern wants to merge 1 commit into
tscircuit:mainfrom
matthewhardern:force-directed-packing
Closed

Pass schLayout.packPlacementStrategy through to the schematic packer#2361
matthewhardern wants to merge 1 commit into
tscircuit:mainfrom
matthewhardern:force-directed-packing

Conversation

@matthewhardern
Copy link
Copy Markdown

@matthewhardern matthewhardern commented May 30, 2026

Summary

Reads schLayout.packPlacementStrategy (or the top-level shortcut) when building the matchpack InputProblem for match-adapt schematic layout, so a board can opt into the force-directed packer:

<board schLayout={{ packPlacementStrategy: "force_directed" }}>
  {/* ...100 resistors... */}
</board>

This is the end-to-end wiring for tscircuit/tscircuit#3208. Measured by rendering N bare resistors, schematic layout goes from this:

resistors greedy (default) force_directed
50 4.6 s 45 ms
100 28.1 s 92 ms

Default stays greedy unless the prop is set, so nothing changes for existing designs. The packer runs behind a validate-then-fall-back-to-greedy gate in calculate-packing, so it cannot produce a worse layout than today.

Testing

bun test, bunx tsc --noEmit. Added bench-core-fd.ts for the end-to-end numbers above.

Part of tscircuit/tscircuit#3208. Depends on the calculate-packing, matchpack, and @tscircuit/props PRs.

Dependencies and CI

This is the top of a four-repo chain and depends on calculate-packing#94, matchpack#116, and props#681. Until those merge and publish and core's dependencies are bumped, type-check here stays red because the published @tscircuit/matchpack, calculate-packing, and @tscircuit/props do not yet expose the force_directed strategy. Merging in dependency order resolves it.

Read schLayout.packPlacementStrategy (or the top-level shortcut) in
convertTreeToInputProblem and pass packPlacementStrategy:"force_directed" into
the matchpack InputProblem. Default keeps greedy. End-to-end (bench-core-fd.ts):
50 resistors schematic layout drops from ~4.6s to ~45ms (103x), all placed.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment May 30, 2026 4:28pm

Request Review

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.

1 participant