@tscircuit/capacity-autorouter 0.0.54 → 0.0.56
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 +68 -42
- package/dist/index.js +1189 -152
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ declare class BaseSolver {
|
|
|
101
101
|
activeSubSolver?: BaseSolver | null;
|
|
102
102
|
failedSubSolvers?: BaseSolver[];
|
|
103
103
|
timeToSolve?: number;
|
|
104
|
+
stats: Record<string, number>;
|
|
104
105
|
/** DO NOT OVERRIDE! Override _step() instead */
|
|
105
106
|
step(): void;
|
|
106
107
|
_step(): void;
|
|
@@ -127,14 +128,24 @@ declare class CapacityMeshEdgeSolver extends BaseSolver {
|
|
|
127
128
|
visualize(): GraphicsObject;
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
|
|
131
|
+
/**
|
|
132
|
+
* ObstacleTree wraps different spatial index implementations:
|
|
133
|
+
* - 'native': original spatial-hash grid
|
|
134
|
+
* - 'rbush': dynamic R-tree via rbush
|
|
135
|
+
* - 'flatbush': static index via flatbush
|
|
136
|
+
*/
|
|
131
137
|
declare class ObstacleSpatialHashIndex {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
private idx;
|
|
139
|
+
private storage;
|
|
140
|
+
constructor(implementation?: "native" | "rbush" | "flatbush", obstacles?: Obstacle[]);
|
|
141
|
+
insert(o: Obstacle): void;
|
|
142
|
+
search(bbox: {
|
|
143
|
+
minX: number;
|
|
144
|
+
minY: number;
|
|
145
|
+
maxX: number;
|
|
146
|
+
maxY: number;
|
|
147
|
+
}): Obstacle[];
|
|
148
|
+
searchArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
interface Target$1 {
|
|
@@ -606,6 +617,7 @@ declare class HyperParameterSupervisorSolver<T extends BaseSolver> extends BaseS
|
|
|
606
617
|
computeH(solver: T): number;
|
|
607
618
|
computeF(g: number, h: number): number;
|
|
608
619
|
getSupervisedSolverWithBestFitness(): SupervisedSolver<T> | null;
|
|
620
|
+
getFailureMessage(): string;
|
|
609
621
|
_step(): void;
|
|
610
622
|
onSolve(solver: SupervisedSolver<T>): void;
|
|
611
623
|
visualize(): GraphicsObject;
|
|
@@ -973,6 +985,16 @@ declare class SingleHighDensityRouteStitchSolver extends BaseSolver {
|
|
|
973
985
|
};
|
|
974
986
|
colorMap?: Record<string, string>;
|
|
975
987
|
});
|
|
988
|
+
/**
|
|
989
|
+
* Scan `remainingHdRoutes` and find a route that has **one** end that is not
|
|
990
|
+
* within `5e-6` of the start or end of any other route on the same layer.
|
|
991
|
+
* That “lonely” end marks one extremity of the whole chain, which we use as
|
|
992
|
+
* our starting segment. If no such route exists (e.g., the data form a loop),
|
|
993
|
+
* we simply return the first route so the solver can proceed.
|
|
994
|
+
*/
|
|
995
|
+
getDisjointedRoute(): {
|
|
996
|
+
firstRoute: HighDensityIntraNodeRoute$1;
|
|
997
|
+
};
|
|
976
998
|
_step(): void;
|
|
977
999
|
visualize(): GraphicsObject;
|
|
978
1000
|
}
|
|
@@ -1367,9 +1389,10 @@ interface CapacityPathingSingleSectionPathingSolverParams {
|
|
|
1367
1389
|
endNodeId: CapacityMeshNodeId;
|
|
1368
1390
|
}>;
|
|
1369
1391
|
colorMap?: Record<string, string>;
|
|
1392
|
+
centerNodeId: string;
|
|
1370
1393
|
hyperParameters?: CpssPathingSolverHyperParameters;
|
|
1371
1394
|
}
|
|
1372
|
-
declare class
|
|
1395
|
+
declare class CapacityPathingSingleSectionSolver extends BaseSolver {
|
|
1373
1396
|
GREEDY_MULTIPLIER: number;
|
|
1374
1397
|
sectionNodes: CapacityMeshNode[];
|
|
1375
1398
|
sectionEdges: CapacityMeshEdge[];
|
|
@@ -1383,6 +1406,7 @@ declare class CapacityPathingSingleSectionPathingSolver extends BaseSolver {
|
|
|
1383
1406
|
nodeEdgeMap: Map<CapacityMeshNodeId, CapacityMeshEdge[]>;
|
|
1384
1407
|
colorMap: Record<string, string>;
|
|
1385
1408
|
usedNodeCapacityMap: Map<CapacityMeshNodeId, number>;
|
|
1409
|
+
centerNodeId: string;
|
|
1386
1410
|
MAX_CANDIDATES_IN_MEMORY: number;
|
|
1387
1411
|
currentConnectionIndex: number;
|
|
1388
1412
|
candidates?: Array<Candidate> | null;
|
|
@@ -1408,50 +1432,50 @@ declare class CapacityPathingSingleSectionPathingSolver extends BaseSolver {
|
|
|
1408
1432
|
doesNodeHaveCapacityForTrace(node: CapacityMeshNode, prevNode: CapacityMeshNode | null): boolean;
|
|
1409
1433
|
reduceCapacityAlongPath(path: CapacityMeshNode[]): void;
|
|
1410
1434
|
_step(): void;
|
|
1435
|
+
computeProgress(): number;
|
|
1411
1436
|
private _setupAStar;
|
|
1412
1437
|
private _handleCandidatesExhausted;
|
|
1413
1438
|
private _handleGoalReached;
|
|
1414
1439
|
visualize(): GraphicsObject;
|
|
1415
1440
|
}
|
|
1441
|
+
declare const CapacityPathingSingleSectionPathingSolver: typeof CapacityPathingSingleSectionSolver;
|
|
1442
|
+
type CapacityPathingSingleSectionPathingSolver = InstanceType<typeof CapacityPathingSingleSectionSolver>;
|
|
1416
1443
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
nodeEdgeMap: Map<CapacityMeshNodeId, CapacityMeshEdge[]>;
|
|
1432
|
-
expansionDegrees: number;
|
|
1433
|
-
colorMap: Record<string, string>;
|
|
1434
|
-
sectionNodes: CapacityMeshNode[];
|
|
1435
|
-
sectionEdges: CapacityMeshEdge[];
|
|
1436
|
-
sectionConnectionTerminals: Array<{
|
|
1444
|
+
declare class HyperCapacityPathingSingleSectionSolver extends HyperParameterSupervisorSolver<CapacityPathingSingleSectionPathingSolver> {
|
|
1445
|
+
constructorParams: CapacityPathingSingleSectionPathingSolverParams;
|
|
1446
|
+
winningSolver?: CapacityPathingSingleSectionPathingSolver;
|
|
1447
|
+
constructor(params: ConstructorParameters<typeof CapacityPathingSingleSectionPathingSolver>[0]);
|
|
1448
|
+
computeG(solver: CapacityPathingSingleSectionPathingSolver): number;
|
|
1449
|
+
computeH(solver: CapacityPathingSingleSectionPathingSolver): number;
|
|
1450
|
+
getCombinationDefs(): Array<Array<string>> | null;
|
|
1451
|
+
getFailureMessage(): string;
|
|
1452
|
+
getHyperParameterDefs(): Array<HyperParameterDef>;
|
|
1453
|
+
generateSolver(hyperParameters: any): CapacityPathingSingleSectionPathingSolver;
|
|
1454
|
+
onSolve({ solver, }: SupervisedSolver<CapacityPathingSingleSectionPathingSolver>): void;
|
|
1455
|
+
get centerNodeId(): string;
|
|
1456
|
+
get sectionNodes(): CapacityMeshNode[];
|
|
1457
|
+
get sectionConnectionTerminals(): {
|
|
1437
1458
|
connectionName: string;
|
|
1438
1459
|
startNodeId: CapacityMeshNodeId;
|
|
1439
1460
|
endNodeId: CapacityMeshNodeId;
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1461
|
+
path?: CapacityMeshNode[];
|
|
1462
|
+
}[] | undefined;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
interface SectionConnectionTerminal {
|
|
1466
|
+
connectionName: string;
|
|
1467
|
+
startNodeId: CapacityMeshNodeId;
|
|
1468
|
+
endNodeId: CapacityMeshNodeId;
|
|
1469
|
+
path?: CapacityMeshNode[];
|
|
1470
|
+
}
|
|
1471
|
+
interface CapacityPathingSection {
|
|
1472
|
+
centerNodeId: string;
|
|
1473
|
+
sectionConnectionTerminals: SectionConnectionTerminal[];
|
|
1474
|
+
sectionNodes: CapacityMeshNode[];
|
|
1475
|
+
sectionEdges: CapacityMeshEdge[];
|
|
1453
1476
|
}
|
|
1454
1477
|
|
|
1478
|
+
type CapacityMeshEdgeId = string;
|
|
1455
1479
|
/**
|
|
1456
1480
|
* This solver solves for capacity paths by first solving with negative
|
|
1457
1481
|
* capacities allowed, then re-solving problematic sections with a section
|
|
@@ -1461,6 +1485,7 @@ declare class CapacityPathingMultiSectionSolver extends BaseSolver {
|
|
|
1461
1485
|
simpleRouteJson: SimpleRouteJson;
|
|
1462
1486
|
nodes: CapacityMeshNode[];
|
|
1463
1487
|
edges: CapacityMeshEdge[];
|
|
1488
|
+
nodeEdgeMap: Map<CapacityMeshEdgeId, CapacityMeshEdge[]>;
|
|
1464
1489
|
connectionsWithNodes: Array<ConnectionPathWithNodes>;
|
|
1465
1490
|
colorMap: Record<string, string>;
|
|
1466
1491
|
initialSolver: CapacityPathingGreedySolver;
|
|
@@ -1470,7 +1495,8 @@ declare class CapacityPathingMultiSectionSolver extends BaseSolver {
|
|
|
1470
1495
|
totalNodeCapacityMap: Map<CapacityMeshNodeId, number>;
|
|
1471
1496
|
nodeCapacityPercentMap: Map<CapacityMeshNodeId, number>;
|
|
1472
1497
|
nodeOptimizationAttemptCountMap: Map<CapacityMeshNodeId, number>;
|
|
1473
|
-
|
|
1498
|
+
currentSection: CapacityPathingSection | null;
|
|
1499
|
+
sectionSolver?: CapacityPathingSingleSectionSolver | HyperCapacityPathingSingleSectionSolver | null;
|
|
1474
1500
|
MAX_ATTEMPTS_PER_NODE: number;
|
|
1475
1501
|
MINIMUM_PROBABILITY_OF_FAILURE_TO_OPTIMIZE: number;
|
|
1476
1502
|
MAX_EXPANSION_DEGREES: number;
|