Skip to content

Allow selecting the force_directed packing strategy via InputProblem#116

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

Allow selecting the force_directed packing strategy via InputProblem#116
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

Threads an optional packPlacementStrategy: "force_directed" through InputProblem into the two packing solvers (PartitionPackingSolver and SingleInnerPartitionPackingSolver). When set, packing routes through calculate-packing's gated pack() (force-directed with a validate-then-fall-back-to-greedy safety net); when unset, the existing greedy strategies are used exactly as before.

This is what lets the schematic layout pipeline opt into the faster packer behind tscircuit/tscircuit#3208. On a 100-resistor LayoutPipelineSolver run, packing drops from about 5 seconds to a few milliseconds with all parts placed and no overlaps.

Purely additive and default-off, so current behavior is unchanged.

Testing

bun test for the packing solvers. Added spike-matchpack-fd.ts for a head-to-head check via the real field.

Part of tscircuit/tscircuit#3208. Builds on the calculate-packing PR that adds the force_directed strategy; the @tscircuit/props and core PRs expose it as a board prop.

Dependencies and CI

This builds on calculate-packing#94, which adds force_directed to PackPlacementStrategy. Until #94 is merged and published and this repo's calculate-packing dependency is bumped, the type-check job here stays red because the published types do not include force_directed yet. That is merge ordering, not a problem with this change.

The failing test job is unrelated to this PR: it is a circuit-to-svg dependency drift (convertCircuitJsonToSchematicSimulationSvg is no longer exported), which also affects a fresh run of main.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

@matthewhardern is attempting to deploy a commit to the tscircuit Team on Vercel.

A member of the Team first needs to authorize it.

Thread an optional packPlacementStrategy:"force_directed" through InputProblem
into PartitionPackingSolver + SingleInnerPartitionPackingSolver. Default
(undefined) keeps the greedy outline packer unchanged; when set, packing routes
through calculate-packing's gated pack() (force-directed + validate + greedy
fallback). Fixes the O(n^3) blowup behind tscircuit#3208: a 100-resistor
LayoutPipelineSolver run drops from ~5.1s to ~3ms, 0 overlaps, all placed.

spike-matchpack-fd.ts: head-to-head verification via the real field.
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