Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { expect, test } from "bun:test"
import missingPortPointsFixture from "../../fixtures/bug-reports/missing-port-points-001/missing-port-points-001.json"
import { AutoroutingPipelineSolver3_HgPortPointPathing } from "../../lib/autorouter-pipelines/AutoroutingPipeline2_PortPointPathing/AutoroutingPipelineSolver3_HgPortPointPathing"
import { SingleTargetNecessaryCrampedPortPointSolver } from "../../lib/solvers/NecessaryCrampedPortPointSolver/SingleTargetNecessaryCrampedPortPointSolver"
import type { SimpleRouteJson } from "../../lib/types"

test("necessary cramped port point solver does not explode duplicate candidates", () => {
const srj = missingPortPointsFixture as SimpleRouteJson
const singleTargetStats: Array<{
candidateCount: number
}> = []

const originalStep =
SingleTargetNecessaryCrampedPortPointSolver.prototype._step

SingleTargetNecessaryCrampedPortPointSolver.prototype._step =
function patchedStep() {
originalStep.call(this)

if (!this.solved) return

singleTargetStats.push({
// methods are private so need to convert to any
candidateCount: (this as any).resultExploredPortPoints.length,
})
}

const solver = new AutoroutingPipelineSolver3_HgPortPointPathing(srj)
solver.solve()

expect(solver.solved).toBe(true)
expect(solver.failed).toBe(false)

const maxCandidateCount = Math.max(
...singleTargetStats.map((stat) => stat.candidateCount),
)

expect(maxCandidateCount).toBeGreaterThan(500)
// currently we are at 14144
SingleTargetNecessaryCrampedPortPointSolver.prototype._step = originalStep
})
Loading