Skip to content

Commit 834aa16

Browse files
committed
add test for failing case
1 parent 9512d02 commit 834aa16

File tree

4 files changed

+2631
-0
lines changed

4 files changed

+2631
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { AutoroutingPipelineDebugger } from "lib/testing/AutoroutingPipelineDebugger"
2+
import { AssignableViaAutoroutingPipelineSolver } from "lib/solvers/AssignableViaAutoroutingPipeline/AssignableViaAutoroutingPipelineSolver"
3+
import { SimpleRouteJson } from "lib/types"
4+
5+
export const simpleRouteJson: SimpleRouteJson = {
6+
bounds: {
7+
minX: -5,
8+
maxX: 5,
9+
minY: -5,
10+
maxY: 5,
11+
},
12+
obstacles: [
13+
{
14+
// @ts-ignore
15+
type: "oval",
16+
layers: ["top"],
17+
center: {
18+
x: 0,
19+
y: 4,
20+
},
21+
width: 1.2,
22+
height: 1.2,
23+
connectedTo: [
24+
"pcb_smtpad_0",
25+
"connectivity_net0",
26+
"source_trace_0",
27+
"source_port_0",
28+
"source_port_2",
29+
"pcb_smtpad_0",
30+
"pcb_port_0",
31+
"pcb_port_2",
32+
],
33+
},
34+
{
35+
// @ts-ignore
36+
type: "oval",
37+
layers: ["bottom"],
38+
center: {
39+
x: 0,
40+
y: -4,
41+
},
42+
width: 1.2,
43+
height: 1.2,
44+
connectedTo: [
45+
"pcb_smtpad_1",
46+
"connectivity_net3",
47+
"source_trace_1",
48+
"source_port_3",
49+
"source_port_1",
50+
"pcb_smtpad_1",
51+
"pcb_port_1",
52+
"pcb_port_3",
53+
],
54+
},
55+
{
56+
type: "rect",
57+
layers: ["bottom", "top"],
58+
center: {
59+
x: 0,
60+
y: 0,
61+
},
62+
connectedTo: [],
63+
width: 0.6,
64+
height: 0.6,
65+
},
66+
],
67+
connections: [
68+
{
69+
name: "source_trace_0",
70+
// @ts-ignore
71+
source_trace_id: "source_trace_0",
72+
pointsToConnect: [
73+
{
74+
x: 0,
75+
y: 4,
76+
layer: "top",
77+
pointId: "pcb_port_0",
78+
pcb_port_id: "pcb_port_0",
79+
},
80+
{
81+
x: 0,
82+
y: 0,
83+
layer: "top",
84+
pointId: "pcb_port_2",
85+
pcb_port_id: "pcb_port_2",
86+
},
87+
],
88+
},
89+
{
90+
name: "source_trace_1",
91+
// @ts-ignore
92+
source_trace_id: "source_trace_1",
93+
pointsToConnect: [
94+
{
95+
x: 0,
96+
y: 0,
97+
layer: "bottom",
98+
pointId: "pcb_port_3",
99+
pcb_port_id: "pcb_port_3",
100+
},
101+
{
102+
x: 0,
103+
y: -4,
104+
layer: "bottom",
105+
pointId: "pcb_port_1",
106+
pcb_port_id: "pcb_port_1",
107+
},
108+
],
109+
},
110+
],
111+
layerCount: 2,
112+
minTraceWidth: 0.15,
113+
}
114+
115+
export default () => (
116+
<AutoroutingPipelineDebugger
117+
createSolver={(srj, opts) =>
118+
new AssignableViaAutoroutingPipelineSolver(srj, opts)
119+
}
120+
srj={simpleRouteJson as any}
121+
/>
122+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { expect, test } from "bun:test"
2+
import { AssignableViaAutoroutingPipelineSolver } from "lib/solvers/AssignableViaAutoroutingPipeline/AssignableViaAutoroutingPipelineSolver"
3+
import type { SimpleRouteJson } from "lib/types"
4+
import { simpleRouteJson } from "../../../examples/unassigned-obstacles/AssignableViaAutoroutingPipelineSolver/AssignableViaAutoroutingPipelineSolver03.fixture"
5+
import { getSvgFromGraphicsObject } from "graphics-debug"
6+
7+
test("assignable via pipeline solves complex two-layer obstacle routing", () => {
8+
const solver = new AssignableViaAutoroutingPipelineSolver(simpleRouteJson)
9+
10+
const MAX_STEPS = 50_000
11+
for (let i = 0; i < MAX_STEPS; i++) {
12+
if (solver.initialPathingSolver?.solved || solver.failed) {
13+
break
14+
}
15+
solver.step()
16+
}
17+
18+
expect(
19+
getSvgFromGraphicsObject(solver.visualize(), {
20+
backgroundColor: "white",
21+
}),
22+
).toMatchSvgSnapshot(import.meta.path)
23+
expect(solver.failed).toBe(false)
24+
})

0 commit comments

Comments
 (0)