@tscircuit/matchpack 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tscircuit Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -12,9 +12,6 @@ This is roughly the hierarchy of solvers:
12
12
  LayoutPipelineSolver: Runs pipeline
13
13
  ↳ ChipPartitionsSolver: Creates partitions (small subset groups) surrounding complex chips
14
14
  ↳ SingleChipPartitionSolver: Creates a single partition for a single chip
15
- ↳ PinRangeMatchSolver: Finds pin ranges on each chip in the partition, constructs a subset group with just that pin range, then matches a laid out design from the corpus
16
- ↳ PinRangeLayoutSolver: Applies the matched layout to the pin ranges, moving passives that are connected to each pin range
17
- ↳ PinRangeOverlapSolver: Finds overlaps between laid out boxes from each pin range and fixes them
18
15
  ↳ PartitionPackingSolver: Packs the laid out chip partitions into a single layout
19
16
  ```
20
17
 
package/dist/index.d.ts CHANGED
@@ -65,8 +65,6 @@ type Net = {
65
65
  type InputProblem = {
66
66
  chipMap: Record<ChipId, Chip>;
67
67
  chipPinMap: Record<PinId, ChipPin>;
68
- groupMap: Record<GroupId, Group>;
69
- groupPinMap: Record<PinId, GroupPin>;
70
68
  netMap: Record<NetId, Net>;
71
69
  /** This is a two-way map */
72
70
  pinStrongConnMap: Record<`${PinId}-${PinId}`, boolean>;
@@ -92,7 +90,7 @@ declare class ChipPartitionsSolver extends BaseSolver {
92
90
  */
93
91
  private createPartitions;
94
92
  /**
95
- * Finds the owner (chip or group) of a given pin
93
+ * Finds the owner chip of a given pin
96
94
  */
97
95
  private findPinOwner;
98
96
  /**
@@ -115,151 +113,65 @@ type OutputLayout = {
115
113
  };
116
114
 
117
115
  /**
118
- * Packs the laid out chip partitions into a single layout.
119
- * Combines all the individually processed partitions into the final schematic layout.
116
+ * Packs components within a single partition to create an optimal internal layout.
117
+ * Uses a packing algorithm to arrange chips and their connections within the partition.
120
118
  */
121
119
 
122
- type LaidOutPartition = InputProblem;
123
- interface PartitionPackingSolverInput {
124
- resolvedLayout: OutputLayout;
125
- laidOutPartitions: LaidOutPartition[];
120
+ declare class SingleInnerPartitionPackingSolver extends BaseSolver {
126
121
  inputProblem: InputProblem;
127
- }
128
- declare class PartitionPackingSolver extends BaseSolver {
129
- resolvedLayout: OutputLayout;
130
- laidOutPartitions: LaidOutPartition[];
131
- inputProblem: InputProblem;
132
- finalLayout: OutputLayout | null;
122
+ layout: OutputLayout | null;
133
123
  phasedPackSolver: PhasedPackSolver | null;
134
- constructor(input: PartitionPackingSolverInput);
135
- _step(): void;
136
- private organizeComponentsByPartition;
137
- private createPackInput;
138
- private applyPackingResult;
139
- visualize(): GraphicsObject;
140
- getConstructorParams(): PartitionPackingSolverInput;
141
- }
142
-
143
- /**
144
- * Sub-solver for processing pin ranges within a single partition
145
- */
146
-
147
- type PinRange = {
148
- pinIds: PinId[];
149
- side: Side;
150
- chipId?: ChipId;
151
- groupId?: GroupId;
152
- connectedPins?: PinId[];
153
- connectedChips?: ChipId[];
154
- };
155
- declare class PartitionPinRangeMatchSolver extends BaseSolver {
156
- inputProblem: InputProblem;
157
- pinRanges: PinRange[];
158
124
  constructor(inputProblem: InputProblem);
159
125
  _step(): void;
160
- private createPinRanges;
161
- private createPinRangesForChip;
162
- private createPinRangesForGroup;
163
- private createPinRangesForSide;
164
- private sortPinsBySide;
165
- private calculateDistance;
166
- private findConnectedPassives;
126
+ private createPackInput;
127
+ private createLayoutFromPackingResult;
167
128
  visualize(): GraphicsObject;
168
- getConstructorParams(): {
169
- inputProblem: InputProblem;
170
- };
129
+ getConstructorParams(): [InputProblem];
171
130
  }
172
131
 
173
132
  /**
174
- * Solves the layout for a single pin range and its connected passive components.
175
- * This solver takes a pin range and applies layout patterns to position the
176
- * connected components optimally around the pin range.
133
+ * Packs the internal layout of each partition using SingleInnerPartitionPackingSolver.
134
+ * This stage takes the partitions from ChipPartitionsSolver and creates optimized
135
+ * internal layouts for each partition before they are packed together.
177
136
  */
178
137
 
179
- declare class SinglePinRangeLayoutSolver extends BaseSolver {
180
- pinRange: PinRange;
138
+ type PackedPartition = {
181
139
  inputProblem: InputProblem;
182
- layoutApplied: boolean;
183
- layout: OutputLayout | null;
184
- constructor(pinRange: PinRange, inputProblem: InputProblem);
185
- _step(): void;
186
- /**
187
- * Build a connectivity map that normalizes network IDs by finding connected components.
188
- * All pins in the same connected component get the same network ID.
189
- */
190
- protected buildNetworkConnectivityMap(relevantPins: Set<string>): Map<string, string>;
191
- protected createPinRangeLayout(): OutputLayout;
192
- visualize(): GraphicsObject;
193
- getConstructorParams(): {
194
- pinRange: PinRange;
195
- inputProblem: InputProblem;
196
- };
197
- }
198
-
199
- /**
200
- * Applies the matched layout to the pin ranges.
201
- * Moves passives that are connected to each pin range according to the matched design.
202
- */
203
-
204
- declare class PinRangeLayoutSolver extends BaseSolver {
205
- pinRanges: PinRange[];
206
- inputProblems: InputProblem[];
207
- currentRangeIndex: number;
208
- activeSolver: SinglePinRangeLayoutSolver | null;
209
- completedSolvers: SinglePinRangeLayoutSolver[];
210
- constructor(pinRanges: PinRange[], inputProblems: InputProblem[]);
211
- _step(): void;
212
- private findInputProblemForRange;
213
- visualize(): GraphicsObject;
214
- getConstructorParams(): {
215
- pinRanges: PinRange[];
216
- inputProblems: InputProblem[];
217
- };
218
- }
219
-
220
- /**
221
- * Finds pin ranges on each chip in the partition and matches layouts from the corpus.
222
- * Creates subset groups with pin ranges and finds pre-laid-out designs that match.
223
- */
224
-
225
- declare class PinRangeMatchSolver extends BaseSolver {
140
+ layout: OutputLayout;
141
+ };
142
+ declare class PackInnerPartitionsSolver extends BaseSolver {
226
143
  partitions: InputProblem[];
144
+ packedPartitions: PackedPartition[];
145
+ completedSolvers: SingleInnerPartitionPackingSolver[];
146
+ activeSolver: SingleInnerPartitionPackingSolver | null;
227
147
  currentPartitionIndex: number;
228
- activeSubSolver: PartitionPinRangeMatchSolver | null;
229
- partitionResults: PinRange[][];
230
148
  constructor(partitions: InputProblem[]);
231
149
  _step(): void;
232
- getAllPinRanges(): PinRange[];
233
150
  visualize(): GraphicsObject;
234
- getConstructorParams(): {
235
- partitions: InputProblem[];
236
- };
151
+ getConstructorParams(): [InputProblem[]];
237
152
  }
238
153
 
239
154
  /**
240
- * Finds overlaps between laid out boxes from each pin range and fixes them.
241
- * Resolves spatial conflicts between different pin range layouts.
155
+ * Packs the laid out chip partitions into a single layout.
156
+ * Combines all the individually processed partitions into the final schematic layout.
242
157
  */
243
158
 
244
- declare class PinRangeOverlapSolver extends BaseSolver {
245
- pinRangeLayoutSolver: PinRangeLayoutSolver | null;
246
- inputProblems: InputProblem[];
247
- resolvedLayout: OutputLayout | null;
248
- constructor(pinRangeLayoutSolver: PinRangeLayoutSolver, inputProblems: InputProblem[]);
159
+ interface PartitionPackingSolverInput {
160
+ packedPartitions: PackedPartition[];
161
+ inputProblem: InputProblem;
162
+ }
163
+ declare class PartitionPackingSolver extends BaseSolver {
164
+ packedPartitions: PackedPartition[];
165
+ inputProblem: InputProblem;
166
+ finalLayout: OutputLayout | null;
167
+ phasedPackSolver: PhasedPackSolver | null;
168
+ constructor(input: PartitionPackingSolverInput);
249
169
  _step(): void;
250
- private groupPlacementsByPartition;
251
- private findPartitionIndexForSolver;
252
- private resolvePartitionOverlaps;
253
- private positionPartitionsHorizontally;
254
- private findOverlaps;
255
- private getComponentBounds;
256
- private boundsOverlap;
257
- private resolveOverlaps;
170
+ private organizePackedPartitions;
171
+ private createPackInput;
172
+ private applyPackingResult;
258
173
  visualize(): GraphicsObject;
259
- getConstructorParams(): {
260
- pinRangeLayoutSolver: PinRangeLayoutSolver | null;
261
- inputProblems: InputProblem[];
262
- };
174
+ getConstructorParams(): PartitionPackingSolverInput;
263
175
  }
264
176
 
265
177
  /**
@@ -275,9 +187,7 @@ type PipelineStep<T extends new (...args: any[]) => BaseSolver> = {
275
187
  };
276
188
  declare class LayoutPipelineSolver extends BaseSolver {
277
189
  chipPartitionsSolver?: ChipPartitionsSolver;
278
- pinRangeMatchSolver?: PinRangeMatchSolver;
279
- pinRangeLayoutSolver?: PinRangeLayoutSolver;
280
- pinRangeOverlapSolver?: PinRangeOverlapSolver;
190
+ packInnerPartitionsSolver?: PackInnerPartitionsSolver;
281
191
  partitionPackingSolver?: PartitionPackingSolver;
282
192
  startTimeOfPhase: Record<string, number>;
283
193
  endTimeOfPhase: Record<string, number>;
@@ -285,8 +195,8 @@ declare class LayoutPipelineSolver extends BaseSolver {
285
195
  firstIterationOfPhase: Record<string, number>;
286
196
  inputProblem: InputProblem;
287
197
  chipPartitions?: ChipPartitionsSolver["partitions"];
288
- pinRanges?: ReturnType<PinRangeMatchSolver["getAllPinRanges"]>;
289
- pipelineDef: (PipelineStep<typeof ChipPartitionsSolver> | PipelineStep<typeof PinRangeMatchSolver> | PipelineStep<typeof PinRangeLayoutSolver> | PipelineStep<typeof PinRangeOverlapSolver> | PipelineStep<typeof PartitionPackingSolver>)[];
198
+ packedPartitions?: PackedPartition[];
199
+ pipelineDef: (PipelineStep<typeof ChipPartitionsSolver> | PipelineStep<typeof PackInnerPartitionsSolver> | PipelineStep<typeof PartitionPackingSolver>)[];
290
200
  constructor(inputProblem: InputProblem);
291
201
  currentPipelineStepIndex: number;
292
202
  _step(): void;