@tscircuit/schematic-trace-solver 0.0.21 → 0.0.23

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.
@@ -99,7 +99,7 @@ const inputProblem: InputProblem = {
99
99
  EN: ["x+", "x-"],
100
100
  GND: ["y-"],
101
101
  },
102
- maxMspPairDistance: 2,
102
+ maxMspPairDistance: 5,
103
103
  }
104
104
 
105
105
  export default () => <PipelineDebugger inputProblem={inputProblem} />
@@ -174,7 +174,7 @@ const inputProblem: InputProblem = {
174
174
  ],
175
175
  netConnections: [],
176
176
  availableNetLabelOrientations: {},
177
- maxMspPairDistance: 2,
177
+ maxMspPairDistance: 10,
178
178
  }
179
179
 
180
180
  export default function Example05Page() {
@@ -54,7 +54,7 @@ const inputProblem: InputProblem = {
54
54
  ],
55
55
  netConnections: [],
56
56
  availableNetLabelOrientations: {},
57
- maxMspPairDistance: 2,
57
+ maxMspPairDistance: 10,
58
58
  }
59
59
 
60
60
  export default () => <PipelineDebugger inputProblem={inputProblem} />
@@ -0,0 +1,417 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import type { InputProblem } from "lib/types/InputProblem"
3
+
4
+ const inputProblem: InputProblem = {
5
+ chips: [
6
+ {
7
+ chipId: "schematic_component_0",
8
+ center: {
9
+ x: 0,
10
+ y: 0,
11
+ },
12
+ width: 2.3,
13
+ height: 1.7999999999999998,
14
+ pins: [
15
+ {
16
+ pinId: "U1.1",
17
+ x: -1.15,
18
+ y: 0.7,
19
+ },
20
+ {
21
+ pinId: "U1.2",
22
+ x: -1.15,
23
+ y: 0.49999999999999994,
24
+ },
25
+ {
26
+ pinId: "U1.3",
27
+ x: -1.15,
28
+ y: 0.29999999999999993,
29
+ },
30
+ {
31
+ pinId: "U1.4",
32
+ x: -1.15,
33
+ y: 0.09999999999999987,
34
+ },
35
+ {
36
+ pinId: "U1.5",
37
+ x: -1.15,
38
+ y: -0.10000000000000009,
39
+ },
40
+ {
41
+ pinId: "U1.6",
42
+ x: -1.15,
43
+ y: -0.30000000000000004,
44
+ },
45
+ {
46
+ pinId: "U1.7",
47
+ x: -1.15,
48
+ y: -0.5,
49
+ },
50
+ {
51
+ pinId: "U1.8",
52
+ x: -1.15,
53
+ y: -0.7,
54
+ },
55
+ {
56
+ pinId: "U1.9",
57
+ x: 1.15,
58
+ y: -0.7,
59
+ },
60
+ {
61
+ pinId: "U1.10",
62
+ x: 1.15,
63
+ y: -0.49999999999999994,
64
+ },
65
+ {
66
+ pinId: "U1.11",
67
+ x: 1.15,
68
+ y: -0.29999999999999993,
69
+ },
70
+ {
71
+ pinId: "U1.12",
72
+ x: 1.15,
73
+ y: -0.09999999999999987,
74
+ },
75
+ {
76
+ pinId: "U1.13",
77
+ x: 1.15,
78
+ y: 0.10000000000000009,
79
+ },
80
+ {
81
+ pinId: "U1.14",
82
+ x: 1.15,
83
+ y: 0.30000000000000004,
84
+ },
85
+ {
86
+ pinId: "U1.15",
87
+ x: 1.15,
88
+ y: 0.5,
89
+ },
90
+ {
91
+ pinId: "U1.16",
92
+ x: 1.15,
93
+ y: 0.7,
94
+ },
95
+ ],
96
+ },
97
+ {
98
+ chipId: "schematic_component_1",
99
+ center: {
100
+ x: -4,
101
+ y: -3,
102
+ },
103
+ width: 1.102581400000001,
104
+ height: 0.388910699999999,
105
+ pins: [
106
+ {
107
+ pinId: "R1.1",
108
+ x: -4.551290700000001,
109
+ y: -2.9997267500000007,
110
+ },
111
+ {
112
+ pinId: "R1.2",
113
+ x: -3.4487092999999995,
114
+ y: -3.0002732499999993,
115
+ },
116
+ ],
117
+ },
118
+ {
119
+ chipId: "schematic_component_2",
120
+ center: {
121
+ x: -4,
122
+ y: -2,
123
+ },
124
+ width: 1.102581400000001,
125
+ height: 0.388910699999999,
126
+ pins: [
127
+ {
128
+ pinId: "R2.1",
129
+ x: -4.551290700000001,
130
+ y: -1.9997267500000007,
131
+ },
132
+ {
133
+ pinId: "R2.2",
134
+ x: -3.4487092999999995,
135
+ y: -2.0002732499999993,
136
+ },
137
+ ],
138
+ },
139
+ {
140
+ chipId: "schematic_component_3",
141
+ center: {
142
+ x: -4,
143
+ y: -1,
144
+ },
145
+ width: 1.102581400000001,
146
+ height: 0.388910699999999,
147
+ pins: [
148
+ {
149
+ pinId: "R3.1",
150
+ x: -4.551290700000001,
151
+ y: -0.9997267500000007,
152
+ },
153
+ {
154
+ pinId: "R3.2",
155
+ x: -3.4487092999999995,
156
+ y: -1.0002732499999993,
157
+ },
158
+ ],
159
+ },
160
+ {
161
+ chipId: "schematic_component_4",
162
+ center: {
163
+ x: -4,
164
+ y: 0,
165
+ },
166
+ width: 1.102581400000001,
167
+ height: 0.388910699999999,
168
+ pins: [
169
+ {
170
+ pinId: "R4.1",
171
+ x: -4.551290700000001,
172
+ y: 0.0002732499999993365,
173
+ },
174
+ {
175
+ pinId: "R4.2",
176
+ x: -3.4487092999999995,
177
+ y: -0.0002732499999993365,
178
+ },
179
+ ],
180
+ },
181
+ {
182
+ chipId: "schematic_component_5",
183
+ center: {
184
+ x: -4,
185
+ y: 1,
186
+ },
187
+ width: 1.102581400000001,
188
+ height: 0.388910699999999,
189
+ pins: [
190
+ {
191
+ pinId: "R5.1",
192
+ x: -4.551290700000001,
193
+ y: 1.0002732499999993,
194
+ },
195
+ {
196
+ pinId: "R5.2",
197
+ x: -3.4487092999999995,
198
+ y: 0.9997267500000007,
199
+ },
200
+ ],
201
+ },
202
+ {
203
+ chipId: "schematic_component_6",
204
+ center: {
205
+ x: -4,
206
+ y: 2,
207
+ },
208
+ width: 1.102581400000001,
209
+ height: 0.388910699999999,
210
+ pins: [
211
+ {
212
+ pinId: "R6.1",
213
+ x: -4.551290700000001,
214
+ y: 2.0002732499999993,
215
+ },
216
+ {
217
+ pinId: "R6.2",
218
+ x: -3.4487092999999995,
219
+ y: 1.9997267500000007,
220
+ },
221
+ ],
222
+ },
223
+ {
224
+ chipId: "schematic_component_7",
225
+ center: {
226
+ x: 4,
227
+ y: -3,
228
+ },
229
+ width: 1.1025814,
230
+ height: 0.388910699999999,
231
+ pins: [
232
+ {
233
+ pinId: "R7.1",
234
+ x: 3.4487093,
235
+ y: -2.9997267500000007,
236
+ },
237
+ {
238
+ pinId: "R7.2",
239
+ x: 4.5512907,
240
+ y: -3.0002732499999993,
241
+ },
242
+ ],
243
+ },
244
+ {
245
+ chipId: "schematic_component_8",
246
+ center: {
247
+ x: 4,
248
+ y: -2,
249
+ },
250
+ width: 1.1025814,
251
+ height: 0.388910699999999,
252
+ pins: [
253
+ {
254
+ pinId: "R8.1",
255
+ x: 3.4487093,
256
+ y: -1.9997267500000007,
257
+ },
258
+ {
259
+ pinId: "R8.2",
260
+ x: 4.5512907,
261
+ y: -2.0002732499999993,
262
+ },
263
+ ],
264
+ },
265
+ {
266
+ chipId: "schematic_component_9",
267
+ center: {
268
+ x: 4,
269
+ y: -1,
270
+ },
271
+ width: 1.1025814,
272
+ height: 0.388910699999999,
273
+ pins: [
274
+ {
275
+ pinId: "R9.1",
276
+ x: 3.4487093,
277
+ y: -0.9997267500000007,
278
+ },
279
+ {
280
+ pinId: "R9.2",
281
+ x: 4.5512907,
282
+ y: -1.0002732499999993,
283
+ },
284
+ ],
285
+ },
286
+ {
287
+ chipId: "schematic_component_10",
288
+ center: {
289
+ x: 4,
290
+ y: 0,
291
+ },
292
+ width: 1.1025814,
293
+ height: 0.388910699999999,
294
+ pins: [
295
+ {
296
+ pinId: "R10.1",
297
+ x: 3.4487093,
298
+ y: 0.0002732499999993365,
299
+ },
300
+ {
301
+ pinId: "R10.2",
302
+ x: 4.5512907,
303
+ y: -0.0002732499999993365,
304
+ },
305
+ ],
306
+ },
307
+ {
308
+ chipId: "schematic_component_11",
309
+ center: {
310
+ x: 4,
311
+ y: 1,
312
+ },
313
+ width: 1.1025814,
314
+ height: 0.388910699999999,
315
+ pins: [
316
+ {
317
+ pinId: "R11.1",
318
+ x: 3.4487093,
319
+ y: 1.0002732499999993,
320
+ },
321
+ {
322
+ pinId: "R11.2",
323
+ x: 4.5512907,
324
+ y: 0.9997267500000007,
325
+ },
326
+ ],
327
+ },
328
+ {
329
+ chipId: "schematic_component_12",
330
+ center: {
331
+ x: 4,
332
+ y: 2,
333
+ },
334
+ width: 1.1025814,
335
+ height: 0.388910699999999,
336
+ pins: [
337
+ {
338
+ pinId: "R12.1",
339
+ x: 3.4487093,
340
+ y: 2.0002732499999993,
341
+ },
342
+ {
343
+ pinId: "R12.2",
344
+ x: 4.5512907,
345
+ y: 1.9997267500000007,
346
+ },
347
+ ],
348
+ },
349
+ ],
350
+ directConnections: [
351
+ {
352
+ pinIds: ["R1.2", "U1.1"],
353
+ netId: ".R1 > .pin2 to .U1 > .IN1",
354
+ },
355
+ {
356
+ pinIds: ["R2.2", "U1.3"],
357
+ netId: ".R2 > .pin2 to .U1 > .IN3",
358
+ },
359
+ {
360
+ pinIds: ["R3.2", "U1.4"],
361
+ netId: ".R3 > .pin2 to .U1 > .IN4",
362
+ },
363
+ {
364
+ pinIds: ["R4.2", "U1.6"],
365
+ netId: ".R4 > .pin2 to .U1 > .IN6",
366
+ },
367
+ {
368
+ pinIds: ["R5.2", "U1.7"],
369
+ netId: ".R5 > .pin2 to .U1 > .IN7",
370
+ },
371
+ {
372
+ pinIds: ["R6.2", "U1.8"],
373
+ netId: ".R6 > .pin2 to .U1 > .IN8",
374
+ },
375
+ {
376
+ pinIds: ["R7.1", "U1.16"],
377
+ netId: ".R7 > .pin1 to .U1 > .OUT8",
378
+ },
379
+ {
380
+ pinIds: ["R8.1", "U1.14"],
381
+ netId: ".R8 > .pin1 to .U1 > .OUT6",
382
+ },
383
+ {
384
+ pinIds: ["R9.1", "U1.13"],
385
+ netId: ".R9 > .pin1 to .U1 > .OUT5",
386
+ },
387
+ {
388
+ pinIds: ["R10.1", "U1.12"],
389
+ netId: ".R10 > .pin1 to .U1 > .OUT4",
390
+ },
391
+ {
392
+ pinIds: ["R11.1", "U1.10"],
393
+ netId: ".R11 > .pin1 to .U1 > .OUT2",
394
+ },
395
+ {
396
+ pinIds: ["R12.1", "U1.9"],
397
+ netId: ".R12 > .pin1 to .U1 > .OUT1",
398
+ },
399
+ {
400
+ pinIds: ["R1.1", "R12.2"],
401
+ netId: ".R1 > .pin1 to .R12 > .pin2",
402
+ },
403
+ {
404
+ pinIds: ["R3.1", "R10.2"],
405
+ netId: ".R3 > .pin1 to .R10 > .pin2",
406
+ },
407
+ {
408
+ pinIds: ["R5.1", "R8.2"],
409
+ netId: ".R5 > .pin1 to .R8 > .pin2",
410
+ },
411
+ ],
412
+ netConnections: [],
413
+ availableNetLabelOrientations: {},
414
+ maxMspPairDistance: 2,
415
+ }
416
+
417
+ export default () => <PipelineDebugger inputProblem={inputProblem} />
@@ -0,0 +1,78 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import type { InputProblem } from "lib/types/InputProblem"
3
+
4
+ const inputProblem: InputProblem = {
5
+ chips: [
6
+ {
7
+ chipId: "schematic_component_0",
8
+ center: {
9
+ x: -2,
10
+ y: 0,
11
+ },
12
+ width: 0.8122621299999988,
13
+ height: 1.1038501999999986,
14
+ pins: [
15
+ {
16
+ pinId: "Q1_NPN.1",
17
+ x: -2.2855604555,
18
+ y: -0.5519250999999993,
19
+ },
20
+ {
21
+ pinId: "Q1_NPN.2",
22
+ x: -2.2855604555000015,
23
+ y: 0.5519250999999993,
24
+ },
25
+ {
26
+ pinId: "Q1_NPN.3",
27
+ x: -1.5938689350000006,
28
+ y: 0.004526300000001031,
29
+ },
30
+ ],
31
+ },
32
+ {
33
+ chipId: "schematic_component_1",
34
+ center: {
35
+ x: 3.5,
36
+ y: 0,
37
+ },
38
+ width: 0.8122621299999988,
39
+ height: 1.1038501999999986,
40
+ pins: [
41
+ {
42
+ pinId: "Q2_PNP.1",
43
+ x: 3.2144395445,
44
+ y: -0.5519250999999993,
45
+ },
46
+ {
47
+ pinId: "Q2_PNP.2",
48
+ x: 3.2144395444999985,
49
+ y: 0.5519250999999993,
50
+ },
51
+ {
52
+ pinId: "Q2_PNP.3",
53
+ x: 3.9061310649999994,
54
+ y: 0.004526300000001031,
55
+ },
56
+ ],
57
+ },
58
+ ],
59
+ directConnections: [],
60
+ netConnections: [
61
+ {
62
+ netId: "collector",
63
+ pinIds: ["Q1_NPN.1", "Q2_PNP.1"],
64
+ },
65
+ {
66
+ netId: "emitter",
67
+ pinIds: ["Q1_NPN.2", "Q2_PNP.2"],
68
+ },
69
+ {
70
+ netId: "base",
71
+ pinIds: ["Q1_NPN.3", "Q2_PNP.3"],
72
+ },
73
+ ],
74
+ availableNetLabelOrientations: {},
75
+ maxMspPairDistance: 2,
76
+ }
77
+
78
+ export default () => <PipelineDebugger inputProblem={inputProblem} />
@@ -30,7 +30,7 @@ test.skip("generateElbowVariants - simple horizontal segment", () => {
30
30
  test("generateElbowVariants - no movable segments", () => {
31
31
  const baseElbow: Point[] = [
32
32
  { x: 0, y: 0 },
33
- { x: 1, y: 1 },
33
+ { x: 1, y: 0 },
34
34
  ]
35
35
 
36
36
  const guidelines: Guideline[] = [
@@ -0,0 +1,92 @@
1
+ import { MspConnectionPairSolver } from "lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver"
2
+ import { test, expect } from "bun:test"
3
+
4
+ test("MspConnectionPairSolver should solve problem correctly", () => {
5
+ const input = {
6
+ inputProblem: {
7
+ chips: [
8
+ {
9
+ chipId: "schematic_component_0",
10
+ center: {
11
+ x: -2,
12
+ y: 0,
13
+ },
14
+ width: 0.8122621299999988,
15
+ height: 1.1038501999999986,
16
+ pins: [
17
+ {
18
+ pinId: "Q1_NPN.1",
19
+ x: -2.2855604555,
20
+ y: -0.5519250999999993,
21
+ },
22
+ {
23
+ pinId: "Q1_NPN.2",
24
+ x: -2.2855604555000015,
25
+ y: 0.5519250999999993,
26
+ },
27
+ {
28
+ pinId: "Q1_NPN.3",
29
+ x: -1.5938689350000006,
30
+ y: 0.004526300000001031,
31
+ },
32
+ ],
33
+ },
34
+ {
35
+ chipId: "schematic_component_1",
36
+ center: {
37
+ x: 3.5,
38
+ y: 0,
39
+ },
40
+ width: 0.8122621299999988,
41
+ height: 1.1038501999999986,
42
+ pins: [
43
+ {
44
+ pinId: "Q2_PNP.1",
45
+ x: 3.2144395445,
46
+ y: -0.5519250999999993,
47
+ },
48
+ {
49
+ pinId: "Q2_PNP.2",
50
+ x: 3.2144395444999985,
51
+ y: 0.5519250999999993,
52
+ },
53
+ {
54
+ pinId: "Q2_PNP.3",
55
+ x: 3.9061310649999994,
56
+ y: 0.004526300000001031,
57
+ },
58
+ ],
59
+ },
60
+ ],
61
+ directConnections: [],
62
+ netConnections: [
63
+ {
64
+ netId: "collector",
65
+ pinIds: ["Q1_NPN.1", "Q2_PNP.1"],
66
+ },
67
+ {
68
+ netId: "emitter",
69
+ pinIds: ["Q1_NPN.2", "Q2_PNP.2"],
70
+ },
71
+ {
72
+ netId: "base",
73
+ pinIds: ["Q1_NPN.3", "Q2_PNP.3"],
74
+ },
75
+ ],
76
+ availableNetLabelOrientations: {},
77
+ maxMspPairDistance: 2,
78
+ },
79
+ }
80
+
81
+ const solver = new MspConnectionPairSolver(input as any)
82
+ solver.solve()
83
+
84
+ for (const { pins } of solver.mspConnectionPairs) {
85
+ const [pin1, pin2] = pins
86
+ const dist = Math.sqrt((pin1.x - pin2.x) ** 2 + (pin1.y - pin2.y) ** 2)
87
+ expect(dist).toBeLessThan(input.inputProblem.maxMspPairDistance)
88
+ }
89
+
90
+ // Add more specific assertions based on expected output
91
+ // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
92
+ })