@tscircuit/hypergraph 0.0.59 → 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 -7
- package/dist/index.js +1292 -502
- 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;
|
|
@@ -83,11 +83,6 @@ type SerializedRegionPortAssignment = {
|
|
|
83
83
|
type SerializedHyperGraph = {
|
|
84
84
|
ports: SerializedGraphPort[];
|
|
85
85
|
regions: SerializedGraphRegion[];
|
|
86
|
-
solvedRoutes?: SerializedSolvedRoute[];
|
|
87
|
-
};
|
|
88
|
-
type SerializedSolvedRoute = {
|
|
89
|
-
pathPortIds: PortId[];
|
|
90
|
-
connectionId: ConnectionId;
|
|
91
86
|
};
|
|
92
87
|
type Connection = {
|
|
93
88
|
connectionId: ConnectionId;
|
|
@@ -184,6 +179,7 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
184
179
|
greedyMultiplier?: number;
|
|
185
180
|
rippingEnabled?: boolean;
|
|
186
181
|
ripCost?: number;
|
|
182
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
187
183
|
};
|
|
188
184
|
getSolverName(): string;
|
|
189
185
|
graph: HyperGraph;
|
|
@@ -204,6 +200,7 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
204
200
|
greedyMultiplier?: number;
|
|
205
201
|
rippingEnabled?: boolean;
|
|
206
202
|
ripCost?: number;
|
|
203
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
207
204
|
});
|
|
208
205
|
getConstructorParams(): {
|
|
209
206
|
inputGraph: SerializedHyperGraph;
|
|
@@ -211,7 +208,9 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
211
208
|
greedyMultiplier: number;
|
|
212
209
|
rippingEnabled: boolean;
|
|
213
210
|
ripCost: number;
|
|
211
|
+
inputSolvedRoutes: SolvedRoute[];
|
|
214
212
|
};
|
|
213
|
+
getOutput(): SolvedRoute[];
|
|
215
214
|
computeH(candidate: CandidateType): number;
|
|
216
215
|
/**
|
|
217
216
|
* OVERRIDE THIS
|
|
@@ -311,6 +310,104 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
311
310
|
_step(): void;
|
|
312
311
|
}
|
|
313
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
|
+
|
|
314
411
|
type Bounds$1 = {
|
|
315
412
|
minX: number;
|
|
316
413
|
minY: number;
|
|
@@ -393,6 +490,7 @@ declare class JumperGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
|
393
490
|
constructor(input: {
|
|
394
491
|
inputGraph: HyperGraph | SerializedHyperGraph;
|
|
395
492
|
inputConnections: (Connection | SerializedConnection)[];
|
|
493
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
396
494
|
ripCost?: number;
|
|
397
495
|
portUsagePenalty?: number;
|
|
398
496
|
crossingPenalty?: number;
|
|
@@ -1007,6 +1105,7 @@ declare class ViaGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
|
1007
1105
|
constructor(input: {
|
|
1008
1106
|
inputGraph: HyperGraph | SerializedHyperGraph;
|
|
1009
1107
|
inputConnections: (Connection | SerializedConnection)[];
|
|
1108
|
+
inputSolvedRoutes?: SolvedRoute[];
|
|
1010
1109
|
viaTile?: ViaTile;
|
|
1011
1110
|
ripCost?: number;
|
|
1012
1111
|
portUsagePenalty?: number;
|
|
@@ -1190,4 +1289,4 @@ declare function generateConvexViaTopologyRegions(opts: {
|
|
|
1190
1289
|
};
|
|
1191
1290
|
};
|
|
1192
1291
|
|
|
1193
|
-
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 };
|