Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { getConnectivityMapsFromInputProblem } from "lib/solvers/MspConnectionPairSolver/getConnectivityMapFromInputProblem"
import {
getConnectivityMapsFromInputProblem,
isGlobalNetHandledByLabels,
} from "lib/solvers/MspConnectionPairSolver/getConnectivityMapFromInputProblem"
import type { MspConnectionPair } from "lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver"
import type {
InputProblem,
Expand Down Expand Up @@ -74,6 +77,8 @@ export class LongDistancePairSolver extends BaseSolver {
const addedPairKeys = new Set<string>()

for (const netId of Object.keys(netConnMap.netMap)) {
if (isGlobalNetHandledByLabels(inputProblem, netConnMap, netId)) continue

const allPinIdsInNet = netConnMap.getIdsConnectedToNet(netId)
if (allPinIdsInNet.length < 2) continue

Expand Down
17 changes: 14 additions & 3 deletions lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import type {
PinId,
} from "lib/types/InputProblem"
import { ConnectivityMap } from "connectivity-map"
import { getConnectivityMapsFromInputProblem } from "./getConnectivityMapFromInputProblem"
import {
getConnectivityMapsFromInputProblem,
isGlobalNetHandledByLabels,
} from "./getConnectivityMapFromInputProblem"
import { getOrthogonalMinimumSpanningTree } from "./getMspConnectionPairsFromPins"
import { doesPairCrossRestrictedCenterLines } from "./doesPairCrossRestrictedCenterLines"
import type { GraphicsObject } from "graphics-debug"
Expand Down Expand Up @@ -75,7 +78,12 @@ export class MspConnectionPairSolver extends BaseSolver {
}
}

this.queuedDcNetIds = Object.keys(netConnMap.netMap)
const directConnNetIds = new Set(Object.keys(directConnMap.netMap))
this.queuedDcNetIds = Object.keys(netConnMap.netMap).filter(
(netId) =>
directConnNetIds.has(netId) ||
!isGlobalNetHandledByLabels(inputProblem, netConnMap, netId),
)
}

override getConstructorParams(): ConstructorParameters<
Expand All @@ -94,7 +102,10 @@ export class MspConnectionPairSolver extends BaseSolver {

const dcNetId = this.queuedDcNetIds.shift()!

const allIds = this.globalConnMap.getIdsConnectedToNet(dcNetId) as string[]
const routeConnMap = this.dcConnMap.netMap[dcNetId]
? this.dcConnMap
: this.globalConnMap
const allIds = routeConnMap.getIdsConnectedToNet(dcNetId) as string[]
const directlyConnectedPins = allIds.filter((id) => !!this.pinMap[id])

if (directlyConnectedPins.length <= 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import { ConnectivityMap } from "connectivity-map"
import type { InputProblem } from "lib/types/InputProblem"

export const getNetConnectionIdsWithLabelOrientations = (
inputProblem: InputProblem,
): Set<string> => {
const netIds = new Set<string>()
for (const netConn of inputProblem.netConnections) {
if (inputProblem.availableNetLabelOrientations[netConn.netId]?.length) {
netIds.add(netConn.netId)
}
}
return netIds
}

export const isGlobalNetHandledByLabels = (
inputProblem: InputProblem,
netConnMap: ConnectivityMap,
netId: string,
): boolean => {
const netIdsWithLabels =
getNetConnectionIdsWithLabelOrientations(inputProblem)
if (netIdsWithLabels.has(netId)) return true

const allIds = netConnMap.getIdsConnectedToNet(netId) as string[]
return allIds.some((id) => netIdsWithLabels.has(id))
}

export const getConnectivityMapsFromInputProblem = (
inputProblem: InputProblem,
): { directConnMap: ConnectivityMap; netConnMap: ConnectivityMap } => {
Expand All @@ -14,7 +39,14 @@ export const getConnectivityMapsFromInputProblem = (
])
}

const netConnMap = new ConnectivityMap(directConnMap.netMap)
const netConnMap = new ConnectivityMap(
Object.fromEntries(
Object.entries(directConnMap.netMap).map(([netId, ids]) => [
netId,
[...ids],
]),
),
)

for (const netConn of inputProblem.netConnections) {
netConnMap.addConnections([[netConn.netId, ...netConn.pinIds]])
Expand Down
75 changes: 40 additions & 35 deletions tests/examples/__snapshots__/example01.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading