Skip to content
Closed
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
14 changes: 14 additions & 0 deletions lib/MinHeap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ export class MinHeap<T> {
this.items.length = 0
}

removeWhere(predicate: (item: T) => boolean): void {
let writeIndex = 0
for (const item of this.items) {
if (predicate(item)) continue
this.items[writeIndex] = item
writeIndex += 1
}
this.items.length = writeIndex

for (let index = (this.items.length >> 1) - 1; index >= 0; index--) {
this.siftDown(index)
}
}

queue(item: T) {
this.items.push(item)
this.siftUp(this.items.length - 1)
Expand Down
4 changes: 2 additions & 2 deletions lib/compat/convertToSerializedHyperGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ const getOrderedRoutePath = (
throw new Error(`Route ${routeId} has no solved segments`)
}

const startPortId = solver.problem.routeStartPort[routeId]
const endPortId = solver.problem.routeEndPort[routeId]
const startPortId = solver.state.solvedRouteStartPort[routeId]
const endPortId = solver.state.solvedRouteEndPort[routeId]
const segmentsByPort = new Map<
PortId,
Array<RouteSegment & { segmentIndex: number }>
Expand Down
2 changes: 2 additions & 0 deletions lib/compat/loadSerializedHyperGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,8 @@ export const loadSerializedHyperGraph = (
const solution: TinyHyperGraphSolution = {
solvedRoutePathSegments,
solvedRoutePathRegionIds,
solvedRouteStartPort: new Int32Array(routeStartPort),
solvedRouteEndPort: new Int32Array(routeEndPort),
}

return { topology, problem, solution }
Expand Down
18 changes: 14 additions & 4 deletions lib/computeRegionCost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ export const isKnownSingleLayerMask = (regionAvailableZMask: number) =>
regionAvailableZMask > 0 &&
(regionAvailableZMask & (regionAvailableZMask - 1)) === 0

export const computeEstimatedViaCount = (
numSameLayerIntersections: number,
numCrossLayerIntersections: number,
numEntryExitChanges: number,
) =>
numSameLayerIntersections * 2 +
numCrossLayerIntersections +
numEntryExitChanges

export const computeRegionCost = (
regionWidth: number,
regionHeight: number,
Expand Down Expand Up @@ -39,10 +48,11 @@ export const computeRegionCostForArea = (
regionAvailableZMask = 0,
minViaPadDiameter = DEFAULT_MIN_VIA_PAD_DIAMETER,
) => {
const estViasRequired =
numSameLayerIntersections * 2 +
numCrossLayerIntersections * 1 +
numEntryExitChanges * 1
const estViasRequired = computeEstimatedViaCount(
numSameLayerIntersections,
numCrossLayerIntersections,
numEntryExitChanges,
)
const viaSizeWithMargin = minViaPadDiameter + TRACE_VIA_MARGIN
const viaSizeWithMarginSq = viaSizeWithMargin ** 2

Expand Down
Loading
Loading