@tscircuit/hypergraph 0.0.1 → 0.0.3
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 +12 -0
- package/dist/index.js +19 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -335,9 +335,21 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
335
335
|
|
|
336
336
|
declare class JumperGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
337
337
|
UNIT_OF_COST: string;
|
|
338
|
+
portUsagePenalty: number;
|
|
339
|
+
portUsagePenaltySq: number;
|
|
340
|
+
crossingPenalty: number;
|
|
341
|
+
crossingPenaltySq: number;
|
|
342
|
+
ripCost: number;
|
|
343
|
+
baseMaxIterations: number;
|
|
344
|
+
additionalMaxIterationsPerConnection: number;
|
|
338
345
|
constructor(input: {
|
|
339
346
|
inputGraph: HyperGraph | SerializedHyperGraph;
|
|
340
347
|
inputConnections: (Connection | SerializedConnection)[];
|
|
348
|
+
ripCost?: number;
|
|
349
|
+
portUsagePenalty?: number;
|
|
350
|
+
crossingPenalty?: number;
|
|
351
|
+
baseMaxIterations?: number;
|
|
352
|
+
additionalMaxIterationsPerConnection?: number;
|
|
341
353
|
});
|
|
342
354
|
estimateCostToEnd(port: JPort): number;
|
|
343
355
|
getPortUsagePenalty(port: JPort): number;
|
package/dist/index.js
CHANGED
|
@@ -2277,23 +2277,36 @@ function computeCrossingAssignments(region, port1, port2) {
|
|
|
2277
2277
|
// lib/JumperGraphSolver/JumperGraphSolver.ts
|
|
2278
2278
|
var JumperGraphSolver = class extends HyperGraphSolver {
|
|
2279
2279
|
UNIT_OF_COST = "distance";
|
|
2280
|
+
portUsagePenalty = 0.197;
|
|
2281
|
+
portUsagePenaltySq = 0;
|
|
2282
|
+
crossingPenalty = 6.007;
|
|
2283
|
+
crossingPenaltySq = 0.111;
|
|
2284
|
+
ripCost = 40;
|
|
2285
|
+
baseMaxIterations = 4e3;
|
|
2286
|
+
additionalMaxIterationsPerConnection = 2e3;
|
|
2280
2287
|
constructor(input) {
|
|
2281
2288
|
super({
|
|
2282
|
-
|
|
2283
|
-
greedyMultiplier: 1.2,
|
|
2289
|
+
greedyMultiplier: 0.45,
|
|
2284
2290
|
rippingEnabled: true,
|
|
2285
|
-
|
|
2291
|
+
...input
|
|
2286
2292
|
});
|
|
2287
|
-
this.
|
|
2293
|
+
this.ripCost = input.ripCost ?? this.ripCost;
|
|
2294
|
+
this.portUsagePenalty = input.portUsagePenalty ?? this.portUsagePenalty;
|
|
2295
|
+
this.crossingPenalty = input.crossingPenalty ?? this.crossingPenalty;
|
|
2296
|
+
this.baseMaxIterations = input.baseMaxIterations ?? this.baseMaxIterations;
|
|
2297
|
+
this.additionalMaxIterationsPerConnection = input.additionalMaxIterationsPerConnection ?? this.additionalMaxIterationsPerConnection;
|
|
2298
|
+
this.MAX_ITERATIONS = this.baseMaxIterations + input.inputConnections.length * this.additionalMaxIterationsPerConnection;
|
|
2288
2299
|
}
|
|
2289
2300
|
estimateCostToEnd(port) {
|
|
2290
2301
|
return distance(port.d, this.currentEndRegion.d.center);
|
|
2291
2302
|
}
|
|
2292
2303
|
getPortUsagePenalty(port) {
|
|
2293
|
-
|
|
2304
|
+
const ripCount = port.ripCount ?? 0;
|
|
2305
|
+
return ripCount * this.portUsagePenalty + ripCount * this.portUsagePenaltySq;
|
|
2294
2306
|
}
|
|
2295
2307
|
computeIncreasedRegionCostIfPortsAreUsed(region, port1, port2) {
|
|
2296
|
-
|
|
2308
|
+
const crossings = computeDifferentNetCrossings(region, port1, port2);
|
|
2309
|
+
return crossings * this.crossingPenalty + crossings * this.crossingPenaltySq;
|
|
2297
2310
|
}
|
|
2298
2311
|
getRipsRequiredForPortUsage(region, port1, port2) {
|
|
2299
2312
|
const crossingAssignments = computeCrossingAssignments(region, port1, port2);
|