@tscircuit/capacity-autorouter 0.0.21 → 0.0.22

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
@@ -73,7 +73,7 @@ interface CapacityMeshNode {
73
73
  _containsObstacle?: boolean;
74
74
  _containsTarget?: boolean;
75
75
  _targetConnectionName?: string;
76
- _shouldBeInGraph?: boolean;
76
+ _strawNode?: boolean;
77
77
  _parent?: CapacityMeshNode;
78
78
  }
79
79
  interface CapacityMeshEdge {
@@ -111,12 +111,11 @@ declare class CapacityMeshEdgeSolver extends BaseSolver {
111
111
  constructor(nodes: CapacityMeshNode[]);
112
112
  getNextCapacityMeshEdgeId(): string;
113
113
  step(): void;
114
- private areNodesBordering;
115
114
  private doNodesHaveSharedLayer;
116
115
  visualize(): GraphicsObject;
117
116
  }
118
117
 
119
- interface CapacityMeshNodeSolverOptions {
118
+ interface CapacityMeshNodeSolverOptions$1 {
120
119
  capacityDepth?: number;
121
120
  }
122
121
  interface Target {
@@ -127,14 +126,14 @@ interface Target {
127
126
  }
128
127
  declare class CapacityMeshNodeSolver extends BaseSolver {
129
128
  srj: SimpleRouteJson;
130
- opts: CapacityMeshNodeSolverOptions;
129
+ opts: CapacityMeshNodeSolverOptions$1;
131
130
  unfinishedNodes: CapacityMeshNode[];
132
131
  finishedNodes: CapacityMeshNode[];
133
132
  nodeToXYOverlappingObstaclesMap: Map<CapacityMeshNodeId, Obstacle[]>;
134
133
  layerCount: number;
135
134
  MAX_DEPTH: number;
136
135
  targets: Target[];
137
- constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions);
136
+ constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$1);
138
137
  _nextNodeCounter: number;
139
138
  getNextNodeId(): string;
140
139
  getCapacityFromDepth(depth: number): number;
@@ -166,6 +165,31 @@ declare class CapacityMeshNodeSolver extends BaseSolver {
166
165
  visualize(): GraphicsObject;
167
166
  }
168
167
 
168
+ interface CapacityMeshNodeSolverOptions {
169
+ capacityDepth?: number;
170
+ }
171
+ declare class CapacityMeshNodeSolver2_NodeUnderObstacle extends CapacityMeshNodeSolver {
172
+ srj: SimpleRouteJson;
173
+ opts: CapacityMeshNodeSolverOptions;
174
+ constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions);
175
+ isNodeCompletelyOutsideBounds(node: CapacityMeshNode): boolean;
176
+ isNodePartiallyOutsideBounds(node: CapacityMeshNode): boolean;
177
+ createChildNodeAtPosition(parent: CapacityMeshNode, opts: {
178
+ center: {
179
+ x: number;
180
+ y: number;
181
+ };
182
+ width: number;
183
+ height: number;
184
+ availableZ: number[];
185
+ _depth?: number;
186
+ }): CapacityMeshNode;
187
+ getZSubdivisionChildNodes(node: CapacityMeshNode): CapacityMeshNode[];
188
+ getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
189
+ shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
190
+ _step(): void;
191
+ }
192
+
169
193
  interface CapacityHyperParameters {
170
194
  VIA_DIAMETER: number;
171
195
  TRACE_WIDTH: number;
@@ -196,6 +220,11 @@ declare class CapacityPathingSolver extends BaseSolver {
196
220
  colorMap: Record<string, string>;
197
221
  maxDepthOfNodes: number;
198
222
  activeCandidateStraightLineDistance?: number;
223
+ debug_lastNodeCostMap: Map<CapacityMeshNodeId, {
224
+ g: number;
225
+ h: number;
226
+ f: number;
227
+ }>;
199
228
  hyperParameters: Partial<CapacityHyperParameters>;
200
229
  constructor({ simpleRouteJson, nodes, edges, colorMap, MAX_ITERATIONS, hyperParameters, }: {
201
230
  simpleRouteJson: SimpleRouteJson;
@@ -640,29 +669,6 @@ declare class HighDensitySolver extends BaseSolver {
640
669
  visualize(): GraphicsObject;
641
670
  }
642
671
 
643
- declare class CapacityPathingSolver4_FlexibleNegativeCapacity extends CapacityPathingSolver {
644
- NEGATIVE_CAPACITY_PENALTY_FACTOR: number;
645
- REDUCED_CAPACITY_PENALTY_FACTOR: number;
646
- get maxCapacityFactor(): number;
647
- /**
648
- * In the FlexibleNegativeCapacity mode, we allow negative capacity
649
- */
650
- doesNodeHaveCapacityForTrace(node: CapacityMeshNode): boolean;
651
- getTotalCapacity(node: CapacityMeshNode): number;
652
- /**
653
- * Penalty you pay for using this node
654
- */
655
- getNodeCapacityPenalty(node: CapacityMeshNode): number;
656
- /**
657
- * We're rewarding travel into big nodes.
658
- *
659
- * To minimize shortest path, you'd want to comment this out.
660
- */
661
- getDistanceBetweenNodes(A: CapacityMeshNode, B: CapacityMeshNode): number;
662
- computeG(prevCandidate: Candidate, node: CapacityMeshNode, endGoal: CapacityMeshNode): number;
663
- computeH(prevCandidate: Candidate, node: CapacityMeshNode, endGoal: CapacityMeshNode): number;
664
- }
665
-
666
672
  /**
667
673
  * Merge targets that are close to each other into a single target
668
674
  */
@@ -1032,6 +1038,7 @@ type UnravelCandidate = {
1032
1038
  declare class UnravelSectionSolver extends BaseSolver {
1033
1039
  nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
1034
1040
  dedupedSegments: SegmentWithAssignedPoints[];
1041
+ dedupedSegmentMap: Map<SegmentId, SegmentWithAssignedPoints>;
1035
1042
  MUTABLE_HOPS: number;
1036
1043
  unravelSection: UnravelSection;
1037
1044
  candidates: UnravelCandidate[];
@@ -1052,6 +1059,7 @@ declare class UnravelSectionSolver extends BaseSolver {
1052
1059
  MUTABLE_HOPS?: number;
1053
1060
  nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
1054
1061
  dedupedSegments: SegmentWithAssignedPoints[];
1062
+ dedupedSegmentMap?: Map<SegmentId, SegmentWithAssignedPoints>;
1055
1063
  nodeIdToSegmentIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
1056
1064
  segmentIdToNodeIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
1057
1065
  segmentPointMap?: SegmentPointMap;
@@ -1081,6 +1089,7 @@ declare class UnravelSectionSolver extends BaseSolver {
1081
1089
 
1082
1090
  declare class UnravelMultiSectionSolver extends BaseSolver {
1083
1091
  nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
1092
+ dedupedSegmentMap: Map<SegmentId, SegmentWithAssignedPoints>;
1084
1093
  dedupedSegments: SegmentWithAssignedPoints[];
1085
1094
  nodeIdToSegmentIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
1086
1095
  segmentIdToNodeIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
@@ -1112,6 +1121,75 @@ declare class UnravelMultiSectionSolver extends BaseSolver {
1112
1121
  getNodesWithPortPoints(): NodeWithPortPoints[];
1113
1122
  }
1114
1123
 
1124
+ declare class CapacityPathingSolver5 extends CapacityPathingSolver {
1125
+ NEGATIVE_CAPACITY_PENALTY_FACTOR: number;
1126
+ REDUCED_CAPACITY_PENALTY_FACTOR: number;
1127
+ constructor(...args: ConstructorParameters<typeof CapacityPathingSolver>);
1128
+ get maxCapacityFactor(): number;
1129
+ getTotalCapacity(node: CapacityMeshNode): number;
1130
+ /**
1131
+ * Penalty you pay for using this node
1132
+ */
1133
+ getNodeCapacityPenalty(node: CapacityMeshNode): number;
1134
+ /**
1135
+ * We're rewarding travel into big nodes.
1136
+ *
1137
+ * To minimize shortest path, you'd want to comment this out.
1138
+ */
1139
+ getDistanceBetweenNodes(A: CapacityMeshNode, B: CapacityMeshNode): number;
1140
+ computeG(prevCandidate: Candidate, node: CapacityMeshNode, endGoal: CapacityMeshNode): number;
1141
+ computeH(prevCandidate: Candidate, node: CapacityMeshNode, endGoal: CapacityMeshNode): number;
1142
+ }
1143
+
1144
+ declare class StrawSolver extends BaseSolver {
1145
+ multiLayerNodes: CapacityMeshNode[];
1146
+ strawNodes: CapacityMeshNode[];
1147
+ skippedNodes: CapacityMeshNode[];
1148
+ unprocessedNodes: CapacityMeshNode[];
1149
+ strawSize: number;
1150
+ nodeIdCounter: number;
1151
+ constructor(params: {
1152
+ nodes: CapacityMeshNode[];
1153
+ strawSize?: number;
1154
+ });
1155
+ getCapacityOfMultiLayerNodesWithinBounds(bounds: {
1156
+ minX: number;
1157
+ maxX: number;
1158
+ minY: number;
1159
+ maxY: number;
1160
+ }): number;
1161
+ getSurroundingCapacities(node: CapacityMeshNode): {
1162
+ leftSurroundingCapacity: number;
1163
+ rightSurroundingCapacity: number;
1164
+ topSurroundingCapacity: number;
1165
+ bottomSurroundingCapacity: number;
1166
+ };
1167
+ /**
1168
+ * Creates straw nodes from a single-layer node based on surrounding capacities
1169
+ */
1170
+ createStrawsForNode(node: CapacityMeshNode): CapacityMeshNode[];
1171
+ getResultNodes(): CapacityMeshNode[];
1172
+ _step(): void;
1173
+ visualize(): GraphicsObject;
1174
+ }
1175
+
1176
+ /**
1177
+ * Merges same layer nodes into larger nodes. Pre-processing stage necessary
1178
+ * for "strawing".
1179
+ */
1180
+ declare class SingleLayerNodeMergerSolver extends BaseSolver {
1181
+ nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
1182
+ currentBatchNodeIds: CapacityMeshNodeId[];
1183
+ absorbedNodeIds: Set<CapacityMeshNodeId>;
1184
+ nextBatchNodeIds: CapacityMeshNodeId[];
1185
+ batchHadModifications: boolean;
1186
+ newNodes: CapacityMeshNode[];
1187
+ constructor(nodes: CapacityMeshNode[]);
1188
+ getAdjacentSameLayerUnprocessedNodes(rootNode: CapacityMeshNode): CapacityMeshNode[];
1189
+ _step(): void;
1190
+ visualize(): GraphicsObject;
1191
+ }
1192
+
1115
1193
  interface CapacityMeshSolverOptions {
1116
1194
  capacityDepth?: number;
1117
1195
  targetMinCapacity?: number;
@@ -1137,13 +1215,16 @@ declare class CapacityMeshSolver extends BaseSolver {
1137
1215
  segmentToPointOptimizer?: CapacitySegmentPointOptimizer;
1138
1216
  highDensityRouteSolver?: HighDensitySolver;
1139
1217
  highDensityStitchSolver?: MultipleHighDensityRouteStitchSolver;
1218
+ singleLayerNodeMerger?: SingleLayerNodeMergerSolver;
1219
+ strawSolver?: StrawSolver;
1140
1220
  startTimeOfPhase: Record<string, number>;
1141
1221
  endTimeOfPhase: Record<string, number>;
1142
1222
  timeSpentOnPhase: Record<string, number>;
1143
- activeSolver?: BaseSolver | null;
1223
+ activeSubSolver?: BaseSolver | null;
1144
1224
  connMap: ConnectivityMap;
1145
1225
  srjWithPointPairs?: SimpleRouteJson;
1146
- pipelineDef: (PipelineStep<typeof NetToPointPairsSolver> | PipelineStep<typeof CapacityMeshNodeSolver> | PipelineStep<typeof CapacityNodeTargetMerger> | PipelineStep<typeof CapacityMeshEdgeSolver> | PipelineStep<typeof CapacityPathingSolver4_FlexibleNegativeCapacity> | PipelineStep<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep<typeof CapacitySegmentToPointSolver> | PipelineStep<typeof UnravelMultiSectionSolver> | PipelineStep<typeof HighDensitySolver> | PipelineStep<typeof MultipleHighDensityRouteStitchSolver>)[];
1226
+ capacityNodes: CapacityMeshNode[] | null;
1227
+ pipelineDef: (PipelineStep<typeof NetToPointPairsSolver> | PipelineStep<typeof CapacityMeshNodeSolver2_NodeUnderObstacle> | PipelineStep<typeof SingleLayerNodeMergerSolver> | PipelineStep<typeof StrawSolver> | PipelineStep<typeof CapacityMeshEdgeSolver> | PipelineStep<typeof CapacityPathingSolver5> | PipelineStep<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep<typeof CapacitySegmentToPointSolver> | PipelineStep<typeof UnravelMultiSectionSolver> | PipelineStep<typeof HighDensitySolver> | PipelineStep<typeof MultipleHighDensityRouteStitchSolver>)[];
1147
1228
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions);
1148
1229
  currentPipelineStepIndex: number;
1149
1230
  _step(): void;