@tscircuit/schematic-trace-solver 0.0.11 → 0.0.12

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/dist/index.js CHANGED
@@ -5264,11 +5264,13 @@ var ConnectivityMap = class {
5264
5264
  var getConnectivityMapsFromInputProblem = (inputProblem) => {
5265
5265
  const directConnMap = new ConnectivityMap({});
5266
5266
  for (const directConn of inputProblem.directConnections) {
5267
- directConnMap.addConnections([directConn.pinIds]);
5267
+ directConnMap.addConnections([
5268
+ directConn.netId ? [directConn.netId, ...directConn.pinIds] : directConn.pinIds
5269
+ ]);
5268
5270
  }
5269
5271
  const netConnMap = new ConnectivityMap(directConnMap.netMap);
5270
5272
  for (const netConn of inputProblem.netConnections) {
5271
- netConnMap.addConnections([netConn.pinIds]);
5273
+ netConnMap.addConnections([[netConn.netId, ...netConn.pinIds]]);
5272
5274
  }
5273
5275
  return { directConnMap, netConnMap };
5274
5276
  };
@@ -5512,7 +5514,7 @@ var MspConnectionPairSolver = class extends BaseSolver {
5512
5514
  return;
5513
5515
  }
5514
5516
  const msp = getOrthogonalMinimumSpanningTree(
5515
- directlyConnectedPins.map((p) => this.pinMap[p]),
5517
+ directlyConnectedPins.map((p) => this.pinMap[p]).filter(Boolean),
5516
5518
  { maxDistance: this.maxMspPairDistance }
5517
5519
  );
5518
5520
  for (const [pin1, pin2] of msp) {
@@ -113,7 +113,7 @@ export class MspConnectionPairSolver extends BaseSolver {
113
113
  // There are more than 3 pins, so we need to run MSP to find the best pairs
114
114
 
115
115
  const msp = getOrthogonalMinimumSpanningTree(
116
- directlyConnectedPins.map((p) => this.pinMap[p]!),
116
+ directlyConnectedPins.map((p) => this.pinMap[p]!).filter(Boolean),
117
117
  { maxDistance: this.maxMspPairDistance },
118
118
  )
119
119
 
@@ -7,13 +7,17 @@ export const getConnectivityMapsFromInputProblem = (
7
7
  const directConnMap = new ConnectivityMap({})
8
8
 
9
9
  for (const directConn of inputProblem.directConnections) {
10
- directConnMap.addConnections([directConn.pinIds])
10
+ directConnMap.addConnections([
11
+ directConn.netId
12
+ ? [directConn.netId, ...directConn.pinIds]
13
+ : directConn.pinIds,
14
+ ])
11
15
  }
12
16
 
13
17
  const netConnMap = new ConnectivityMap(directConnMap.netMap)
14
18
 
15
19
  for (const netConn of inputProblem.netConnections) {
16
- netConnMap.addConnections([netConn.pinIds])
20
+ netConnMap.addConnections([[netConn.netId, ...netConn.pinIds]])
17
21
  }
18
22
 
19
23
  return { directConnMap, netConnMap }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/schematic-trace-solver",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.11",
4
+ "version": "0.0.12",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "cosmos",
@@ -0,0 +1,111 @@
1
+ import type { InputProblem } from "lib/types/InputProblem"
2
+ import { test, expect } from "bun:test"
3
+ import { SchematicTracePipelineSolver } from "lib/index"
4
+
5
+ const inputProblem: InputProblem = {
6
+ chips: [
7
+ {
8
+ chipId: "U1",
9
+ center: { x: 0, y: 0 },
10
+ width: 1.6,
11
+ height: 0.6,
12
+ pins: [
13
+ {
14
+ pinId: "U1.1",
15
+ x: -0.8,
16
+ y: 0.2,
17
+ },
18
+ {
19
+ pinId: "U1.2",
20
+ x: -0.8,
21
+ y: 0,
22
+ },
23
+ {
24
+ pinId: "U1.3",
25
+ x: -0.8,
26
+ y: -0.2,
27
+ },
28
+ {
29
+ pinId: "U1.4",
30
+ x: 0.8,
31
+ y: -0.2,
32
+ },
33
+ {
34
+ pinId: "U1.5",
35
+ x: 0.8,
36
+ y: 0,
37
+ },
38
+ {
39
+ pinId: "U1.6",
40
+ x: 0.8,
41
+ y: 0.2,
42
+ },
43
+ ],
44
+ },
45
+ {
46
+ chipId: "C1",
47
+ center: { x: -2, y: 0 },
48
+ width: 0.5,
49
+ height: 1,
50
+ pins: [
51
+ {
52
+ pinId: "C1.1",
53
+ x: -2,
54
+ y: 0.5,
55
+ },
56
+ {
57
+ pinId: "C1.2",
58
+ x: -2,
59
+ y: -0.5,
60
+ },
61
+ ],
62
+ },
63
+ {
64
+ chipId: "C2",
65
+ center: { x: -4, y: 0 },
66
+ width: 0.5,
67
+ height: 1,
68
+ pins: [
69
+ {
70
+ pinId: "C2.1",
71
+ x: -4,
72
+ y: 0.5,
73
+ },
74
+ {
75
+ pinId: "C2.2",
76
+ x: -4,
77
+ y: -0.5,
78
+ },
79
+ ],
80
+ },
81
+ ],
82
+ directConnections: [
83
+ {
84
+ pinIds: ["U1.1", "C1.1"],
85
+ netId: "VCC",
86
+ },
87
+ {
88
+ pinIds: ["U1.2", "C2.1"],
89
+ netId: "EN",
90
+ },
91
+ ],
92
+ netConnections: [
93
+ {
94
+ pinIds: ["U1.3", "C2.2", "C1.2"],
95
+ netId: "GND",
96
+ },
97
+ ],
98
+ availableNetLabelOrientations: {
99
+ VCC: ["y+"],
100
+ EN: ["x+", "x-"],
101
+ GND: ["y-"],
102
+ },
103
+ maxMspPairDistance: 2,
104
+ }
105
+
106
+ test("SchematicTracePipelineSolver_repro01", () => {
107
+ const solver = new SchematicTracePipelineSolver(inputProblem)
108
+ solver.solve()
109
+
110
+ // console.log(solver.schematicTraceLinesSolver!.solvedTracePaths)
111
+ })