@tscircuit/capacity-autorouter 0.0.85 → 0.0.86
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/dist/index.d.ts +19 -1
- package/dist/index.js +116 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1732,6 +1732,22 @@ declare class CapacityMeshEdgeSolver2_NodeTreeOptimization extends CapacityMeshE
|
|
|
1732
1732
|
_step(): void;
|
|
1733
1733
|
}
|
|
1734
1734
|
|
|
1735
|
+
declare class DeadEndSolver extends BaseSolver {
|
|
1736
|
+
removedNodeIds: Set<string>;
|
|
1737
|
+
private targetNodeIds;
|
|
1738
|
+
private leaves;
|
|
1739
|
+
private leavesIndex;
|
|
1740
|
+
private adjacencyList;
|
|
1741
|
+
private nodes;
|
|
1742
|
+
private edges;
|
|
1743
|
+
constructor({ nodes, edges, }: {
|
|
1744
|
+
nodes: CapacityMeshNode[];
|
|
1745
|
+
edges: CapacityMeshEdge[];
|
|
1746
|
+
});
|
|
1747
|
+
_step(): void;
|
|
1748
|
+
visualize(): GraphicsObject;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1735
1751
|
interface Point {
|
|
1736
1752
|
x: number;
|
|
1737
1753
|
y: number;
|
|
@@ -1871,6 +1887,7 @@ declare class AutoroutingPipelineSolver extends BaseSolver {
|
|
|
1871
1887
|
highDensityStitchSolver?: MultipleHighDensityRouteStitchSolver;
|
|
1872
1888
|
singleLayerNodeMerger?: SingleLayerNodeMergerSolver;
|
|
1873
1889
|
strawSolver?: StrawSolver;
|
|
1890
|
+
deadEndSolver?: DeadEndSolver;
|
|
1874
1891
|
uselessViaRemovalSolver1?: UselessViaRemovalSolver;
|
|
1875
1892
|
uselessViaRemovalSolver2?: UselessViaRemovalSolver;
|
|
1876
1893
|
multiSimplifiedPathSolver1?: MultiSimplifiedPathSolver;
|
|
@@ -1882,8 +1899,9 @@ declare class AutoroutingPipelineSolver extends BaseSolver {
|
|
|
1882
1899
|
connMap: ConnectivityMap;
|
|
1883
1900
|
srjWithPointPairs?: SimpleRouteJson;
|
|
1884
1901
|
capacityNodes: CapacityMeshNode[] | null;
|
|
1902
|
+
capacityEdges: CapacityMeshEdge[] | null;
|
|
1885
1903
|
cacheProvider: CacheProvider | null;
|
|
1886
|
-
pipelineDef: (PipelineStep<typeof NetToPointPairsSolver> | PipelineStep<typeof CapacityMeshNodeSolver2_NodeUnderObstacle> | PipelineStep<typeof SingleLayerNodeMergerSolver> | PipelineStep<typeof StrawSolver> | PipelineStep<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep<typeof CapacityPathingGreedySolver> | PipelineStep<typeof CapacityPathingMultiSectionSolver> | PipelineStep<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep<typeof CapacitySegmentToPointSolver> | PipelineStep<typeof UnravelMultiSectionSolver> | PipelineStep<typeof HighDensitySolver> | PipelineStep<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep<typeof UselessViaRemovalSolver> | PipelineStep<typeof MultiSimplifiedPathSolver>)[];
|
|
1904
|
+
pipelineDef: (PipelineStep<typeof NetToPointPairsSolver> | PipelineStep<typeof CapacityMeshNodeSolver2_NodeUnderObstacle> | PipelineStep<typeof SingleLayerNodeMergerSolver> | PipelineStep<typeof StrawSolver> | PipelineStep<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep<typeof DeadEndSolver> | PipelineStep<typeof CapacityPathingGreedySolver> | PipelineStep<typeof CapacityPathingMultiSectionSolver> | PipelineStep<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep<typeof CapacitySegmentToPointSolver> | PipelineStep<typeof UnravelMultiSectionSolver> | PipelineStep<typeof HighDensitySolver> | PipelineStep<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep<typeof UselessViaRemovalSolver> | PipelineStep<typeof MultiSimplifiedPathSolver>)[];
|
|
1887
1905
|
constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions);
|
|
1888
1906
|
currentPipelineStepIndex: number;
|
|
1889
1907
|
_step(): void;
|
package/dist/index.js
CHANGED
|
@@ -15801,6 +15801,93 @@ var CapacityMeshEdgeSolver2_NodeTreeOptimization = class extends CapacityMeshEdg
|
|
|
15801
15801
|
}
|
|
15802
15802
|
};
|
|
15803
15803
|
|
|
15804
|
+
// lib/solvers/DeadEndSolver/DeadEndSolver.ts
|
|
15805
|
+
var DeadEndSolver = class extends BaseSolver {
|
|
15806
|
+
removedNodeIds;
|
|
15807
|
+
targetNodeIds;
|
|
15808
|
+
leaves;
|
|
15809
|
+
leavesIndex;
|
|
15810
|
+
adjacencyList;
|
|
15811
|
+
// Store the nodes and edges just for visualization purposes
|
|
15812
|
+
nodes;
|
|
15813
|
+
edges;
|
|
15814
|
+
constructor({
|
|
15815
|
+
nodes,
|
|
15816
|
+
edges
|
|
15817
|
+
}) {
|
|
15818
|
+
super();
|
|
15819
|
+
this.MAX_ITERATIONS = nodes.length;
|
|
15820
|
+
this.nodes = nodes;
|
|
15821
|
+
this.edges = edges;
|
|
15822
|
+
this.removedNodeIds = /* @__PURE__ */ new Set();
|
|
15823
|
+
this.targetNodeIds = new Set(
|
|
15824
|
+
nodes.filter((n) => n._containsTarget).map((n) => n.capacityMeshNodeId)
|
|
15825
|
+
);
|
|
15826
|
+
this.adjacencyList = new Map(
|
|
15827
|
+
nodes.map(({ capacityMeshNodeId }) => [capacityMeshNodeId, /* @__PURE__ */ new Set()])
|
|
15828
|
+
);
|
|
15829
|
+
for (const {
|
|
15830
|
+
nodeIds: [u, v]
|
|
15831
|
+
} of edges) {
|
|
15832
|
+
this.adjacencyList.get(u).add(v);
|
|
15833
|
+
this.adjacencyList.get(v).add(u);
|
|
15834
|
+
}
|
|
15835
|
+
this.leavesIndex = 0;
|
|
15836
|
+
this.leaves = [...this.adjacencyList.entries()].filter(([_, neighbours]) => neighbours.size === 1).filter(([nodeId, _]) => !this.targetNodeIds.has(nodeId)).map(([nodeId, _]) => nodeId);
|
|
15837
|
+
}
|
|
15838
|
+
_step() {
|
|
15839
|
+
if (this.leavesIndex === this.leaves.length) {
|
|
15840
|
+
this.solved = true;
|
|
15841
|
+
return;
|
|
15842
|
+
}
|
|
15843
|
+
const leaf = this.leaves[this.leavesIndex];
|
|
15844
|
+
const [neighbor] = this.adjacencyList.get(leaf);
|
|
15845
|
+
const neighborsOfLeafNeighbor = this.adjacencyList.get(neighbor);
|
|
15846
|
+
neighborsOfLeafNeighbor.delete(leaf);
|
|
15847
|
+
this.removedNodeIds.add(leaf);
|
|
15848
|
+
if (neighborsOfLeafNeighbor.size === 1 && !this.targetNodeIds.has(neighbor)) {
|
|
15849
|
+
this.leaves.push(neighbor);
|
|
15850
|
+
}
|
|
15851
|
+
this.leavesIndex += 1;
|
|
15852
|
+
if (this.leavesIndex === this.leaves.length) {
|
|
15853
|
+
this.solved = true;
|
|
15854
|
+
}
|
|
15855
|
+
}
|
|
15856
|
+
visualize() {
|
|
15857
|
+
const graphics = {
|
|
15858
|
+
lines: [],
|
|
15859
|
+
points: [],
|
|
15860
|
+
rects: [],
|
|
15861
|
+
circles: []
|
|
15862
|
+
};
|
|
15863
|
+
for (const edge of this.edges) {
|
|
15864
|
+
if (!edge.nodeIds.some((nodeId) => this.removedNodeIds.has(nodeId))) {
|
|
15865
|
+
continue;
|
|
15866
|
+
}
|
|
15867
|
+
const [node1, node2] = edge.nodeIds.map((nodeId) => {
|
|
15868
|
+
return this.nodes.find((node) => node.capacityMeshNodeId === nodeId);
|
|
15869
|
+
});
|
|
15870
|
+
if (node1?.center && node2?.center) {
|
|
15871
|
+
const lowestZ1 = Math.min(...node1.availableZ);
|
|
15872
|
+
const lowestZ2 = Math.min(...node2.availableZ);
|
|
15873
|
+
const nodeCenter1Adj = {
|
|
15874
|
+
x: node1.center.x + lowestZ1 * node1.width * 0.05,
|
|
15875
|
+
y: node1.center.y - lowestZ1 * node1.width * 0.05
|
|
15876
|
+
};
|
|
15877
|
+
const nodeCenter2Adj = {
|
|
15878
|
+
x: node2.center.x + lowestZ2 * node2.width * 0.05,
|
|
15879
|
+
y: node2.center.y - lowestZ2 * node2.width * 0.05
|
|
15880
|
+
};
|
|
15881
|
+
graphics.lines.push({
|
|
15882
|
+
strokeColor: "black",
|
|
15883
|
+
points: [nodeCenter1Adj, nodeCenter2Adj]
|
|
15884
|
+
});
|
|
15885
|
+
}
|
|
15886
|
+
}
|
|
15887
|
+
return graphics;
|
|
15888
|
+
}
|
|
15889
|
+
};
|
|
15890
|
+
|
|
15804
15891
|
// lib/data-structures/HighDensityRouteSpatialIndex.ts
|
|
15805
15892
|
var getSegmentBounds2 = (segment) => {
|
|
15806
15893
|
return {
|
|
@@ -16409,6 +16496,7 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16409
16496
|
highDensityStitchSolver;
|
|
16410
16497
|
singleLayerNodeMerger;
|
|
16411
16498
|
strawSolver;
|
|
16499
|
+
deadEndSolver;
|
|
16412
16500
|
uselessViaRemovalSolver1;
|
|
16413
16501
|
uselessViaRemovalSolver2;
|
|
16414
16502
|
multiSimplifiedPathSolver1;
|
|
@@ -16420,6 +16508,7 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16420
16508
|
connMap;
|
|
16421
16509
|
srjWithPointPairs;
|
|
16422
16510
|
capacityNodes = null;
|
|
16511
|
+
capacityEdges = null;
|
|
16423
16512
|
cacheProvider = null;
|
|
16424
16513
|
pipelineDef = [
|
|
16425
16514
|
definePipelineStep(
|
|
@@ -16484,7 +16573,28 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16484
16573
|
definePipelineStep(
|
|
16485
16574
|
"edgeSolver",
|
|
16486
16575
|
CapacityMeshEdgeSolver2_NodeTreeOptimization,
|
|
16487
|
-
(cms) => [cms.capacityNodes]
|
|
16576
|
+
(cms) => [cms.capacityNodes],
|
|
16577
|
+
{
|
|
16578
|
+
onSolved: (cms) => {
|
|
16579
|
+
cms.capacityEdges = cms.edgeSolver?.edges;
|
|
16580
|
+
}
|
|
16581
|
+
}
|
|
16582
|
+
),
|
|
16583
|
+
definePipelineStep(
|
|
16584
|
+
"deadEndSolver",
|
|
16585
|
+
DeadEndSolver,
|
|
16586
|
+
(cms) => [{ nodes: cms.capacityNodes, edges: cms.capacityEdges }],
|
|
16587
|
+
{
|
|
16588
|
+
onSolved: (cms) => {
|
|
16589
|
+
const removedNodeIds = cms.deadEndSolver?.removedNodeIds;
|
|
16590
|
+
cms.capacityNodes = cms.capacityNodes.filter(
|
|
16591
|
+
(n) => !removedNodeIds.has(n.capacityMeshNodeId)
|
|
16592
|
+
);
|
|
16593
|
+
cms.capacityEdges = cms.capacityEdges.filter(
|
|
16594
|
+
(e) => e.nodeIds.every((nodeId) => !removedNodeIds.has(nodeId))
|
|
16595
|
+
);
|
|
16596
|
+
}
|
|
16597
|
+
}
|
|
16488
16598
|
),
|
|
16489
16599
|
definePipelineStep(
|
|
16490
16600
|
"initialPathingSolver",
|
|
@@ -16493,7 +16603,7 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16493
16603
|
{
|
|
16494
16604
|
simpleRouteJson: cms.srjWithPointPairs,
|
|
16495
16605
|
nodes: cms.capacityNodes,
|
|
16496
|
-
edges: cms.
|
|
16606
|
+
edges: cms.capacityEdges || [],
|
|
16497
16607
|
colorMap: cms.colorMap,
|
|
16498
16608
|
hyperParameters: {
|
|
16499
16609
|
MAX_CAPACITY_FACTOR: 1
|
|
@@ -16511,7 +16621,7 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16511
16621
|
initialPathingSolver: cms.initialPathingSolver,
|
|
16512
16622
|
simpleRouteJson: cms.srjWithPointPairs,
|
|
16513
16623
|
nodes: cms.capacityNodes,
|
|
16514
|
-
edges: cms.
|
|
16624
|
+
edges: cms.capacityEdges || [],
|
|
16515
16625
|
colorMap: cms.colorMap,
|
|
16516
16626
|
cacheProvider: cms.cacheProvider,
|
|
16517
16627
|
hyperParameters: {
|
|
@@ -16526,7 +16636,7 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16526
16636
|
(cms) => [
|
|
16527
16637
|
{
|
|
16528
16638
|
nodes: cms.capacityNodes,
|
|
16529
|
-
edges: cms.
|
|
16639
|
+
edges: cms.capacityEdges || [],
|
|
16530
16640
|
capacityPaths: cms.pathingOptimizer?.getCapacityPaths() || [],
|
|
16531
16641
|
colorMap: cms.colorMap
|
|
16532
16642
|
}
|
|
@@ -16687,6 +16797,7 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16687
16797
|
const singleLayerNodeMergerViz = this.singleLayerNodeMerger?.visualize();
|
|
16688
16798
|
const strawSolverViz = this.strawSolver?.visualize();
|
|
16689
16799
|
const edgeViz = this.edgeSolver?.visualize();
|
|
16800
|
+
const deadEndViz = this.deadEndSolver?.visualize();
|
|
16690
16801
|
const initialPathingViz = this.initialPathingSolver?.visualize();
|
|
16691
16802
|
const pathingOptimizerViz = this.pathingOptimizer?.visualize();
|
|
16692
16803
|
const edgeToPortSegmentViz = this.edgeToPortSegmentSolver?.visualize();
|
|
@@ -16743,6 +16854,7 @@ var AutoroutingPipelineSolver = class extends BaseSolver {
|
|
|
16743
16854
|
singleLayerNodeMergerViz,
|
|
16744
16855
|
strawSolverViz,
|
|
16745
16856
|
edgeViz,
|
|
16857
|
+
deadEndViz,
|
|
16746
16858
|
initialPathingViz,
|
|
16747
16859
|
pathingOptimizerViz,
|
|
16748
16860
|
edgeToPortSegmentViz,
|