@tscircuit/schematic-trace-solver 0.0.48 → 0.0.50
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/README.md +1 -1
- package/dist/index.d.ts +128 -1
- package/dist/index.js +1450 -42
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +682 -0
- package/lib/solvers/AvailableNetOrientationSolver/constants.ts +6 -0
- package/lib/solvers/AvailableNetOrientationSolver/geometry.ts +192 -0
- package/lib/solvers/AvailableNetOrientationSolver/traces.ts +43 -0
- package/lib/solvers/AvailableNetOrientationSolver/types.ts +44 -0
- package/lib/solvers/AvailableNetOrientationSolver/visualize.ts +123 -0
- package/lib/solvers/Example28Solver/Example28Solver.ts +182 -0
- package/lib/solvers/Example28Solver/geometry.ts +246 -0
- package/lib/solvers/Example28Solver/labelMovement.ts +82 -0
- package/lib/solvers/Example28Solver/reroute.ts +368 -0
- package/lib/solvers/Example28Solver/types.ts +47 -0
- package/lib/solvers/Example28Solver/visualize.ts +96 -0
- package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +30 -0
- package/package.json +1 -1
- package/site/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2_01-example17-d1_1-u1_1.page.tsx +2 -0
- package/site/TraceCleanupSolver/TraceCleanupSolver.page.tsx +23 -0
- package/site/TraceLabelOverlapAvoidanceSolver/MergedNetLabelObstacles.page.tsx +18 -0
- package/site/TraceLabelOverlapAvoidanceSolver/OverlapAvoidanceStepSolver.page.tsx +24 -0
- package/site/TraceLabelOverlapAvoidanceSolver/SingleOverlapSolver.page.tsx +10 -0
- package/site/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver.page.tsx +146 -0
- package/site/TraceLabelOverlapAvoidanceSolver/renderComparisonView01.page.tsx +32 -0
- package/site/TraceLabelOverlapAvoidanceSolver/renderComparisonView02.page.tsx +32 -0
- package/site/TraceLabelOverlapAvoidanceSolver/renderComparisonView03.page.tsx +35 -0
- package/site/examples/example01.page.tsx +6 -0
- package/site/examples/example02.page.tsx +4 -180
- package/site/examples/example03.page.tsx +3 -212
- package/site/examples/example04.page.tsx +6 -0
- package/site/examples/example05.page.tsx +3 -179
- package/site/examples/example06.page.tsx +3 -57
- package/site/examples/example07.page.tsx +3 -132
- package/site/examples/example08.page.tsx +3 -91
- package/site/examples/example09.page.tsx +3 -414
- package/site/examples/example10.page.tsx +3 -75
- package/site/examples/example11.page.tsx +3 -116
- package/site/examples/example12.page.tsx +3 -94
- package/site/examples/example13.page.tsx +3 -216
- package/site/examples/example14.page.tsx +3 -207
- package/site/examples/example15.page.tsx +6 -0
- package/site/examples/example16.page.tsx +6 -0
- package/site/examples/example17.page.tsx +6 -0
- package/site/examples/example18.page.tsx +3 -178
- package/site/examples/example19.page.tsx +3 -166
- package/site/examples/example20.page.tsx +3 -100
- package/site/examples/example21.page.tsx +3 -174
- package/site/examples/example22.page.tsx +3 -105
- package/site/examples/example23.page.tsx +3 -134
- package/site/examples/example24.page.tsx +3 -125
- package/site/examples/example25.page.tsx +2 -0
- package/site/examples/example26.page.tsx +2 -0
- package/site/examples/example27.page.tsx +2 -0
- package/site/examples/example28.page.tsx +3 -58
- package/site/examples/example29.page.tsx +6 -0
- package/site/examples/example30.page.tsx +6 -0
- package/site/examples/example31.page.tsx +4 -0
- package/tests/assets/example01.json +109 -0
- package/tests/assets/example02.json +178 -0
- package/tests/assets/example03.json +210 -0
- package/tests/assets/example04.json +41 -0
- package/tests/assets/example05.json +175 -0
- package/tests/assets/example06.json +55 -0
- package/tests/assets/example07.json +130 -0
- package/tests/assets/example08.json +89 -0
- package/tests/assets/example09.json +412 -0
- package/tests/assets/example10.json +73 -0
- package/tests/assets/example11.json +114 -0
- package/tests/assets/example12.json +92 -0
- package/tests/assets/example13.json +214 -0
- package/tests/assets/example14.json +205 -0
- package/tests/assets/example15.json +618 -0
- package/tests/assets/example16.json +102 -0
- package/tests/assets/example17.json +160 -0
- package/tests/assets/example18.json +176 -0
- package/tests/assets/example19.json +164 -0
- package/tests/assets/example20.json +98 -0
- package/tests/assets/example21.json +172 -0
- package/tests/assets/example22.json +103 -0
- package/tests/assets/example23.json +132 -0
- package/tests/assets/example24.json +123 -0
- package/tests/assets/example25.json +146 -33
- package/tests/assets/example26.json +51 -1134
- package/tests/assets/example27.json +151 -91
- package/tests/assets/example28.json +56 -0
- package/tests/assets/example29.json +1206 -0
- package/tests/assets/example30.json +168 -0
- package/tests/assets/example31.json +46 -0
- package/tests/examples/__snapshots__/example01.snap.svg +12 -6
- package/tests/examples/__snapshots__/example02.snap.svg +16 -8
- package/tests/examples/__snapshots__/example03.snap.svg +36 -18
- package/tests/examples/__snapshots__/example04.snap.svg +8 -4
- package/tests/examples/__snapshots__/example05.snap.svg +4 -2
- package/tests/examples/__snapshots__/example06.snap.svg +4 -2
- package/tests/examples/__snapshots__/example07.snap.svg +20 -10
- package/tests/examples/__snapshots__/example08.snap.svg +16 -8
- package/tests/examples/__snapshots__/example09.snap.svg +80 -40
- package/tests/examples/__snapshots__/example10.snap.svg +16 -8
- package/tests/examples/__snapshots__/example11.snap.svg +24 -12
- package/tests/examples/__snapshots__/example12.snap.svg +41 -30
- package/tests/examples/__snapshots__/example13.snap.svg +38 -16
- package/tests/examples/__snapshots__/example14.snap.svg +121 -48
- package/tests/examples/__snapshots__/example15.snap.svg +36 -18
- package/tests/examples/__snapshots__/example16.snap.svg +41 -27
- package/tests/examples/__snapshots__/example17.snap.svg +16 -8
- package/tests/examples/__snapshots__/example18.snap.svg +20 -10
- package/tests/examples/__snapshots__/example19.snap.svg +16 -8
- package/tests/examples/__snapshots__/example20.snap.svg +45 -131
- package/tests/examples/__snapshots__/example21.snap.svg +93 -65
- package/tests/examples/__snapshots__/example22.snap.svg +43 -23
- package/tests/examples/__snapshots__/example23.snap.svg +62 -26
- package/tests/examples/__snapshots__/example24.snap.svg +50 -28
- package/tests/examples/__snapshots__/example25.snap.svg +175 -49
- package/tests/examples/__snapshots__/example26.snap.svg +16 -8
- package/tests/examples/__snapshots__/example27.snap.svg +24 -12
- package/tests/examples/__snapshots__/example28.snap.svg +24 -18
- package/tests/examples/__snapshots__/example29.snap.svg +184 -92
- package/tests/examples/__snapshots__/example30.snap.svg +48 -24
- package/tests/examples/__snapshots__/example31.snap.svg +88 -0
- package/tests/examples/example01.test.ts +2 -2
- package/tests/examples/example02.test.ts +2 -2
- package/tests/examples/example03.test.ts +2 -2
- package/tests/examples/example04.test.ts +2 -2
- package/tests/examples/example05.test.ts +2 -2
- package/tests/examples/example06.test.ts +2 -2
- package/tests/examples/example07.test.ts +2 -2
- package/tests/examples/example08.test.ts +2 -2
- package/tests/examples/example09.test.ts +2 -2
- package/tests/examples/example10.test.ts +2 -2
- package/tests/examples/{example11.test.tsx → example11.test.ts} +2 -2
- package/tests/examples/{example12.test.tsx → example12.test.ts} +2 -2
- package/tests/examples/{example13.test.tsx → example13.test.ts} +2 -2
- package/tests/examples/example14.test.ts +12 -0
- package/tests/examples/example15.test.ts +12 -0
- package/tests/examples/example16.test.ts +12 -0
- package/tests/examples/example17.test.ts +12 -0
- package/tests/examples/example18.test.ts +12 -0
- package/tests/examples/example19.test.ts +12 -0
- package/tests/examples/example20.test.ts +12 -0
- package/tests/examples/example21.test.ts +12 -0
- package/tests/examples/example22.test.ts +12 -0
- package/tests/examples/example23.test.ts +12 -0
- package/tests/examples/example24.test.ts +12 -0
- package/tests/examples/example25.test.ts +12 -0
- package/tests/examples/example26.test.ts +12 -0
- package/tests/examples/example27.test.ts +3 -232
- package/tests/examples/example28.test.ts +2 -2
- package/tests/examples/example29.test.ts +1 -2
- package/tests/examples/example30.test.ts +2 -2
- package/tests/examples/example31.test.ts +12 -0
- package/site/examples/example01-basic.page.tsx +0 -105
- package/site/examples/example04-single-symbol.page.tsx +0 -46
- package/site/examples/example15-rp2040-caps.page.tsx +0 -623
- package/site/examples/example16-core-repro51.page.tsx +0 -107
- package/site/examples/example17-straight-line-trace.page.tsx +0 -165
- package/tests/examples/example14.test.tsx +0 -11
- package/tests/examples/example15.test.tsx +0 -629
- package/tests/examples/example16.test.tsx +0 -113
- package/tests/examples/example17.test.tsx +0 -171
- package/tests/examples/example18.test.tsx +0 -187
- package/tests/examples/example19.test.tsx +0 -175
- package/tests/examples/example20.test.tsx +0 -190
- package/tests/examples/example21.test.tsx +0 -183
- package/tests/examples/example22.test.tsx +0 -109
- package/tests/examples/example23.test.tsx +0 -109
- package/tests/examples/example24.test.tsx +0 -114
- package/tests/examples/example25.test.tsx +0 -143
- package/tests/examples/example26.test.tsx +0 -134
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Point } from "@tscircuit/math-utils"
|
|
2
|
+
import type { NetLabelPlacement } from "lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver"
|
|
3
|
+
import type { getObstacleRects } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/rect"
|
|
4
|
+
import type { SolvedTracePath } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceLinesSolver"
|
|
5
|
+
import type { TraceLabelOverlap } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/detectTraceLabelOverlap"
|
|
6
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
7
|
+
|
|
8
|
+
export interface Example28SolverParams {
|
|
9
|
+
inputProblem: InputProblem
|
|
10
|
+
traces: SolvedTracePath[]
|
|
11
|
+
netLabelPlacements: NetLabelPlacement[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type TracePathScore = {
|
|
15
|
+
labelIntersections: number
|
|
16
|
+
labelHugDistance: number
|
|
17
|
+
traceIntersections: number
|
|
18
|
+
pathLength: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type SegmentOrientation = "horizontal" | "vertical"
|
|
22
|
+
|
|
23
|
+
export type PathSegment = {
|
|
24
|
+
start: Point
|
|
25
|
+
end: Point
|
|
26
|
+
orientation: SegmentOrientation
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type ChipObstacle = ReturnType<typeof getObstacleRects>[number]
|
|
30
|
+
|
|
31
|
+
export type RerouteCandidateResult = {
|
|
32
|
+
path: Point[]
|
|
33
|
+
score?: TracePathScore
|
|
34
|
+
status: "valid" | "duplicate" | "chip-collision"
|
|
35
|
+
selected: boolean
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type Example28VisualizationState = {
|
|
39
|
+
inputProblem: InputProblem
|
|
40
|
+
outputTraces: SolvedTracePath[]
|
|
41
|
+
outputNetLabelPlacements: NetLabelPlacement[]
|
|
42
|
+
solved: boolean
|
|
43
|
+
currentOverlap: TraceLabelOverlap | null
|
|
44
|
+
currentCandidateResults: RerouteCandidateResult[]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const EPS = 1e-9
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { GraphicsObject } from "graphics-debug"
|
|
2
|
+
import { visualizeInputProblem } from "lib/solvers/SchematicTracePipelineSolver/visualizeInputProblem"
|
|
3
|
+
import { getColorFromString } from "lib/utils/getColorFromString"
|
|
4
|
+
import type {
|
|
5
|
+
Example28VisualizationState,
|
|
6
|
+
RerouteCandidateResult,
|
|
7
|
+
} from "./types"
|
|
8
|
+
|
|
9
|
+
const CANDIDATE_SELECTED_COLOR = "blue"
|
|
10
|
+
const CANDIDATE_REJECTED_COLOR = "red"
|
|
11
|
+
|
|
12
|
+
export const visualizeExample28Solver = (
|
|
13
|
+
state: Example28VisualizationState,
|
|
14
|
+
): GraphicsObject => {
|
|
15
|
+
const graphics = visualizeInputProblem(state.inputProblem)
|
|
16
|
+
|
|
17
|
+
drawTraces(graphics, state)
|
|
18
|
+
drawNetLabels(graphics, state)
|
|
19
|
+
|
|
20
|
+
if (!state.solved) {
|
|
21
|
+
drawCurrentCandidates(graphics, state.currentCandidateResults)
|
|
22
|
+
drawCurrentOverlap(graphics, state)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return graphics
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const drawTraces = (
|
|
29
|
+
graphics: GraphicsObject,
|
|
30
|
+
state: Example28VisualizationState,
|
|
31
|
+
) => {
|
|
32
|
+
for (const trace of state.outputTraces) {
|
|
33
|
+
graphics.lines!.push({
|
|
34
|
+
points: trace.tracePath,
|
|
35
|
+
strokeColor: "purple",
|
|
36
|
+
} as any)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const drawNetLabels = (
|
|
41
|
+
graphics: GraphicsObject,
|
|
42
|
+
state: Example28VisualizationState,
|
|
43
|
+
) => {
|
|
44
|
+
for (const label of state.outputNetLabelPlacements) {
|
|
45
|
+
const color = getColorFromString(label.globalConnNetId, 0.35)
|
|
46
|
+
graphics.rects!.push({
|
|
47
|
+
center: label.center,
|
|
48
|
+
width: label.width,
|
|
49
|
+
height: label.height,
|
|
50
|
+
fill: color,
|
|
51
|
+
strokeColor: getColorFromString(label.globalConnNetId, 0.9),
|
|
52
|
+
label: `netId: ${label.netId}\nglobalConnNetId: ${label.globalConnNetId}`,
|
|
53
|
+
} as any)
|
|
54
|
+
graphics.points!.push({
|
|
55
|
+
...label.anchorPoint,
|
|
56
|
+
color: getColorFromString(label.globalConnNetId, 0.9),
|
|
57
|
+
label: `anchorPoint\norientation: ${label.orientation}`,
|
|
58
|
+
} as any)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const drawCurrentCandidates = (
|
|
63
|
+
graphics: GraphicsObject,
|
|
64
|
+
candidateResults: RerouteCandidateResult[],
|
|
65
|
+
) => {
|
|
66
|
+
for (const candidate of candidateResults) {
|
|
67
|
+
const scoreLabel = candidate.score
|
|
68
|
+
? `\nlabel intersections: ${candidate.score.labelIntersections}\ntrace intersections: ${candidate.score.traceIntersections}`
|
|
69
|
+
: ""
|
|
70
|
+
graphics.lines!.push({
|
|
71
|
+
points: candidate.path,
|
|
72
|
+
strokeColor: candidate.selected
|
|
73
|
+
? CANDIDATE_SELECTED_COLOR
|
|
74
|
+
: CANDIDATE_REJECTED_COLOR,
|
|
75
|
+
strokeDash: candidate.selected ? undefined : "4 2",
|
|
76
|
+
label: `${candidate.selected ? "selected" : candidate.status} reroute${scoreLabel}`,
|
|
77
|
+
} as any)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const drawCurrentOverlap = (
|
|
82
|
+
graphics: GraphicsObject,
|
|
83
|
+
state: Example28VisualizationState,
|
|
84
|
+
) => {
|
|
85
|
+
if (!state.currentOverlap) return
|
|
86
|
+
|
|
87
|
+
const label = state.currentOverlap.label
|
|
88
|
+
graphics.rects!.push({
|
|
89
|
+
center: label.center,
|
|
90
|
+
width: label.width,
|
|
91
|
+
height: label.height,
|
|
92
|
+
fill: "rgba(255, 0, 0, 0.2)",
|
|
93
|
+
strokeColor: CANDIDATE_REJECTED_COLOR,
|
|
94
|
+
label: `overlap target\n${label.netId ?? label.globalConnNetId}`,
|
|
95
|
+
} as any)
|
|
96
|
+
}
|
|
@@ -20,6 +20,8 @@ import { expandChipsToFitPins } from "./expandChipsToFitPins"
|
|
|
20
20
|
import { LongDistancePairSolver } from "../LongDistancePairSolver/LongDistancePairSolver"
|
|
21
21
|
import { MergedNetLabelObstacleSolver } from "../TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/LabelMergingSolver"
|
|
22
22
|
import { TraceCleanupSolver } from "../TraceCleanupSolver/TraceCleanupSolver"
|
|
23
|
+
import { Example28Solver } from "../Example28Solver/Example28Solver"
|
|
24
|
+
import { AvailableNetOrientationSolver } from "../AvailableNetOrientationSolver/AvailableNetOrientationSolver"
|
|
23
25
|
|
|
24
26
|
type PipelineStep<T extends new (...args: any[]) => BaseSolver> = {
|
|
25
27
|
solverName: string
|
|
@@ -69,6 +71,8 @@ export class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
69
71
|
labelMergingSolver?: MergedNetLabelObstacleSolver
|
|
70
72
|
traceLabelOverlapAvoidanceSolver?: TraceLabelOverlapAvoidanceSolver
|
|
71
73
|
traceCleanupSolver?: TraceCleanupSolver
|
|
74
|
+
example28Solver?: Example28Solver
|
|
75
|
+
availableNetOrientationSolver?: AvailableNetOrientationSolver
|
|
72
76
|
|
|
73
77
|
startTimeOfPhase: Record<string, number>
|
|
74
78
|
endTimeOfPhase: Record<string, number>
|
|
@@ -224,6 +228,32 @@ export class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
224
228
|
]
|
|
225
229
|
},
|
|
226
230
|
),
|
|
231
|
+
definePipelineStep("example28Solver", Example28Solver, (instance) => {
|
|
232
|
+
const traces =
|
|
233
|
+
instance.traceCleanupSolver?.getOutput().traces ??
|
|
234
|
+
instance.traceLabelOverlapAvoidanceSolver!.getOutput().traces
|
|
235
|
+
|
|
236
|
+
return [
|
|
237
|
+
{
|
|
238
|
+
inputProblem: instance.inputProblem,
|
|
239
|
+
traces,
|
|
240
|
+
netLabelPlacements:
|
|
241
|
+
instance.netLabelPlacementSolver!.netLabelPlacements,
|
|
242
|
+
},
|
|
243
|
+
]
|
|
244
|
+
}),
|
|
245
|
+
definePipelineStep(
|
|
246
|
+
"availableNetOrientationSolver",
|
|
247
|
+
AvailableNetOrientationSolver,
|
|
248
|
+
(instance) => [
|
|
249
|
+
{
|
|
250
|
+
inputProblem: instance.inputProblem,
|
|
251
|
+
traces: instance.example28Solver!.outputTraces,
|
|
252
|
+
netLabelPlacements:
|
|
253
|
+
instance.example28Solver!.outputNetLabelPlacements,
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
),
|
|
227
257
|
]
|
|
228
258
|
|
|
229
259
|
constructor(inputProblem: InputProblem) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { GenericSolverDebugger } from "site/components/GenericSolverDebugger"
|
|
3
|
+
import { TraceCleanupSolver } from "lib/solvers/TraceCleanupSolver/TraceCleanupSolver"
|
|
4
|
+
import inputData from "../../tests/assets/TraceCleanupSolver.test.input.json"
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const solver = useMemo(
|
|
8
|
+
() =>
|
|
9
|
+
new TraceCleanupSolver({
|
|
10
|
+
...inputData,
|
|
11
|
+
targetTraceIds: new Set(inputData.targetTraceIds),
|
|
12
|
+
mergedLabelNetIdMap: Object.fromEntries(
|
|
13
|
+
Object.entries(inputData.mergedLabelNetIdMap).map(([k, v]) => [
|
|
14
|
+
k,
|
|
15
|
+
new Set(v as any),
|
|
16
|
+
]),
|
|
17
|
+
),
|
|
18
|
+
} as any),
|
|
19
|
+
[],
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
return <GenericSolverDebugger solver={solver} />
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { GenericSolverDebugger } from "site/components/GenericSolverDebugger"
|
|
3
|
+
import { MergedNetLabelObstacleSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/LabelMergingSolver"
|
|
4
|
+
import inputData from "../../tests/assets/MergedNetLabelObstacles.test.input.json"
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const solver = useMemo(
|
|
8
|
+
() =>
|
|
9
|
+
new MergedNetLabelObstacleSolver({
|
|
10
|
+
netLabelPlacements: inputData.netLabelPlacements as any,
|
|
11
|
+
inputProblem: inputData.inputProblem as any,
|
|
12
|
+
traces: inputData.traces as any,
|
|
13
|
+
}),
|
|
14
|
+
[],
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
return <GenericSolverDebugger solver={solver} />
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { GenericSolverDebugger } from "site/components/GenericSolverDebugger"
|
|
3
|
+
import { OverlapAvoidanceStepSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/OverlapAvoidanceStepSolver"
|
|
4
|
+
import inputData from "../../tests/assets/OverlapAvoidanceStepSolver.test.input.json"
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const solver = useMemo(
|
|
8
|
+
() =>
|
|
9
|
+
new OverlapAvoidanceStepSolver({
|
|
10
|
+
inputProblem: inputData.problem as any,
|
|
11
|
+
traces: inputData.traces as any,
|
|
12
|
+
netLabelPlacements: inputData.netLabelPlacements as any,
|
|
13
|
+
mergedLabelNetIdMap: Object.fromEntries(
|
|
14
|
+
Object.entries(inputData.mergedLabelNetIdMap).map(([k, v]) => [
|
|
15
|
+
k,
|
|
16
|
+
new Set(v as any),
|
|
17
|
+
]),
|
|
18
|
+
),
|
|
19
|
+
} as any),
|
|
20
|
+
[],
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
return <GenericSolverDebugger solver={solver} />
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { GenericSolverDebugger } from "site/components/GenericSolverDebugger"
|
|
3
|
+
import { SingleOverlapSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/SingleOverlapSolver/SingleOverlapSolver"
|
|
4
|
+
import inputData from "../../tests/assets/SingleOverlapSolver.test.input.json"
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const solver = useMemo(() => new SingleOverlapSolver(inputData as any), [])
|
|
8
|
+
|
|
9
|
+
return <GenericSolverDebugger solver={solver} />
|
|
10
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { GenericSolverDebugger } from "site/components/GenericSolverDebugger"
|
|
3
|
+
import { TraceLabelOverlapAvoidanceSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver"
|
|
4
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
5
|
+
import testInput from "../../tests/assets/TraceLabelOverlapAvoidanceSolver.test.input.json"
|
|
6
|
+
|
|
7
|
+
const inputProblem: InputProblem = {
|
|
8
|
+
chips: [
|
|
9
|
+
{
|
|
10
|
+
chipId: "schematic_component_0",
|
|
11
|
+
center: { x: -5, y: 2 },
|
|
12
|
+
width: 0.6394553499999995,
|
|
13
|
+
height: 1.08,
|
|
14
|
+
pins: [
|
|
15
|
+
{ pinId: "V1.1", x: -5.005, y: 2.54 },
|
|
16
|
+
{ pinId: "V1.2", x: -4.995, y: 1.46 },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
chipId: "schematic_component_1",
|
|
21
|
+
center: { x: 0, y: 3 },
|
|
22
|
+
width: 1.16,
|
|
23
|
+
height: 0.46,
|
|
24
|
+
pins: [
|
|
25
|
+
{ pinId: "L1.1", x: -0.55, y: 2.98 },
|
|
26
|
+
{ pinId: "L1.2", x: 0.55, y: 2.97 },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
chipId: "schematic_component_2",
|
|
31
|
+
center: { x: 3, y: 3 },
|
|
32
|
+
width: 1.04,
|
|
33
|
+
height: 0.54,
|
|
34
|
+
pins: [
|
|
35
|
+
{ pinId: "D1.1", x: 2.48, y: 3 },
|
|
36
|
+
{ pinId: "D1.2", x: 3.52, y: 3 },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
chipId: "schematic_component_3",
|
|
41
|
+
center: { x: 3, y: 0 },
|
|
42
|
+
width: 0.5700000000000001,
|
|
43
|
+
height: 0.99,
|
|
44
|
+
pins: [
|
|
45
|
+
{ pinId: "C1.2", x: 3, y: -0.49500000000000005 },
|
|
46
|
+
{ pinId: "C1.1", x: 3, y: 0.495 },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
chipId: "schematic_component_4",
|
|
51
|
+
center: { x: 6, y: 0 },
|
|
52
|
+
width: 0.3194553499999995,
|
|
53
|
+
height: 1.1,
|
|
54
|
+
pins: [
|
|
55
|
+
{ pinId: "R1.1", x: 6, y: 0.5499999999999999 },
|
|
56
|
+
{ pinId: "R1.2", x: 6, y: -0.55 },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
chipId: "schematic_component_5",
|
|
61
|
+
center: { x: -3, y: 0 },
|
|
62
|
+
width: 0.39624869999999945,
|
|
63
|
+
height: 0.8916016,
|
|
64
|
+
pins: [
|
|
65
|
+
{ pinId: "V2.1", x: -2.9999378, y: 0.4458008 },
|
|
66
|
+
{ pinId: "V2.2", x: -3.0000622, y: -0.4458008 },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
chipId: "schematic_component_6",
|
|
71
|
+
center: { x: 0, y: 0 },
|
|
72
|
+
width: 0.89,
|
|
73
|
+
height: 1.16,
|
|
74
|
+
pins: [
|
|
75
|
+
{ pinId: "M1.1", x: 0.3, y: 0.55 },
|
|
76
|
+
{ pinId: "M1.2", x: 0.31, y: -0.55 },
|
|
77
|
+
{ pinId: "M1.3", x: -0.42, y: -0.1 },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
directConnections: [
|
|
82
|
+
{
|
|
83
|
+
pinIds: ["V1.1", "L1.1"],
|
|
84
|
+
netId: ".V1 > .pin1 to .L1 > .pin1",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
pinIds: ["L1.2", "D1.1"],
|
|
88
|
+
netId: ".L1 > .pin2 to .D1 > .anode",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
pinIds: ["D1.2", "C1.1"],
|
|
92
|
+
netId: ".D1 > .cathode to .C1 > .pin1",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
pinIds: ["D1.2", "R1.1"],
|
|
96
|
+
netId: ".D1 > .cathode to .R1 > .pin1",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
pinIds: ["C1.2", "R1.2"],
|
|
100
|
+
netId: ".C1 > .pin2 to .R1 > .pin2",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
pinIds: ["R1.2", "V1.2"],
|
|
104
|
+
netId: ".R1 > .pin2 to .V1 > .pin2",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
pinIds: ["L1.2", "M1.1"],
|
|
108
|
+
netId: ".L1 > .pin2 to .M1 > .drain",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
pinIds: ["M1.2", "V1.2"],
|
|
112
|
+
netId: ".M1 > .source to .V1 > .pin2",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
pinIds: ["M1.3", "V2.1"],
|
|
116
|
+
netId: ".M1 > .gate to .V2 > .pin1",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
pinIds: ["V2.2", "V1.2"],
|
|
120
|
+
netId: ".V2 > .pin2 to .V1 > .pin2",
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
netConnections: [
|
|
124
|
+
{
|
|
125
|
+
netId: "GND",
|
|
126
|
+
pinIds: ["V1.2", "C1.2", "R1.2", "V2.2", "M1.2"],
|
|
127
|
+
netLabelWidth: 0.3,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
availableNetLabelOrientations: { GND: ["y-"] },
|
|
131
|
+
maxMspPairDistance: 2.4,
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default () => {
|
|
135
|
+
const solver = useMemo(
|
|
136
|
+
() =>
|
|
137
|
+
new TraceLabelOverlapAvoidanceSolver({
|
|
138
|
+
inputProblem: inputProblem as any,
|
|
139
|
+
netLabelPlacements: testInput.netLabelPlacements as any,
|
|
140
|
+
traces: testInput.traces as any,
|
|
141
|
+
}),
|
|
142
|
+
[],
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
return <GenericSolverDebugger solver={solver} />
|
|
146
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { InteractiveGraphics } from "graphics-debug/react"
|
|
3
|
+
import { stackGraphicsHorizontally } from "graphics-debug"
|
|
4
|
+
import { NetLabelPlacementSolver } from "lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver"
|
|
5
|
+
import { MergedNetLabelObstacleSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/LabelMergingSolver"
|
|
6
|
+
import inputData from "../../tests/assets/1.input.json"
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
const graphics = useMemo(() => {
|
|
10
|
+
const mergedNetLabelObstacleSolver = new MergedNetLabelObstacleSolver(
|
|
11
|
+
inputData.mergedNetLabelObstacleSolver as any,
|
|
12
|
+
)
|
|
13
|
+
const netLabelPlacementSolver = new NetLabelPlacementSolver(
|
|
14
|
+
inputData.netLabelPlacementSolver as any,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
mergedNetLabelObstacleSolver.solve()
|
|
18
|
+
netLabelPlacementSolver.solve()
|
|
19
|
+
|
|
20
|
+
return stackGraphicsHorizontally(
|
|
21
|
+
[
|
|
22
|
+
netLabelPlacementSolver.visualize(),
|
|
23
|
+
mergedNetLabelObstacleSolver.visualize(),
|
|
24
|
+
],
|
|
25
|
+
{
|
|
26
|
+
titles: ["NetLabelPlacementSolver", "MergedNetLabelObstacles"],
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
}, [])
|
|
30
|
+
|
|
31
|
+
return <InteractiveGraphics graphics={graphics} />
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { InteractiveGraphics } from "graphics-debug/react"
|
|
3
|
+
import { stackGraphicsHorizontally } from "graphics-debug"
|
|
4
|
+
import { MergedNetLabelObstacleSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/LabelMergingSolver"
|
|
5
|
+
import { SingleOverlapSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/SingleOverlapSolver/SingleOverlapSolver"
|
|
6
|
+
import inputData from "../../tests/assets/2.input.json"
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
const graphics = useMemo(() => {
|
|
10
|
+
const mergedNetLabelObstacleSolver = new MergedNetLabelObstacleSolver(
|
|
11
|
+
inputData.mergedNetLabelObstacleSolver as any,
|
|
12
|
+
)
|
|
13
|
+
const singleOverlapSolver = new SingleOverlapSolver(
|
|
14
|
+
inputData.singleOverlapSolver as any,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
mergedNetLabelObstacleSolver.solve()
|
|
18
|
+
singleOverlapSolver.solve()
|
|
19
|
+
|
|
20
|
+
return stackGraphicsHorizontally(
|
|
21
|
+
[
|
|
22
|
+
mergedNetLabelObstacleSolver.visualize(),
|
|
23
|
+
singleOverlapSolver.visualize(),
|
|
24
|
+
],
|
|
25
|
+
{
|
|
26
|
+
titles: ["MergedNetLabelObstaclesSolver", "SingleOverlapSolver"],
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
}, [])
|
|
30
|
+
|
|
31
|
+
return <InteractiveGraphics graphics={graphics} />
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { InteractiveGraphics } from "graphics-debug/react"
|
|
3
|
+
import { stackGraphicsHorizontally } from "graphics-debug"
|
|
4
|
+
import { TraceCleanupSolver } from "lib/solvers/TraceCleanupSolver/TraceCleanupSolver"
|
|
5
|
+
import { SingleOverlapSolver } from "lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/SingleOverlapSolver/SingleOverlapSolver"
|
|
6
|
+
import inputData from "../../tests/assets/3.input.json"
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
const graphics = useMemo(() => {
|
|
10
|
+
const traceCleanupSolver = new TraceCleanupSolver({
|
|
11
|
+
...inputData.traceCleanupSolver,
|
|
12
|
+
targetTraceIds: new Set(inputData.traceCleanupSolver.targetTraceIds),
|
|
13
|
+
mergedLabelNetIdMap: Object.fromEntries(
|
|
14
|
+
Object.entries(inputData.traceCleanupSolver.mergedLabelNetIdMap).map(
|
|
15
|
+
([key, value]) => [key, new Set(value as any)],
|
|
16
|
+
),
|
|
17
|
+
),
|
|
18
|
+
} as any)
|
|
19
|
+
const singleOverlapSolver = new SingleOverlapSolver(
|
|
20
|
+
inputData.singleOverlapSolver as any,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
traceCleanupSolver.solve()
|
|
24
|
+
singleOverlapSolver.solve()
|
|
25
|
+
|
|
26
|
+
return stackGraphicsHorizontally(
|
|
27
|
+
[singleOverlapSolver.visualize(), traceCleanupSolver.visualize()],
|
|
28
|
+
{
|
|
29
|
+
titles: ["SingleOverlapSolver", "TraceCleanupSolver"],
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
return <InteractiveGraphics graphics={graphics} />
|
|
35
|
+
}
|