@mark1russell7/highways 0.4.0 → 0.4.2
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/README.md +67 -1
- package/build/index.d.ts +954 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5914 -1419
- package/build/index.js.map +1 -1
- package/package.json +2 -1
- package/src/bench/measures/bundles.ts +101 -2
- package/src/bench/measures/highways.ts +93 -0
- package/src/bench/measures/index.ts +2 -0
- package/src/bench/measures/order.ts +97 -0
- package/src/bench/room.ts +126 -9
- package/src/bench/screen/measures.ts +17 -0
- package/src/bench/screen/screen.ts +87 -9
- package/src/highways/base.ts +126 -0
- package/src/highways/flow-field/index.ts +49 -0
- package/src/highways/gates/ambiguity/index.ts +110 -0
- package/src/highways/gates/breakeven/index.ts +62 -0
- package/src/highways/gates/hysteresis/index.ts +48 -0
- package/src/highways/gates/ids/index.ts +59 -0
- package/src/highways/gates/index.ts +6 -0
- package/src/highways/gates/model.ts +129 -0
- package/src/highways/gates/stretch/index.ts +39 -0
- package/src/highways/grouped.ts +123 -0
- package/src/highways/index.ts +15 -0
- package/src/highways/level-links/index.ts +114 -0
- package/src/highways/meet/index.ts +84 -0
- package/src/highways/model.ts +5 -0
- package/src/highways/od-cells/index.ts +50 -0
- package/src/highways/quickbundles/index.ts +117 -0
- package/src/highways/road-classes/index.ts +74 -0
- package/src/highways/router.ts +1 -1
- package/src/highways/select/index.ts +162 -0
- package/src/highways/stretches.ts +141 -0
- package/src/highways/stubs/index.ts +117 -0
- package/src/highways/weiszfeld/index.ts +105 -0
- package/src/highways/wspd/index.ts +130 -0
- package/src/highways/zipper/index.ts +168 -0
- package/src/index.ts +2 -0
- package/src/order/index.ts +65 -0
- package/src/plugs/justify.ts +48 -0
- package/src/plugs/side.ts +138 -0
- package/src/repair/index.ts +377 -0
- package/src/repair/walk.ts +220 -0
- package/src/room/lanes.ts +109 -10
- package/src/routers/corners.ts +73 -6
- package/src/routers/fan.ts +145 -0
- package/src/routers/index.ts +2 -2
- package/src/routers/shared.ts +107 -8
- package/src/routers/snell.ts +140 -0
- package/src/routers/trunks.ts +43 -2
- package/src/strategies/builtins.ts +149 -7
- package/src/strategies/schemas.ts +173 -2
package/build/index.d.ts
CHANGED
|
@@ -983,12 +983,24 @@ export declare const straightRouter: Router;
|
|
|
983
983
|
* It goes to the target plug on the curve of the rule. This router measures the rule alone.
|
|
984
984
|
*/
|
|
985
985
|
export declare const plugsRouter: Router;
|
|
986
|
+
/** The ways to place a free plug of the corner router. */
|
|
987
|
+
type PlugPlace = "facing" | "side";
|
|
986
988
|
/** The options of the corner router. */
|
|
987
989
|
interface CornersOptions extends WayOptions {
|
|
988
990
|
/** The name in the benchmark. */
|
|
989
991
|
readonly name: string;
|
|
990
992
|
/** The benchmark skips a fixture with more nodes. */
|
|
991
993
|
readonly maxNodes?: number;
|
|
994
|
+
/**
|
|
995
|
+
* The place of a free plug. The default is `facing`: the plug faces the other end (`placePlug`).
|
|
996
|
+
* With `side`, the search starts from the whole free side, and the plug goes where the way leaves the side (`sidePlugs`, WILD-001).
|
|
997
|
+
*/
|
|
998
|
+
readonly plugs?: PlugPlace;
|
|
999
|
+
/**
|
|
1000
|
+
* The least gap between two free plugs of one side. The default is 0: each plug stays where it is.
|
|
1001
|
+
* Above 0, the free plugs of each side keep their order and move the least distance (`justifyPlugs`, WILD-002).
|
|
1002
|
+
*/
|
|
1003
|
+
readonly plugGap?: number;
|
|
992
1004
|
}
|
|
993
1005
|
/**
|
|
994
1006
|
* This function makes a router that goes around the nodes.
|
|
@@ -996,6 +1008,12 @@ interface CornersOptions extends WayOptions {
|
|
|
996
1008
|
* of the box corners, without the needless corners. It enters the target plug along its normal.
|
|
997
1009
|
*/
|
|
998
1010
|
export declare function cornersRouter(options: CornersOptions): Router;
|
|
1011
|
+
/** The cost of a link that edges of one key share: a fixed discount, or the flow cost `len * f^alpha` (EDA-029). */
|
|
1012
|
+
type ShareCost = "fixed" | "flow";
|
|
1013
|
+
/** The order of the edges of one key: the longest first, the shortest first, the most load first, or the order of the input (NAT-024). */
|
|
1014
|
+
type ShareOrder = "span" | "shortest" | "load" | "input";
|
|
1015
|
+
/** The place where a route joins or leaves a run: at a corner of the graph, or at the Snell angle (NAT-035). */
|
|
1016
|
+
type ShareMerge = "corner" | "snell";
|
|
999
1017
|
/** The options of the router with shared ways. */
|
|
1000
1018
|
interface SharedOptions extends WayOptions {
|
|
1001
1019
|
/** The name in the benchmark. */
|
|
@@ -1006,6 +1024,25 @@ interface SharedOptions extends WayOptions {
|
|
|
1006
1024
|
readonly discount?: number;
|
|
1007
1025
|
/** The lane order of the runs. With `bundle`, the default, two edges keep one order on each run of their common stretch. With `run`, each run gets its order alone. */
|
|
1008
1026
|
readonly laneOrder?: RunOrder;
|
|
1027
|
+
/**
|
|
1028
|
+
* The cost of a shared link. With `fixed`, the default, a link that the key uses already costs `discount` times its length.
|
|
1029
|
+
* With `flow`, one more edge on a link with `f` edges costs `len * ((f + 1)^alpha - f^alpha)` (EDA-029).
|
|
1030
|
+
*/
|
|
1031
|
+
readonly cost?: ShareCost;
|
|
1032
|
+
/** The exponent of the flow cost, from 0.1 to 1. A smaller value gives more sharing. The default is 0.6. Only the cost `flow` uses it. */
|
|
1033
|
+
readonly alpha?: number;
|
|
1034
|
+
/** The number of passes. In each pass after the first, each edge leaves its links and finds its way again with the others fixed (HWY-039). The default is 1. */
|
|
1035
|
+
readonly passes?: number;
|
|
1036
|
+
/**
|
|
1037
|
+
* The order of the edges of one key. With `span`, the default, the longest edge goes first. With `shortest`, the shortest edge goes first.
|
|
1038
|
+
* With `load`, the edge with the most edges between its two sections goes first. With `input`, the edges keep the order of the graph (NAT-024).
|
|
1039
|
+
*/
|
|
1040
|
+
readonly order?: ShareOrder;
|
|
1041
|
+
/**
|
|
1042
|
+
* The place where a route joins or leaves a run. With `corner`, the default, it is a corner of the graph.
|
|
1043
|
+
* With `snell`, the route meets the run at the angle `acos(d)`, with `d` the cost share of the run for the route (NAT-035).
|
|
1044
|
+
*/
|
|
1045
|
+
readonly merge?: ShareMerge;
|
|
1009
1046
|
/** The benchmark skips a fixture with more nodes. */
|
|
1010
1047
|
readonly maxNodes?: number;
|
|
1011
1048
|
}
|
|
@@ -1046,6 +1083,14 @@ interface HighwayInput {
|
|
|
1046
1083
|
* The strategy `corridors` makes the ways of the corner graph, as the router `corners` finds them.
|
|
1047
1084
|
*/
|
|
1048
1085
|
readonly routes?: Result;
|
|
1086
|
+
/**
|
|
1087
|
+
* This value is the graph before an edit and the plan of the same strategy on it. A strategy that keeps its highways stable over edits reads it.
|
|
1088
|
+
* The gates `hysteresis` (HWY-046) and `ids` (HWY-054) read it. The other strategies ignore it.
|
|
1089
|
+
*/
|
|
1090
|
+
readonly previous?: {
|
|
1091
|
+
readonly graph: Graph;
|
|
1092
|
+
readonly plan: HighwayPlan;
|
|
1093
|
+
};
|
|
1049
1094
|
}
|
|
1050
1095
|
/**
|
|
1051
1096
|
* One edge of a highway. The edge joins the spine at the merge point and leaves it at the split point.
|
|
@@ -1557,11 +1602,29 @@ interface TrunksOptions extends WayOptions {
|
|
|
1557
1602
|
* A lane that turns back over the trunk leaves at an earlier point of the trunk. With `split`, each lane leaves at the split point, as in version 0.2.0.
|
|
1558
1603
|
*/
|
|
1559
1604
|
readonly leave?: TrunkLeave;
|
|
1605
|
+
/**
|
|
1606
|
+
* The place of the split point. With `share`, the default, it is at `split` of the way to the center of the targets.
|
|
1607
|
+
* With `gilbert`, it is where the flow cost of the trunk and its branches is least, with the exponent `alpha` (EDA-030).
|
|
1608
|
+
*/
|
|
1609
|
+
readonly splitAt?: TrunkSplit;
|
|
1610
|
+
/** The exponent of the flow cost of the split `gilbert`, from 0 to 1. The default is 0.5. */
|
|
1611
|
+
readonly alpha?: number;
|
|
1612
|
+
/**
|
|
1613
|
+
* The shape of each group. With `split`, the default, the edges share a trunk to a split point.
|
|
1614
|
+
* With `tree`, the edges grow a balancing-factor tree from the plug, with the factor `bf` (NAT-017).
|
|
1615
|
+
*/
|
|
1616
|
+
readonly fan?: TrunkFan;
|
|
1617
|
+
/** The balancing factor of the fan `tree`, from 0 to 1. 0 gives the least ink, and a larger factor gives more direct routes. The default is 0.4. */
|
|
1618
|
+
readonly bf?: number;
|
|
1560
1619
|
/** The benchmark skips a fixture with more nodes. */
|
|
1561
1620
|
readonly maxNodes?: number;
|
|
1562
1621
|
}
|
|
1563
1622
|
/** The place where the lanes of a trunk leave it: where their ways part, or at the split point. */
|
|
1564
1623
|
type TrunkLeave = "part" | "split";
|
|
1624
|
+
/** The place of the split point of a trunk: at a share of the way, or at the Gilbert point of the flow cost (EDA-030). */
|
|
1625
|
+
type TrunkSplit = "share" | "gilbert";
|
|
1626
|
+
/** The shape of a group of the router `trunks`: a trunk and a split point, or a balancing-factor tree (NAT-017). */
|
|
1627
|
+
type TrunkFan = "split" | "tree";
|
|
1565
1628
|
/** The rule that groups the edges by the collection of their target, in `data.collection`. */
|
|
1566
1629
|
export declare const byCollection: GroupRule;
|
|
1567
1630
|
/**
|
|
@@ -1600,6 +1663,17 @@ export declare const ROUTERS: readonly Router[];
|
|
|
1600
1663
|
export type LaneOrder = "links" | "ends" | "crossings";
|
|
1601
1664
|
/** The lane orders of `gapLanes`, in the order of the benchmark. */
|
|
1602
1665
|
export declare const LANE_ORDERS: readonly LaneOrder[];
|
|
1666
|
+
/**
|
|
1667
|
+
* The rule that gives each piece of a gap its lane (its track), after the lane order.
|
|
1668
|
+
*
|
|
1669
|
+
* - `stack`: a piece goes one lane past each piece before it in the order that it overlaps. Thus two pieces that overlap keep their order.
|
|
1670
|
+
* - `left-edge`: the constrained left-edge rule of chip routing (EDA-004). Two pieces that overlap keep their order only where a swap adds crossings.
|
|
1671
|
+
* The rule fills the lowest lane first, with the pieces sorted by their start. Two pieces that do not overlap can share a lane.
|
|
1672
|
+
* - `free`: the left-edge rule without the order. It gives the fewest lanes, but it can add crossings.
|
|
1673
|
+
*/
|
|
1674
|
+
export type LaneTracks = "stack" | "left-edge" | "free";
|
|
1675
|
+
/** The lane rules of `gapLanes`, in the order of the benchmark. */
|
|
1676
|
+
export declare const LANE_TRACKS: readonly LaneTracks[];
|
|
1603
1677
|
/** The options of `gapLanes`. */
|
|
1604
1678
|
export interface GapLaneOptions {
|
|
1605
1679
|
/** The largest distance between two lanes. A narrow gap puts its lanes nearer. The default is 4. */
|
|
@@ -1608,6 +1682,21 @@ export interface GapLaneOptions {
|
|
|
1608
1682
|
readonly order?: LaneOrder;
|
|
1609
1683
|
/** Two box edges nearer than this distance make one boundary of the sweep, as in `boardGaps`. The default is 0.5. */
|
|
1610
1684
|
readonly snap?: number;
|
|
1685
|
+
/** The rule that gives each piece its lane. The default is `stack`. */
|
|
1686
|
+
readonly tracks?: LaneTracks;
|
|
1687
|
+
}
|
|
1688
|
+
/** The lanes of one gap: the axis and the place of the gap, and the number of lanes that its pieces use. */
|
|
1689
|
+
export interface GapLaneCount {
|
|
1690
|
+
readonly axis: "x" | "y";
|
|
1691
|
+
readonly at: number;
|
|
1692
|
+
/** The width of the gap. */
|
|
1693
|
+
readonly width: number;
|
|
1694
|
+
/** The number of lanes of the gap. */
|
|
1695
|
+
readonly lanes: number;
|
|
1696
|
+
/** The number of pieces in the gap: the legs of the links that run along it. */
|
|
1697
|
+
readonly pieces: number;
|
|
1698
|
+
/** The largest number of pieces that overlap at one place of the gap. No rule gives fewer lanes. */
|
|
1699
|
+
readonly density: number;
|
|
1611
1700
|
}
|
|
1612
1701
|
/**
|
|
1613
1702
|
* This function gives each link that runs along a gap its own lane in the gap. The lanes of a gap are `spacing` apart, around its middle line.
|
|
@@ -1615,6 +1704,8 @@ export interface GapLaneOptions {
|
|
|
1615
1704
|
* When a move puts a link through more boxes than before, the link keeps its points.
|
|
1616
1705
|
*/
|
|
1617
1706
|
export declare function gapLanes(items: readonly Boxed[], links: readonly LevelLink[], options?: GapLaneOptions): LevelLink[];
|
|
1707
|
+
/** This function gives the lanes of each gap that holds a piece of a link, with the options of `gapLanes`. A gap without a piece is not in the list. */
|
|
1708
|
+
export declare function gapLaneCounts(items: readonly Boxed[], links: readonly LevelLink[], options?: GapLaneOptions): GapLaneCount[];
|
|
1618
1709
|
/**
|
|
1619
1710
|
* The boards of the zoom levels of `levelRoom`.
|
|
1620
1711
|
*
|
|
@@ -2191,6 +2282,42 @@ export interface BendRoomRow extends HighwayMeasures {
|
|
|
2191
2282
|
export declare function benchBendRoom(router: Router, fixture: string, graph: Graph, options?: RoomOptions): BendRoomRow[];
|
|
2192
2283
|
/** This function writes the rows of `benchBendRoom` as a Markdown table. The spacing error is a percent of the spacing. */
|
|
2193
2284
|
export declare function formatBendRoom(rows: readonly BendRoomRow[]): string;
|
|
2285
|
+
/** One row of `benchTracks` (EDA-004): the lanes of the far view of one board with one lane rule of `gapLanes`. */
|
|
2286
|
+
export interface TrackBenchRow {
|
|
2287
|
+
readonly fixture: string;
|
|
2288
|
+
/** The board: `given` (the board as it is) or `open` (the board that `makeRoom` opens at gutter 8 and spacing 4). */
|
|
2289
|
+
readonly board: string;
|
|
2290
|
+
readonly tracks: LaneTracks;
|
|
2291
|
+
/** The number of gaps with at least one piece. */
|
|
2292
|
+
readonly gaps: number;
|
|
2293
|
+
/** The sum of the lanes of the gaps. */
|
|
2294
|
+
readonly lanes: number;
|
|
2295
|
+
/** The sum of the densities of the gaps: the most pieces that overlap at one place. No rule gives fewer lanes. */
|
|
2296
|
+
readonly density: number;
|
|
2297
|
+
/** The number of gaps whose lanes are nearer than `spacing`, because the gap is too narrow for its lanes. */
|
|
2298
|
+
readonly squeezed: number;
|
|
2299
|
+
/** The crossings of the links of the far view (`measureQuality`). */
|
|
2300
|
+
readonly crossings: number;
|
|
2301
|
+
/** The ink of the links of the far view. */
|
|
2302
|
+
readonly ink: number;
|
|
2303
|
+
/** R12: the length of parallel legs of two links nearer than `spacing`, as a share of the ink. */
|
|
2304
|
+
readonly separation: number;
|
|
2305
|
+
/** The number of links of the far view that go through a box. */
|
|
2306
|
+
readonly through: number;
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* This function gives R12 (lane separation) of the links. Two legs of two links are near when they are parallel and nearer than `near`.
|
|
2310
|
+
* R12 is the length of the near legs, as a share of the ink.
|
|
2311
|
+
* It reads only the legs on an axis. The links of the far view have no other legs.
|
|
2312
|
+
*/
|
|
2313
|
+
export declare function laneSeparation(links: readonly LevelLink[], near: number): number;
|
|
2314
|
+
/**
|
|
2315
|
+
* This function measures each lane rule of `gapLanes` (EDA-004) on the board as it is, and on the board that `makeRoom` opens.
|
|
2316
|
+
* The lane order is `crossings` for each rule. The lanes are `spacing` apart where the gap has room.
|
|
2317
|
+
*/
|
|
2318
|
+
export declare function benchTracks(fixture: string, graph: Graph, spacing?: number, rules?: readonly LaneTracks[]): TrackBenchRow[];
|
|
2319
|
+
/** This function writes the rows of `benchTracks` as a Markdown table. */
|
|
2320
|
+
export declare function formatTracks(rows: readonly TrackBenchRow[]): string;
|
|
2194
2321
|
/** The options of one setting of the router `sections`, without the name. */
|
|
2195
2322
|
export type SectionsSettingOptions = Omit<SectionsOptions, "name" | "maxNodes">;
|
|
2196
2323
|
/** One setting of a sweep of the router `sections`. */
|
|
@@ -2377,6 +2504,34 @@ export interface AmbiguityOptions {
|
|
|
2377
2504
|
* `amb = Σ_v count(w in N(v) : no edge v-w) / Σ_v count(N(v))`. The cost is quadratic, so a seeded sample serves above `exact` nodes.
|
|
2378
2505
|
*/
|
|
2379
2506
|
export declare function ambiguity(graph: Graph, routes: readonly Route[], options?: AmbiguityOptions): Ambiguity;
|
|
2507
|
+
/**
|
|
2508
|
+
* This function gives the bundled share of a result (B2 of MEAS0): `count(e : e is in a run or a bundle) / m`.
|
|
2509
|
+
* An edge is also in a bundle when its route shares a drawn segment with the route of another edge. Thus a router without `runs` and `bundles` gets a value too.
|
|
2510
|
+
* The scale is 0 to 1. A higher value is better only in context. The cost is linear.
|
|
2511
|
+
*/
|
|
2512
|
+
export declare function bundledShare(result: Result): number;
|
|
2513
|
+
/** The bundle stretch of the routes against base routes (B3 of MEAS0). */
|
|
2514
|
+
export interface BundleStretch {
|
|
2515
|
+
/** The median of `st(e) = L(r_e) / L(r*_e)`. A value of 1 is the length of the base route. Lower is better. */
|
|
2516
|
+
readonly median: number;
|
|
2517
|
+
/** The `0.95` quantile of `st(e)`: the tail of long detours that the bundles add. */
|
|
2518
|
+
readonly q95: number;
|
|
2519
|
+
/** The number of edges with a route in both lists and a base route longer than 1 unit. */
|
|
2520
|
+
readonly edges: number;
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* This function gives the bundle stretch (B3 of MEAS0): `st(e) = L(r_e) / L(r*_e)` for each edge, with `r*_e` the base route of the edge.
|
|
2524
|
+
* The base routes are the routes of `corners` on the same input. An edge without a base route, or with a base route of 1 unit or less, does not count.
|
|
2525
|
+
* The cost is an extra run of the base router, and then linear.
|
|
2526
|
+
*/
|
|
2527
|
+
export declare function bundleStretch(routes: readonly Route[], base: readonly Route[]): BundleStretch;
|
|
2528
|
+
/**
|
|
2529
|
+
* This function gives the merge angle of the routes (B6 of MEAS0): the largest turn of a lane where it joins or leaves a run, in degrees.
|
|
2530
|
+
* A run is a drawn segment that the routes of two edges or more share. A route joins or leaves a run at a vertex where the edges on its segment change.
|
|
2531
|
+
* One of the two segments at that vertex has two edges or more. The turn is the angle between the two segments.
|
|
2532
|
+
* Routes without a shared segment give 0. The scale is 0 to 180 degrees, and lower is better. The cost is linear.
|
|
2533
|
+
*/
|
|
2534
|
+
export declare function mergeAngle(routes: readonly Route[]): number;
|
|
2380
2535
|
/** A joint of a curve: the end of one drawn segment and the start of the next drawn segment. */
|
|
2381
2536
|
export interface CurveJoint {
|
|
2382
2537
|
readonly at: Point;
|
|
@@ -2558,6 +2713,80 @@ export declare function dominates(a: Readonly<Record<string, number>>, b: Readon
|
|
|
2558
2713
|
* The function `values` gives the measures of an item. The front keeps the order of the list. The cost is quadratic in the items.
|
|
2559
2714
|
*/
|
|
2560
2715
|
export declare function paretoFront<T>(items: readonly T[], values: (item: T) => Readonly<Record<string, number>>, objectives: readonly Objective[]): T[];
|
|
2716
|
+
/** The order fragility of a router on one graph (W3 of MEAS3, from WILD-056). */
|
|
2717
|
+
export interface OrderFragility {
|
|
2718
|
+
/** The number of random orders. */
|
|
2719
|
+
readonly orders: number;
|
|
2720
|
+
/** `IQR / median` of the crossings (R1) over the orders. A value of 0 is a router that the order does not move. */
|
|
2721
|
+
readonly crossings: number;
|
|
2722
|
+
/** `IQR / median` of the median detour (R5) over the orders. */
|
|
2723
|
+
readonly detour: number;
|
|
2724
|
+
/** `IQR / median` of the ink saved (B1) over the orders. */
|
|
2725
|
+
readonly inkSaved: number;
|
|
2726
|
+
/** `IQR / median` of the ink over the orders. */
|
|
2727
|
+
readonly ink: number;
|
|
2728
|
+
/** The share of the orders whose routes differ from the routes of the input order. A value of 0 is a router that is free of the order. */
|
|
2729
|
+
readonly changed: number;
|
|
2730
|
+
/**
|
|
2731
|
+
* The crossings of the input order divided by the fewest crossings over the orders (the price of anarchy of WILD-056).
|
|
2732
|
+
* A value of 1 is a default order as good as the best random order. It is `NaN` when the best order has 0 crossings and the input order has more.
|
|
2733
|
+
*/
|
|
2734
|
+
readonly poa: number;
|
|
2735
|
+
}
|
|
2736
|
+
/** The options of `orderFragility`. */
|
|
2737
|
+
export interface OrderFragilityOptions {
|
|
2738
|
+
/** The number of random orders of the edges. The default is 20. */
|
|
2739
|
+
readonly orders?: number;
|
|
2740
|
+
/** The seed of the first order. The order `k` has the seed `seed + k`. The default is 1. */
|
|
2741
|
+
readonly seed?: number;
|
|
2742
|
+
/** The result of the input order, when the caller has it. Without it, the function routes the input order one time more. */
|
|
2743
|
+
readonly base?: Result;
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2746
|
+
* This function measures the order fragility of a router on one graph (W3, from WILD-056).
|
|
2747
|
+
* It routes the graph with `orders` random orders of the edges.
|
|
2748
|
+
* It gives the spread `IQR / median` of the crossings, the detour, the ink saved and the ink.
|
|
2749
|
+
* It also gives the share of orders that change a route, and the price of anarchy of the crossings.
|
|
2750
|
+
* The cost is `orders` extra runs of the router.
|
|
2751
|
+
*/
|
|
2752
|
+
export declare function orderFragility(graph: Graph, route: (graph: Graph) => Result, options?: OrderFragilityOptions): OrderFragility;
|
|
2753
|
+
/**
|
|
2754
|
+
* This function gives the churn of the highways over one edit (Z10 for highways, from HWY-046). Two edges are a pair when they share a highway.
|
|
2755
|
+
* The churn is the share of the pairs that come or go: `|P ∆ P'| / |P ∪ P'|`. Only the edges of `edges` count, for example the edges of both graphs.
|
|
2756
|
+
* Two plans without pairs give 0. The scale is 0 to 1, and lower is better.
|
|
2757
|
+
*/
|
|
2758
|
+
export declare function highwayChurn(before: HighwayPlan, after: HighwayPlan, edges: ReadonlySet<string>): number;
|
|
2759
|
+
/** The match of the highways over one edit. */
|
|
2760
|
+
export interface HighwayIdKeep {
|
|
2761
|
+
/** The number of new highways with a match in the old plan: a Jaccard index of their edges of 0.5 or more. */
|
|
2762
|
+
readonly matched: number;
|
|
2763
|
+
/** The number of matched highways that keep the id of their match. */
|
|
2764
|
+
readonly kept: number;
|
|
2765
|
+
/** `kept / matched`, or `NaN` without a match. The scale is 0 to 1, and higher is better. */
|
|
2766
|
+
readonly share: number;
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* This function tells how many highways keep their id over one edit (HWY-054). It matches the new highways with the old ones by `matchHighways`, with the index 0.5.
|
|
2770
|
+
* A matched highway keeps its id when its id is the id of its match. Only the edges of `edges` count.
|
|
2771
|
+
*/
|
|
2772
|
+
export declare function highwayIdKeep(before: HighwayPlan, after: HighwayPlan, edges: ReadonlySet<string>): HighwayIdKeep;
|
|
2773
|
+
/** The stability of a highway strategy over a seeded sequence of edits. Each value is the mean over the edits. */
|
|
2774
|
+
export interface HighwayEdits {
|
|
2775
|
+
/** The mean Fréchet distance of the routes over one edit, in units of the board (Z10). */
|
|
2776
|
+
readonly mean: number;
|
|
2777
|
+
/** The share of the routes that move over one edit (Z10). */
|
|
2778
|
+
readonly moved: number;
|
|
2779
|
+
/** The churn of the highways over one edit (`highwayChurn`). */
|
|
2780
|
+
readonly churn: number;
|
|
2781
|
+
/** The share of the matched highways that keep their id over one edit (`highwayIdKeep`), or `NaN` without a match. */
|
|
2782
|
+
readonly ids: number;
|
|
2783
|
+
}
|
|
2784
|
+
/**
|
|
2785
|
+
* This function measures a highway strategy over a sequence of `edits` seeded edits. Each edit is the small change of `changeGraph` with the seed `seed + i`.
|
|
2786
|
+
* The strategy gets the graph and its plan before the edit as `previous`, so a strategy with memory can keep its highways.
|
|
2787
|
+
* `follow` routes each plan with the way options of the strategy. The same graph, strategy, options and seed give the same values.
|
|
2788
|
+
*/
|
|
2789
|
+
export declare function highwayEdits(graph: Graph, strategy: Strategy<"highway", object>, options: object | undefined, edits: number, seed?: number): HighwayEdits;
|
|
2561
2790
|
/** The names of the proposed hard rules of MEAS0. The suite counts them. It does not apply them as rules yet. */
|
|
2562
2791
|
export declare const PROPOSED_RULES: readonly string[];
|
|
2563
2792
|
/** The options of `runSuite`. */
|
|
@@ -2827,6 +3056,180 @@ export declare function minHash(keys: Iterable<string>, count: number): number[]
|
|
|
2827
3056
|
* The edges of the cluster that are not on the spine make the next highway, while `minSize` of them remain.
|
|
2828
3057
|
*/
|
|
2829
3058
|
export declare function corridorPlan(input: HighwayInput, o: Readonly<CorridorOptions>): HighwayPlan;
|
|
3059
|
+
/**
|
|
3060
|
+
* A gate: a rule that keeps, drops or changes the highways of a plan. `gateStrategy` puts a gate after a highway strategy.
|
|
3061
|
+
* A gate does not move a spine. It takes members out of a highway, drops a highway or changes the id of a highway.
|
|
3062
|
+
*/
|
|
3063
|
+
interface Gate<G extends object> {
|
|
3064
|
+
/** The name of the gate. The strategy of a gate has the name `<strategy>+<gate>`. */
|
|
3065
|
+
readonly name: string;
|
|
3066
|
+
/** One or two sentences that tell what the gate does. */
|
|
3067
|
+
readonly describe: string;
|
|
3068
|
+
/** The values of the options of the gate. Their keys must not be keys of the options of the strategy before the gate. */
|
|
3069
|
+
readonly defaults: G;
|
|
3070
|
+
readonly schema: OptionSchema<G>;
|
|
3071
|
+
/** This function gives the plan after the gate. `way` holds the options of the way finder of the strategy. */
|
|
3072
|
+
apply(input: HighwayInput, plan: HighwayPlan, options: Readonly<G>, way: WayOptions): HighwayPlan;
|
|
3073
|
+
}
|
|
3074
|
+
/**
|
|
3075
|
+
* This function puts a gate after a highway strategy. The new strategy has the name `<strategy>+<gate>`, and the options of both.
|
|
3076
|
+
* The strategy gets its own options, and the gate gets the plan of the strategy and the options of the gate.
|
|
3077
|
+
* Thus a gate can follow each plan, for example `corridors+breakeven` or `shared-ways+stretch`. Gates can follow gates.
|
|
3078
|
+
*/
|
|
3079
|
+
export declare function gateStrategy<O extends object, G extends object>(strategy: Strategy<"highway", O>, gate: Gate<G>): Strategy<"highway", O & G>;
|
|
3080
|
+
/**
|
|
3081
|
+
* This function gives the plan with only the members that `keep` accepts. A highway with fewer than two members goes away.
|
|
3082
|
+
* The lanes keep their order, and each highway keeps its id, its key and its spine.
|
|
3083
|
+
*/
|
|
3084
|
+
export declare function keepMembers(plan: HighwayPlan, keep: (h: Highway, m: HighwayMember) => boolean): HighwayPlan;
|
|
3085
|
+
/** The lengths of the route of one edge of a plan. */
|
|
3086
|
+
interface EdgeLengths {
|
|
3087
|
+
/** The length of the route along the plan, after `follow`. */
|
|
3088
|
+
readonly route: number;
|
|
3089
|
+
/** The length of the route without a highway: the route of the router `corners`. */
|
|
3090
|
+
readonly alone: number;
|
|
3091
|
+
}
|
|
3092
|
+
/**
|
|
3093
|
+
* This function gives the length of the route of each edge of a plan, along the plan and alone. `follow` routes each edge of a plan on its own.
|
|
3094
|
+
* Thus the route of an edge does not change when another edge leaves the plan.
|
|
3095
|
+
*/
|
|
3096
|
+
export declare function edgeLengths(graph: Graph, plan: HighwayPlan, way: WayOptions): Map<string, EdgeLengths>;
|
|
3097
|
+
/** This function gives the ids of the edges that both graphs have. */
|
|
3098
|
+
export declare function commonEdges(a: Graph, b: Graph): Set<string>;
|
|
3099
|
+
/** This function gives the Jaccard index of two sets of edges: the common edges over all edges. Two empty sets give 0. */
|
|
3100
|
+
export declare function jaccard(a: ReadonlySet<string>, b: ReadonlySet<string>): number;
|
|
3101
|
+
/**
|
|
3102
|
+
* This function matches the highways of a plan with the highways of an earlier plan. It pairs the highways with the largest Jaccard index of their edges first.
|
|
3103
|
+
* A pair needs an index of `min` or more. Each highway is in one pair at most. The result maps the index of a new highway to the index of its old highway.
|
|
3104
|
+
* Only the edges of `edges` count, when this set is present: for example the edges of both graphs.
|
|
3105
|
+
*/
|
|
3106
|
+
export declare function matchHighways(before: HighwayPlan, after: HighwayPlan, min: number, edges?: ReadonlySet<string>): Map<number, number>;
|
|
3107
|
+
/** The options of the gate `ambiguity` (HWY-049). */
|
|
3108
|
+
interface AmbiguityGuardOptions {
|
|
3109
|
+
/** Two groups of edges merge only when the merge adds this share of false pairs, or less. The default is 0.5. */
|
|
3110
|
+
readonly maxAmbiguity: number;
|
|
3111
|
+
/** With `node`, the default, two groups merge only when they share an end node. With `any`, only `maxAmbiguity` decides. */
|
|
3112
|
+
readonly link: "node" | "any";
|
|
3113
|
+
}
|
|
3114
|
+
/** The default options of the gate `ambiguity`. */
|
|
3115
|
+
export declare const AMBIGUITY_GUARD_DEFAULTS: Readonly<AmbiguityGuardOptions>;
|
|
3116
|
+
/**
|
|
3117
|
+
* This function gives the ambiguity of a set of nodes: the share of the pairs of distinct nodes without an edge between them.
|
|
3118
|
+
* The nodes are the ends of the edges of one highway. A set with fewer than two nodes gives 0.
|
|
3119
|
+
*/
|
|
3120
|
+
export declare function nodeAmbiguity(nodes: ReadonlySet<string>, adj: ReadonlyMap<string, ReadonlySet<string>>): number;
|
|
3121
|
+
/**
|
|
3122
|
+
* This function applies the ambiguity guard of HWY-049 to a plan. A highway joins edges that belong together.
|
|
3123
|
+
*
|
|
3124
|
+
* Two nodes are a false pair when their edges share a highway and no edge joins them. The ambiguity of a group of edges is the share of false pairs among the pairs of its end nodes.
|
|
3125
|
+
* In each highway, each edge starts as a group. Two groups merge only when `amb(A ∪ B) - max(amb A, amb B)` is at most `maxAmbiguity`.
|
|
3126
|
+
* With the link `node`, they also must share an end node. The merge with the smallest rise comes first.
|
|
3127
|
+
*
|
|
3128
|
+
* The largest group stays on the highway. The other edges leave it and go alone.
|
|
3129
|
+
*/
|
|
3130
|
+
export declare function ambiguityPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<AmbiguityGuardOptions>): HighwayPlan;
|
|
3131
|
+
/** The gate `ambiguity` (HWY-049): the ambiguity guard. A highway does not join edges whose end nodes have no edges between them. */
|
|
3132
|
+
export declare const ambiguityGate: Gate<AmbiguityGuardOptions>;
|
|
3133
|
+
/** The options of the gate `breakeven` (HWY-047). */
|
|
3134
|
+
interface BreakEvenOptions {
|
|
3135
|
+
/**
|
|
3136
|
+
* The exponent of the cost law: a stretch with `n` edges costs `n^shareAlpha` times its length. Each edge pays the share `n^(shareAlpha - 1)`.
|
|
3137
|
+
* With 0, a shared stretch is one line, as the ink of B1 counts it. The default is 0.5, as the break-even floor of `corridors`.
|
|
3138
|
+
*/
|
|
3139
|
+
readonly shareAlpha: number;
|
|
3140
|
+
}
|
|
3141
|
+
/** The default options of the gate `breakeven`. */
|
|
3142
|
+
export declare const BREAK_EVEN_DEFAULTS: Readonly<BreakEvenOptions>;
|
|
3143
|
+
/**
|
|
3144
|
+
* This function applies the break-even law of HWY-047 to a plan. An edge stays on its highways only when sharing saves ink.
|
|
3145
|
+
*
|
|
3146
|
+
* The edge pays `n^(shareAlpha - 1)` of each shared stretch, with `n` the members of the highway. Thus it saves `(1 - n^(shareAlpha - 1)) L` on a stretch of the length `L`.
|
|
3147
|
+
* It adds the length of its route along the plan less the length of its route alone. An edge stays when the saving is as large as the added length.
|
|
3148
|
+
* For two parallel edges at the gap `d`, this rule gives the break-even overlap `d √((2 + t) / (2 - t))` with `t = 2^shareAlpha`.
|
|
3149
|
+
*
|
|
3150
|
+
* An edge that does not save ink leaves each of its highways. Then the other members of those highways save less, so the test repeats until no edge leaves.
|
|
3151
|
+
*/
|
|
3152
|
+
export declare function breakEvenPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<BreakEvenOptions>, way?: WayOptions): HighwayPlan;
|
|
3153
|
+
/** The gate `breakeven` (HWY-047): an edge stays on a highway only when sharing saves ink. */
|
|
3154
|
+
export declare const breakEvenGate: Gate<BreakEvenOptions>;
|
|
3155
|
+
/** The options of the gate `hysteresis` (HWY-046). */
|
|
3156
|
+
interface HysteresisOptions {
|
|
3157
|
+
/** A new highway needs this number of edges or more. The default is 3. */
|
|
3158
|
+
readonly kOn: number;
|
|
3159
|
+
/** A highway of the earlier plan stays while it has this number of edges or more. The default is 2. */
|
|
3160
|
+
readonly kOff: number;
|
|
3161
|
+
}
|
|
3162
|
+
/** The default options of the gate `hysteresis`. */
|
|
3163
|
+
export declare const HYSTERESIS_DEFAULTS: Readonly<HysteresisOptions>;
|
|
3164
|
+
/** Two highways of two plans are the same highway when the Jaccard index of their edges is this value or more. */
|
|
3165
|
+
export declare const SAME_HIGHWAY = .5;
|
|
3166
|
+
/**
|
|
3167
|
+
* This function applies the count threshold with hysteresis of HWY-046 to a plan.
|
|
3168
|
+
* A highway with `kOn` edges or more stays. A highway with fewer than `kOff` edges goes away.
|
|
3169
|
+
* A highway between the two limits stays only when it was in the earlier plan, `input.previous`.
|
|
3170
|
+
* The highway of the earlier plan with the most common edges is its match, with a Jaccard index of `SAME_HIGHWAY` or more.
|
|
3171
|
+
*
|
|
3172
|
+
* Thus an edit that adds or removes one edge near the limit does not make a highway come and go. Without an earlier plan, the limit is `kOn`.
|
|
3173
|
+
*/
|
|
3174
|
+
export declare function hysteresisPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<HysteresisOptions>): HighwayPlan;
|
|
3175
|
+
/** The gate `hysteresis` (HWY-046): a highway forms at `kOn` edges and goes away below `kOff` edges. */
|
|
3176
|
+
export declare const hysteresisGate: Gate<HysteresisOptions>;
|
|
3177
|
+
/** The options of the gate `ids` (HWY-054). */
|
|
3178
|
+
interface StableIdOptions {
|
|
3179
|
+
/** A new highway takes the id of an old highway when the Jaccard index of their edges is this value or more. The default is 0.5. */
|
|
3180
|
+
readonly minJaccard: number;
|
|
3181
|
+
}
|
|
3182
|
+
/** The default options of the gate `ids`. */
|
|
3183
|
+
export declare const STABLE_ID_DEFAULTS: Readonly<StableIdOptions>;
|
|
3184
|
+
/**
|
|
3185
|
+
* This function gives stable ids to the highways of a plan (HWY-054). The earlier plan is `input.previous`.
|
|
3186
|
+
* Each new highway takes the id of the old highway with the most common edges.
|
|
3187
|
+
* The pairs with the largest Jaccard index of their edges come first.
|
|
3188
|
+
*
|
|
3189
|
+
* A pair needs an index of `minJaccard` or more, and only the edges of both graphs count.
|
|
3190
|
+
* A new highway without a match gets a new id `h<n>` that no old highway and no new highway has. Thus the old highway of a new id ends.
|
|
3191
|
+
* The gate changes only the ids, so the routes do not change. Without an earlier plan, the plan does not change.
|
|
3192
|
+
*/
|
|
3193
|
+
export declare function stableIdPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<StableIdOptions>): HighwayPlan;
|
|
3194
|
+
/** The gate `ids` (HWY-054): stable highway ids across edits. A highway keeps the id of its match in the earlier plan. */
|
|
3195
|
+
export declare const stableIdGate: Gate<StableIdOptions>;
|
|
3196
|
+
/** The options of the gate `stretch` (HWY-048). */
|
|
3197
|
+
interface StretchOptions {
|
|
3198
|
+
/** An edge stays on its highways when its route is at most this number times its route alone, plus `pad`. The default is 1.2. */
|
|
3199
|
+
readonly budget: number;
|
|
3200
|
+
/** The added length that each edge can use, in units of the board. The default is 0. */
|
|
3201
|
+
readonly pad: number;
|
|
3202
|
+
}
|
|
3203
|
+
/** The default options of the gate `stretch`. */
|
|
3204
|
+
export declare const STRETCH_DEFAULTS: Readonly<StretchOptions>;
|
|
3205
|
+
/**
|
|
3206
|
+
* This function applies the stretch budget of HWY-048 to a plan: the join test of each edge.
|
|
3207
|
+
* An edge stays on its highways only when its route along the plan is at most `budget` times its route alone, plus `pad`.
|
|
3208
|
+
* The route alone is the route of the router `corners`. An edge that fails leaves each of its highways and goes alone, so the highways do not bend for it.
|
|
3209
|
+
* `follow` routes each edge on its own, so the test of one edge does not change with the other edges. One pass is enough.
|
|
3210
|
+
*/
|
|
3211
|
+
export declare function stretchPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<StretchOptions>, way?: WayOptions): HighwayPlan;
|
|
3212
|
+
/** The gate `stretch` (HWY-048): an edge joins a highway only when its route stays in a budget of its route alone. */
|
|
3213
|
+
export declare const stretchGate: Gate<StretchOptions>;
|
|
3214
|
+
/** The end of the edges that gets a field: the target of a fan-in, or the source of a fan-out. */
|
|
3215
|
+
type FieldEnd = "target" | "source";
|
|
3216
|
+
/** The options of the highway strategy `flow-field` (EDA-046 with HWY-037 of the notes). */
|
|
3217
|
+
interface FlowFieldOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3218
|
+
/** An end with this number of edges or more on one side of its box gets a field. The default is 2. */
|
|
3219
|
+
readonly minFanIn: number;
|
|
3220
|
+
/** The end that gets a field. The default is `target`. */
|
|
3221
|
+
readonly end: FieldEnd;
|
|
3222
|
+
}
|
|
3223
|
+
/** The default options of the strategy `flow-field`. */
|
|
3224
|
+
export declare const FLOW_FIELD_DEFAULTS: Readonly<Required<Omit<FlowFieldOptions, "margin" | "k">>>;
|
|
3225
|
+
/**
|
|
3226
|
+
* This function gives the highways of a flow field for each target (EDA-046, HWY-037).
|
|
3227
|
+
* The edges into one side of one box make a fan. The root of the fan is the point out of the median plug of the fan.
|
|
3228
|
+
* Each edge of the fan goes the shortest way from the point out of its other plug to the root, through the corner graph.
|
|
3229
|
+
* The shortest ways to one root make a tree, so they merge like streams and do not cross. Each stretch that two ways share is one highway.
|
|
3230
|
+
* With the end `source`, the same holds for the edges out of one side of one box.
|
|
3231
|
+
*/
|
|
3232
|
+
export declare function flowFieldPlan(input: HighwayInput, o: Readonly<FlowFieldOptions>): HighwayPlan;
|
|
2830
3233
|
/** The options of the highway strategy `keys`: the options of the router `trunks`, without the name and the limit of the benchmark. */
|
|
2831
3234
|
type KeysOptions = Omit<TrunksOptions, "name" | "maxNodes">;
|
|
2832
3235
|
/**
|
|
@@ -2835,6 +3238,223 @@ type KeysOptions = Omit<TrunksOptions, "name" | "maxNodes">;
|
|
|
2835
3238
|
* Each trunk and each run becomes one highway. The function does not change the router: it reads its bundles and its runs.
|
|
2836
3239
|
*/
|
|
2837
3240
|
export declare function keysPlan(input: HighwayInput, options: KeysOptions): HighwayPlan;
|
|
3241
|
+
/**
|
|
3242
|
+
* The plan that a post step changes. `none` is the empty plan: `follow` then routes each edge as the router `corners` does.
|
|
3243
|
+
* `shared-ways` and `corridors` are the plans of those highway strategies, with their defaults.
|
|
3244
|
+
*/
|
|
3245
|
+
type HighwayBase = "none" | "shared-ways" | "corridors";
|
|
3246
|
+
/** The values of `HighwayBase`. */
|
|
3247
|
+
export declare const HIGHWAY_BASES: readonly HighwayBase[];
|
|
3248
|
+
/** This function gives the plan of a base. */
|
|
3249
|
+
export declare function basePlan(input: HighwayInput, base: HighwayBase): HighwayPlan;
|
|
3250
|
+
/** The options of the highway strategy `level-links` (HWY-056 with WILD-034 of the notes). */
|
|
3251
|
+
interface LevelHighwayOptions {
|
|
3252
|
+
/** The plan of the edges that do not ride a level link. The default is `shared-ways`. */
|
|
3253
|
+
readonly from: HighwayBase;
|
|
3254
|
+
/** The depth of the level in the tree of sections. Depth 1 is the level below the root. The default is 1. */
|
|
3255
|
+
readonly depth: number;
|
|
3256
|
+
/** A level link becomes a highway when this number of edges or more ride it. The default is 2. */
|
|
3257
|
+
readonly minSize: number;
|
|
3258
|
+
/** An edge rides the link only when its way along the link is this many times its first route, or shorter. The default is 1.5. */
|
|
3259
|
+
readonly stretch: number;
|
|
3260
|
+
}
|
|
3261
|
+
/** The default options of the strategy `level-links`. */
|
|
3262
|
+
export declare const LEVEL_HIGHWAY_DEFAULTS: Readonly<LevelHighwayOptions>;
|
|
3263
|
+
/**
|
|
3264
|
+
* This function gives a highway for each link of a zoom level, with the edges between its two items (HWY-056, WILD-034).
|
|
3265
|
+
* The level is the cut of the tree of sections at `depth`. The link goes around the boxes of the other items (`levelLinks`).
|
|
3266
|
+
* The spine is the link without a margin at each end, so it stays off the boxes of the two items. It must stay out of each box.
|
|
3267
|
+
* The edges between the two items, in each direction, ride the spine. The ramps go through the corner graph inside the items.
|
|
3268
|
+
*
|
|
3269
|
+
* An edge rides only when the ramps (as straight lines) and the spine are `stretch` times its first route, or shorter.
|
|
3270
|
+
* A link with fewer than `minSize` such edges is not a highway. The other edges keep their highways of the plan `from`.
|
|
3271
|
+
* Thus a zoom from the level to the routes shows the same lines, which open into lanes.
|
|
3272
|
+
*/
|
|
3273
|
+
export declare function levelHighwayPlan(input: HighwayInput, o: Readonly<LevelHighwayOptions>): HighwayPlan;
|
|
3274
|
+
/** The options of the highway strategy `meet` (HWY-050 of the note on highways). */
|
|
3275
|
+
interface MeetOptions {
|
|
3276
|
+
/** The plan whose merge points and split points the strategy moves. The default is `shared-ways`. */
|
|
3277
|
+
readonly from: HighwayBase;
|
|
3278
|
+
/** A first route meets the spine where it is this distance from the spine, or nearer. The default is 8: two lanes of 4. */
|
|
3279
|
+
readonly near: number;
|
|
3280
|
+
/** A first route meets the spine only where it runs at this angle to the spine, or less, in degrees. The default is 45. */
|
|
3281
|
+
readonly maxTurn: number;
|
|
3282
|
+
/** A member keeps its places when the stretch where its first route meets the spine is shorter than this length. The default is 10. */
|
|
3283
|
+
readonly minRun: number;
|
|
3284
|
+
}
|
|
3285
|
+
/** The default options of the strategy `meet`. */
|
|
3286
|
+
export declare const MEET_DEFAULTS: Readonly<MeetOptions>;
|
|
3287
|
+
/**
|
|
3288
|
+
* This function gives a member with its merge point and its split point where its first route meets the spine and parts from it (HWY-050).
|
|
3289
|
+
* The function samples the stretch of the member on the spine, at steps of `near / 2` or less.
|
|
3290
|
+
* A sample meets the route when the route is `near` or nearer, and its nearest leg runs at `maxTurn` or less to the spine.
|
|
3291
|
+
* The new merge point is the first sample that meets the route, in the direction of the member. The new split point is the last one.
|
|
3292
|
+
* So the edge joins the spine late and leaves it early. The places only move inward.
|
|
3293
|
+
* The member keeps its places when no sample meets the route, or when the met stretch is shorter than `minRun`.
|
|
3294
|
+
*/
|
|
3295
|
+
export declare function meetMember(spine: readonly Point[], member: HighwayMember, route: readonly Point[] | undefined, o: Readonly<MeetOptions>): HighwayMember;
|
|
3296
|
+
/**
|
|
3297
|
+
* This function gives the highways of the plan `from`, with merge points and split points where the routes meet and part (HWY-050).
|
|
3298
|
+
* The first route of each edge is the route of `input.routes`, or its route without highways.
|
|
3299
|
+
* Each member gets the places of `meetMember`. The spines and the trips do not change.
|
|
3300
|
+
*/
|
|
3301
|
+
export declare function meetPlan(input: HighwayInput, o: Readonly<MeetOptions>): HighwayPlan;
|
|
3302
|
+
/**
|
|
3303
|
+
* The spine of a group of edges. With `shared`, the edges of each group go through the router `shared` with the group as their key.
|
|
3304
|
+
* Each stretch that they share is a highway. With `trunk`, each group gets one trunk between two terminals, with a leg from each plug.
|
|
3305
|
+
*/
|
|
3306
|
+
type GroupSpine = "shared" | "trunk";
|
|
3307
|
+
/** The values of `GroupSpine`. */
|
|
3308
|
+
export declare const GROUP_SPINES: readonly GroupSpine[];
|
|
3309
|
+
/** The group of one edge: its key, and `flip` when the edge goes from the second end of the group to the first end. */
|
|
3310
|
+
interface EdgeGroup {
|
|
3311
|
+
readonly key: string;
|
|
3312
|
+
readonly flip: boolean;
|
|
3313
|
+
}
|
|
3314
|
+
/** The options of `groupedPlan`. */
|
|
3315
|
+
interface GroupedOptions extends WayOptions {
|
|
3316
|
+
readonly spine: GroupSpine;
|
|
3317
|
+
/** A group has this number of edges or more. The value is 2 or more. */
|
|
3318
|
+
readonly minSize: number;
|
|
3319
|
+
/**
|
|
3320
|
+
* With the spine `trunk`, an edge rides the trunk only when each of its legs is this share of the span or shorter.
|
|
3321
|
+
* The span is the distance between the two terminals. `Infinity` sets no limit.
|
|
3322
|
+
*/
|
|
3323
|
+
readonly legMax?: number;
|
|
3324
|
+
}
|
|
3325
|
+
/**
|
|
3326
|
+
* This function gives the geometric median of points (the Weber point), with the iterations of Weiszfeld.
|
|
3327
|
+
* The point has the least sum of the distances to the points.
|
|
3328
|
+
*/
|
|
3329
|
+
export declare function weberPoint(points: readonly Point[], iterations?: number): Point;
|
|
3330
|
+
/**
|
|
3331
|
+
* This function gives the highways of the groups of edges. Only the edges in `groups` ride a highway, and each group needs `minSize` edges.
|
|
3332
|
+
* The spine `shared` gives the shared stretches of the router `shared` with the group as the key.
|
|
3333
|
+
* The spine `trunk` gives one trunk for each group, through the corner graph between two terminals.
|
|
3334
|
+
* A terminal is the Weber point of the points out of the plugs at one end of the group. A terminal in a box moves to the nearest of those points.
|
|
3335
|
+
*/
|
|
3336
|
+
export declare function groupedPlan(input: HighwayInput, groups: ReadonlyMap<string, EdgeGroup>, o: Readonly<GroupedOptions>): HighwayPlan;
|
|
3337
|
+
/** The options of the highway strategy `od-cells` (EDA-033 with WILD-032 of the notes). */
|
|
3338
|
+
interface OdCellOptions {
|
|
3339
|
+
/** The depth of the cells in the tree of sections. Depth 1 is the level below the root. The default is 2. */
|
|
3340
|
+
readonly level: number;
|
|
3341
|
+
/** A pair of cells with this number of edges or more gets a trunk. The default is 3. */
|
|
3342
|
+
readonly minGroup: number;
|
|
3343
|
+
/** An edge rides the trunk only when each of its legs is this share of the span or shorter. The default is 0.3. */
|
|
3344
|
+
readonly legMax: number;
|
|
3345
|
+
/** The spine of each pair of cells. The default is `trunk`. */
|
|
3346
|
+
readonly spine: GroupSpine;
|
|
3347
|
+
}
|
|
3348
|
+
/** The default options of the strategy `od-cells`. */
|
|
3349
|
+
export declare const OD_CELL_DEFAULTS: Readonly<OdCellOptions>;
|
|
3350
|
+
/**
|
|
3351
|
+
* This function gives the groups of the edges by the pair of the cells of their two nodes (EDA-033, WILD-032).
|
|
3352
|
+
* The cells are the items of the zoom level at the depth `level`. The edges of one pair of cells, in either direction, are one group.
|
|
3353
|
+
* An edge inside one cell is in no group.
|
|
3354
|
+
*/
|
|
3355
|
+
export declare function odGroups(input: HighwayInput, o: Readonly<OdCellOptions>): Map<string, EdgeGroup>;
|
|
3356
|
+
/**
|
|
3357
|
+
* This function gives the highways of the consolidation by origin and destination cells (EDA-033, WILD-032).
|
|
3358
|
+
* Carriers merge the loads from one region to another into one truck between two terminals. Thus each pair of cells with `minGroup` edges or more gets one trunk.
|
|
3359
|
+
* The terminals are the Weber points of the plugs in each cell. An edge with a leg longer than `legMax` times the span goes alone.
|
|
3360
|
+
*/
|
|
3361
|
+
export declare function odCellPlan(input: HighwayInput, o: Readonly<OdCellOptions>): HighwayPlan;
|
|
3362
|
+
/** The line of each edge that QuickBundles compares: its first route, or the straight line between its plugs. */
|
|
3363
|
+
type BundleLine = "routes" | "lines";
|
|
3364
|
+
/** The order of the edges in the one pass: the order of the graph, or the longest line first. */
|
|
3365
|
+
type BundleOrder = "input" | "length";
|
|
3366
|
+
/** The options of the highway strategy `quickbundles` (HWY-026 of the note on highways). */
|
|
3367
|
+
interface QuickBundlesOptions {
|
|
3368
|
+
/** An edge joins a cluster when its distance to the centroid is this value or less, in units of the board. The default is 3. */
|
|
3369
|
+
readonly theta: number;
|
|
3370
|
+
/** The number of points of each line after the resampling. The default is 12. */
|
|
3371
|
+
readonly points: number;
|
|
3372
|
+
/** The line of each edge. The default is `routes`. */
|
|
3373
|
+
readonly line: BundleLine;
|
|
3374
|
+
/** The order of the edges. The default is `input`, so an added edge does not change the clusters before it. */
|
|
3375
|
+
readonly order: BundleOrder;
|
|
3376
|
+
/** A cluster with this number of edges or more gets highways. The default is 2. */
|
|
3377
|
+
readonly minSize: number;
|
|
3378
|
+
/** The spine of each cluster. The default is `shared`. */
|
|
3379
|
+
readonly spine: GroupSpine;
|
|
3380
|
+
}
|
|
3381
|
+
/** The default options of the strategy `quickbundles`. */
|
|
3382
|
+
export declare const QUICKBUNDLES_DEFAULTS: Readonly<QuickBundlesOptions>;
|
|
3383
|
+
/** This function gives `k` points at equal steps of length along a polyline, from its first point to its last point. */
|
|
3384
|
+
export declare function resample(line: readonly Point[], k: number): Point[];
|
|
3385
|
+
/**
|
|
3386
|
+
* This function gives the MDF distance of two lines with the same number of points. It is the mean distance of their points.
|
|
3387
|
+
* The function compares the points in the same direction and in the opposite direction, and keeps the smaller mean.
|
|
3388
|
+
* `flip` is `true` when the opposite direction is smaller.
|
|
3389
|
+
*/
|
|
3390
|
+
export declare function mdf(p: readonly Point[], q: readonly Point[]): {
|
|
3391
|
+
d: number;
|
|
3392
|
+
flip: boolean;
|
|
3393
|
+
};
|
|
3394
|
+
/**
|
|
3395
|
+
* This function gives the clusters of QuickBundles (Garyfallidis 2012) as groups of edges.
|
|
3396
|
+
* In one pass, each edge joins the cluster with the nearest centroid when the MDF distance is `theta` units or less. Else it starts a cluster.
|
|
3397
|
+
* The centroid is the running mean of the lines of the cluster, each in the direction of the centroid.
|
|
3398
|
+
*/
|
|
3399
|
+
export declare function quickBundles(input: HighwayInput, o: Readonly<QuickBundlesOptions>): Map<string, EdgeGroup>;
|
|
3400
|
+
/**
|
|
3401
|
+
* This function gives the highways of QuickBundles (HWY-026). The clusters of `quickBundles` with `minSize` edges or more get highways.
|
|
3402
|
+
* With the spine `shared`, the edges of each cluster share their ways through the corner graph. With `trunk`, each cluster gets one trunk.
|
|
3403
|
+
*/
|
|
3404
|
+
export declare function quickBundlesPlan(input: HighwayInput, o: Readonly<QuickBundlesOptions>): HighwayPlan;
|
|
3405
|
+
/** The options of the highway strategy `road-classes` (HWY-034 with EDA-050 of the notes). */
|
|
3406
|
+
interface RoadClassOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3407
|
+
/** A link is a highway link when its use is at this quantile of the use of the links, or higher. The default is 0.9. */
|
|
3408
|
+
readonly quantile: number;
|
|
3409
|
+
/** A highway link has this number of edges or more on it, and a highway has this number of edges or more. The default is 2. */
|
|
3410
|
+
readonly minSize: number;
|
|
3411
|
+
/** The second pass gives each highway link this discount, as a share of its length. The default is 0.5. */
|
|
3412
|
+
readonly discount: number;
|
|
3413
|
+
}
|
|
3414
|
+
/** The default options of the strategy `road-classes`. */
|
|
3415
|
+
export declare const ROAD_CLASS_DEFAULTS: Readonly<Required<Omit<RoadClassOptions, "margin" | "k">>>;
|
|
3416
|
+
/**
|
|
3417
|
+
* This function gives the highways of the road classes (HWY-034, EDA-050). It counts how many first ways use each link of the corner graph.
|
|
3418
|
+
* The links with a use at the quantile `quantile` or higher, and at least `minSize`, are the highway links.
|
|
3419
|
+
* They are the main roads of a road map.
|
|
3420
|
+
* A second pass routes each edge again, with the discount on the highway links, so more edges join them.
|
|
3421
|
+
* Each stretch of highway links that `minSize` ways or more share after the second pass is one highway.
|
|
3422
|
+
*/
|
|
3423
|
+
export declare function roadClassPlan(input: HighwayInput, o: Readonly<RoadClassOptions>): HighwayPlan;
|
|
3424
|
+
/** A generator of candidate highways: a highway strategy with its defaults. */
|
|
3425
|
+
type CandidateSource = "corridors" | "quickbundles" | "wspd" | "road-classes" | "flow-field" | "od-cells" | "shared-ways";
|
|
3426
|
+
/** The values of `CandidateSource`. */
|
|
3427
|
+
export declare const CANDIDATE_SOURCES: readonly CandidateSource[];
|
|
3428
|
+
/** The options of the highway strategy `select` (HWY-045 of the note on highways). */
|
|
3429
|
+
interface SelectOptions {
|
|
3430
|
+
/** The generators of the candidates. The default is `corridors`, `quickbundles`, `wspd` and `road-classes`. */
|
|
3431
|
+
readonly generators: readonly CandidateSource[];
|
|
3432
|
+
/** The weight of the added length of the edges against the ink that a highway saves (lambda 3 of the note). The default is 1. */
|
|
3433
|
+
readonly lambda: number;
|
|
3434
|
+
/** The number of passes of the local search with one swap. The default is 2. */
|
|
3435
|
+
readonly swaps: number;
|
|
3436
|
+
}
|
|
3437
|
+
/** The default options of the strategy `select`. */
|
|
3438
|
+
export declare const SELECT_DEFAULTS: Readonly<SelectOptions>;
|
|
3439
|
+
/** This function gives the plan of a generator, with its defaults. */
|
|
3440
|
+
export declare function candidatePlan(input: HighwayInput, source: CandidateSource): HighwayPlan;
|
|
3441
|
+
/**
|
|
3442
|
+
* This function gives the ink that a highway saves. It is the sum of the spine lengths of the members, less the length of their union.
|
|
3443
|
+
* The extra length of a member is its detour from its first route. The detour goes to the merge point, along the spine and back from the split point.
|
|
3444
|
+
*/
|
|
3445
|
+
export declare function candidateScore(h: Highway, routes: ReadonlyMap<string, readonly Point[]>): {
|
|
3446
|
+
gain: number;
|
|
3447
|
+
extra: number;
|
|
3448
|
+
};
|
|
3449
|
+
/**
|
|
3450
|
+
* This function gives the highways of the candidate generation and selection (HWY-045). Each generator proposes its highways as candidates.
|
|
3451
|
+
* The net gain of a candidate is the ink that it saves, less `lambda` times the length that it adds to its edges.
|
|
3452
|
+
* Two candidates of two generators conflict when they share an edge. The highways of one generator do not conflict.
|
|
3453
|
+
*
|
|
3454
|
+
* The selection takes the candidates by net gain for each edge, without a conflict. Then each pass of the local search
|
|
3455
|
+
* swaps in a candidate. The swap occurs when the net gain of the candidate is more than the sum of the selected candidates in conflict with it.
|
|
3456
|
+
*/
|
|
3457
|
+
export declare function selectPlan(input: HighwayInput, o: Readonly<SelectOptions>): HighwayPlan;
|
|
2838
3458
|
/** The options of the highway strategy `shared-ways`: the options of the router `shared`, without the name and the limit of the benchmark. */
|
|
2839
3459
|
type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
|
|
2840
3460
|
/**
|
|
@@ -2843,6 +3463,156 @@ type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
|
|
|
2843
3463
|
* The function does not change the router: it reads its runs.
|
|
2844
3464
|
*/
|
|
2845
3465
|
export declare function sharedWaysPlan(input: HighwayInput, options: SharedWaysOptions): HighwayPlan;
|
|
3466
|
+
/** The ends of the edges that get stubs: the source ends, the target ends, or both. */
|
|
3467
|
+
type StubEnds = "source" | "target" | "both";
|
|
3468
|
+
/** The options of the highway strategy `stubs` (HWY-015 with WILD-005 of the notes). */
|
|
3469
|
+
interface StubOptions {
|
|
3470
|
+
/** The plan that the stubs go into. The default is `shared-ways`. */
|
|
3471
|
+
readonly from: HighwayBase;
|
|
3472
|
+
/** The ends of one side of a box whose directions are in a window of this angle share a stub, in degrees. The default is 30. */
|
|
3473
|
+
readonly omega: number;
|
|
3474
|
+
/** The length of a stub is this share of the distance to the nearest other end. The default is 0.25. */
|
|
3475
|
+
readonly sigma: number;
|
|
3476
|
+
/** The ends that get stubs. The default is `both`. */
|
|
3477
|
+
readonly ends: StubEnds;
|
|
3478
|
+
/** A stub has this number of edges or more. The default is 2. */
|
|
3479
|
+
readonly minSize: number;
|
|
3480
|
+
}
|
|
3481
|
+
/** The default options of the strategy `stubs`. */
|
|
3482
|
+
export declare const STUB_DEFAULTS: Readonly<StubOptions>;
|
|
3483
|
+
/**
|
|
3484
|
+
* This function gives the highways of the plan `from`, with a stub at the ends of the edges (HWY-015, WILD-005).
|
|
3485
|
+
* The ends on one side of one box are sorted by the direction of their other node. A run of ends in a window of `omega` makes a group.
|
|
3486
|
+
* Each group of `minSize` ends or more shares one plug and one stub along the normal of the side. Then the edges fan out.
|
|
3487
|
+
*
|
|
3488
|
+
* The length of the stub is `sigma` times the distance to the nearest other node, and half that distance at most.
|
|
3489
|
+
* It is two times the margin of the way finder at least, and the stub stays out of the other boxes. Else the group gets no stub.
|
|
3490
|
+
* An end with a fixed plug or a side of its own gets no stub. An end whose first highway starts on its box, or near it, keeps the plan.
|
|
3491
|
+
*/
|
|
3492
|
+
export declare function stubPlan(input: HighwayInput, o: Readonly<StubOptions>): HighwayPlan;
|
|
3493
|
+
/** The options of the highway strategy `weiszfeld` (HWY-043 of the note on highways). */
|
|
3494
|
+
interface WeiszfeldOptions {
|
|
3495
|
+
/** The plan whose highways get new meeting points. The default is `shared-ways`. */
|
|
3496
|
+
readonly from: HighwayBase;
|
|
3497
|
+
/** The weight of the trunk is `k^alpha` for `k` members. With 0, the trunk costs its ink one time. With 1, it costs each lane. The default is 0.5. */
|
|
3498
|
+
readonly alpha: number;
|
|
3499
|
+
/** The number of steps of Weiszfeld. The default is 20. */
|
|
3500
|
+
readonly steps: number;
|
|
3501
|
+
}
|
|
3502
|
+
/** The default options of the strategy `weiszfeld`. */
|
|
3503
|
+
export declare const WEISZFELD_DEFAULTS: Readonly<WeiszfeldOptions>;
|
|
3504
|
+
/**
|
|
3505
|
+
* This function gives the meeting points `M1` and `M2` of a bundle with the least weighted ink (HWY-043):
|
|
3506
|
+
* `Σ |a_i - M1| + w |M1 - M2| + Σ |M2 - b_i|`. The lists `a` and `b` are the ends of the edges on each side, and `w` is the weight of the trunk.
|
|
3507
|
+
* The function starts at the means of `a` and `b`. Each step moves `M1` and then `M2` by one step of Weiszfeld.
|
|
3508
|
+
*/
|
|
3509
|
+
export declare function meetingPoints(a: readonly Point[], b: readonly Point[], w: number, steps: number): [Point, Point];
|
|
3510
|
+
/**
|
|
3511
|
+
* This function gives the highways of the plan `from`, with the meeting points of Weiszfeld (HWY-043).
|
|
3512
|
+
* The ends of a member are the points where its edge comes to the highway and goes away from it after `follow` of the plan.
|
|
3513
|
+
* They are the plugs, or the split point of the highway before and the merge point of the highway after.
|
|
3514
|
+
* The weight of the trunk is `k^alpha` for `k` members. The trunk stays on the spine: the function projects `M1` and `M2` on the spine.
|
|
3515
|
+
* Each member then joins the spine at `M1` and leaves it at `M2`, but not outside its own stretch. So a member only gets shorter on the spine.
|
|
3516
|
+
*/
|
|
3517
|
+
export declare function weiszfeldPlan(input: HighwayInput, o: Readonly<WeiszfeldOptions>): HighwayPlan;
|
|
3518
|
+
/** The options of the highway strategy `wspd` (HWY-018 of the note on highways). */
|
|
3519
|
+
interface WspdOptions {
|
|
3520
|
+
/** The separation `s` of the pairs: the gap between two sets is at least `s` times the radius of the larger set. The default is 2. */
|
|
3521
|
+
readonly separation: number;
|
|
3522
|
+
/** A pair with this number of edges or more gets a highway. The default is 3. */
|
|
3523
|
+
readonly minSize: number;
|
|
3524
|
+
/** The spine of each pair. The default is `trunk`. */
|
|
3525
|
+
readonly spine: GroupSpine;
|
|
3526
|
+
}
|
|
3527
|
+
/** The default options of the strategy `wspd`. */
|
|
3528
|
+
export declare const WSPD_DEFAULTS: Readonly<WspdOptions>;
|
|
3529
|
+
/** A cell of the split tree: the points at the places `lo` to `hi - 1` of the order, with their bounding circle. */
|
|
3530
|
+
interface SplitCell {
|
|
3531
|
+
readonly id: number;
|
|
3532
|
+
readonly lo: number;
|
|
3533
|
+
readonly hi: number;
|
|
3534
|
+
readonly c: Point;
|
|
3535
|
+
readonly r: number;
|
|
3536
|
+
readonly kids?: readonly [SplitCell, SplitCell];
|
|
3537
|
+
}
|
|
3538
|
+
/**
|
|
3539
|
+
* The split tree of a set of points and its well-separated pairs (Callahan and Kosaraju 1995).
|
|
3540
|
+
* Each cell splits at the middle of the longer side of its bounding box. A cell of equal points is a leaf.
|
|
3541
|
+
*/
|
|
3542
|
+
export declare class SplitTree {
|
|
3543
|
+
#private;
|
|
3544
|
+
readonly root: SplitCell;
|
|
3545
|
+
/** This constructor builds the tree of the points. */
|
|
3546
|
+
constructor(points: readonly Point[]);
|
|
3547
|
+
/** This method tells if the cell holds the point `i`. */
|
|
3548
|
+
holds(cell: SplitCell, i: number): boolean;
|
|
3549
|
+
/**
|
|
3550
|
+
* This method gives the well-separated pair that holds the pair of points `u` and `v`, with the cell of `u` first.
|
|
3551
|
+
* Each pair of two different points is in one pair of the decomposition. Two equal points give `undefined`.
|
|
3552
|
+
*/
|
|
3553
|
+
pairOf(u: number, v: number, s: number): [SplitCell, SplitCell] | undefined;
|
|
3554
|
+
}
|
|
3555
|
+
/**
|
|
3556
|
+
* This function gives the groups of the edges by the well-separated pair of their two nodes (HWY-018).
|
|
3557
|
+
* The points are the centers of the boxes. The edges of one pair, in either direction, are one group.
|
|
3558
|
+
*/
|
|
3559
|
+
export declare function wspdGroups(input: HighwayInput, o: Readonly<WspdOptions>): Map<string, EdgeGroup>;
|
|
3560
|
+
/**
|
|
3561
|
+
* This function gives the highways of clustered edge routing with the WSPD (HWY-018, after Bouts and Speckmann 2015).
|
|
3562
|
+
* The well-separated pairs split all the pairs of nodes. The edges of one pair with `minSize` edges or more get one highway from one set to the other.
|
|
3563
|
+
*/
|
|
3564
|
+
export declare function wspdPlan(input: HighwayInput, o: Readonly<WspdOptions>): HighwayPlan;
|
|
3565
|
+
/** The options of the highway strategy `zipper` (NAT-022 with WILD-037 of the notes). */
|
|
3566
|
+
interface ZipperOptions {
|
|
3567
|
+
/** The plan whose routes the zipper joins. The default is `shared-ways`. */
|
|
3568
|
+
readonly from: HighwayBase;
|
|
3569
|
+
/** Two legs zip when they are this distance apart or nearer, in units of the board (the median short side of the boxes). The default is 1. */
|
|
3570
|
+
readonly near: number;
|
|
3571
|
+
/** Two legs zip when the angle between them is this value or less, in degrees. The default is 15. */
|
|
3572
|
+
readonly maxAngle: number;
|
|
3573
|
+
/** The adhesion over the tension: two legs zip when `adhesion * overlap` is more than the length that the zip adds. The default is 0.3. */
|
|
3574
|
+
readonly adhesion: number;
|
|
3575
|
+
/** Two legs zip when they overlap along this length or more, in units of the board. The default is 1. */
|
|
3576
|
+
readonly minOverlap: number;
|
|
3577
|
+
/** The number of passes. Each pass routes the plan and zips the legs again. The default is 1. */
|
|
3578
|
+
readonly passes: number;
|
|
3579
|
+
}
|
|
3580
|
+
/** The default options of the strategy `zipper`. */
|
|
3581
|
+
export declare const ZIPPER_DEFAULTS: Readonly<ZipperOptions>;
|
|
3582
|
+
/** A pair of legs that can zip, with the line of the zip. */
|
|
3583
|
+
interface Zip {
|
|
3584
|
+
readonly gain: number;
|
|
3585
|
+
/** The first point of the zipped line. */
|
|
3586
|
+
readonly from: Point;
|
|
3587
|
+
/** The last point of the zipped line. */
|
|
3588
|
+
readonly to: Point;
|
|
3589
|
+
/** This value is `true` when the leg goes from `from` to `to`, for each of the two legs. */
|
|
3590
|
+
readonly forward: readonly [boolean, boolean];
|
|
3591
|
+
}
|
|
3592
|
+
/** The limits of `zipLegs`, in the units of the board. */
|
|
3593
|
+
interface ZipLimits {
|
|
3594
|
+
readonly near: number;
|
|
3595
|
+
readonly maxAngle: number;
|
|
3596
|
+
readonly adhesion: number;
|
|
3597
|
+
readonly minOverlap: number;
|
|
3598
|
+
}
|
|
3599
|
+
/**
|
|
3600
|
+
* This function tells if two legs zip (NAT-022), and gives the zipped line.
|
|
3601
|
+
* The zipped line is the mean of the two legs, with the weight of their lengths, along the stretch where they overlap.
|
|
3602
|
+
* The legs zip when the angle between them is `maxAngle` or less, and they are `near` or nearer along the overlap.
|
|
3603
|
+
* The overlap must be `minOverlap` or more.
|
|
3604
|
+
* The zip adds two jogs to each leg, so it adds the length `2 (d_a + d_b)`, with the distances of the legs to the zipped line.
|
|
3605
|
+
* The legs zip only when `adhesion * overlap` is more than that length.
|
|
3606
|
+
*/
|
|
3607
|
+
export declare function zipLegs(a0: Point, a1: Point, b0: Point, b1: Point, o: ZipLimits): Zip | undefined;
|
|
3608
|
+
/**
|
|
3609
|
+
* This function gives the highways of the plan `from`, with the legs that run near and nearly parallel zipped together (NAT-022, WILD-037).
|
|
3610
|
+
* A pass routes the plan with `follow` and takes each leg that no other route shares. A grid of the legs finds the near pairs.
|
|
3611
|
+
* The pairs that zip (`zipLegs`) go from the largest gain to the smallest, and each leg zips one time in a pass at most.
|
|
3612
|
+
* A zipped line that goes into a box, made larger by 1, does not zip.
|
|
3613
|
+
* Each zip is a new highway of two members. The `seq` of each member follows the place of its merge point along the route of the edge.
|
|
3614
|
+
*/
|
|
3615
|
+
export declare function zipperPlan(input: HighwayInput, o: Readonly<ZipperOptions>): HighwayPlan;
|
|
2846
3616
|
/** The options of a router strategy: the options of its router, without the name and the limit of the benchmark. */
|
|
2847
3617
|
export type RouterPreset<O> = Omit<O, "name" | "maxNodes">;
|
|
2848
3618
|
/** The built-in router strategies, in the order of the benchmark. They route as the routers of `ROUTERS`. */
|
|
@@ -2929,12 +3699,30 @@ export declare const groupStrategies: {
|
|
|
2929
3699
|
};
|
|
2930
3700
|
/**
|
|
2931
3701
|
* The built-in highway strategies: the decisions of the routers `trunks` and `shared` as plans, and corridor signatures (HWY-031).
|
|
3702
|
+
* The strategies `corridors+<gate>` put a gate of BUILD-W2A after `corridors`: `breakeven` (HWY-047), `stretch` (HWY-048), `ambiguity` (HWY-049),
|
|
3703
|
+
* `hysteresis` (HWY-046) and `ids` (HWY-054). `gateStrategy` puts a gate after any other plan.
|
|
2932
3704
|
* `follow` routes the edges along a plan, and `highwayRouter` gives a router that does both.
|
|
2933
3705
|
*/
|
|
2934
3706
|
export declare const highwayStrategies: {
|
|
2935
3707
|
readonly keys: Strategy<"highway", KeysOptions>;
|
|
2936
3708
|
readonly "shared-ways": Strategy<"highway", SharedWaysOptions>;
|
|
2937
3709
|
readonly corridors: Strategy<"highway", CorridorOptions>;
|
|
3710
|
+
readonly meet: Strategy<"highway", MeetOptions>;
|
|
3711
|
+
readonly weiszfeld: Strategy<"highway", WeiszfeldOptions>;
|
|
3712
|
+
readonly stubs: Strategy<"highway", StubOptions>;
|
|
3713
|
+
readonly zipper: Strategy<"highway", ZipperOptions>;
|
|
3714
|
+
readonly "level-links": Strategy<"highway", LevelHighwayOptions>;
|
|
3715
|
+
readonly quickbundles: Strategy<"highway", QuickBundlesOptions>;
|
|
3716
|
+
readonly "road-classes": Strategy<"highway", RoadClassOptions>;
|
|
3717
|
+
readonly "flow-field": Strategy<"highway", FlowFieldOptions>;
|
|
3718
|
+
readonly wspd: Strategy<"highway", WspdOptions>;
|
|
3719
|
+
readonly "od-cells": Strategy<"highway", OdCellOptions>;
|
|
3720
|
+
readonly select: Strategy<"highway", SelectOptions>;
|
|
3721
|
+
readonly "corridors+breakeven": Strategy<"highway", CorridorOptions & BreakEvenOptions>;
|
|
3722
|
+
readonly "corridors+stretch": Strategy<"highway", CorridorOptions & StretchOptions>;
|
|
3723
|
+
readonly "corridors+ambiguity": Strategy<"highway", CorridorOptions & AmbiguityGuardOptions>;
|
|
3724
|
+
readonly "corridors+hysteresis": Strategy<"highway", CorridorOptions & HysteresisOptions>;
|
|
3725
|
+
readonly "corridors+ids": Strategy<"highway", CorridorOptions & StableIdOptions>;
|
|
2938
3726
|
};
|
|
2939
3727
|
/** The built-in strategies of each step, in order. A consumer adds its own: `createRegistry([...BUILT_IN_STRATEGIES, mine])`. */
|
|
2940
3728
|
export declare const BUILT_IN_STRATEGIES: readonly AnyStrategy[];
|
|
@@ -3373,6 +4161,13 @@ export type ScreenStep = CompareStep | "highway";
|
|
|
3373
4161
|
export declare const SCREEN_STEPS: readonly ScreenStep[];
|
|
3374
4162
|
/** The routers that the screen of the step `highway` also runs by default. They are the baselines of the note on highways. */
|
|
3375
4163
|
export declare const HIGHWAY_BASE_ROUTERS: readonly string[];
|
|
4164
|
+
/**
|
|
4165
|
+
* A wrapper of each router of a screen. `stable` routes the edges in the stable order of WILD-053 (`stableOrderStrategy`).
|
|
4166
|
+
* `repair` runs the repair step of RULE-046 after the router (`repairStrategy`).
|
|
4167
|
+
*/
|
|
4168
|
+
export type ScreenWrap = "stable" | "repair";
|
|
4169
|
+
/** The wrappers of `ScreenWrap`. */
|
|
4170
|
+
export declare const SCREEN_WRAPS: readonly ScreenWrap[];
|
|
3376
4171
|
/** The hard rules of each step of the screen, in the order of the records. A good run has 0 for each rule. */
|
|
3377
4172
|
export declare const SCREEN_RULES: Readonly<Record<ScreenStep, readonly string[]>>;
|
|
3378
4173
|
/** The options of `screen`. */
|
|
@@ -3397,8 +4192,24 @@ export interface ScreenOptions {
|
|
|
3397
4192
|
* The default is `HIGHWAY_BASE_ROUTERS`. The other steps do not read it.
|
|
3398
4193
|
*/
|
|
3399
4194
|
readonly baseRouters?: readonly string[];
|
|
3400
|
-
/** The seed of the small change of the stability measures
|
|
4195
|
+
/** The seed of the small change of the stability measures, and of the first random order of `shuffles`. The default is 1. */
|
|
3401
4196
|
readonly seed?: number;
|
|
4197
|
+
/**
|
|
4198
|
+
* The wrappers of each router of the steps `router` and `highway`. Each wrapper `w` adds the router `<name>+<w>` as a new strategy, beside the router `<name>`.
|
|
4199
|
+
* The default is none. The steps `group` and `curve` do not read it.
|
|
4200
|
+
*/
|
|
4201
|
+
readonly wrap?: readonly ScreenWrap[];
|
|
4202
|
+
/**
|
|
4203
|
+
* The number of random orders of the edges for the order fragility (W3, from WILD-056). Each router routes each input this number of times more.
|
|
4204
|
+
* The default is 0: no measure of the order fragility. The steps `group` and `curve` do not read it.
|
|
4205
|
+
*/
|
|
4206
|
+
readonly shuffles?: number;
|
|
4207
|
+
/**
|
|
4208
|
+
* The number of seeded edits of the step `highway` (BUILD-W2A). Each highway strategy runs again after each edit of `highwayEdits`, with its plan before the edit.
|
|
4209
|
+
* The records then get `Z10.edits.*`, the churn of the highways and the share of the highways that keep their id.
|
|
4210
|
+
* The default is 0: no edits. The other steps and the base routers do not read it.
|
|
4211
|
+
*/
|
|
4212
|
+
readonly edits?: number;
|
|
3402
4213
|
/** The commit of the code, for the records. */
|
|
3403
4214
|
readonly commit?: string;
|
|
3404
4215
|
/** The predictions of the run. Each record names the first prediction with its strategy, its set and its input. */
|
|
@@ -3462,6 +4273,8 @@ export interface ScreenReport {
|
|
|
3462
4273
|
readonly records: readonly LayoutRecord[];
|
|
3463
4274
|
readonly summary: ScreenSummary;
|
|
3464
4275
|
}
|
|
4276
|
+
/** This function gives the name of a router without the suffix of a wrapper, for example `shared` for `shared+repair`. */
|
|
4277
|
+
export declare function unwrappedName(name: string): string;
|
|
3465
4278
|
/**
|
|
3466
4279
|
* This function screens strategies of one step on the inputs of a screen set. It is the cheap test of a new idea before a full build.
|
|
3467
4280
|
* Each strategy runs on each input with `compareStep`, and each run gives one record of the form `layout-record/1`.
|
|
@@ -3534,5 +4347,144 @@ export declare function highwayRouter<O extends object>(strategy: Strategy<"high
|
|
|
3534
4347
|
* The benchmark and the screen race such a router with the other routers.
|
|
3535
4348
|
*/
|
|
3536
4349
|
export declare function highwayRouterStrategy<O extends object>(strategy: Strategy<"highway", O>): Strategy<"router", O>;
|
|
3537
|
-
|
|
4350
|
+
/** An edge with its two plugs, as the router `corners` places them. */
|
|
4351
|
+
interface EdgePlugs {
|
|
4352
|
+
readonly edge: Edge;
|
|
4353
|
+
readonly ps: Plug;
|
|
4354
|
+
readonly pt: Plug;
|
|
4355
|
+
}
|
|
4356
|
+
/** This function gives the plugs of each edge of the graph, in the order of the edges. An edge with an unknown node is not in the list. */
|
|
4357
|
+
export declare function edgePlugs(graph: Graph): EdgePlugs[];
|
|
4358
|
+
/** The way of one edge through the corner graph, with a key. Only the ways with one key share a highway. */
|
|
4359
|
+
interface KeyedWay {
|
|
4360
|
+
readonly edge: string;
|
|
4361
|
+
readonly key: string;
|
|
4362
|
+
/** The points of the way, without the plugs. Two ways share a link when the link has the same two points. */
|
|
4363
|
+
readonly points: readonly Point[];
|
|
4364
|
+
}
|
|
4365
|
+
/** The options of `sharedStretches`. */
|
|
4366
|
+
interface SharedStretchOptions {
|
|
4367
|
+
/** A highway has this number of edges or more. The value is 2 or more. */
|
|
4368
|
+
readonly minSize: number;
|
|
4369
|
+
/** This function tells if a link can be part of a highway. Without it, each link can. */
|
|
4370
|
+
readonly link?: (a: Point, b: Point) => boolean;
|
|
4371
|
+
/** This function removes the needless corners of a spine. Without it, the spine keeps each point of the stretch. */
|
|
4372
|
+
readonly pull?: (points: readonly Point[]) => Point[];
|
|
4373
|
+
}
|
|
4374
|
+
/**
|
|
4375
|
+
* This function gives a highway for each stretch that two ways or more of one key share. A way is a polyline through the corner graph.
|
|
4376
|
+
* Each way breaks into stretches where the set of the ways on its links stays the same. The router `shared` makes its runs in the same way.
|
|
4377
|
+
* A stretch with fewer than `minSize` ways is not a highway. Each way joins the spine at one end of the stretch and leaves it at the other end.
|
|
4378
|
+
* The `seq` of each member follows the order of the stretches along the way.
|
|
4379
|
+
*/
|
|
4380
|
+
export declare function sharedStretches(ways: readonly KeyedWay[], o: Readonly<SharedStretchOptions>): HighwayPlan;
|
|
4381
|
+
/**
|
|
4382
|
+
* This function gives the graph with its edges in the stable order of WILD-053: by the FNV-1a hash of the id, then by the id.
|
|
4383
|
+
* The nodes and the edges do not change. Two orders of the same edges give the same graph.
|
|
4384
|
+
* The hash spreads the edges, so the stable order does not favor the edges of one node or one collection.
|
|
4385
|
+
*/
|
|
4386
|
+
export declare function stableOrder(graph: Graph): Graph;
|
|
4387
|
+
/** This function gives the graph with its edges in a random order of the seed. The same graph and seed always give the same order. */
|
|
4388
|
+
export declare function shuffleEdges(graph: Graph, seed: number): Graph;
|
|
4389
|
+
/**
|
|
4390
|
+
* This function routes the graph in the stable order of `stableOrder`, with the function `route`.
|
|
4391
|
+
* The routes come back in the order of the input edges, so the caller sees no change of order.
|
|
4392
|
+
* The bundles, the runs and the levels come from the stable order. Thus each order of the input gives the same data.
|
|
4393
|
+
*/
|
|
4394
|
+
export declare function routeInStableOrder(graph: Graph, route: (graph: Graph) => Result): Result;
|
|
4395
|
+
/** This function gives a router that routes each graph in the stable order of WILD-053. It keeps the name and the `maxNodes` of the router. */
|
|
4396
|
+
export declare function withStableOrder(router: Router): Router;
|
|
4397
|
+
/**
|
|
4398
|
+
* This function gives a router strategy that runs `strategy` in the stable order of WILD-053. The output does not depend on the order of the input edges.
|
|
4399
|
+
* The new strategy has the name `<name>+stable`, and the options and the schema of `strategy`. The strategy `strategy` does not change.
|
|
4400
|
+
*/
|
|
4401
|
+
export declare function stableOrderStrategy<O extends object>(strategy: Strategy<"router", O>): Strategy<"router", O>;
|
|
4402
|
+
/**
|
|
4403
|
+
* The boundary walk of the repair step (RULE-046): a graph of the sides of the boxes.
|
|
4404
|
+
* The vertices are the corners of the boxes. The edges are the parts of each side between two corners on it.
|
|
4405
|
+
* A walk on this graph goes along the boundaries of the boxes, and not through a box. Thus it joins two boxes also when the boxes touch.
|
|
4406
|
+
* The graph drops each part of a side that goes through another box, so overlapping boxes do not open a way.
|
|
4407
|
+
*/
|
|
4408
|
+
export declare class BoundaryWalk {
|
|
4409
|
+
#private;
|
|
4410
|
+
/** This constructor makes the graph of the sides of the nodes. `grid` holds the nodes by their boxes. */
|
|
4411
|
+
constructor(nodes: readonly Node[], grid: Grid<Node>);
|
|
4412
|
+
/**
|
|
4413
|
+
* This method gives a way along the boundaries of the boxes. The way goes from the point `a` on the box of `s` to the point `b` on the box of `t`.
|
|
4414
|
+
* A point that is not on its box goes first to the nearest point of the boundary.
|
|
4415
|
+
* The method gives `undefined` when no way joins the two boxes.
|
|
4416
|
+
*/
|
|
4417
|
+
path(a: Point, s: Node, b: Point, t: Node): Point[] | undefined;
|
|
4418
|
+
}
|
|
4419
|
+
/** This function gives the point of the boundary of the box that is nearest to `p`. A point on the boundary gives itself. */
|
|
4420
|
+
export declare function nearestOnBoundary(box: Box, p: Point): Point;
|
|
4421
|
+
/** The options of the repair step (RULE-046). */
|
|
4422
|
+
export interface RepairOptions {
|
|
4423
|
+
/** The distance from a box to the corners of a detour, and twice the clearance of a pushed leg. The default is 5. */
|
|
4424
|
+
readonly margin?: number;
|
|
4425
|
+
/** The number of visible neighbours of each corner of the detour graph. The default is 8. */
|
|
4426
|
+
readonly k?: number;
|
|
4427
|
+
/** With `false`, the step does not push a leg out of a box. The default is `true`. */
|
|
4428
|
+
readonly push?: boolean;
|
|
4429
|
+
/** With `false`, the step takes no detour through the corner graph. The default is `true`. */
|
|
4430
|
+
readonly detour?: boolean;
|
|
4431
|
+
/** With `false`, the step does not route a whole faulty route again through the corner graph. The default is `true`. */
|
|
4432
|
+
readonly reroute?: boolean;
|
|
4433
|
+
/** With `false`, the step does not walk along the boundaries of the boxes. The default is `true`. */
|
|
4434
|
+
readonly walk?: boolean;
|
|
4435
|
+
}
|
|
4436
|
+
/** The counts of one repair: what the step found and what it did. */
|
|
4437
|
+
export interface RepairCounts {
|
|
4438
|
+
/** The number of edges whose two nodes are in the graph. */
|
|
4439
|
+
readonly routes: number;
|
|
4440
|
+
/** The routes with a break of a hard rule before the repair, and the missing routes. */
|
|
4441
|
+
readonly faulty: number;
|
|
4442
|
+
/** The ends that the step moved back to their plugs or to the boxes of their nodes. */
|
|
4443
|
+
readonly snapped: number;
|
|
4444
|
+
/** The legs that the step pushed out of a box. */
|
|
4445
|
+
readonly pushed: number;
|
|
4446
|
+
/** The legs that the step replaced with a detour through the corner graph. */
|
|
4447
|
+
readonly detoured: number;
|
|
4448
|
+
/** The faulty routes that the step routed again from end to end through the corner graph. */
|
|
4449
|
+
readonly rerouted: number;
|
|
4450
|
+
/** The faulty routes that the step replaced with a walk along the boundaries of the boxes. */
|
|
4451
|
+
readonly walked: number;
|
|
4452
|
+
/** The missing routes that the step added. */
|
|
4453
|
+
readonly added: number;
|
|
4454
|
+
/** The faulty routes that the step could not repair. They keep their base routes. */
|
|
4455
|
+
readonly kept: number;
|
|
4456
|
+
/** The edges that the step took out of a run or a bundle. The repaired route of such an edge does not hold the run or the trunk. */
|
|
4457
|
+
readonly unbundled: number;
|
|
4458
|
+
/** The ends of level links that the step moved to the boundaries of their items. */
|
|
4459
|
+
readonly linkEnds: number;
|
|
4460
|
+
}
|
|
4461
|
+
/** The result of `repairResult`: the repaired result and the counts. */
|
|
4462
|
+
export interface RepairReport {
|
|
4463
|
+
readonly result: Result;
|
|
4464
|
+
readonly counts: RepairCounts;
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4467
|
+
* This function repairs the breaks of the hard rules in the routes of any router (RULE-046). The input result does not change.
|
|
4468
|
+
*
|
|
4469
|
+
* - It adds a route through the corner graph for each edge without a route (`complete`).
|
|
4470
|
+
* - It moves each end back to its fixed plug, or to the nearest point of the box of its node (`ends-at-plugs` and `fixed-plugs`).
|
|
4471
|
+
* - It pushes each inner leg out of a box that it goes through, to the near side of the box (`no-pass-through`).
|
|
4472
|
+
* - It replaces each other leg through a box with a detour through the corner graph.
|
|
4473
|
+
* - When a leg does not repair, it routes the whole route again through the corner graph.
|
|
4474
|
+
* Else it walks along the boundaries of the boxes (`BoundaryWalk`).
|
|
4475
|
+
* - A route that still breaks a rule keeps its base route.
|
|
4476
|
+
* - It takes an edge out of a run or a bundle when its new route does not hold the run or the trunk (`run-shared` and `bundle-trunk`).
|
|
4477
|
+
* - It moves the ends of each level link to the boundaries of its items (`link-ends`).
|
|
4478
|
+
*
|
|
4479
|
+
* A route without a break does not change. The same input gives the same output.
|
|
4480
|
+
*/
|
|
4481
|
+
export declare function repairResult(graph: Graph, result: Result, options?: RepairOptions): RepairReport;
|
|
4482
|
+
/** This function gives a router that repairs the routes of `router` with `repairResult`. It keeps the name and the `maxNodes` of the router. */
|
|
4483
|
+
export declare function withRepair(router: Router, options?: RepairOptions): Router;
|
|
4484
|
+
/**
|
|
4485
|
+
* This function gives a router strategy that runs `strategy` and then the repair step (RULE-046) with `repair`.
|
|
4486
|
+
* The new strategy has the name `<name>+repair`, and the options and the schema of `strategy`. The strategy `strategy` does not change.
|
|
4487
|
+
*/
|
|
4488
|
+
export declare function repairStrategy<O extends object>(strategy: Strategy<"router", O>, repair?: RepairOptions): Strategy<"router", O>;
|
|
4489
|
+
export type { AmbiguityGuardOptions, ArcOptions, BreakEvenOptions, BundleLine, BundleOrder, CandidateSource, ClothoidOptions, CornersOptions, CorridorOptions, CurveSpace, CutObjective, CutOptions, EdgeGroup, EdgeLengths, EdgePlugs, FieldEnd, FlowFieldOptions, FollowOptions, Gate, GroupSpine, GroupedOptions, Highway, HighwayBase, HighwayInput, HighwayMember, HighwayOptions, HighwayPlan, HysteresisOptions, JogStyle, KdAxis, KdLine, KdOptions, KeyOptions, KeyedWay, KeysOptions, LaneCurve, LevelHighwayOptions, MeetOptions, NodeKey, OdCellOptions, QuickBundlesOptions, RoadClassOptions, RoomBends, RoundedOptions, SectionsOptions, SelectOptions, ShareCost, ShareMerge, ShareOrder, SharedOptions, SharedStretchOptions, SharedWaysOptions, SmoothOptions, SplineOptions, SplitCell, StableIdOptions, StretchOptions, StubEnds, StubOptions, TrunkFan, TrunkSplit, TrunksOptions, WeiszfeldOptions, WspdOptions, Zip, ZipLimits, ZipperOptions };
|
|
3538
4490
|
//# sourceMappingURL=index.d.ts.map
|