@mark1russell7/highways 0.9.0 → 0.9.1
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 +38 -0
- package/build/index.d.ts +286 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2036 -453
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bench/screen/exercise.ts +5 -0
- package/src/bench/screen/forms.ts +5 -1
- package/src/highways/fixtures.test-util.ts +13 -0
- package/src/highways/follow.ts +3 -2
- package/src/highways/free-lines.ts +141 -0
- package/src/highways/gaps/index.ts +85 -0
- package/src/highways/index.ts +6 -0
- package/src/highways/interchanges/index.ts +231 -0
- package/src/highways/search/index.ts +170 -0
- package/src/highways/snap.ts +4 -2
- package/src/highways/steiner/index.ts +215 -0
- package/src/highways/streets/index.ts +78 -0
- package/src/model.ts +60 -4
- package/src/routers/attraction/index.ts +61 -0
- package/src/routers/corners.ts +4 -4
- package/src/routers/index.ts +2 -1
- package/src/routers/plugs.ts +3 -2
- package/src/routers/sections.ts +3 -2
- package/src/routers/shared.ts +70 -7
- package/src/routers/straight.ts +3 -2
- package/src/routers/trunks.ts +3 -2
- package/src/strategies/builtins.ts +56 -1
- package/src/strategies/schemas.ts +56 -0
package/README.md
CHANGED
|
@@ -26,6 +26,29 @@ const result = cornersRouter({ name: "corners" }).route(graph);
|
|
|
26
26
|
// Each route is a polyline: result.routes[0].points
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
### Plugs
|
|
30
|
+
|
|
31
|
+
A node can have `ports`, and an end of an edge can name one of them in `port`. Each plug has one of these forms:
|
|
32
|
+
|
|
33
|
+
| Form | The place of the plug |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `{ id }` | The router picks the side and the point. |
|
|
36
|
+
| `{ id, side }` | The router picks the point on that side. |
|
|
37
|
+
| `{ id, at }` | The plug is fixed at `at`, relative to the top-left corner of the box. |
|
|
38
|
+
| `{ id, side, along }` | The plug is fixed at the side start plus `along` times the side length. |
|
|
39
|
+
|
|
40
|
+
- `along` goes from 0 to 1. The start of `north` and `south` is the left end. The start of `east` and `west` is the top end.
|
|
41
|
+
- When the box gets taller or wider, a plug with `along` keeps its fraction of the side.
|
|
42
|
+
- `resolvePorts(graph)` gives each plug with `along` a fixed `at`. Each router calls it at the start of `route`.
|
|
43
|
+
- The arithmetic is the arithmetic of `portPoint` of `@mark1russell7/layout-contract`. `portOffset` calls it.
|
|
44
|
+
- `resolvePorts` throws a `RangeError` for a bad `along`. A bad value is not finite or is outside 0 to 1. A plug with `along` also needs a `side` and has no `at`.
|
|
45
|
+
- In an input file, such a plug has `side` and `along`, with no `x` and no `y`.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const node = { id: "a", box: { x: 0, y: 0, w: 80, h: 40 }, ports: [{ id: "out", side: "east", along: 0.25 }] };
|
|
49
|
+
// The plug "out" is at (80, 10). With h = 120, it is at (80, 30).
|
|
50
|
+
```
|
|
51
|
+
|
|
29
52
|
## Curve types
|
|
30
53
|
|
|
31
54
|
A router gives polylines. The curve layer turns a polyline into a curve of a type. The polyline can come from any router, from a lane of `laneRoutes` or from a link of a zoom level.
|
|
@@ -453,6 +476,11 @@ The step `highway` decides which edges share a way. It gives a plan, not routes.
|
|
|
453
476
|
| `consensus` | The consensus of HWY-035. The finders vote on the pairs of edges, and the pairs that most finders agree on stay. |
|
|
454
477
|
| `p-hub` | The p-hub median of HWY-041. The p-median of the plugs gives the hubs, and the links between two hubs become highways. |
|
|
455
478
|
| `scale-space` | The scale space of HWY-053. Only the clusters that live over a long range of scales get highways. |
|
|
479
|
+
| `steiner` | The Steiner trees of HWY-036. Each group of edges gets one rectilinear tree around the boxes, and the shared parts of the tree become highways. |
|
|
480
|
+
| `gaps` | The gap highways of HWY-057. A free line in a gap between boxes holds a highway when enough edges can ride it. |
|
|
481
|
+
| `streets` | The orthogonal streets of HWY-058. A greedy set cover picks the free horizontal and vertical lines that carry the most edge length. |
|
|
482
|
+
| `search` | The local search of HWY-059. It adds, drops and changes the highways of a start plan, and it keeps the plan with the best score. |
|
|
483
|
+
| `interchanges` | The interchanges of HWY-060. An edge can change from one highway to another at an interchange, where two spines come near. |
|
|
456
484
|
|
|
457
485
|
The strategy `corridors` joins two ways when they share a long length. The length is `BREAK_EVEN` times the lane width or more, and the share `rho` of the shorter way or more.
|
|
458
486
|
The strategies `meet`, `weiszfeld`, `stubs`, `zipper`, `level-links`, `lanes`, `divided` and `crossbars` change the plan of the option `from`: `shared-ways` (the default), `corridors` or `none`.
|
|
@@ -518,6 +546,16 @@ const shared = stableOrderStrategy(routerStrategies.shared);
|
|
|
518
546
|
const result = repairStrategy(shared).run(graph); // The router `shared+stable+repair`.
|
|
519
547
|
```
|
|
520
548
|
|
|
549
|
+
### The router `attraction`
|
|
550
|
+
|
|
551
|
+
The router `attraction` is opt-in. It is not in `STRATEGIES`, so the default outputs do not change.
|
|
552
|
+
|
|
553
|
+
- `attractionRouter(options)` gives the negotiated attraction of HWY-044, and `attractionStrategy` is its router strategy.
|
|
554
|
+
- Each pass after the first routes each edge again. A link that many edges used in the passes before gets a lower cost.
|
|
555
|
+
- The options are `passes` (1 to 10), `attraction` (0 to 1), `capacityWeight` (0 to 10) and `laneWidth` (1 to 12).
|
|
556
|
+
- A capacity term raises the cost of a link when its users are more than its width holds.
|
|
557
|
+
- With 1 pass, `attraction: 0` and `capacityWeight: 0`, the routes are the routes of `shared`.
|
|
558
|
+
|
|
521
559
|
### The portfolio router
|
|
522
560
|
|
|
523
561
|
The router `portfolio` is opt-in. It is not in `STRATEGIES`, so the default outputs do not change. [`PORTFOLIO.md`](../../docs/research/PORTFOLIO.md#the-portfolio-router-portfolio-api) gives its tables.
|
package/build/index.d.ts
CHANGED
|
@@ -83,7 +83,8 @@ export declare function segmentBounds(a: Point, b: Point): Box;
|
|
|
83
83
|
export type Side = "north" | "east" | "south" | "west";
|
|
84
84
|
/**
|
|
85
85
|
* A plug of a node: a place where edges go into the node.
|
|
86
|
-
* A plug with `at` is fixed. The router does not move it. A plug
|
|
86
|
+
* A plug with `at` is fixed. The router does not move it. A plug with `side` and `along` is fixed too.
|
|
87
|
+
* Another plug is free: the router places it.
|
|
87
88
|
*/
|
|
88
89
|
export interface Port {
|
|
89
90
|
readonly id: string;
|
|
@@ -91,6 +92,12 @@ export interface Port {
|
|
|
91
92
|
readonly at?: Point;
|
|
92
93
|
/** This side is where a free plug goes. Without it, the router picks the side. */
|
|
93
94
|
readonly side?: Side;
|
|
95
|
+
/**
|
|
96
|
+
* This fraction from 0 to 1 fixes the plug on its `side`. The plug is at the side start plus `along` times the side length.
|
|
97
|
+
* The start of `north` and `south` is the left end. The start of `east` and `west` is the top end.
|
|
98
|
+
* A plug with `along` needs a `side` and has no `at`. `resolvePorts` throws a `RangeError` for a bad value.
|
|
99
|
+
*/
|
|
100
|
+
readonly along?: number;
|
|
94
101
|
}
|
|
95
102
|
/** A node: a box that routes must not go through. */
|
|
96
103
|
export interface Node {
|
|
@@ -190,7 +197,20 @@ export interface Router {
|
|
|
190
197
|
}
|
|
191
198
|
/** This function gives a map from the id of each node to the node. */
|
|
192
199
|
export declare function nodeIndex(g: Graph): Map<string, Node>;
|
|
193
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* This function gives the place of a fixed plug, relative to the top-left corner of the node box, or `undefined` for a free plug.
|
|
202
|
+
* A plug with `at` gives `at`. A plug with `side` and `along` gives the point of `portPoint` of `@mark1russell7/layout-contract`.
|
|
203
|
+
*/
|
|
204
|
+
export declare function portOffset(box: Box, port: Port): Point | undefined;
|
|
205
|
+
/** This function throws a `RangeError` when the `along` of a plug is bad: not finite, outside 0 to 1, without `side` or with `at`. */
|
|
206
|
+
export declare function checkPort(node: Node, port: Port): void;
|
|
207
|
+
/**
|
|
208
|
+
* This function checks the plugs of a graph, and gives each plug with `side` and `along` a fixed `at`. The plug keeps its `side`.
|
|
209
|
+
* Each router calls it at the start of `route`, so all routers agree. A graph without `along` comes back as the same object.
|
|
210
|
+
* It throws a `RangeError` for a bad `along` (`checkPort`).
|
|
211
|
+
*/
|
|
212
|
+
export declare function resolvePorts(graph: Graph): Graph;
|
|
213
|
+
/** This function gives the absolute place of a fixed plug, or `undefined` for a free plug or no plug. A plug with `side` and `along` is fixed. */
|
|
194
214
|
export declare function fixedPortPoint(node: Node, end: End): Point | undefined;
|
|
195
215
|
/** This function gives a seeded random source with values in [0, 1) (mulberry32). */
|
|
196
216
|
export declare function rng(seed: number): () => number;
|
|
@@ -1771,13 +1791,58 @@ interface SharedOptions extends WayOptions {
|
|
|
1771
1791
|
/** The benchmark skips a fixture with more nodes. */
|
|
1772
1792
|
readonly maxNodes?: number;
|
|
1773
1793
|
}
|
|
1794
|
+
/**
|
|
1795
|
+
* The negotiation of the router `attraction` (HWY-044, PathFinder turned around). Each pass routes each edge again from no ways.
|
|
1796
|
+
* A link costs `len (1 - attraction h) (1 + weight max(0, use - cap))` more than in `shared`, with `h` the history of the link.
|
|
1797
|
+
*/
|
|
1798
|
+
interface SharedNegotiation {
|
|
1799
|
+
/** The number of passes, 1 or more. */
|
|
1800
|
+
readonly passes: number;
|
|
1801
|
+
/** The pull of the history of a link, from 0 to 1. */
|
|
1802
|
+
readonly attraction: number;
|
|
1803
|
+
/** The cost weight of each edge over the capacity of a link, 0 or more. */
|
|
1804
|
+
readonly capacityWeight: number;
|
|
1805
|
+
/** The width of one lane. The capacity of a link is its free width divided by this width, and 1 or more. */
|
|
1806
|
+
readonly laneWidth: number;
|
|
1807
|
+
}
|
|
1774
1808
|
/**
|
|
1775
1809
|
* This function makes a router where edges share their ways (after Pupyrev, Nachmanson, Bereg and Holroyd, "Edge routing with ordered bundles").
|
|
1776
1810
|
* The edges go one by one through the corner graph. A link that an edge with the same key uses already costs less.
|
|
1777
1811
|
* Thus the edges of a key come together on common ways. Each stretch that several edges share has the same points in each route.
|
|
1778
1812
|
* The result gives each stretch as a run, with the order of its lanes.
|
|
1779
1813
|
*/
|
|
1780
|
-
export declare function sharedRouter(options: SharedOptions): Router;
|
|
1814
|
+
export declare function sharedRouter(options: SharedOptions, negotiation?: SharedNegotiation): Router;
|
|
1815
|
+
/** The options of the router `attraction` (HWY-044 of the note on highways: negotiated attraction, PathFinder turned around). */
|
|
1816
|
+
interface AttractionOptions {
|
|
1817
|
+
/** The number of passes, from 1 to 10. Each pass after the first routes each edge again from no ways. The default is 3. */
|
|
1818
|
+
readonly passes: number;
|
|
1819
|
+
/** The pull `a` of the history of a link, from 0 to 1. A link then costs `1 - a h` times more. The default is 0.5. */
|
|
1820
|
+
readonly attraction: number;
|
|
1821
|
+
/** The cost weight `b` of each edge over the capacity of a link, from 0 to 10. The default is 1. */
|
|
1822
|
+
readonly capacityWeight: number;
|
|
1823
|
+
/** The width of one lane. The capacity of a link is its free width divided by this width. The default is 4. */
|
|
1824
|
+
readonly laneWidth: number;
|
|
1825
|
+
}
|
|
1826
|
+
/** The default options of the router `attraction`. */
|
|
1827
|
+
export declare const ATTRACTION_DEFAULTS: Readonly<AttractionOptions>;
|
|
1828
|
+
/** The declarations of the options of the router `attraction` (HWY-044). */
|
|
1829
|
+
export declare const ATTRACTION_SCHEMA: OptionSchema<AttractionOptions>;
|
|
1830
|
+
/**
|
|
1831
|
+
* This function makes the router `attraction` (HWY-044). It is the router `shared` with a negotiation over the passes.
|
|
1832
|
+
* After each pass, the history `h` of each link grows by `use / m`, with `m` the edges of the key. The history stops at `0.9 / a`.
|
|
1833
|
+
* In each pass, a link costs `len (1 - a h) (1 + b max(0, use - cap))` times the cost in `shared`.
|
|
1834
|
+
* The busy links of the passes before thus pull the edges, and a link over its capacity pushes them away.
|
|
1835
|
+
*/
|
|
1836
|
+
export declare function attractionRouter(options: Partial<AttractionOptions> & {
|
|
1837
|
+
readonly name: string;
|
|
1838
|
+
readonly rule?: GroupRule;
|
|
1839
|
+
readonly maxNodes?: number;
|
|
1840
|
+
}): Router;
|
|
1841
|
+
/**
|
|
1842
|
+
* The router strategy `attraction` (HWY-044), with the rule `byCollection` of `shared`. It is not a built-in router, so the benchmark and the hashes of `ROUTERS` do not change.
|
|
1843
|
+
* A screen module or a consumer adds it to a registry.
|
|
1844
|
+
*/
|
|
1845
|
+
export declare const attractionStrategy: Strategy<"router", AttractionOptions>;
|
|
1781
1846
|
/** Two items of a level that a link joins, and the count of the edges between them. */
|
|
1782
1847
|
interface ItemPair {
|
|
1783
1848
|
readonly source: string;
|
|
@@ -3844,6 +3909,8 @@ interface SnapLine {
|
|
|
3844
3909
|
interface SnapOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3845
3910
|
/** A highway has this number of edges or more. The value is 2 or more. */
|
|
3846
3911
|
readonly minSize: number;
|
|
3912
|
+
/** With `true`, a line in clear view is its own spine, with no path through the corner graph. The default is `false`. */
|
|
3913
|
+
readonly direct?: boolean;
|
|
3847
3914
|
}
|
|
3848
3915
|
/** This function gives the line `u d + rho n` of the direction angle `theta`, with `d = (cos, sin)` and the normal `n = (-sin, cos)`. */
|
|
3849
3916
|
export declare function linePoint(theta: number, rho: number, u: number): Point;
|
|
@@ -4880,6 +4947,212 @@ export declare function scaleSpaceGroups(input: HighwayInput, o: Readonly<ScaleS
|
|
|
4880
4947
|
* A short-lived cluster is noise, so a zoom level shows only the stable structure.
|
|
4881
4948
|
*/
|
|
4882
4949
|
export declare function scaleSpacePlan(input: HighwayInput, o: Readonly<ScaleSpaceOptions>): HighwayPlan;
|
|
4950
|
+
/** The source of the candidate streets: the middle lines of the gaps of the room step, or the lines through the corners. */
|
|
4951
|
+
type StreetSource = "room" | "corners";
|
|
4952
|
+
/** The values of `StreetSource`. */
|
|
4953
|
+
export declare const STREET_SOURCES: readonly StreetSource[];
|
|
4954
|
+
/** One axis-parallel street in the free space, from `a` to `b`. */
|
|
4955
|
+
interface FreeLine {
|
|
4956
|
+
readonly a: Point;
|
|
4957
|
+
readonly b: Point;
|
|
4958
|
+
}
|
|
4959
|
+
/** One edge for the streets: its two points out of its plugs, and the length of its first route. */
|
|
4960
|
+
interface StreetEdge {
|
|
4961
|
+
readonly edge: string;
|
|
4962
|
+
readonly s: Point;
|
|
4963
|
+
readonly t: Point;
|
|
4964
|
+
readonly base: number;
|
|
4965
|
+
}
|
|
4966
|
+
/** The ride of one edge on one street. It has the points where the edge joins and leaves the street, and two lengths. */
|
|
4967
|
+
interface StreetRide {
|
|
4968
|
+
readonly on: Point;
|
|
4969
|
+
readonly off: Point;
|
|
4970
|
+
/** The length on the street. */
|
|
4971
|
+
readonly ride: number;
|
|
4972
|
+
/** The length of the two ramps, to the street and from it. */
|
|
4973
|
+
readonly ramps: number;
|
|
4974
|
+
}
|
|
4975
|
+
/**
|
|
4976
|
+
* This function gives the candidate streets of a board. Each street is an axis-parallel piece of free space.
|
|
4977
|
+
* The source `room` takes the middle line of each gap of `boardGaps` that is two margins wide or more.
|
|
4978
|
+
* The source `corners` takes the lines one margin out from each side of each box.
|
|
4979
|
+
* A street is two margins long or more. The list has no copies, and its order is the same each time.
|
|
4980
|
+
*/
|
|
4981
|
+
export declare function freeLines(graph: Graph, finder: WayFinder, source: StreetSource): FreeLine[];
|
|
4982
|
+
/** This function gives the edges of the input for the streets, with the points out of their plugs and the lengths of their first routes. */
|
|
4983
|
+
export declare function streetEdges(input: HighwayInput, finder: WayFinder): StreetEdge[];
|
|
4984
|
+
/** This function gives the point of the street nearest to `p`. */
|
|
4985
|
+
export declare function streetPoint(line: FreeLine, p: Point): Point;
|
|
4986
|
+
/** This function gives the ride of an edge on a street. The edge joins the street at the point nearest to `s`, and leaves it at the point nearest to `t`. */
|
|
4987
|
+
export declare function streetRide(line: FreeLine, e: StreetEdge): StreetRide;
|
|
4988
|
+
/** The options of the highway strategy `gaps` (HWY-057 of the note on highways). */
|
|
4989
|
+
interface GapOptions {
|
|
4990
|
+
/** A street with fewer edges than this number (the demand `k`) is not a highway. The default is 3. */
|
|
4991
|
+
readonly minSize: number;
|
|
4992
|
+
/** The cost of a length on a street against a length off the streets, from 0.1 to 0.8. The default is 0.5. */
|
|
4993
|
+
readonly discount: number;
|
|
4994
|
+
/** An edge rides a street only when its way along the street is this many times its first route or less. The default is 1.3. */
|
|
4995
|
+
readonly detour: number;
|
|
4996
|
+
/** The source of the streets: the gaps of the room step, or the lines through the corners. The default is `room`. */
|
|
4997
|
+
readonly source: StreetSource;
|
|
4998
|
+
}
|
|
4999
|
+
/** The default options of the strategy `gaps`. */
|
|
5000
|
+
export declare const GAP_DEFAULTS: Readonly<GapOptions>;
|
|
5001
|
+
/**
|
|
5002
|
+
* This function gives the highways on the gaps of the board (HWY-057). The streets are the free middle lines of the gaps.
|
|
5003
|
+
* Each edge takes the street that saves it the most cost, when a length on a street costs `discount` times its length.
|
|
5004
|
+
* A street with `minSize` edges or more becomes a highway. The edges of the other streets then choose again among the highways, two times.
|
|
5005
|
+
*/
|
|
5006
|
+
export declare function gapPlan(input: HighwayInput, o: Readonly<GapOptions>): HighwayPlan;
|
|
5007
|
+
/** The plan that gives the highways of the network: the plan of `corridors` or of `shared-ways`, with their defaults. */
|
|
5008
|
+
type InterchangeBase = "corridors" | "shared-ways";
|
|
5009
|
+
/** The values of `InterchangeBase`. */
|
|
5010
|
+
export declare const INTERCHANGE_BASES: readonly InterchangeBase[];
|
|
5011
|
+
/** The options of the highway strategy `interchanges` (HWY-060 of the note on highways). */
|
|
5012
|
+
interface InterchangeOptions {
|
|
5013
|
+
/** The plan that gives the highways. The default is `corridors`. */
|
|
5014
|
+
readonly from: InterchangeBase;
|
|
5015
|
+
/** The cost of a change between two highways, in units of the board, from 0 to 8. The default is 2. */
|
|
5016
|
+
readonly changeCost: number;
|
|
5017
|
+
/** The largest number of interchanges, from 1 to 32. The default is 16. */
|
|
5018
|
+
readonly interchanges: number;
|
|
5019
|
+
/** The largest number of highways on the way of one edge, from 1 to 3. The default is 2. */
|
|
5020
|
+
readonly perEdge: number;
|
|
5021
|
+
/** Two highways get an interchange where they come this near, in units of the board. The default is 2. */
|
|
5022
|
+
readonly radius: number;
|
|
5023
|
+
/** The cost of a length on a highway against a length off the highways, from 0.1 to 1. The default is 0.5. */
|
|
5024
|
+
readonly discount: number;
|
|
5025
|
+
/** An edge rides the network only when its way is this many times its first route or less. The default is 1.5. */
|
|
5026
|
+
readonly detour: number;
|
|
5027
|
+
}
|
|
5028
|
+
/** The default options of the strategy `interchanges`. */
|
|
5029
|
+
export declare const INTERCHANGE_DEFAULTS: Readonly<InterchangeOptions>;
|
|
5030
|
+
/** One interchange: a place on the highway `h`, a place on the highway `g`, and the length of the link between the two places. */
|
|
5031
|
+
interface Interchange {
|
|
5032
|
+
readonly h: number;
|
|
5033
|
+
readonly hAt: number;
|
|
5034
|
+
readonly g: number;
|
|
5035
|
+
readonly gAt: number;
|
|
5036
|
+
readonly gap: number;
|
|
5037
|
+
}
|
|
5038
|
+
/** This function gives the candidate interchanges: the nearest places of each pair of spines that come within `radius`, with a link in clear view. */
|
|
5039
|
+
export declare function interchangeCandidates(spines: readonly (readonly Point[])[], radius: number, clear: (a: Point, b: Point) => boolean): Interchange[];
|
|
5040
|
+
/**
|
|
5041
|
+
* This function gives the highways of a network with interchanges (HWY-060). The highways come from a plan. Two highways that come near get an interchange.
|
|
5042
|
+
* Each edge takes its cheapest way: a ride on one highway, or on up to `perEdge` highways with a change at an interchange.
|
|
5043
|
+
* A change costs `changeCost` units. The interchanges that the most edges use stay, up to `interchanges`.
|
|
5044
|
+
*/
|
|
5045
|
+
export declare function interchangePlan(input: HighwayInput, o: Readonly<InterchangeOptions>): HighwayPlan;
|
|
5046
|
+
/** The options of the highway strategy `search` (HWY-059 of the note on highways). */
|
|
5047
|
+
interface SearchOptions {
|
|
5048
|
+
/** The plan where the search starts. The default is `corridors`. */
|
|
5049
|
+
readonly from: CandidateSource;
|
|
5050
|
+
/** The generators of the highways that the move `add` takes. The default is `quickbundles` and `road-classes`. */
|
|
5051
|
+
readonly pool: readonly CandidateSource[];
|
|
5052
|
+
/** The number of plans that the search measures, from 0 to 400. The value 0 gives the start plan. The default is 16. */
|
|
5053
|
+
readonly evaluations: number;
|
|
5054
|
+
/** The first temperature of the annealing, on the scale of the score. Each sweep of 4 moves multiplies it by 0.95. The default is 0.02. */
|
|
5055
|
+
readonly temperature: number;
|
|
5056
|
+
/** The weight of the ink that the routes save (B1). The default is 1. */
|
|
5057
|
+
readonly inkWeight: number;
|
|
5058
|
+
/** The weight of the 0.95 quantile of the stretch against the first routes (B3). The default is 0.5. */
|
|
5059
|
+
readonly stretchWeight: number;
|
|
5060
|
+
/** The weight of the ambiguity (B4). The default is 0.5. */
|
|
5061
|
+
readonly ambiguityWeight: number;
|
|
5062
|
+
/** The weight of the largest merge angle (B6), divided by 180 degrees. The default is 0.25. */
|
|
5063
|
+
readonly angleWeight: number;
|
|
5064
|
+
/** The seed of the moves. The default is 1. */
|
|
5065
|
+
readonly seed: number;
|
|
5066
|
+
}
|
|
5067
|
+
/** The default options of the strategy `search`. */
|
|
5068
|
+
export declare const SEARCH_DEFAULTS: Readonly<SearchOptions>;
|
|
5069
|
+
/** The moves of the search. */
|
|
5070
|
+
type SearchMove = "add" | "drop" | "edge" | "point";
|
|
5071
|
+
/** The values of `SearchMove`, in the order of the draw. */
|
|
5072
|
+
export declare const SEARCH_MOVES: readonly SearchMove[];
|
|
5073
|
+
/**
|
|
5074
|
+
* This function gives the score of the routes of a plan: `w1 B1 - w3 B3 - w4 B4 - w6 B6 / 180`. Higher is better.
|
|
5075
|
+
* B3 is the 0.95 quantile of the stretch against the first routes. The score reads only the graph and the routes of the plan.
|
|
5076
|
+
*/
|
|
5077
|
+
export declare function searchScore(graph: Graph, routes: readonly Route[], first: readonly Route[], o: Readonly<SearchOptions>): number;
|
|
5078
|
+
/**
|
|
5079
|
+
* This function gives the highways of a local search over the set of highways (HWY-059). The search starts at the plan of `from`.
|
|
5080
|
+
* Each move adds a highway of the pool, drops a highway, moves one edge to another highway, or moves one point of a spine.
|
|
5081
|
+
* The annealing keeps a worse plan with the chance `acceptance(-delta / T)`. The best plan that the search measures is the result.
|
|
5082
|
+
*
|
|
5083
|
+
* The score reads only this graph and its routes. Thus the search does not fit to the inputs of a screen.
|
|
5084
|
+
*/
|
|
5085
|
+
export declare function searchPlan(input: HighwayInput, o: Readonly<SearchOptions>): HighwayPlan;
|
|
5086
|
+
/** The groups of the trees: the edges from one source node, or the edges of one collection. */
|
|
5087
|
+
type SteinerGroup = "source" | "key";
|
|
5088
|
+
/** The values of `SteinerGroup`. */
|
|
5089
|
+
export declare const STEINER_GROUPS: readonly SteinerGroup[];
|
|
5090
|
+
/** The method of the tree: the iterated 1-Steiner method on the Hanan grid, or the spanning tree of the terminals alone. */
|
|
5091
|
+
type SteinerMethod = "one-steiner" | "spanning";
|
|
5092
|
+
/** The values of `SteinerMethod`. */
|
|
5093
|
+
export declare const STEINER_METHODS: readonly SteinerMethod[];
|
|
5094
|
+
/** The metric of the tree: rectilinear (two directions) or octilinear (four directions). */
|
|
5095
|
+
type SteinerMetric = "rectilinear" | "octilinear";
|
|
5096
|
+
/** The values of `SteinerMetric`. */
|
|
5097
|
+
export declare const STEINER_METRICS: readonly SteinerMetric[];
|
|
5098
|
+
/** The options of the highway strategy `steiner` (HWY-036 of the note on highways, with EDA-015). */
|
|
5099
|
+
interface SteinerOptions {
|
|
5100
|
+
/** The groups of the trees. The default is `source`. */
|
|
5101
|
+
readonly group: SteinerGroup;
|
|
5102
|
+
/** The method of the tree. The default is `one-steiner`. */
|
|
5103
|
+
readonly method: SteinerMethod;
|
|
5104
|
+
/** A group with more terminals than this number gets the spanning tree alone. The default is 12. */
|
|
5105
|
+
readonly maxGroup: number;
|
|
5106
|
+
/** The metric of the tree. The default is `rectilinear`. */
|
|
5107
|
+
readonly metric: SteinerMetric;
|
|
5108
|
+
/** An edge rides the tree only when its path in the tree is this many times its first route or less. The default is 1.5. */
|
|
5109
|
+
readonly detour: number;
|
|
5110
|
+
/** A stretch of a tree with fewer edges than this number is not a highway. The default is 2. */
|
|
5111
|
+
readonly minSize: number;
|
|
5112
|
+
}
|
|
5113
|
+
/** The default options of the strategy `steiner`. */
|
|
5114
|
+
export declare const STEINER_DEFAULTS: Readonly<SteinerOptions>;
|
|
5115
|
+
/** This function gives the links of the spanning tree of the points (Prim), as pairs of indices, and the sum of their lengths. */
|
|
5116
|
+
export declare function spanningTree(points: readonly Point[], metric: SteinerMetric): {
|
|
5117
|
+
links: [number, number][];
|
|
5118
|
+
cost: number;
|
|
5119
|
+
};
|
|
5120
|
+
/**
|
|
5121
|
+
* This function gives a Steiner tree of the terminals by the iterated 1-Steiner method (Kahng and Robins). The candidates are the points of the Hanan grid.
|
|
5122
|
+
* Each round adds the candidate that makes the spanning tree shortest, and drops each added point with two links or fewer.
|
|
5123
|
+
* The test `free` removes the candidates in the boxes. The result has the terminals first, then the added points.
|
|
5124
|
+
*/
|
|
5125
|
+
export declare function oneSteiner(terminals: readonly Point[], metric: SteinerMetric, free: (p: Point) => boolean): {
|
|
5126
|
+
points: Point[];
|
|
5127
|
+
links: [number, number][];
|
|
5128
|
+
};
|
|
5129
|
+
/**
|
|
5130
|
+
* This function gives the highways of obstacle-avoiding Steiner trees (HWY-036 with EDA-015). Each group of edges gets one tree over the points out of its plugs.
|
|
5131
|
+
* The links of the tree are rectilinear or octilinear, and they go around the boxes. Each edge takes its path in the tree, when that path is short enough.
|
|
5132
|
+
* The stretches of the tree that two edges or more share become highways.
|
|
5133
|
+
*/
|
|
5134
|
+
export declare function steinerPlan(input: HighwayInput, o: Readonly<SteinerOptions>): HighwayPlan;
|
|
5135
|
+
/** The options of the highway strategy `streets` (HWY-058 of the note on highways). */
|
|
5136
|
+
interface StreetOptions {
|
|
5137
|
+
/** A street covers an edge when the way of the edge along the street is this many times its first route or less (the limit `s`). The default is 1.2. */
|
|
5138
|
+
readonly detour: number;
|
|
5139
|
+
/** The greedy cover stops when the best street gives less than this gain: the length that its edges ride over the length of the street. The default is 2. */
|
|
5140
|
+
readonly minGain: number;
|
|
5141
|
+
/** The largest number of streets. The default is 32. */
|
|
5142
|
+
readonly maxStreets: number;
|
|
5143
|
+
/** A street with fewer new edges than this number is not a highway. The default is 2. */
|
|
5144
|
+
readonly minSize: number;
|
|
5145
|
+
/** The source of the streets: the gaps of the room step, or the lines through the corners. The default is `corners`. */
|
|
5146
|
+
readonly source: StreetSource;
|
|
5147
|
+
}
|
|
5148
|
+
/** The default options of the strategy `streets`. */
|
|
5149
|
+
export declare const STREET_DEFAULTS: Readonly<StreetOptions>;
|
|
5150
|
+
/**
|
|
5151
|
+
* This function gives orthogonal streets by a greedy set cover (HWY-058). A street covers each edge whose way along it is at most `detour` times its first route.
|
|
5152
|
+
* Each step takes the street with the largest gain: the length that its new edges ride, over the length of the street that they use.
|
|
5153
|
+
* The cover stops at `maxStreets` streets, or when the best gain is below `minGain`. Each edge rides one street at most.
|
|
5154
|
+
*/
|
|
5155
|
+
export declare function streetPlan(input: HighwayInput, o: Readonly<StreetOptions>): HighwayPlan;
|
|
4883
5156
|
/** The lines that make the density: the straight lines of the edges, or their first routes. */
|
|
4884
5157
|
type RidgeSource = "lines" | "routes";
|
|
4885
5158
|
/** The options of the highway strategy `ridges` (HWY-032 of the note on highways). */
|
|
@@ -5648,6 +5921,11 @@ export declare const highwayStrategies: {
|
|
|
5648
5921
|
readonly consensus: Strategy<"highway", ConsensusOptions>;
|
|
5649
5922
|
readonly "p-hub": Strategy<"highway", PHubOptions>;
|
|
5650
5923
|
readonly "scale-space": Strategy<"highway", ScaleSpaceOptions>;
|
|
5924
|
+
readonly steiner: Strategy<"highway", SteinerOptions>;
|
|
5925
|
+
readonly gaps: Strategy<"highway", GapOptions>;
|
|
5926
|
+
readonly streets: Strategy<"highway", StreetOptions>;
|
|
5927
|
+
readonly search: Strategy<"highway", SearchOptions>;
|
|
5928
|
+
readonly interchanges: Strategy<"highway", InterchangeOptions>;
|
|
5651
5929
|
readonly "corridors+breakeven": Strategy<"highway", CorridorOptions & BreakEvenOptions>;
|
|
5652
5930
|
readonly "corridors+stretch": Strategy<"highway", CorridorOptions & StretchOptions>;
|
|
5653
5931
|
readonly "corridors+ambiguity": Strategy<"highway", CorridorOptions & AmbiguityGuardOptions>;
|
|
@@ -5837,6 +6115,8 @@ export interface LayoutPort {
|
|
|
5837
6115
|
/** The fixed place of the port, from the top-left corner of the box. The router does not move a port with `x` and `y`. */
|
|
5838
6116
|
readonly x?: number;
|
|
5839
6117
|
readonly y?: number;
|
|
6118
|
+
/** The fixed place of the port on its `side`: a fraction from 0 to 1. The start is the top end or the left end of the side. */
|
|
6119
|
+
readonly along?: number;
|
|
5840
6120
|
}
|
|
5841
6121
|
/** A point of a region: `[x, y]`. The y axis points down. */
|
|
5842
6122
|
export type RegionPoint = readonly [number, number];
|
|
@@ -6049,7 +6329,7 @@ export interface LayoutPrediction {
|
|
|
6049
6329
|
}
|
|
6050
6330
|
/**
|
|
6051
6331
|
* This function writes a graph as an input file of the form `layout-input/1`, with its hash.
|
|
6052
|
-
* A fixed plug gets `x`, `y` and the side that holds it. `inputGraph` reads the file back.
|
|
6332
|
+
* A fixed plug gets `x`, `y` and the side that holds it. A plug with `along` keeps its `side` and `along`. `inputGraph` reads the file back.
|
|
6053
6333
|
*/
|
|
6054
6334
|
export declare function graphInput(graph: Graph, head: LayoutInputHead): LayoutInput;
|
|
6055
6335
|
/**
|
|
@@ -6827,7 +7107,7 @@ interface FollowOptions extends WayOptions {
|
|
|
6827
7107
|
* The result has a shared run for each stretch of a spine where the same two edges or more go. Each run holds the points of its routes in a row.
|
|
6828
7108
|
* The same graph, plan and options give the same result.
|
|
6829
7109
|
*/
|
|
6830
|
-
export declare function follow(
|
|
7110
|
+
export declare function follow(input: Graph, plan: HighwayPlan, options?: FollowOptions): Result;
|
|
6831
7111
|
/**
|
|
6832
7112
|
* This function gives the highways of a result of a router: one highway for each shared run and for each trunk of a bundle.
|
|
6833
7113
|
* The spine is the points of the run or of the trunk. Each edge of the run is a member, from one end of the spine to the other end, in the way of its route.
|
|
@@ -7181,5 +7461,5 @@ export declare const PORTFOLIO_SETS: Readonly<Record<`${PortfolioRule}|${Portfol
|
|
|
7181
7461
|
* The default stretch order is `sifting`, the best order of the screen. The option `stretchOrder` selects `consensus` or `periphery`.
|
|
7182
7462
|
*/
|
|
7183
7463
|
export declare const sharedStretchStrategy: Strategy<"router", RouterPreset<SharedOptions>>;
|
|
7184
|
-
export { type AdvectionSettings, type AmbiguityGuardOptions, type ArcOptions, type ArcSource, type AreaOptions, type AreaWidth, type Biclique, type BreakEvenOptions, type BundleLine, type BundleOrder, type CandidateSource, type CellStep, type ClothoidOptions, type ConfluentOptions, type ConsensusLinkage, type ConsensusOptions, type CornersOptions, type CorpusDimension, type CorpusFamily, type CorridorOptions, type Crossbar, type CrossbarOptions, type CubuOptions, type CurveSpace, type CutObjective, type CutOptions, DEFAULT_RNG, type DensityGrid, type DensityImage, type DensityKernel, type DensitySource, type DiffusionOptions, type DimensionValues, type DividedOptions, type EdgeDistance, type EdgeEnds, type EdgeGroup, type EdgeLengths, type EdgePathOptions, type EdgePlugs, type ExerciseEvidence, type FamilyRegistry, type FdebOptions, type FieldEnd, type FlowClusterOptions, type FlowFieldOptions, type FollowOptions, type FrechetBundle, type FrechetOptions, type Gate, type GenerateContext, type GroupScope, type GroupSpine, type GroupedOptions, type GrowthOptions, type GrowthOrder, type HashOptions, type HdbscanOptions, type HierarchyGroups, type HierarchyOptions, type Highway, type HighwayBase, type HighwayInput, type HighwayMember, type HighwayOptions, type HighwayPlan, type HoughOptions, type HoughPeak, type HubAllocation, type HubArcOptions, type HubCandidates, type HysteresisOptions, type JogStyle, type KdAxis, type KdLine, type KdOptions, type KdeebOptions, type KeyOptions, type KeyedWay, type KeysOptions, type LaneCurve, type LanesOptions, type LevelHighwayOptions, type LinkCommunityOptions, type LinkEdge, type Linkage, type MeetOptions, type Member, type MemberStatus, type MemberTrace, type MeshOptions, type MingleOptions, type MlsFit, type MlsebOptions, type ModuleRule, type NestedOptions, type NodeKey, type NodeLinks, type OdCellOptions, type OutputGroup, type PHubOptions, type ParamValue, type PathStep, type PickSpec, type Portfolio, type PortfolioKey, type PortfolioLevel, type PortfolioOptions, type PortfolioPick, type PortfolioTrace, type PowerOptions, type QuickBundlesOptions, RECORD_EPS, type ResistanceOptions, type Ridge, type RidgeOptions, type RidgeSource, type RoadClassOptions, type RoomBends, type RoundedOptions, type RouteCrossing, type RouteSegment, type SbebOptions, type ScaleCluster, type ScaleSpaceOptions, type SectionsOptions, type SelectCandidate, type SelectLevel, type SelectOptions, type Selection, type ShapeSkeleton, type ShareCost, type ShareMerge, type ShareOrder, type SharedOptions, type SharedStretchOptions, type SharedWaysOptions, type SkeletonGroups, type SkeletonTarget, type SmoothOptions, type SnapLine, type SnapMember, type SnapOptions, type SoftKeyOptions, type SpectralOptions, type SpiralNode, type SpiralOptions, type SplineOptions, type SplitCell, type StableIdOptions, type StretchOptions, type StubEnds, type StubOptions, type TerritoryOptions, type TerritoryPoints, type TraceOptions, type TraclusOptions, type TrafficRule, type TrunkFan, type TrunkSplit, type TrunksOptions, type WeiszfeldOptions, type WspdOptions, type Zip, type ZipLimits, type ZipperOptions, canonicalJson, compareMeasure, createFamilyRegistry, dimensionAt, dimensionUnit, exercised, familyKind, levelsOf, minEffectOf, outputGroups, outputHash, paramProblem, pickMoves, portfolio, randomInt, selectBest, sha256Hex };
|
|
7464
|
+
export { type AdvectionSettings, type AmbiguityGuardOptions, type ArcOptions, type ArcSource, type AreaOptions, type AreaWidth, type AttractionOptions, type Biclique, type BreakEvenOptions, type BundleLine, type BundleOrder, type CandidateSource, type CellStep, type ClothoidOptions, type ConfluentOptions, type ConsensusLinkage, type ConsensusOptions, type CornersOptions, type CorpusDimension, type CorpusFamily, type CorridorOptions, type Crossbar, type CrossbarOptions, type CubuOptions, type CurveSpace, type CutObjective, type CutOptions, DEFAULT_RNG, type DensityGrid, type DensityImage, type DensityKernel, type DensitySource, type DiffusionOptions, type DimensionValues, type DividedOptions, type EdgeDistance, type EdgeEnds, type EdgeGroup, type EdgeLengths, type EdgePathOptions, type EdgePlugs, type ExerciseEvidence, type FamilyRegistry, type FdebOptions, type FieldEnd, type FlowClusterOptions, type FlowFieldOptions, type FollowOptions, type FrechetBundle, type FrechetOptions, type FreeLine, type GapOptions, type Gate, type GenerateContext, type GroupScope, type GroupSpine, type GroupedOptions, type GrowthOptions, type GrowthOrder, type HashOptions, type HdbscanOptions, type HierarchyGroups, type HierarchyOptions, type Highway, type HighwayBase, type HighwayInput, type HighwayMember, type HighwayOptions, type HighwayPlan, type HoughOptions, type HoughPeak, type HubAllocation, type HubArcOptions, type HubCandidates, type HysteresisOptions, type Interchange, type InterchangeBase, type InterchangeOptions, type JogStyle, type KdAxis, type KdLine, type KdOptions, type KdeebOptions, type KeyOptions, type KeyedWay, type KeysOptions, type LaneCurve, type LanesOptions, type LevelHighwayOptions, type LinkCommunityOptions, type LinkEdge, type Linkage, type MeetOptions, type Member, type MemberStatus, type MemberTrace, type MeshOptions, type MingleOptions, type MlsFit, type MlsebOptions, type ModuleRule, type NestedOptions, type NodeKey, type NodeLinks, type OdCellOptions, type OutputGroup, type PHubOptions, type ParamValue, type PathStep, type PickSpec, type Portfolio, type PortfolioKey, type PortfolioLevel, type PortfolioOptions, type PortfolioPick, type PortfolioTrace, type PowerOptions, type QuickBundlesOptions, RECORD_EPS, type ResistanceOptions, type Ridge, type RidgeOptions, type RidgeSource, type RoadClassOptions, type RoomBends, type RoundedOptions, type RouteCrossing, type RouteSegment, type SbebOptions, type ScaleCluster, type ScaleSpaceOptions, type SearchMove, type SearchOptions, type SectionsOptions, type SelectCandidate, type SelectLevel, type SelectOptions, type Selection, type ShapeSkeleton, type ShareCost, type ShareMerge, type ShareOrder, type SharedNegotiation, type SharedOptions, type SharedStretchOptions, type SharedWaysOptions, type SkeletonGroups, type SkeletonTarget, type SmoothOptions, type SnapLine, type SnapMember, type SnapOptions, type SoftKeyOptions, type SpectralOptions, type SpiralNode, type SpiralOptions, type SplineOptions, type SplitCell, type StableIdOptions, type SteinerGroup, type SteinerMethod, type SteinerMetric, type SteinerOptions, type StreetEdge, type StreetOptions, type StreetRide, type StreetSource, type StretchOptions, type StubEnds, type StubOptions, type TerritoryOptions, type TerritoryPoints, type TraceOptions, type TraclusOptions, type TrafficRule, type TrunkFan, type TrunkSplit, type TrunksOptions, type WeiszfeldOptions, type WspdOptions, type Zip, type ZipLimits, type ZipperOptions, canonicalJson, compareMeasure, createFamilyRegistry, dimensionAt, dimensionUnit, exercised, familyKind, levelsOf, minEffectOf, outputGroups, outputHash, paramProblem, pickMoves, portfolio, randomInt, selectBest, sha256Hex };
|
|
7185
7465
|
//# sourceMappingURL=index.d.ts.map
|