diff --git a/lib/compat/loadSerializedHyperGraph.ts b/lib/compat/loadSerializedHyperGraph.ts index a76dded..758c0ff 100644 --- a/lib/compat/loadSerializedHyperGraph.ts +++ b/lib/compat/loadSerializedHyperGraph.ts @@ -33,6 +33,25 @@ const isFullObstacleRegion = ( return netId === undefined || netId === -1 } +const getParentObstacleIds = ( + region: SerializedHyperGraph["regions"][number], +): string[] => { + const parentObstacleIds = region.d?._parentObstacleIds + if (Array.isArray(parentObstacleIds)) { + return parentObstacleIds.filter( + (parentObstacleId): parentObstacleId is string => + typeof parentObstacleId === "string" && parentObstacleId.length > 0, + ) + } + + const parentObstacleId = region.d?.parentObstacleId + if (typeof parentObstacleId === "string" && parentObstacleId.length > 0) { + return [parentObstacleId] + } + + return [] +} + const filterObstacleRegions = (serializedHyperGraph: SerializedHyperGraph) => { const connectedRegionIds = new Set() for (const connection of serializedHyperGraph.connections ?? []) { @@ -40,12 +59,23 @@ const filterObstacleRegions = (serializedHyperGraph: SerializedHyperGraph) => { connectedRegionIds.add(connection.endRegionId) } + const preservedParentObstacleIds = new Set() + for (const region of serializedHyperGraph.regions) { + if (!connectedRegionIds.has(region.regionId)) continue + for (const parentObstacleId of getParentObstacleIds(region)) { + preservedParentObstacleIds.add(parentObstacleId) + } + } + const removedRegionIds = new Set( serializedHyperGraph.regions .filter( (region) => isFullObstacleRegion(region) && - !connectedRegionIds.has(region.regionId), + !connectedRegionIds.has(region.regionId) && + !getParentObstacleIds(region).some((parentObstacleId) => + preservedParentObstacleIds.has(parentObstacleId), + ), ) .map((region) => region.regionId), ) diff --git a/results/run001/sample014/logs.txt b/results/run001/sample014/logs.txt new file mode 100644 index 0000000..d623403 --- /dev/null +++ b/results/run001/sample014/logs.txt @@ -0,0 +1,25 @@ +sample=sample014 +circuitId=018 +status=failed +duration=0.001s + +error= +Error: Connection "source_trace_69" could not be mapped to route endpoints + at (/home/ohmx/Documents/tiny-hypergraph/lib/compat/loadSerializedHyperGraph.ts:454:17) + at forEach (native:1:11) + at loadSerializedHyperGraph (/home/ohmx/Documents/tiny-hypergraph/lib/compat/loadSerializedHyperGraph.ts:429:23) + at getConstructorParams (/home/ohmx/Documents/tiny-hypergraph/lib/section-solver/TinyHyperGraphSectionPipelineSolver.ts:495:39) + at _step (/home/ohmx/Documents/tiny-hypergraph/node_modules/@tscircuit/solver-utils/dist/index.js:151:48) + at step (/home/ohmx/Documents/tiny-hypergraph/node_modules/@tscircuit/solver-utils/dist/index.js:34:12) + at solve (/home/ohmx/Documents/tiny-hypergraph/node_modules/@tscircuit/solver-utils/dist/index.js:68:12) + at (/home/ohmx/Documents/tiny-hypergraph/scripts/benchmarking/benchmark.ts:295:22) + +snapshotError= +Error: Connection "source_trace_69" could not be mapped to route endpoints + at (/home/ohmx/Documents/tiny-hypergraph/lib/compat/loadSerializedHyperGraph.ts:454:17) + at forEach (native:1:11) + at loadSerializedHyperGraph (/home/ohmx/Documents/tiny-hypergraph/lib/compat/loadSerializedHyperGraph.ts:429:23) + at getInitialVisualizationSolver (/home/ohmx/Documents/tiny-hypergraph/lib/section-solver/TinyHyperGraphSectionPipelineSolver.ts:629:37) + at initialVisualize (/home/ohmx/Documents/tiny-hypergraph/lib/section-solver/TinyHyperGraphSectionPipelineSolver.ts:642:17) + at getSnapshotPng (/home/ohmx/Documents/tiny-hypergraph/scripts/benchmarking/benchmark.ts:256:22) + at (/home/ohmx/Documents/tiny-hypergraph/scripts/benchmarking/benchmark.ts:379:27) diff --git a/results/run001/sample076/logs.txt b/results/run001/sample076/logs.txt new file mode 100644 index 0000000..ad02648 --- /dev/null +++ b/results/run001/sample076/logs.txt @@ -0,0 +1,15 @@ +sample=sample076 +circuitId=162 +status=failed +duration=0.009s + +error= +Error: Route 18 is not a single ordered path from 1660 to 823 + at getOrderedRoutePath (/home/ohmx/Documents/tiny-hypergraph/lib/compat/convertToSerializedHyperGraph.ts:230:17) + at getSerializedSolvedRoute (/home/ohmx/Documents/tiny-hypergraph/lib/compat/convertToSerializedHyperGraph.ts:300:48) + at map (native:1:11) + at convertToSerializedHyperGraph (/home/ohmx/Documents/tiny-hypergraph/lib/compat/convertToSerializedHyperGraph.ts:408:49) + at _step (/home/ohmx/Documents/tiny-hypergraph/node_modules/@tscircuit/solver-utils/dist/index.js:137:45) + at step (/home/ohmx/Documents/tiny-hypergraph/node_modules/@tscircuit/solver-utils/dist/index.js:34:12) + at solve (/home/ohmx/Documents/tiny-hypergraph/node_modules/@tscircuit/solver-utils/dist/index.js:68:12) + at (/home/ohmx/Documents/tiny-hypergraph/scripts/benchmarking/benchmark.ts:295:22) diff --git a/results/run001/sample076/snapshot.png b/results/run001/sample076/snapshot.png new file mode 100644 index 0000000..d58af68 Binary files /dev/null and b/results/run001/sample076/snapshot.png differ