@tscircuit/capacity-autorouter 0.0.53 → 0.0.55

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 CHANGED
@@ -117,22 +117,34 @@ declare class BaseSolver {
117
117
  declare class CapacityMeshEdgeSolver extends BaseSolver {
118
118
  nodes: CapacityMeshNode[];
119
119
  edges: Array<CapacityMeshEdge>;
120
+ /** Only used for visualization, dynamically instantiated if necessary */
121
+ nodeMap?: Map<CapacityMeshNodeId, CapacityMeshNode>;
120
122
  constructor(nodes: CapacityMeshNode[]);
121
123
  getNextCapacityMeshEdgeId(): string;
122
- step(): void;
124
+ _step(): void;
123
125
  handleTargetNodes(): void;
124
126
  doNodesHaveSharedLayer(node1: CapacityMeshNode, node2: CapacityMeshNode): boolean;
125
127
  visualize(): GraphicsObject;
126
128
  }
127
129
 
128
- type BucketCoordinate$1 = `${number}x${number}`;
130
+ /**
131
+ * ObstacleTree wraps different spatial index implementations:
132
+ * - 'native': original spatial-hash grid
133
+ * - 'rbush': dynamic R-tree via rbush
134
+ * - 'flatbush': static index via flatbush
135
+ */
129
136
  declare class ObstacleSpatialHashIndex {
130
- obstacles: Obstacle[];
131
- buckets: Map<BucketCoordinate$1, [Obstacle, number][]>;
132
- CELL_SIZE: number;
133
- constructor(obstacles: Obstacle[]);
134
- getBucketKey(x: number, y: number): BucketCoordinate$1;
135
- getNodesInArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
137
+ private idx;
138
+ private storage;
139
+ constructor(implementation?: "native" | "rbush" | "flatbush", obstacles?: Obstacle[]);
140
+ insert(o: Obstacle): void;
141
+ search(bbox: {
142
+ minX: number;
143
+ minY: number;
144
+ maxX: number;
145
+ maxY: number;
146
+ }): Obstacle[];
147
+ searchArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
136
148
  }
137
149
 
138
150
  interface Target$1 {
@@ -297,6 +309,7 @@ type NodeWithPortPoints = {
297
309
  width: number;
298
310
  height: number;
299
311
  portPoints: PortPoint[];
312
+ availableZ?: number[];
300
313
  };
301
314
  /**
302
315
  * A path for a wire in high-density intra-node routing.
@@ -398,6 +411,8 @@ interface HighDensityHyperParameters {
398
411
  SHUFFLE_SEED: number;
399
412
  CELL_SIZE_FACTOR: number;
400
413
  FLIP_TRACE_ALIGNMENT_DIRECTION: boolean;
414
+ MULTI_HEAD_POLYLINE_SOLVER: boolean;
415
+ SEGMENTS_PER_POLYLINE: number;
401
416
  }
402
417
 
403
418
  type Node = {
@@ -409,9 +424,9 @@ type Node = {
409
424
  f: number;
410
425
  parent: Node | null;
411
426
  };
412
- declare class SingleRouteCandidatePriorityQueue {
427
+ declare class SingleRouteCandidatePriorityQueue<T extends Node = Node> {
413
428
  private heap;
414
- constructor(nodes: Node[]);
429
+ constructor(nodes: T[]);
415
430
  private getLeftChildIndex;
416
431
  private getRightChildIndex;
417
432
  private getParentIndex;
@@ -422,9 +437,9 @@ declare class SingleRouteCandidatePriorityQueue {
422
437
  private rightChild;
423
438
  private parent;
424
439
  private swap;
425
- dequeue(): Node | null;
426
- peek(): Node | null;
427
- enqueue(item: Node): void;
440
+ dequeue(): T | null;
441
+ peek(): T | null;
442
+ enqueue(item: T): void;
428
443
  heapifyUp(): void;
429
444
  heapifyDown(): void;
430
445
  }
@@ -728,6 +743,12 @@ declare class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
728
743
  CLOSED_FORM_TWO_TRACE_TRANSITION_CROSSING: boolean;
729
744
  CLOSED_FORM_TWO_TRACE_SAME_LAYER?: undefined;
730
745
  })[];
746
+ } | {
747
+ name: string;
748
+ possibleValues: {
749
+ MULTI_HEAD_POLYLINE_SOLVER: boolean;
750
+ SEGMENTS_PER_POLYLINE: number;
751
+ }[];
731
752
  })[];
732
753
  computeG(solver: IntraNodeRouteSolver): number;
733
754
  computeH(solver: IntraNodeRouteSolver): number;
@@ -962,6 +983,16 @@ declare class SingleHighDensityRouteStitchSolver extends BaseSolver {
962
983
  };
963
984
  colorMap?: Record<string, string>;
964
985
  });
986
+ /**
987
+ * Scan `remainingHdRoutes` and find a route that has **one** end that is not
988
+ * within `5e-6` of the start or end of any other route on the same layer.
989
+ * That “lonely” end marks one extremity of the whole chain, which we use as
990
+ * our starting segment. If no such route exists (e.g., the data form a loop),
991
+ * we simply return the first route so the solver can proceed.
992
+ */
993
+ getDisjointedRoute(): {
994
+ firstRoute: HighDensityIntraNodeRoute$1;
995
+ };
965
996
  _step(): void;
966
997
  visualize(): GraphicsObject;
967
998
  }
@@ -1050,6 +1081,7 @@ interface UnravelSection {
1050
1081
  mutableSegmentIds: Set<string>;
1051
1082
  immutableNodeIds: CapacityMeshNodeId[];
1052
1083
  segmentPointMap: SegmentPointMap;
1084
+ mutableSegmentPointIds: Set<SegmentPointId>;
1053
1085
  segmentPairsInNode: Map<CapacityMeshNodeId, Array<[SegmentPointId, SegmentPointId]>>;
1054
1086
  segmentPointsInNode: Map<CapacityMeshNodeId, SegmentPointId[]>;
1055
1087
  segmentPointsInSegment: Map<SegmentId, SegmentPointId[]>;
@@ -1112,6 +1144,19 @@ type SegmentPointMapAndReverseMaps = {
1112
1144
  segmentToSegmentPointMap: Map<SegmentId, SegmentPointId[]>;
1113
1145
  };
1114
1146
 
1147
+ interface UnravelSectionSolverParams {
1148
+ rootNodeId: CapacityMeshNodeId;
1149
+ colorMap?: Record<string, string>;
1150
+ MUTABLE_HOPS?: number;
1151
+ nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
1152
+ dedupedSegments: SegmentWithAssignedPoints[];
1153
+ dedupedSegmentMap?: Map<SegmentId, SegmentWithAssignedPoints>;
1154
+ nodeIdToSegmentIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
1155
+ segmentIdToNodeIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
1156
+ segmentPointMap?: SegmentPointMap;
1157
+ nodeToSegmentPointMap?: Map<CapacityMeshNodeId, SegmentPointId[]>;
1158
+ segmentToSegmentPointMap?: Map<SegmentId, SegmentPointId[]>;
1159
+ }
1115
1160
  /**
1116
1161
  * The UntangleSectionSolver optimizes a section of connected capacity nodes
1117
1162
  * with their deduplicated segments.
@@ -1158,19 +1203,9 @@ declare class UnravelSectionSolver extends BaseSolver {
1158
1203
  iterationsSinceImprovement: number;
1159
1204
  selectedCandidateIndex: number | "best" | "original" | null;
1160
1205
  queuedOrExploredCandidatePointModificationHashes: Set<string>;
1161
- constructor(params: {
1162
- rootNodeId: CapacityMeshNodeId;
1163
- colorMap?: Record<string, string>;
1164
- MUTABLE_HOPS?: number;
1165
- nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
1166
- dedupedSegments: SegmentWithAssignedPoints[];
1167
- dedupedSegmentMap?: Map<SegmentId, SegmentWithAssignedPoints>;
1168
- nodeIdToSegmentIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
1169
- segmentIdToNodeIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
1170
- segmentPointMap?: SegmentPointMap;
1171
- nodeToSegmentPointMap?: Map<CapacityMeshNodeId, SegmentPointId[]>;
1172
- segmentToSegmentPointMap?: Map<SegmentId, SegmentPointId[]>;
1173
- });
1206
+ constructorParams: UnravelSectionSolverParams;
1207
+ constructor(params: UnravelSectionSolverParams);
1208
+ getConstructorParams(): UnravelSectionSolverParams;
1174
1209
  createUnravelSection(largeSpMaps?: SegmentPointMapAndReverseMaps): UnravelSection;
1175
1210
  createInitialCandidate(): UnravelCandidate;
1176
1211
  get nextCandidate(): UnravelCandidate | null;
@@ -1207,12 +1242,13 @@ declare class UnravelMultiSectionSolver extends BaseSolver {
1207
1242
  MAX_NODE_ATTEMPTS: number;
1208
1243
  MUTABLE_HOPS: number;
1209
1244
  ACCEPTABLE_PF: number;
1245
+ MAX_ITERATIONS_WITHOUT_IMPROVEMENT: number;
1210
1246
  /**
1211
1247
  * Probability of failure for each node
1212
1248
  */
1213
1249
  nodePfMap: Map<CapacityMeshNodeId, number>;
1214
1250
  attemptsToFixNode: Map<CapacityMeshNodeId, number>;
1215
- activeSolver: UnravelSectionSolver | null;
1251
+ activeSubSolver: UnravelSectionSolver | null;
1216
1252
  segmentPointMap: SegmentPointMap;
1217
1253
  constructor({ assignedSegments, colorMap, nodes, }: {
1218
1254
  assignedSegments: NodePortSegment[];
@@ -1256,6 +1292,7 @@ declare class CapacityPathingSolver extends BaseSolver {
1256
1292
  nodes: CapacityMeshNode[];
1257
1293
  edges: CapacityMeshEdge[];
1258
1294
  GREEDY_MULTIPLIER: number;
1295
+ MAX_CANDIDATES_IN_MEMORY: number;
1259
1296
  nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
1260
1297
  nodeEdgeMap: Map<CapacityMeshNodeId, CapacityMeshEdge[]>;
1261
1298
  connectionNameToGoalNodeIds: Map<string, CapacityMeshNodeId[]>;
@@ -1354,8 +1391,6 @@ interface CapacityPathingSingleSectionPathingSolverParams {
1354
1391
  }
1355
1392
  declare class CapacityPathingSingleSectionPathingSolver extends BaseSolver {
1356
1393
  GREEDY_MULTIPLIER: number;
1357
- NEGATIVE_CAPACITY_PENALTY_FACTOR: number;
1358
- REDUCED_CAPACITY_PENALTY_FACTOR: number;
1359
1394
  sectionNodes: CapacityMeshNode[];
1360
1395
  sectionEdges: CapacityMeshEdge[];
1361
1396
  sectionConnectionTerminals: Array<{
@@ -1368,6 +1403,7 @@ declare class CapacityPathingSingleSectionPathingSolver extends BaseSolver {
1368
1403
  nodeEdgeMap: Map<CapacityMeshNodeId, CapacityMeshEdge[]>;
1369
1404
  colorMap: Record<string, string>;
1370
1405
  usedNodeCapacityMap: Map<CapacityMeshNodeId, number>;
1406
+ MAX_CANDIDATES_IN_MEMORY: number;
1371
1407
  currentConnectionIndex: number;
1372
1408
  candidates?: Array<Candidate> | null;
1373
1409
  visitedNodes?: Set<CapacityMeshNodeId> | null;
@@ -1456,6 +1492,8 @@ declare class CapacityPathingMultiSectionSolver extends BaseSolver {
1456
1492
  nodeOptimizationAttemptCountMap: Map<CapacityMeshNodeId, number>;
1457
1493
  sectionSolver?: CapacityPathingSingleSectionSolver | null;
1458
1494
  MAX_ATTEMPTS_PER_NODE: number;
1495
+ MINIMUM_PROBABILITY_OF_FAILURE_TO_OPTIMIZE: number;
1496
+ MAX_EXPANSION_DEGREES: number;
1459
1497
  constructor(params: ConstructorParameters<typeof CapacityPathingSolver>[0]);
1460
1498
  _stepInitialization(): void;
1461
1499
  _getNextNodeToOptimize(): CapacityMeshNodeId | null;
@@ -1581,7 +1619,12 @@ declare class MultiSimplifiedPathSolver extends BaseSolver {
1581
1619
  }
1582
1620
 
1583
1621
  declare class CapacityMeshEdgeSolver2_NodeTreeOptimization extends CapacityMeshEdgeSolver {
1584
- step(): void;
1622
+ nodes: CapacityMeshNode[];
1623
+ private nodeTree;
1624
+ private currentNodeIndex;
1625
+ private edgeSet;
1626
+ constructor(nodes: CapacityMeshNode[]);
1627
+ _step(): void;
1585
1628
  }
1586
1629
 
1587
1630
  interface Point {
@@ -1732,7 +1775,7 @@ declare class AutoroutingPipelineSolver extends BaseSolver {
1732
1775
  connMap: ConnectivityMap;
1733
1776
  srjWithPointPairs?: SimpleRouteJson;
1734
1777
  capacityNodes: CapacityMeshNode[] | null;
1735
- pipelineDef: (PipelineStep<typeof NetToPointPairsSolver> | PipelineStep<typeof CapacityMeshNodeSolver2_NodeUnderObstacle> | PipelineStep<typeof SingleLayerNodeMergerSolver> | PipelineStep<typeof StrawSolver> | PipelineStep<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep<typeof CapacityPathingSolver5> | PipelineStep<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep<typeof CapacitySegmentToPointSolver> | PipelineStep<typeof UnravelMultiSectionSolver> | PipelineStep<typeof HighDensitySolver> | PipelineStep<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep<typeof UselessViaRemovalSolver> | PipelineStep<typeof MultiSimplifiedPathSolver>)[];
1778
+ pipelineDef: (PipelineStep<typeof NetToPointPairsSolver> | PipelineStep<typeof CapacityMeshNodeSolver2_NodeUnderObstacle> | PipelineStep<typeof SingleLayerNodeMergerSolver> | PipelineStep<typeof StrawSolver> | PipelineStep<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep<typeof CapacityPathingMultiSectionSolver> | PipelineStep<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep<typeof CapacitySegmentToPointSolver> | PipelineStep<typeof UnravelMultiSectionSolver> | PipelineStep<typeof HighDensitySolver> | PipelineStep<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep<typeof UselessViaRemovalSolver> | PipelineStep<typeof MultiSimplifiedPathSolver>)[];
1736
1779
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions);
1737
1780
  currentPipelineStepIndex: number;
1738
1781
  _step(): void;