@tscircuit/hypergraph 0.0.60 → 0.0.61
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 +106 -8
- package/dist/index.js +1292 -503
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseSolver } from '@tscircuit/solver-utils';
|
|
2
|
-
import { Matrix } from 'transformation-matrix';
|
|
3
2
|
import { GraphicsObject, Point } from 'graphics-debug';
|
|
3
|
+
import { Matrix } from 'transformation-matrix';
|
|
4
4
|
|
|
5
5
|
type PortId = string;
|
|
6
6
|
type GraphEdgeId = string;
|
|
@@ -62,7 +62,6 @@ type Candidate<RegionType extends Region = Region, RegionPortType extends Region
|
|
|
62
62
|
type HyperGraph = {
|
|
63
63
|
ports: RegionPort[];
|
|
64
64
|
regions: Region[];
|
|
65
|
-
solvedRoutes?: SolvedRoute[];
|
|
66
65
|
};
|
|
67
66
|
type SerializedGraphPort = {
|
|
68
67
|
portId: PortId;
|
|
@@ -84,11 +83,6 @@ type SerializedRegionPortAssignment = {
|
|
|
84
83
|
type SerializedHyperGraph = {
|
|
85
84
|
ports: SerializedGraphPort[];
|
|
86
85
|
regions: SerializedGraphRegion[];
|
|
87
|
-
solvedRoutes?: SerializedSolvedRoute[];
|
|
88
|
-
};
|
|
89
|
-
type SerializedSolvedRoute = {
|
|
90
|
-
pathPortIds: PortId[];
|
|
91
|
-
connectionId: ConnectionId;
|
|
92
86
|
};
|
|
93
87
|
type Connection = {
|
|
94
88
|
connectionId: ConnectionId;
|
|
@@ -185,6 +179,7 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
185
179
|
greedyMultiplier?: number;
|
|
186
180
|
rippingEnabled?: boolean;
|
|
187
181
|
ripCost?: number;
|
|
182
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
188
183
|
};
|
|
189
184
|
getSolverName(): string;
|
|
190
185
|
graph: HyperGraph;
|
|
@@ -205,6 +200,7 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
205
200
|
greedyMultiplier?: number;
|
|
206
201
|
rippingEnabled?: boolean;
|
|
207
202
|
ripCost?: number;
|
|
203
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
208
204
|
});
|
|
209
205
|
getConstructorParams(): {
|
|
210
206
|
inputGraph: SerializedHyperGraph;
|
|
@@ -212,7 +208,9 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
212
208
|
greedyMultiplier: number;
|
|
213
209
|
rippingEnabled: boolean;
|
|
214
210
|
ripCost: number;
|
|
211
|
+
inputSolvedRoutes: SolvedRoute[];
|
|
215
212
|
};
|
|
213
|
+
getOutput(): SolvedRoute[];
|
|
216
214
|
computeH(candidate: CandidateType): number;
|
|
217
215
|
/**
|
|
218
216
|
* OVERRIDE THIS
|
|
@@ -312,6 +310,104 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
312
310
|
_step(): void;
|
|
313
311
|
}
|
|
314
312
|
|
|
313
|
+
type CreateHyperGraphSolverInput = {
|
|
314
|
+
inputGraph: HyperGraph | SerializedHyperGraph;
|
|
315
|
+
inputConnections: (Connection | SerializedConnection)[];
|
|
316
|
+
inputSolvedRoutes: SolvedRoute[];
|
|
317
|
+
};
|
|
318
|
+
type CreateHyperGraphSolver = (input: CreateHyperGraphSolverInput) => HyperGraphSolver<Region, RegionPort>;
|
|
319
|
+
type SectionRoute = {
|
|
320
|
+
globalRoute: SolvedRoute;
|
|
321
|
+
globalConnection: Connection;
|
|
322
|
+
sectionConnection: Connection;
|
|
323
|
+
sectionRoute: SolvedRoute;
|
|
324
|
+
canRemainFixedInSectionSolve: boolean;
|
|
325
|
+
sectionStartIndex: number;
|
|
326
|
+
sectionEndIndex: number;
|
|
327
|
+
};
|
|
328
|
+
type HyperGraphSection = {
|
|
329
|
+
centralRegionId: RegionId;
|
|
330
|
+
sectionRegionIds: Set<RegionId>;
|
|
331
|
+
graph: HyperGraph;
|
|
332
|
+
connections: Connection[];
|
|
333
|
+
sectionRoutes: SectionRoute[];
|
|
334
|
+
};
|
|
335
|
+
declare class HyperGraphSectionOptimizer extends BaseSolver {
|
|
336
|
+
input: {
|
|
337
|
+
hyperGraphSolver: HyperGraphSolver<Region, RegionPort>;
|
|
338
|
+
inputSolvedRoutes: SolvedRoute[];
|
|
339
|
+
expansionHopsFromCentralRegion: number;
|
|
340
|
+
createHyperGraphSolver: CreateHyperGraphSolver;
|
|
341
|
+
computeRegionCost: (region: Region) => number;
|
|
342
|
+
regionCost: (region: Region) => number;
|
|
343
|
+
effort: number;
|
|
344
|
+
ACCEPTABLE_REGION_COST: number;
|
|
345
|
+
MAX_ATTEMPTS_PER_REGION: number;
|
|
346
|
+
MAX_ATTEMPTS_PER_SECTION?: number;
|
|
347
|
+
FRACTION_TO_REPLACE?: number;
|
|
348
|
+
alwaysRipConflicts?: boolean;
|
|
349
|
+
computeSolvedGraphCost?: (solvedRoutes: SolvedRoute[]) => number;
|
|
350
|
+
};
|
|
351
|
+
graph: HyperGraph;
|
|
352
|
+
connections: Connection[];
|
|
353
|
+
solvedRoutes: SolvedRoute[];
|
|
354
|
+
activeSection: HyperGraphSection | null;
|
|
355
|
+
baselineSectionCost: number;
|
|
356
|
+
baselineGlobalCost: number;
|
|
357
|
+
regionAttemptCounts: Map<string, number>;
|
|
358
|
+
sectionAttempts: number;
|
|
359
|
+
maxAttemptsPerRegion: number;
|
|
360
|
+
maxSectionAttempts: number;
|
|
361
|
+
fractionToReplace: number;
|
|
362
|
+
alwaysRipConflicts: boolean;
|
|
363
|
+
random: () => number;
|
|
364
|
+
activeSubSolver: HyperGraphSolver<Region, RegionPort> | null;
|
|
365
|
+
constructor(input: {
|
|
366
|
+
hyperGraphSolver: HyperGraphSolver<Region, RegionPort>;
|
|
367
|
+
inputSolvedRoutes: SolvedRoute[];
|
|
368
|
+
expansionHopsFromCentralRegion: number;
|
|
369
|
+
createHyperGraphSolver: CreateHyperGraphSolver;
|
|
370
|
+
computeRegionCost: (region: Region) => number;
|
|
371
|
+
regionCost: (region: Region) => number;
|
|
372
|
+
effort: number;
|
|
373
|
+
ACCEPTABLE_REGION_COST: number;
|
|
374
|
+
MAX_ATTEMPTS_PER_REGION: number;
|
|
375
|
+
MAX_ATTEMPTS_PER_SECTION?: number;
|
|
376
|
+
FRACTION_TO_REPLACE?: number;
|
|
377
|
+
alwaysRipConflicts?: boolean;
|
|
378
|
+
computeSolvedGraphCost?: (solvedRoutes: SolvedRoute[]) => number;
|
|
379
|
+
});
|
|
380
|
+
getSolverName(): string;
|
|
381
|
+
getConstructorParams(): {
|
|
382
|
+
inputGraph: SerializedHyperGraph;
|
|
383
|
+
inputConnections: SerializedConnection[];
|
|
384
|
+
inputSolvedRoutes: SolvedRoute[];
|
|
385
|
+
expansionHopsFromCentralRegion: number;
|
|
386
|
+
maxAttemptsPerRegion: number;
|
|
387
|
+
maxSectionAttempts: number;
|
|
388
|
+
effort: number;
|
|
389
|
+
fractionToReplace: number;
|
|
390
|
+
alwaysRipConflicts: boolean;
|
|
391
|
+
ACCEPTABLE_COST: number;
|
|
392
|
+
};
|
|
393
|
+
getOutput(): SolvedRoute[];
|
|
394
|
+
_setup(): void;
|
|
395
|
+
visualize(): GraphicsObject;
|
|
396
|
+
getCostOfRegionWithAttempts(region: Region): number;
|
|
397
|
+
computeCostOfSection({ section, solvedRoutes, }: {
|
|
398
|
+
section: HyperGraphSection;
|
|
399
|
+
solvedRoutes: SolvedRoute[];
|
|
400
|
+
}): number;
|
|
401
|
+
private computeSolvedGraphCost;
|
|
402
|
+
/**
|
|
403
|
+
* TODO default behavior should be to rip entire section
|
|
404
|
+
*/
|
|
405
|
+
determineConnectionsToRip(section: HyperGraphSection, evaluationSolver: HyperGraphSolver<Region, RegionPort>): Set<string>;
|
|
406
|
+
private getNextCentralRegion;
|
|
407
|
+
private beginSectionSolve;
|
|
408
|
+
_step(): void;
|
|
409
|
+
}
|
|
410
|
+
|
|
315
411
|
type Bounds$1 = {
|
|
316
412
|
minX: number;
|
|
317
413
|
minY: number;
|
|
@@ -394,6 +490,7 @@ declare class JumperGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
|
394
490
|
constructor(input: {
|
|
395
491
|
inputGraph: HyperGraph | SerializedHyperGraph;
|
|
396
492
|
inputConnections: (Connection | SerializedConnection)[];
|
|
493
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
397
494
|
ripCost?: number;
|
|
398
495
|
portUsagePenalty?: number;
|
|
399
496
|
crossingPenalty?: number;
|
|
@@ -1008,6 +1105,7 @@ declare class ViaGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
|
1008
1105
|
constructor(input: {
|
|
1009
1106
|
inputGraph: HyperGraph | SerializedHyperGraph;
|
|
1010
1107
|
inputConnections: (Connection | SerializedConnection)[];
|
|
1108
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
1011
1109
|
viaTile?: ViaTile;
|
|
1012
1110
|
ripCost?: number;
|
|
1013
1111
|
portUsagePenalty?: number;
|
|
@@ -1191,4 +1289,4 @@ declare function generateConvexViaTopologyRegions(opts: {
|
|
|
1191
1289
|
};
|
|
1192
1290
|
};
|
|
1193
1291
|
|
|
1194
|
-
export { type Bounds$1 as Bounds, type BuildOpts, type Candidate, ConnectBuilder, type ConnectOpts, type Connection, type ConnectionId, type ConvexViaGraphFromXYConnectionsResult, type GScore, type GraphEdgeId, type HyperGraph, HyperGraphSolver, type JPort, type JRegion, JUMPER_GRAPH_SOLVER_DEFAULTS, type JumperGraph, JumperGraphSolver, type JumperGraphWithConnections, type NetworkId, type PortAssignment, PortBuilder, type PortData, type PortId, type PortSpread, type Region, RegionBuilder, type RegionData, type RegionId, type RegionPort, type RegionPortAssignment, type RegionRef, type RouteSegment, type SerializedConnection, type SerializedGraphPort, type SerializedGraphRegion, type SerializedHyperGraph, type SerializedRegionPortAssignment, type
|
|
1292
|
+
export { type Bounds$1 as Bounds, type BuildOpts, type Candidate, ConnectBuilder, type ConnectOpts, type Connection, type ConnectionId, type ConvexViaGraphFromXYConnectionsResult, type CreateHyperGraphSolver, type CreateHyperGraphSolverInput, type GScore, type GraphEdgeId, type HyperGraph, type HyperGraphSection, HyperGraphSectionOptimizer, HyperGraphSolver, type JPort, type JRegion, JUMPER_GRAPH_SOLVER_DEFAULTS, type JumperGraph, JumperGraphSolver, type JumperGraphWithConnections, type NetworkId, type PortAssignment, PortBuilder, type PortData, type PortId, type PortSpread, type Region, RegionBuilder, type RegionData, type RegionId, type RegionPort, type RegionPortAssignment, type RegionRef, type RouteSegment, type SectionRoute, type SerializedConnection, type SerializedGraphPort, type SerializedGraphRegion, type SerializedHyperGraph, type SerializedRegionPortAssignment, type SharedBoundary, type SolvedRoute, Topology, TopologyError, VIA_GRAPH_SOLVER_DEFAULTS, type ValidateOpts, type ViaByNet, type ViaData, ViaGraphSolver, type ViaGraphWithConnections, type ViaTile, type ViaTileRecommendation, type ViaTileRecommendationCandidate, type ViaTileRecommendationProblemInput, type XYConnection, applyTransformToGraph, calculateGraphBounds, convertConnectionsToSerializedConnections, convertHyperGraphToSerializedHyperGraph, createConvexViaGraphFromXYConnections, createGraphWithConnectionsFromBaseGraph, createViaGraphWithConnections, generateConvexViaTopologyRegions, generateDefaultViaTopologyRegions, generateJumperGrid, generateJumperX4Grid, generateViaTopologyRegions, recommendViaTileFromGraphInput, rotateGraph90Degrees, viaTile4Regions as viaTile };
|