@tscircuit/capacity-autorouter 0.0.20 → 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 +118 -32
- package/dist/index.js +1411 -730
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ interface SimpleRouteJson {
|
|
|
18
18
|
interface Obstacle {
|
|
19
19
|
type: "rect";
|
|
20
20
|
layers: string[];
|
|
21
|
+
zLayers?: number[];
|
|
21
22
|
center: {
|
|
22
23
|
x: number;
|
|
23
24
|
y: number;
|
|
@@ -72,6 +73,7 @@ interface CapacityMeshNode {
|
|
|
72
73
|
_containsObstacle?: boolean;
|
|
73
74
|
_containsTarget?: boolean;
|
|
74
75
|
_targetConnectionName?: string;
|
|
76
|
+
_strawNode?: boolean;
|
|
75
77
|
_parent?: CapacityMeshNode;
|
|
76
78
|
}
|
|
77
79
|
interface CapacityMeshEdge {
|
|
@@ -109,11 +111,11 @@ declare class CapacityMeshEdgeSolver extends BaseSolver {
|
|
|
109
111
|
constructor(nodes: CapacityMeshNode[]);
|
|
110
112
|
getNextCapacityMeshEdgeId(): string;
|
|
111
113
|
step(): void;
|
|
112
|
-
private
|
|
114
|
+
private doNodesHaveSharedLayer;
|
|
113
115
|
visualize(): GraphicsObject;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
interface CapacityMeshNodeSolverOptions {
|
|
118
|
+
interface CapacityMeshNodeSolverOptions$1 {
|
|
117
119
|
capacityDepth?: number;
|
|
118
120
|
}
|
|
119
121
|
interface Target {
|
|
@@ -124,18 +126,20 @@ interface Target {
|
|
|
124
126
|
}
|
|
125
127
|
declare class CapacityMeshNodeSolver extends BaseSolver {
|
|
126
128
|
srj: SimpleRouteJson;
|
|
127
|
-
opts: CapacityMeshNodeSolverOptions;
|
|
129
|
+
opts: CapacityMeshNodeSolverOptions$1;
|
|
128
130
|
unfinishedNodes: CapacityMeshNode[];
|
|
129
131
|
finishedNodes: CapacityMeshNode[];
|
|
130
|
-
|
|
132
|
+
nodeToXYOverlappingObstaclesMap: Map<CapacityMeshNodeId, Obstacle[]>;
|
|
133
|
+
layerCount: number;
|
|
131
134
|
MAX_DEPTH: number;
|
|
132
135
|
targets: Target[];
|
|
133
|
-
constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions);
|
|
136
|
+
constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$1);
|
|
134
137
|
_nextNodeCounter: number;
|
|
135
138
|
getNextNodeId(): string;
|
|
136
139
|
getCapacityFromDepth(depth: number): number;
|
|
137
140
|
getTargetIfNodeContainsTarget(node: CapacityMeshNode): Target | null;
|
|
138
|
-
|
|
141
|
+
getXYOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
|
|
142
|
+
getXYZOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
|
|
139
143
|
/**
|
|
140
144
|
* Checks if the given mesh node overlaps with any obstacle.
|
|
141
145
|
* We treat both obstacles and nodes as axis‐aligned rectangles.
|
|
@@ -146,7 +150,7 @@ declare class CapacityMeshNodeSolver extends BaseSolver {
|
|
|
146
150
|
*/
|
|
147
151
|
isNodeCompletelyInsideObstacle(node: CapacityMeshNode): boolean;
|
|
148
152
|
getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
|
|
149
|
-
|
|
153
|
+
shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
|
|
150
154
|
_step(): void;
|
|
151
155
|
/**
|
|
152
156
|
* Creates a GraphicsObject to visualize the mesh, its nodes, obstacles, and connection points.
|
|
@@ -161,6 +165,31 @@ declare class CapacityMeshNodeSolver extends BaseSolver {
|
|
|
161
165
|
visualize(): GraphicsObject;
|
|
162
166
|
}
|
|
163
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
|
+
|
|
164
193
|
interface CapacityHyperParameters {
|
|
165
194
|
VIA_DIAMETER: number;
|
|
166
195
|
TRACE_WIDTH: number;
|
|
@@ -191,6 +220,11 @@ declare class CapacityPathingSolver extends BaseSolver {
|
|
|
191
220
|
colorMap: Record<string, string>;
|
|
192
221
|
maxDepthOfNodes: number;
|
|
193
222
|
activeCandidateStraightLineDistance?: number;
|
|
223
|
+
debug_lastNodeCostMap: Map<CapacityMeshNodeId, {
|
|
224
|
+
g: number;
|
|
225
|
+
h: number;
|
|
226
|
+
f: number;
|
|
227
|
+
}>;
|
|
194
228
|
hyperParameters: Partial<CapacityHyperParameters>;
|
|
195
229
|
constructor({ simpleRouteJson, nodes, edges, colorMap, MAX_ITERATIONS, hyperParameters, }: {
|
|
196
230
|
simpleRouteJson: SimpleRouteJson;
|
|
@@ -635,29 +669,6 @@ declare class HighDensitySolver extends BaseSolver {
|
|
|
635
669
|
visualize(): GraphicsObject;
|
|
636
670
|
}
|
|
637
671
|
|
|
638
|
-
declare class CapacityPathingSolver4_FlexibleNegativeCapacity extends CapacityPathingSolver {
|
|
639
|
-
NEGATIVE_CAPACITY_PENALTY_FACTOR: number;
|
|
640
|
-
REDUCED_CAPACITY_PENALTY_FACTOR: number;
|
|
641
|
-
get maxCapacityFactor(): number;
|
|
642
|
-
/**
|
|
643
|
-
* In the FlexibleNegativeCapacity mode, we allow negative capacity
|
|
644
|
-
*/
|
|
645
|
-
doesNodeHaveCapacityForTrace(node: CapacityMeshNode): boolean;
|
|
646
|
-
getTotalCapacity(node: CapacityMeshNode): number;
|
|
647
|
-
/**
|
|
648
|
-
* Penalty you pay for using this node
|
|
649
|
-
*/
|
|
650
|
-
getNodeCapacityPenalty(node: CapacityMeshNode): number;
|
|
651
|
-
/**
|
|
652
|
-
* We're rewarding travel into big nodes.
|
|
653
|
-
*
|
|
654
|
-
* To minimize shortest path, you'd want to comment this out.
|
|
655
|
-
*/
|
|
656
|
-
getDistanceBetweenNodes(A: CapacityMeshNode, B: CapacityMeshNode): number;
|
|
657
|
-
computeG(prevCandidate: Candidate, node: CapacityMeshNode, endGoal: CapacityMeshNode): number;
|
|
658
|
-
computeH(prevCandidate: Candidate, node: CapacityMeshNode, endGoal: CapacityMeshNode): number;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
672
|
/**
|
|
662
673
|
* Merge targets that are close to each other into a single target
|
|
663
674
|
*/
|
|
@@ -1027,6 +1038,7 @@ type UnravelCandidate = {
|
|
|
1027
1038
|
declare class UnravelSectionSolver extends BaseSolver {
|
|
1028
1039
|
nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
|
|
1029
1040
|
dedupedSegments: SegmentWithAssignedPoints[];
|
|
1041
|
+
dedupedSegmentMap: Map<SegmentId, SegmentWithAssignedPoints>;
|
|
1030
1042
|
MUTABLE_HOPS: number;
|
|
1031
1043
|
unravelSection: UnravelSection;
|
|
1032
1044
|
candidates: UnravelCandidate[];
|
|
@@ -1047,6 +1059,7 @@ declare class UnravelSectionSolver extends BaseSolver {
|
|
|
1047
1059
|
MUTABLE_HOPS?: number;
|
|
1048
1060
|
nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
|
|
1049
1061
|
dedupedSegments: SegmentWithAssignedPoints[];
|
|
1062
|
+
dedupedSegmentMap?: Map<SegmentId, SegmentWithAssignedPoints>;
|
|
1050
1063
|
nodeIdToSegmentIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
|
|
1051
1064
|
segmentIdToNodeIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
|
|
1052
1065
|
segmentPointMap?: SegmentPointMap;
|
|
@@ -1076,6 +1089,7 @@ declare class UnravelSectionSolver extends BaseSolver {
|
|
|
1076
1089
|
|
|
1077
1090
|
declare class UnravelMultiSectionSolver extends BaseSolver {
|
|
1078
1091
|
nodeMap: Map<CapacityMeshNodeId, CapacityMeshNode>;
|
|
1092
|
+
dedupedSegmentMap: Map<SegmentId, SegmentWithAssignedPoints>;
|
|
1079
1093
|
dedupedSegments: SegmentWithAssignedPoints[];
|
|
1080
1094
|
nodeIdToSegmentIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
|
|
1081
1095
|
segmentIdToNodeIds: Map<CapacityMeshNodeId, CapacityMeshNodeId[]>;
|
|
@@ -1107,6 +1121,75 @@ declare class UnravelMultiSectionSolver extends BaseSolver {
|
|
|
1107
1121
|
getNodesWithPortPoints(): NodeWithPortPoints[];
|
|
1108
1122
|
}
|
|
1109
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
|
+
|
|
1110
1193
|
interface CapacityMeshSolverOptions {
|
|
1111
1194
|
capacityDepth?: number;
|
|
1112
1195
|
targetMinCapacity?: number;
|
|
@@ -1132,13 +1215,16 @@ declare class CapacityMeshSolver extends BaseSolver {
|
|
|
1132
1215
|
segmentToPointOptimizer?: CapacitySegmentPointOptimizer;
|
|
1133
1216
|
highDensityRouteSolver?: HighDensitySolver;
|
|
1134
1217
|
highDensityStitchSolver?: MultipleHighDensityRouteStitchSolver;
|
|
1218
|
+
singleLayerNodeMerger?: SingleLayerNodeMergerSolver;
|
|
1219
|
+
strawSolver?: StrawSolver;
|
|
1135
1220
|
startTimeOfPhase: Record<string, number>;
|
|
1136
1221
|
endTimeOfPhase: Record<string, number>;
|
|
1137
1222
|
timeSpentOnPhase: Record<string, number>;
|
|
1138
|
-
|
|
1223
|
+
activeSubSolver?: BaseSolver | null;
|
|
1139
1224
|
connMap: ConnectivityMap;
|
|
1140
1225
|
srjWithPointPairs?: SimpleRouteJson;
|
|
1141
|
-
|
|
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>)[];
|
|
1142
1228
|
constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions);
|
|
1143
1229
|
currentPipelineStepIndex: number;
|
|
1144
1230
|
_step(): void;
|