@mark1russell7/highways 0.3.0 → 0.4.0
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 +26 -2
- package/build/index.d.ts +698 -12
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2353 -55
- package/build/index.js.map +1 -1
- package/package.json +3 -1
- package/src/bench/compare.ts +41 -6
- package/src/bench/screen/forms.ts +372 -0
- package/src/bench/screen/generators.ts +54 -0
- package/src/bench/screen/hash.ts +129 -0
- package/src/bench/screen/index.ts +6 -0
- package/src/bench/screen/measures.ts +114 -0
- package/src/bench/screen/screen.ts +390 -0
- package/src/bench/screen/set.ts +136 -0
- package/src/bench/suite.ts +71 -13
- package/src/highways/corridors/index.ts +305 -0
- package/src/highways/follow.ts +155 -0
- package/src/highways/index.ts +7 -0
- package/src/highways/keys/index.ts +15 -0
- package/src/highways/model.ts +111 -0
- package/src/highways/result.ts +34 -0
- package/src/highways/router.ts +40 -0
- package/src/highways/shared-ways/index.ts +15 -0
- package/src/index.ts +2 -0
- package/src/strategies/builtins.ts +82 -6
- package/src/strategies/model.ts +36 -6
- package/src/strategies/schemas.ts +13 -0
package/build/index.d.ts
CHANGED
|
@@ -1038,6 +1038,64 @@ interface LevelLinkOptions extends WayOptions {
|
|
|
1038
1038
|
*/
|
|
1039
1039
|
readonly throughCost?: number;
|
|
1040
1040
|
}
|
|
1041
|
+
/** The input of a highway strategy: the boxes and the edges, and optionally the first routes of a router. */
|
|
1042
|
+
interface HighwayInput {
|
|
1043
|
+
readonly graph: Graph;
|
|
1044
|
+
/**
|
|
1045
|
+
* These routes are the first routes, from a router. A strategy that reads first routes makes them itself when this value is absent.
|
|
1046
|
+
* The strategy `corridors` makes the ways of the corner graph, as the router `corners` finds them.
|
|
1047
|
+
*/
|
|
1048
|
+
readonly routes?: Result;
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* One edge of a highway. The edge joins the spine at the merge point and leaves it at the split point.
|
|
1052
|
+
* A place on the spine is the index of a point of the spine plus the share of the next leg. Point `i` of the spine is at `i`.
|
|
1053
|
+
* When `on` is larger than `off`, the edge goes along the spine from its last point to its first point.
|
|
1054
|
+
*/
|
|
1055
|
+
interface HighwayMember {
|
|
1056
|
+
readonly edge: string;
|
|
1057
|
+
/** The place of the merge point on the spine. */
|
|
1058
|
+
readonly on: number;
|
|
1059
|
+
/** The place of the split point on the spine. */
|
|
1060
|
+
readonly off: number;
|
|
1061
|
+
/** The point where the edge joins the spine. */
|
|
1062
|
+
readonly merge: Point;
|
|
1063
|
+
/** The point where the edge leaves the spine. */
|
|
1064
|
+
readonly split: Point;
|
|
1065
|
+
/**
|
|
1066
|
+
* The place of this highway in the trip of the edge, from 0. An edge can go along several highways, one after the other.
|
|
1067
|
+
* `follow` takes the highways of an edge in the order of this value.
|
|
1068
|
+
*/
|
|
1069
|
+
readonly seq: number;
|
|
1070
|
+
}
|
|
1071
|
+
/** A highway: a shared way that a bundle of edges follows, from their merge points to their split points. */
|
|
1072
|
+
interface Highway {
|
|
1073
|
+
readonly id: string;
|
|
1074
|
+
/** The key of the highway, for example the key of the grouping rule or the index of a cluster. */
|
|
1075
|
+
readonly key: string;
|
|
1076
|
+
/** The spine: the polyline that the edges follow, in free space. */
|
|
1077
|
+
readonly spine: readonly Point[];
|
|
1078
|
+
/** The edges in lane order. Lane 0 is on the left of the spine, from its first point to its last point. The y axis points down. */
|
|
1079
|
+
readonly lanes: readonly string[];
|
|
1080
|
+
/** The edges with their merge points and their split points, in the order of `lanes`. */
|
|
1081
|
+
readonly members: readonly HighwayMember[];
|
|
1082
|
+
}
|
|
1083
|
+
/** The output of a highway strategy: the highways, as data. `follow` routes the edges along them. */
|
|
1084
|
+
interface HighwayPlan {
|
|
1085
|
+
readonly highways: readonly Highway[];
|
|
1086
|
+
}
|
|
1087
|
+
/** This function gives the point at a place on a polyline. A place outside the polyline gives its nearest end. */
|
|
1088
|
+
export declare function pointAt(line: readonly Point[], at: number): Point;
|
|
1089
|
+
/** This function gives the length of a polyline from the place `from` to the place `to`, with `from` not larger than `to`. */
|
|
1090
|
+
export declare function lengthBetween(line: readonly Point[], from: number, to: number): number;
|
|
1091
|
+
/** This function gives a member of a highway with its merge point and its split point at the places `on` and `off` of the spine. */
|
|
1092
|
+
export declare function memberAt(spine: readonly Point[], edge: string, on: number, off: number, seq?: number): HighwayMember;
|
|
1093
|
+
/**
|
|
1094
|
+
* This function lists the problems of a plan against its graph. A good plan gives an empty list.
|
|
1095
|
+
* Each highway has a spine of two points or more, and two members or more. Each member is an edge of the graph, with `on` and `off` on the spine and apart.
|
|
1096
|
+
* An edge is a member of a highway one time at most.
|
|
1097
|
+
*/
|
|
1098
|
+
export declare function checkPlan(graph: Graph, plan: HighwayPlan): string[];
|
|
1041
1099
|
/**
|
|
1042
1100
|
* The options of the room for the bends of the bundles (HWC-D). With them, `roomDemand` also opens the gaps where a bundle bends.
|
|
1043
1101
|
* The values agree with the options of `highwayCurves` that draw the bundles.
|
|
@@ -1296,6 +1354,25 @@ export interface CurveInput {
|
|
|
1296
1354
|
readonly endNormal?: Point;
|
|
1297
1355
|
/** The boxes that the curve must not go through, from `curveSpace`. */
|
|
1298
1356
|
readonly space?: CurveSpace;
|
|
1357
|
+
/**
|
|
1358
|
+
* The lane of the polyline on its board, for a strategy that bends the lanes of a bundle as one. Then `points` is the route of `laneRoutes` with the index `index`.
|
|
1359
|
+
* The other strategies do not read it.
|
|
1360
|
+
*/
|
|
1361
|
+
readonly lane?: {
|
|
1362
|
+
readonly board: LaneBoard;
|
|
1363
|
+
readonly index: number;
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
/** The lanes of the bundles of one board: the input of `laneRoutes` and `highwayCurves`. */
|
|
1367
|
+
export interface LaneBoard {
|
|
1368
|
+
/** The shared segments and the paths of the routes, from `segmentsOf`. */
|
|
1369
|
+
readonly graph: SegmentGraph;
|
|
1370
|
+
/** The keys of the open segments, from `runKey`. Each edge of an open segment gets its own lane. */
|
|
1371
|
+
readonly open: ReadonlySet<string>;
|
|
1372
|
+
/** The distance between two lanes of an open segment. */
|
|
1373
|
+
readonly width: number;
|
|
1374
|
+
/** The largest width of an open segment, from its outer lane to its outer lane. The default is `Infinity`. */
|
|
1375
|
+
readonly maxWidth?: number;
|
|
1299
1376
|
}
|
|
1300
1377
|
/** The input of a room strategy: the boxes of a board and the links between them. */
|
|
1301
1378
|
export interface RoomInput {
|
|
@@ -1312,6 +1389,7 @@ export interface RoomInput {
|
|
|
1312
1389
|
*
|
|
1313
1390
|
* - `group`: a graph in, the tree of sections out. The router `sections` makes its hubs and its zoom levels from this tree.
|
|
1314
1391
|
* - `router`: a graph in, the routes (and the `levels`, `bundles` and `runs`) out.
|
|
1392
|
+
* - `highway`: a graph and optionally its first routes in, a highway plan out. `follow` routes the edges along the plan.
|
|
1315
1393
|
* - `curve`: a polyline in, the segments of a curve out.
|
|
1316
1394
|
* - `room`: the boxes and links of a board in, the gaps of the board with their need out.
|
|
1317
1395
|
*/
|
|
@@ -1324,6 +1402,10 @@ export interface StepTypes {
|
|
|
1324
1402
|
readonly input: Graph;
|
|
1325
1403
|
readonly output: Result;
|
|
1326
1404
|
};
|
|
1405
|
+
readonly highway: {
|
|
1406
|
+
readonly input: HighwayInput;
|
|
1407
|
+
readonly output: HighwayPlan;
|
|
1408
|
+
};
|
|
1327
1409
|
readonly curve: {
|
|
1328
1410
|
readonly input: CurveInput;
|
|
1329
1411
|
readonly output: CurveSegment[];
|
|
@@ -1384,10 +1466,11 @@ export declare function defineStrategy<S extends Step, O extends object>(definit
|
|
|
1384
1466
|
/**
|
|
1385
1467
|
* A registry: the strategies of each step, in order. A registry is data. No import changes it.
|
|
1386
1468
|
* A consumer makes its own registry with `createRegistry`, and adds a strategy with `register`.
|
|
1387
|
-
* The
|
|
1469
|
+
* The lists `group` and `highway` are optional in the type, so a registry from version 0.1.5 or 0.3.0 stays a registry. `createRegistry` always gives them.
|
|
1388
1470
|
*/
|
|
1389
|
-
export type Registry = { readonly [S in Exclude<Step, "group">]: readonly Strategy<S>[]; } & {
|
|
1471
|
+
export type Registry = { readonly [S in Exclude<Step, "group" | "highway">]: readonly Strategy<S>[]; } & {
|
|
1390
1472
|
readonly group?: readonly Strategy<"group">[];
|
|
1473
|
+
readonly highway?: readonly Strategy<"highway">[];
|
|
1391
1474
|
};
|
|
1392
1475
|
/** This function makes a registry from a list of strategies. It keeps their order. Two strategies with one step and one name are an error. */
|
|
1393
1476
|
export declare function createRegistry(strategies: readonly AnyStrategy[]): Registry;
|
|
@@ -2615,6 +2698,11 @@ export interface CurveRunOptions {
|
|
|
2615
2698
|
readonly normals: ReadonlySet<string>;
|
|
2616
2699
|
/** The options of each curve strategy, by its name. A strategy without an entry gets its defaults. */
|
|
2617
2700
|
readonly curveOptions?: Readonly<Record<string, object>>;
|
|
2701
|
+
/**
|
|
2702
|
+
* With this board, each curve draws the lanes of `laneRoutes` in place of the routes of the result, and each input has its `lane`.
|
|
2703
|
+
* So the curve `highway` bends the lanes of a bundle as one. Without it, each curve draws the routes of the result.
|
|
2704
|
+
*/
|
|
2705
|
+
readonly lanes?: LaneBoard;
|
|
2618
2706
|
}
|
|
2619
2707
|
/** One curve strategy on the routes of one result: the row of the suite and the drawn curves. */
|
|
2620
2708
|
export interface CurveRun {
|
|
@@ -2645,8 +2733,8 @@ export declare function groupRun(graph: Graph, strategy: Strategy<"group">, opti
|
|
|
2645
2733
|
readonly seed: number;
|
|
2646
2734
|
}): GroupRun;
|
|
2647
2735
|
/**
|
|
2648
|
-
* This function gives the options of a grouping rule on a fixture. The rule `keys` gets
|
|
2649
|
-
* the collection of the first edge into the node. A node without such an edge is a group alone.
|
|
2736
|
+
* This function gives the options of a grouping rule on a fixture. The rule `keys` gets the string `data.group` of the node.
|
|
2737
|
+
* A node without it gets a key from the data of the edges: the collection of the first edge into the node. A node without such an edge is a group alone.
|
|
2650
2738
|
*/
|
|
2651
2739
|
export declare function fixtureGroupOptions(strategy: string, graph: Graph): object;
|
|
2652
2740
|
/**
|
|
@@ -2659,7 +2747,7 @@ export declare function runSuite(options?: SuiteOptions): {
|
|
|
2659
2747
|
};
|
|
2660
2748
|
/**
|
|
2661
2749
|
* This function puts the rows of the suite in the order of one run. It sorts them by fixture family, then by seed.
|
|
2662
|
-
* In one seed, the routers come first, and the curves come after the router of the curves.
|
|
2750
|
+
* In one seed, the routers come first, and the curves come after the router of the curves. Then the highway strategies come, and the grouping rules and the room come last.
|
|
2663
2751
|
* A name that is not in its list goes after the names of the list.
|
|
2664
2752
|
* The workflow `Bench` uses it to join the reports of its parts.
|
|
2665
2753
|
*/
|
|
@@ -2703,6 +2791,58 @@ export declare function formatRules(rules: readonly RuleCount[]): string;
|
|
|
2703
2791
|
* It gives one row for each fixture family of a step. The extra routes of the stability measures have their own column.
|
|
2704
2792
|
*/
|
|
2705
2793
|
export declare function formatMeasureTime(rows: readonly SuiteRow[], step?: Step): string;
|
|
2794
|
+
/**
|
|
2795
|
+
* The options of the highway strategy `corridors` (HWY-031 of the note on highways).
|
|
2796
|
+
* The options `margin` and `k` set the corner graph of the first ways, when the input has no first routes.
|
|
2797
|
+
*/
|
|
2798
|
+
interface CorridorOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
2799
|
+
/** Two edges join when their common links are this share of the shorter way, or longer. The default is 0.3. */
|
|
2800
|
+
readonly rho: number;
|
|
2801
|
+
/** A highway has this number of edges or more. The default is 2. */
|
|
2802
|
+
readonly minSize: number;
|
|
2803
|
+
/** The number of hash functions of the MinHash signature of a way. The default is 64. */
|
|
2804
|
+
readonly hashes: number;
|
|
2805
|
+
/** The number of bands of the signature. Two ways with one equal band are a candidate pair. The default is 32. */
|
|
2806
|
+
readonly bands: number;
|
|
2807
|
+
/** Two link ends nearer than this grid size are one point. With 0, the default, only equal points are one point. */
|
|
2808
|
+
readonly near: number;
|
|
2809
|
+
/** The gap between two lanes. Two edges join only when their common links are longer than the break-even overlap for this gap. The default is 4. */
|
|
2810
|
+
readonly lane: number;
|
|
2811
|
+
}
|
|
2812
|
+
/** The default options of the strategy `corridors`. */
|
|
2813
|
+
export declare const CORRIDOR_DEFAULTS: Readonly<Required<Omit<CorridorOptions, "margin" | "k">>>;
|
|
2814
|
+
/**
|
|
2815
|
+
* The break-even overlap of two parallel edges for each unit of the lane gap, with the cost exponent 0.5 of the note.
|
|
2816
|
+
* A shared stretch shorter than this times the gap adds ink.
|
|
2817
|
+
*/
|
|
2818
|
+
export declare const BREAK_EVEN: number;
|
|
2819
|
+
/** This function gives the MinHash signature of a set of keys with `count` hash functions. */
|
|
2820
|
+
export declare function minHash(keys: Iterable<string>, count: number): number[];
|
|
2821
|
+
/**
|
|
2822
|
+
* This function gives the highways of corridor signatures (HWY-031). Each edge gets a first way: the route of `input.routes`, or its way through the corner graph.
|
|
2823
|
+
* The signature of a way is the set of its links. Two edges join when their common links are at least `rho` times the shorter way, and longer than the break-even overlap.
|
|
2824
|
+
* MinHash with `hashes` hash functions in `bands` bands finds the candidate pairs fast. Union-find gives the clusters.
|
|
2825
|
+
*
|
|
2826
|
+
* In each cluster, the spine is the longest common run of links of the way with the most shared length. Each edge on the spine joins it at its first common link and leaves it at its last one.
|
|
2827
|
+
* The edges of the cluster that are not on the spine make the next highway, while `minSize` of them remain.
|
|
2828
|
+
*/
|
|
2829
|
+
export declare function corridorPlan(input: HighwayInput, o: Readonly<CorridorOptions>): HighwayPlan;
|
|
2830
|
+
/** The options of the highway strategy `keys`: the options of the router `trunks`, without the name and the limit of the benchmark. */
|
|
2831
|
+
type KeysOptions = Omit<TrunksOptions, "name" | "maxNodes">;
|
|
2832
|
+
/**
|
|
2833
|
+
* This function gives the highways that the router `trunks` decides. A rule gives each edge a key.
|
|
2834
|
+
* The edges from one plug with one key share a trunk to a split point. The edges that go on together share a run past it.
|
|
2835
|
+
* Each trunk and each run becomes one highway. The function does not change the router: it reads its bundles and its runs.
|
|
2836
|
+
*/
|
|
2837
|
+
export declare function keysPlan(input: HighwayInput, options: KeysOptions): HighwayPlan;
|
|
2838
|
+
/** The options of the highway strategy `shared-ways`: the options of the router `shared`, without the name and the limit of the benchmark. */
|
|
2839
|
+
type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
|
|
2840
|
+
/**
|
|
2841
|
+
* This function gives the highways that the router `shared` decides. The edges of one key go one by one through the corner graph.
|
|
2842
|
+
* A link that the key uses already costs less, so the ways of a key come together. Each stretch that two edges or more share becomes one highway.
|
|
2843
|
+
* The function does not change the router: it reads its runs.
|
|
2844
|
+
*/
|
|
2845
|
+
export declare function sharedWaysPlan(input: HighwayInput, options: SharedWaysOptions): HighwayPlan;
|
|
2706
2846
|
/** The options of a router strategy: the options of its router, without the name and the limit of the benchmark. */
|
|
2707
2847
|
export type RouterPreset<O> = Omit<O, "name" | "maxNodes">;
|
|
2708
2848
|
/** The built-in router strategies, in the order of the benchmark. They route as the routers of `ROUTERS`. */
|
|
@@ -2727,7 +2867,10 @@ export interface TensionOptions {
|
|
|
2727
2867
|
/** The tension of the spline, from 0 (the spline) to 1 (the polyline). The default is 0. */
|
|
2728
2868
|
readonly tension: number;
|
|
2729
2869
|
}
|
|
2730
|
-
/**
|
|
2870
|
+
/**
|
|
2871
|
+
* The options of the curve strategy `highway`. The options `minRadius`, `jog` and `jogPieces` change only the lanes of a bundle.
|
|
2872
|
+
* So they change the curve only when the input has a `lane` on a board with open segments.
|
|
2873
|
+
*/
|
|
2731
2874
|
export interface HighwayStrategyOptions {
|
|
2732
2875
|
/** The radius of the center line of a bundle at a bend, and of each lone corner. The default is 12. */
|
|
2733
2876
|
readonly radius: number;
|
|
@@ -2756,7 +2899,7 @@ export interface ClothoidStrategyOptions {
|
|
|
2756
2899
|
}
|
|
2757
2900
|
/**
|
|
2758
2901
|
* The built-in curve strategies. The first six are in the order of `CURVE_TYPES`, and each one gives the same segments as `curveOf` with its type.
|
|
2759
|
-
* The strategy `highway` gives the curve of `arc` for one polyline. `
|
|
2902
|
+
* The strategy `highway` gives the curve of `arc` for one polyline. For a polyline with a `lane`, it bends the lanes of each bundle as one with `highwayCurves`.
|
|
2760
2903
|
*/
|
|
2761
2904
|
export declare const curveStrategies: {
|
|
2762
2905
|
readonly straight: Strategy<"curve", object>;
|
|
@@ -2784,12 +2927,24 @@ export declare const groupStrategies: {
|
|
|
2784
2927
|
readonly kd: Strategy<"group", Required<KdOptions>>;
|
|
2785
2928
|
readonly cut: Strategy<"group", Required<CutOptions>>;
|
|
2786
2929
|
};
|
|
2930
|
+
/**
|
|
2931
|
+
* The built-in highway strategies: the decisions of the routers `trunks` and `shared` as plans, and corridor signatures (HWY-031).
|
|
2932
|
+
* `follow` routes the edges along a plan, and `highwayRouter` gives a router that does both.
|
|
2933
|
+
*/
|
|
2934
|
+
export declare const highwayStrategies: {
|
|
2935
|
+
readonly keys: Strategy<"highway", KeysOptions>;
|
|
2936
|
+
readonly "shared-ways": Strategy<"highway", SharedWaysOptions>;
|
|
2937
|
+
readonly corridors: Strategy<"highway", CorridorOptions>;
|
|
2938
|
+
};
|
|
2787
2939
|
/** The built-in strategies of each step, in order. A consumer adds its own: `createRegistry([...BUILT_IN_STRATEGIES, mine])`. */
|
|
2788
2940
|
export declare const BUILT_IN_STRATEGIES: readonly AnyStrategy[];
|
|
2789
2941
|
/** The registry of the built-in strategies. The benchmark and the site take their lists from it. */
|
|
2790
2942
|
export declare const STRATEGIES: Registry;
|
|
2791
|
-
/**
|
|
2792
|
-
|
|
2943
|
+
/**
|
|
2944
|
+
* The steps that `compareStep` compares. The step `room` takes a packed board, not a graph, so it is not in the list.
|
|
2945
|
+
* The step `highway` gives a plan, not routes. The screen routes each plan with `follow` and compares it as a router.
|
|
2946
|
+
*/
|
|
2947
|
+
export type CompareStep = Exclude<Step, "room" | "highway">;
|
|
2793
2948
|
/** The steps that `compareStep` compares, in the order of the pipeline. */
|
|
2794
2949
|
export declare const COMPARE_STEPS: readonly CompareStep[];
|
|
2795
2950
|
/** The options of `compareStep`. */
|
|
@@ -2800,6 +2955,14 @@ export interface CompareOptions {
|
|
|
2800
2955
|
readonly options?: Readonly<Record<string, object>>;
|
|
2801
2956
|
/** The router whose routes the step `curve` draws. The default is `corners`, as in `runSuite`. */
|
|
2802
2957
|
readonly curveRouter?: string;
|
|
2958
|
+
/**
|
|
2959
|
+
* With this value, the step `curve` opens each shared segment of the routes of `curveRouter`, and each curve draws the lanes of `laneRoutes`.
|
|
2960
|
+
* So the curve `highway` bends the lanes of a bundle as one. Without it, each curve draws the routes. A router without shared segments gives the routes in both cases.
|
|
2961
|
+
*/
|
|
2962
|
+
readonly lanes?: {
|
|
2963
|
+
readonly width: number;
|
|
2964
|
+
readonly maxWidth?: number;
|
|
2965
|
+
};
|
|
2803
2966
|
/** The seed of the small change of the graph for the stability measures (Z10 and G9). The default is 1. */
|
|
2804
2967
|
readonly seed?: number;
|
|
2805
2968
|
/** The route stability (Z10) routes a changed graph again, so the function measures it only up to this number of nodes. The default is 1000. */
|
|
@@ -2815,7 +2978,10 @@ export interface CompareRow {
|
|
|
2815
2978
|
readonly violations: number;
|
|
2816
2979
|
/** The time of the step, in milliseconds. For the step `router`, it is the median of two routes. */
|
|
2817
2980
|
readonly ms: number;
|
|
2818
|
-
/**
|
|
2981
|
+
/**
|
|
2982
|
+
* The measures, by the keys of `runSuite`, and `ms`. The step `router` adds `ink`, and the step `curve` adds `C5.peak`.
|
|
2983
|
+
* A router with zoom levels also gets `Z3.through` and `Z3.length`, the measures of its level links.
|
|
2984
|
+
*/
|
|
2819
2985
|
readonly values: Readonly<Record<string, number>>;
|
|
2820
2986
|
/** The reason when the strategy did not run, for example a graph over its `maxNodes`. */
|
|
2821
2987
|
readonly skipped?: string;
|
|
@@ -2842,11 +3008,531 @@ export interface StepComparison {
|
|
|
2842
3008
|
}
|
|
2843
3009
|
/**
|
|
2844
3010
|
* This function runs each strategy of one step on one graph and measures it with the measures of `runSuite`. Then it gives the Pareto front.
|
|
2845
|
-
* The step `router` routes the graph with each router. The step `curve` draws the routes of `curveRouter` with each curve
|
|
3011
|
+
* The step `router` routes the graph with each router. The step `curve` draws the routes of `curveRouter` with each curve, or their lanes with the option `lanes`.
|
|
2846
3012
|
* The step `group` routes the graph with `sections` on the tree of each grouping rule.
|
|
2847
3013
|
*
|
|
2848
3014
|
* The same graph and the same options give the same measures. Only the times change.
|
|
2849
3015
|
*/
|
|
2850
3016
|
export declare function compareStep(step: CompareStep, graph: Graph, options?: CompareOptions): StepComparison;
|
|
2851
|
-
|
|
3017
|
+
/** This function gives the bytes of a string in UTF-8. */
|
|
3018
|
+
export declare function utf8(text: string): Uint8Array;
|
|
3019
|
+
/** This function gives the SHA-256 digest of a string, as 64 lowercase hex characters. It encodes the string in UTF-8. */
|
|
3020
|
+
export declare function sha256Hex(text: string): string;
|
|
3021
|
+
/**
|
|
3022
|
+
* This function writes a value as canonical JSON: the keys of each object in sorted order, and no whitespace.
|
|
3023
|
+
* It drops a key whose value is `undefined`, as `JSON.stringify` does.
|
|
3024
|
+
*/
|
|
3025
|
+
export declare function canonicalJson(value: unknown): string;
|
|
3026
|
+
/**
|
|
3027
|
+
* This function gives the hash of a JSON document: the first 16 hex characters of the SHA-256 of its canonical JSON.
|
|
3028
|
+
* The document does not include its own field `hash`. The function removes that field before it calculates the hash.
|
|
3029
|
+
*/
|
|
3030
|
+
export declare function documentHash(value: object): string;
|
|
3031
|
+
/** This function gives the 32-bit FNV-1a hash of the UTF-8 bytes of a text, as an unsigned integer. */
|
|
3032
|
+
export declare function fnv1a32(text: string): number;
|
|
3033
|
+
/** This function gives the seed of one step of a generator: `fnv1a32("<seed>:<step>")`. */
|
|
3034
|
+
export declare function stepSeed(seed: number, step: string): number;
|
|
3035
|
+
/** This function gives the generator `mulberry32` for a seed. Each call gives the next number from 0 to below 1. */
|
|
3036
|
+
export declare function mulberry32(seed: number): () => number;
|
|
3037
|
+
/** This function rounds a number to 3 decimals, as the files of a corpus keep it. The value `-0` becomes `0`. */
|
|
3038
|
+
export declare function round3(value: number): number;
|
|
3039
|
+
/** The side of a port in an input file. The router calls the same sides `north`, `east`, `south` and `west`. */
|
|
3040
|
+
export type LayoutSide = "top" | "right" | "bottom" | "left";
|
|
3041
|
+
/** A port of a box in an input file. */
|
|
3042
|
+
export interface LayoutPort {
|
|
3043
|
+
readonly id: string;
|
|
3044
|
+
/** The side of the box. Without it and without `x` and `y`, the router picks the side. */
|
|
3045
|
+
readonly side?: LayoutSide;
|
|
3046
|
+
/** 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`. */
|
|
3047
|
+
readonly x?: number;
|
|
3048
|
+
readonly y?: number;
|
|
3049
|
+
}
|
|
3050
|
+
/** A point of a region: `[x, y]`. The y axis points down. */
|
|
3051
|
+
export type RegionPoint = readonly [number, number];
|
|
3052
|
+
/**
|
|
3053
|
+
* An area of the plane. The y axis points down. A ring of a polygon closes itself: its last point joins its first point.
|
|
3054
|
+
* A hole of a polygon does not touch the outer ring. The router reads only the bounding box of a region.
|
|
3055
|
+
*/
|
|
3056
|
+
export type Region = {
|
|
3057
|
+
readonly kind: "rect";
|
|
3058
|
+
readonly x: number;
|
|
3059
|
+
readonly y: number;
|
|
3060
|
+
readonly w: number;
|
|
3061
|
+
readonly h: number;
|
|
3062
|
+
} | {
|
|
3063
|
+
readonly kind: "polygon";
|
|
3064
|
+
readonly points: readonly RegionPoint[];
|
|
3065
|
+
readonly holes?: readonly (readonly RegionPoint[])[];
|
|
3066
|
+
} | {
|
|
3067
|
+
readonly kind: "circle";
|
|
3068
|
+
readonly cx: number;
|
|
3069
|
+
readonly cy: number;
|
|
3070
|
+
readonly r: number;
|
|
3071
|
+
} | {
|
|
3072
|
+
readonly kind: "ellipse";
|
|
3073
|
+
readonly cx: number;
|
|
3074
|
+
readonly cy: number;
|
|
3075
|
+
readonly rx: number;
|
|
3076
|
+
readonly ry: number;
|
|
3077
|
+
};
|
|
3078
|
+
/** An area that the boxes and the routes must not use. The router uses the bounding box of its region as a box without edges. */
|
|
3079
|
+
export interface LayoutObstacle {
|
|
3080
|
+
readonly id: string;
|
|
3081
|
+
readonly region: Region;
|
|
3082
|
+
/** The cost to move the obstacle. Only the packer reads it. */
|
|
3083
|
+
readonly move?: {
|
|
3084
|
+
readonly cost: number;
|
|
3085
|
+
};
|
|
3086
|
+
}
|
|
3087
|
+
/** A box of an input file. */
|
|
3088
|
+
export interface LayoutBox {
|
|
3089
|
+
readonly id: string;
|
|
3090
|
+
readonly w: number;
|
|
3091
|
+
readonly h: number;
|
|
3092
|
+
/** The position of the top-left corner. The packer writes it. The router reads it. */
|
|
3093
|
+
readonly x?: number;
|
|
3094
|
+
readonly y?: number;
|
|
3095
|
+
/** The id of the box that holds this box. */
|
|
3096
|
+
readonly parent?: string;
|
|
3097
|
+
/** The group of the box. */
|
|
3098
|
+
readonly group?: string;
|
|
3099
|
+
/** This value is `true` when the box is an obstacle: the packer keeps its `x` and `y`. The router ignores it. */
|
|
3100
|
+
readonly locked?: true;
|
|
3101
|
+
/** The reading order that the caller wants. The router ignores it. */
|
|
3102
|
+
readonly rank?: number;
|
|
3103
|
+
readonly ports?: readonly LayoutPort[];
|
|
3104
|
+
/** The shape of the box, relative to the top-left corner of the box. The router ignores it and uses `w` and `h` as the bounding box. */
|
|
3105
|
+
readonly shape?: Region;
|
|
3106
|
+
/** The free data of the node. The grouping rule `keys` reads `data.group`. */
|
|
3107
|
+
readonly data?: Readonly<Record<string, unknown>>;
|
|
3108
|
+
}
|
|
3109
|
+
/** An edge of an input file. `sourcePort` and `targetPort` name a port of the box at that end. */
|
|
3110
|
+
export interface LayoutEdge {
|
|
3111
|
+
readonly id: string;
|
|
3112
|
+
readonly source: string;
|
|
3113
|
+
readonly target: string;
|
|
3114
|
+
readonly sourcePort?: string;
|
|
3115
|
+
readonly targetPort?: string;
|
|
3116
|
+
readonly data?: Readonly<Record<string, unknown>>;
|
|
3117
|
+
}
|
|
3118
|
+
/** The change of a variant against its base input. */
|
|
3119
|
+
export type LayoutChange = "add" | "remove" | "resize" | "reorder" | "packed";
|
|
3120
|
+
/** The origin of an input: `made-up`, `published:<set>` or `known-best:<construction>`. */
|
|
3121
|
+
export type LayoutSource = "made-up" | `published:${string}` | `known-best:${string}`;
|
|
3122
|
+
/** The generator of an input. The same name, version, parameters and seed give the same file, byte for byte. */
|
|
3123
|
+
export interface LayoutGenerator {
|
|
3124
|
+
readonly name: string;
|
|
3125
|
+
readonly version: number;
|
|
3126
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
3127
|
+
readonly seed: number;
|
|
3128
|
+
}
|
|
3129
|
+
/**
|
|
3130
|
+
* The cell of an input in the taxonomy of the corpus, with one value for each dimension.
|
|
3131
|
+
* The packer reads the first six dimensions. The router reads the last four.
|
|
3132
|
+
*/
|
|
3133
|
+
export interface LayoutCell {
|
|
3134
|
+
readonly containerSize?: "fixed" | "freeWidth" | "freeAspect";
|
|
3135
|
+
readonly containerShape?: "rect" | "convex" | "polygon" | "circle" | "ellipse" | "holes";
|
|
3136
|
+
readonly obstacles?: "none" | "center" | "scattered" | "wall" | "corridors" | "touching" | "edge";
|
|
3137
|
+
readonly sizes?: "identical" | "uniform" | "heavyTail" | "bimodal" | "extremeAspect" | "nearIdentical";
|
|
3138
|
+
readonly count?: "1" | "10" | "100" | "1k" | "10k";
|
|
3139
|
+
readonly mode?: "offline" | "online" | "incremental";
|
|
3140
|
+
readonly edgeDensity?: "sparse" | "medium" | "dense";
|
|
3141
|
+
readonly edgeShape?: "random" | "clustered" | "hubChain" | "longRange" | "tree" | "bundled";
|
|
3142
|
+
readonly groups?: "none" | "flat" | "nested";
|
|
3143
|
+
readonly ports?: "free" | "sides" | "fixed";
|
|
3144
|
+
}
|
|
3145
|
+
/** The outer rectangle of a packing. The router ignores it. */
|
|
3146
|
+
export interface LayoutContainer {
|
|
3147
|
+
readonly w?: number;
|
|
3148
|
+
readonly h?: number;
|
|
3149
|
+
/** `none`: the packer picks the size. `width`: the width stays. `height`: the height stays. `size`: the width and the height stay. */
|
|
3150
|
+
readonly fixed: "none" | "width" | "height" | "size";
|
|
3151
|
+
/** The ratio `w / h` that the packer aims for. */
|
|
3152
|
+
readonly aspect?: number;
|
|
3153
|
+
/** The shape of the container. */
|
|
3154
|
+
readonly shape?: Region;
|
|
3155
|
+
}
|
|
3156
|
+
/** The identity of an input in a set: the set, the family, the seed, and the base of a variant. */
|
|
3157
|
+
export interface LayoutInputHead {
|
|
3158
|
+
/** The id: `<set>/<family>/s<seed>`. */
|
|
3159
|
+
readonly id: string;
|
|
3160
|
+
readonly set: string;
|
|
3161
|
+
readonly family: string;
|
|
3162
|
+
readonly seed: number;
|
|
3163
|
+
/** The id of the base input of a variant. The stability measures compare the run on the variant with the run on its base. */
|
|
3164
|
+
readonly base?: string;
|
|
3165
|
+
readonly change?: LayoutChange;
|
|
3166
|
+
/** The place of the input in a change sequence. */
|
|
3167
|
+
readonly step?: number;
|
|
3168
|
+
/** The generator of the input. The default is `null`: a hand-made input. */
|
|
3169
|
+
readonly generator?: LayoutGenerator | null;
|
|
3170
|
+
/** The origin of the input. The default is `made-up`. */
|
|
3171
|
+
readonly source?: LayoutSource;
|
|
3172
|
+
readonly cell?: LayoutCell;
|
|
3173
|
+
}
|
|
3174
|
+
/**
|
|
3175
|
+
* An input file of the form `layout-input/1`. The packer and the router read the same files.
|
|
3176
|
+
* The file `docs/LAYOUT-RECORDS.md` gives the form. The repository `packing` keeps a twin of that document.
|
|
3177
|
+
*/
|
|
3178
|
+
export interface LayoutInput extends LayoutInputHead {
|
|
3179
|
+
readonly schema: "layout-input/1";
|
|
3180
|
+
/** The origin of the input. The data of this repository is made-up, because the repository is public. */
|
|
3181
|
+
readonly source: LayoutSource;
|
|
3182
|
+
/** The generator of the input, or `null` for a hand-made input. */
|
|
3183
|
+
readonly generator: LayoutGenerator | null;
|
|
3184
|
+
/** The first 16 hex characters of the SHA-256 of the canonical file without this field. `documentHash` calculates it. */
|
|
3185
|
+
readonly hash: string;
|
|
3186
|
+
readonly container?: LayoutContainer;
|
|
3187
|
+
/** The space between two boxes. The router ignores it. */
|
|
3188
|
+
readonly gap?: number;
|
|
3189
|
+
/** The areas that the boxes and the routes must not use. */
|
|
3190
|
+
readonly obstacles?: readonly LayoutObstacle[];
|
|
3191
|
+
readonly boxes: readonly LayoutBox[];
|
|
3192
|
+
readonly edges: readonly LayoutEdge[];
|
|
3193
|
+
}
|
|
3194
|
+
/** One run of one strategy on one input and one seed: a line of the form `layout-record/1`. */
|
|
3195
|
+
export interface LayoutRecord {
|
|
3196
|
+
readonly schema: "layout-record/1";
|
|
3197
|
+
/** `pack`, `route` or `joint`. The screen of this package writes `route`. */
|
|
3198
|
+
readonly stage: "pack" | "route" | "joint";
|
|
3199
|
+
readonly step: string;
|
|
3200
|
+
readonly strategy: string;
|
|
3201
|
+
/** The options of the run: the defaults of the strategy with the options of the caller. A function is the text `function:<name>`. */
|
|
3202
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
3203
|
+
/** The corpus version, for example `screen-v1`. */
|
|
3204
|
+
readonly corpus: string;
|
|
3205
|
+
/** The id of the input. */
|
|
3206
|
+
readonly input: string;
|
|
3207
|
+
/** The `hash` of the input file. */
|
|
3208
|
+
readonly inputHash: string;
|
|
3209
|
+
readonly set: string;
|
|
3210
|
+
readonly seed: number;
|
|
3211
|
+
readonly nodes: number;
|
|
3212
|
+
readonly edges: number;
|
|
3213
|
+
/** The measures, by the names of `MEASURES`. A measure without a finite value is not in the record. */
|
|
3214
|
+
readonly measures: Readonly<Record<string, number>>;
|
|
3215
|
+
/** The count of the breaks of each hard rule. A good run has 0 for each rule. */
|
|
3216
|
+
readonly hard: Readonly<Record<string, number>>;
|
|
3217
|
+
/** The tolerance of each hard rule of the run, for example `{ through: 0.5 }`. */
|
|
3218
|
+
readonly tolerance?: Readonly<Record<string, number>>;
|
|
3219
|
+
/** This value is `true` when two runs on the same input give the same output. */
|
|
3220
|
+
readonly deterministic: boolean;
|
|
3221
|
+
/** The id of the prediction of this run, from the predictions file. */
|
|
3222
|
+
readonly prediction?: string;
|
|
3223
|
+
/** The time of the run, in milliseconds. Only the times of CI compare. */
|
|
3224
|
+
readonly ms: number;
|
|
3225
|
+
/** The commit of the code that made the record. */
|
|
3226
|
+
readonly commit?: string;
|
|
3227
|
+
/** The reason when the strategy did not run, for example an input over its `maxNodes`. Then the record has no measures. */
|
|
3228
|
+
readonly skipped?: string;
|
|
3229
|
+
}
|
|
3230
|
+
/** The comparison of a prediction. Without it, `<=` applies to a measure where lower is better, and `>=` to the other measures. */
|
|
3231
|
+
export type PredictionOp = "<" | "<=" | "=" | ">=" | ">";
|
|
3232
|
+
/** A prediction about a run: one line of a predictions file. A commit adds the file before the run starts. */
|
|
3233
|
+
export interface LayoutPrediction {
|
|
3234
|
+
readonly schema?: "layout-prediction/1";
|
|
3235
|
+
readonly id: string;
|
|
3236
|
+
readonly strategy: string;
|
|
3237
|
+
readonly set: string;
|
|
3238
|
+
/** The id of one input. Without it, the prediction is about the median of the measure over the set. */
|
|
3239
|
+
readonly input?: string;
|
|
3240
|
+
/** The name of the measure, from `MEASURES`. */
|
|
3241
|
+
readonly measure: string;
|
|
3242
|
+
readonly expected: number;
|
|
3243
|
+
readonly op?: PredictionOp;
|
|
3244
|
+
readonly reason: string;
|
|
3245
|
+
}
|
|
3246
|
+
/**
|
|
3247
|
+
* This function writes a graph as an input file of the form `layout-input/1`, with its hash.
|
|
3248
|
+
* A fixed plug gets `x`, `y` and the side that holds it. `inputGraph` reads the file back.
|
|
3249
|
+
*/
|
|
3250
|
+
export declare function graphInput(graph: Graph, head: LayoutInputHead): LayoutInput;
|
|
3251
|
+
/**
|
|
3252
|
+
* This function gives the bounding box of a region: the smallest box that holds it.
|
|
3253
|
+
*/
|
|
3254
|
+
export declare function regionBounds(region: Region): {
|
|
3255
|
+
x: number;
|
|
3256
|
+
y: number;
|
|
3257
|
+
w: number;
|
|
3258
|
+
h: number;
|
|
3259
|
+
};
|
|
3260
|
+
/**
|
|
3261
|
+
* This function reads the graph of the router from an input file. The router reads the positions, the ports, the edges and the data.
|
|
3262
|
+
* Each obstacle becomes a node without edges, with the bounding box of its region, after the boxes.
|
|
3263
|
+
* The router ignores the other fields of the packer: `container`, `gap`, `locked`, `rank`, the `shape` of a box and the `move` of an obstacle.
|
|
3264
|
+
* A box without `x` and `y` is an error.
|
|
3265
|
+
*/
|
|
3266
|
+
export declare function inputGraph(input: LayoutInput): Graph;
|
|
3267
|
+
/**
|
|
3268
|
+
* This function writes an input file as text: the keys in sorted order, and one box or one edge on each line.
|
|
3269
|
+
* `JSON.parse` of the text gives the input again.
|
|
3270
|
+
*/
|
|
3271
|
+
export declare function formatInput(input: LayoutInput): string;
|
|
3272
|
+
/** This function writes records as JSON Lines: one record on each line. */
|
|
3273
|
+
export declare function recordLines(records: readonly LayoutRecord[]): string;
|
|
3274
|
+
/** This function reads JSON Lines. It ignores an empty line. */
|
|
3275
|
+
export declare function parseLines<T>(text: string): T[];
|
|
3276
|
+
/**
|
|
3277
|
+
* This function gives a copy of a value that JSON keeps.
|
|
3278
|
+
* A function becomes the text `function:<name>`, and a number that is not finite becomes its text.
|
|
3279
|
+
*/
|
|
3280
|
+
export declare function jsonSafe(value: unknown): unknown;
|
|
3281
|
+
/**
|
|
3282
|
+
* One measure of a record. `key` is the key of the measure in the values of `runSuite` and `compareStep`.
|
|
3283
|
+
* `name` is the name of the measure in a record of the form `layout-record/1`.
|
|
3284
|
+
*/
|
|
3285
|
+
export interface MeasureInfo {
|
|
3286
|
+
/** The key in the values of `runSuite` and `compareStep`, for example `R5.median`. */
|
|
3287
|
+
readonly key: string;
|
|
3288
|
+
/** The id of the measure in `docs/research/MEASURES.md` (MEAS0), for example `R5`. */
|
|
3289
|
+
readonly id: string;
|
|
3290
|
+
/** The name in a record: lowercase, with a dot after the stage, for example `route.detour.median`. */
|
|
3291
|
+
readonly name: string;
|
|
3292
|
+
readonly unit: string;
|
|
3293
|
+
readonly better: "lower" | "higher";
|
|
3294
|
+
/**
|
|
3295
|
+
* This value is `true` when the positions of the boxes alone can move the value, with the same router.
|
|
3296
|
+
* Then two values compare only on the same input. The value is `false` when the measure scores the routes or the curves for a fixed placement.
|
|
3297
|
+
*/
|
|
3298
|
+
readonly placementDependent: boolean;
|
|
3299
|
+
}
|
|
3300
|
+
/**
|
|
3301
|
+
* The measures of the records of the stage `route`, with the placement dependence of each one.
|
|
3302
|
+
* A joint harness that moves the boxes and routes the edges reads `placementDependent`.
|
|
3303
|
+
* It compares a measure with the value `true` only between runs on the same input.
|
|
3304
|
+
*/
|
|
3305
|
+
export declare const MEASURES: readonly MeasureInfo[];
|
|
3306
|
+
/** This function gives the measure of a key of `runSuite` or `compareStep`, or `undefined` for a key that is not in `MEASURES`. */
|
|
3307
|
+
export declare function measureByKey(key: string): MeasureInfo | undefined;
|
|
3308
|
+
/** This function gives the measure of a name of a record, or `undefined` for a name that is not in `MEASURES`. */
|
|
3309
|
+
export declare function measureByName(name: string): MeasureInfo | undefined;
|
|
3310
|
+
/** This function gives the name of a key in a record. A key that is not in `MEASURES` gets the name `route.other.<key>`. */
|
|
3311
|
+
export declare function measureName(key: string): string;
|
|
3312
|
+
/** This function gives the objectives of a Pareto front by the names of a record, from objectives by the keys of `runSuite`. */
|
|
3313
|
+
export declare function namedObjectives(objectives: readonly Objective[]): Objective[];
|
|
3314
|
+
/** A family of boards of a screen set. The member `k` of the family has the seed `k`. */
|
|
3315
|
+
export interface ScreenFamily {
|
|
3316
|
+
readonly name: string;
|
|
3317
|
+
/** The known hard case that the family shows, in a few words. */
|
|
3318
|
+
readonly shows: string;
|
|
3319
|
+
/** The number of members. */
|
|
3320
|
+
readonly seeds: number;
|
|
3321
|
+
/** This function makes the member `k`. The same `k` always gives the same graph. */
|
|
3322
|
+
readonly make: (k: number) => Graph;
|
|
3323
|
+
/** This function gives the generator of the member `k`: its name, version, parameters and seed. */
|
|
3324
|
+
readonly generator: (k: number) => LayoutGenerator;
|
|
3325
|
+
/** The cell of each member in the taxonomy of the corpus. */
|
|
3326
|
+
readonly cell: LayoutCell;
|
|
3327
|
+
}
|
|
3328
|
+
/** A screen set: a fixed list of small boards with an id. A new board or a changed board gets a new id. */
|
|
3329
|
+
export interface ScreenSet {
|
|
3330
|
+
/** The id of the set, for example `screen-v1`. The records name it in `set` and `corpus`. */
|
|
3331
|
+
readonly id: string;
|
|
3332
|
+
readonly families: readonly ScreenFamily[];
|
|
3333
|
+
}
|
|
3334
|
+
/**
|
|
3335
|
+
* The screen set `screen-v1`: 14 boards of made-up data from 10 to 150 nodes. Each family shows a known hard case.
|
|
3336
|
+
* The seed 0 of each family is the fixture or the case board of the benchmark. The seed `k` of a fixture family is `familySeed(spec, k)`, as in `runSuite`.
|
|
3337
|
+
* The generators wrap the fixtures and the case boards without a change to their output.
|
|
3338
|
+
* This set does not change. The tests compare it with the files in `corpus/screen-v1`.
|
|
3339
|
+
*/
|
|
3340
|
+
export declare const SCREEN_V1: ScreenSet;
|
|
3341
|
+
/** The screen sets by id. */
|
|
3342
|
+
export declare const SCREEN_SETS: Readonly<Record<string, ScreenSet>>;
|
|
3343
|
+
/** This function gives the id of the member `seed` of a family of a set: `<set>/<family>/s<seed>`. */
|
|
3344
|
+
export declare function inputId(set: string, family: string, seed: number): string;
|
|
3345
|
+
/** This function gives the input files of a screen set, in the order of its families and seeds. Each file has its hash. */
|
|
3346
|
+
export declare function screenInputs(set?: ScreenSet): LayoutInput[];
|
|
3347
|
+
/** A spec of a manifest: one generator with its version and parameters, and the seeds that the corpus uses. */
|
|
3348
|
+
export interface CorpusSpec {
|
|
3349
|
+
readonly generator: string;
|
|
3350
|
+
readonly version: number;
|
|
3351
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
3352
|
+
readonly seeds: readonly number[];
|
|
3353
|
+
}
|
|
3354
|
+
/** The manifest `corpus.json` of a corpus, of the form `layout-corpus/1`. */
|
|
3355
|
+
export interface LayoutCorpus {
|
|
3356
|
+
readonly schema: "layout-corpus/1";
|
|
3357
|
+
readonly corpus: string;
|
|
3358
|
+
readonly specs: readonly CorpusSpec[];
|
|
3359
|
+
readonly inputs: readonly {
|
|
3360
|
+
readonly id: string;
|
|
3361
|
+
readonly hash: string;
|
|
3362
|
+
readonly cell: LayoutCell;
|
|
3363
|
+
}[];
|
|
3364
|
+
}
|
|
3365
|
+
/** This function gives the manifest of a list of inputs. The inputs of one generator, version and parameters share one spec. */
|
|
3366
|
+
export declare function corpusManifest(corpus: string, inputs: readonly LayoutInput[]): LayoutCorpus;
|
|
3367
|
+
/**
|
|
3368
|
+
* The steps of the screen: the steps of `compareStep` and the step `highway`.
|
|
3369
|
+
* The screen of the step `highway` routes the plan of each strategy with `follow`, and measures the routes as the routes of a router.
|
|
3370
|
+
*/
|
|
3371
|
+
export type ScreenStep = CompareStep | "highway";
|
|
3372
|
+
/** The steps of the screen, in the order of the pipeline. */
|
|
3373
|
+
export declare const SCREEN_STEPS: readonly ScreenStep[];
|
|
3374
|
+
/** The routers that the screen of the step `highway` also runs by default. They are the baselines of the note on highways. */
|
|
3375
|
+
export declare const HIGHWAY_BASE_ROUTERS: readonly string[];
|
|
3376
|
+
/** The hard rules of each step of the screen, in the order of the records. A good run has 0 for each rule. */
|
|
3377
|
+
export declare const SCREEN_RULES: Readonly<Record<ScreenStep, readonly string[]>>;
|
|
3378
|
+
/** The options of `screen`. */
|
|
3379
|
+
export interface ScreenOptions {
|
|
3380
|
+
/** The screen set. The default is `SCREEN_V1`. */
|
|
3381
|
+
readonly set?: ScreenSet;
|
|
3382
|
+
/** The input files. The default is the files of `set`. */
|
|
3383
|
+
readonly inputs?: readonly LayoutInput[];
|
|
3384
|
+
/** The families of the inputs that the screen runs. The default is each family. */
|
|
3385
|
+
readonly families?: readonly string[];
|
|
3386
|
+
/**
|
|
3387
|
+
* With `true`, the screen also runs each built-in strategy of the step, and the front compares the new strategies with them.
|
|
3388
|
+
* With `false`, it runs only the strategies of the call. The default is `true`.
|
|
3389
|
+
*/
|
|
3390
|
+
readonly baseline?: boolean;
|
|
3391
|
+
/** The options of each strategy, by its name. A strategy without an entry gets its defaults. */
|
|
3392
|
+
readonly options?: Readonly<Record<string, object>>;
|
|
3393
|
+
/** The router whose routes the step `curve` draws. The default is `corners`. */
|
|
3394
|
+
readonly curveRouter?: string;
|
|
3395
|
+
/**
|
|
3396
|
+
* The routers that the screen of the step `highway` also runs. Their records have the step `router`.
|
|
3397
|
+
* The default is `HIGHWAY_BASE_ROUTERS`. The other steps do not read it.
|
|
3398
|
+
*/
|
|
3399
|
+
readonly baseRouters?: readonly string[];
|
|
3400
|
+
/** The seed of the small change of the stability measures. The default is 1. */
|
|
3401
|
+
readonly seed?: number;
|
|
3402
|
+
/** The commit of the code, for the records. */
|
|
3403
|
+
readonly commit?: string;
|
|
3404
|
+
/** The predictions of the run. Each record names the first prediction with its strategy, its set and its input. */
|
|
3405
|
+
readonly predictions?: readonly LayoutPrediction[];
|
|
3406
|
+
/** This function gets one line of progress for each input. */
|
|
3407
|
+
readonly log?: (line: string) => void;
|
|
3408
|
+
}
|
|
3409
|
+
/** The summary of one strategy over the inputs of a screen. */
|
|
3410
|
+
export interface ScreenStrategySummary {
|
|
3411
|
+
readonly strategy: string;
|
|
3412
|
+
/** This value is `true` for a strategy of the call, and `false` for a built-in strategy of the baseline. */
|
|
3413
|
+
readonly candidate: boolean;
|
|
3414
|
+
/** The number of inputs where the strategy ran. */
|
|
3415
|
+
readonly runs: number;
|
|
3416
|
+
/** The number of inputs that the strategy skipped. */
|
|
3417
|
+
readonly skipped: number;
|
|
3418
|
+
/** This value is `true` when each run gave the same output two times. */
|
|
3419
|
+
readonly deterministic: boolean;
|
|
3420
|
+
/** The sum of the breaks of each hard rule over the runs. */
|
|
3421
|
+
readonly hard: Readonly<Record<string, number>>;
|
|
3422
|
+
/** The sum of `hard`. */
|
|
3423
|
+
readonly hardTotal: number;
|
|
3424
|
+
/**
|
|
3425
|
+
* The breaks over the floor of each input. The floor is the counts of the built-in strategy with the fewest breaks on that input.
|
|
3426
|
+
* Each built-in breaks a rule on some boards, for example on a board where the boxes touch. Without built-ins, the floor is 0.
|
|
3427
|
+
*/
|
|
3428
|
+
readonly hardOverFloor: number;
|
|
3429
|
+
/** The median of each measure over the runs, by the names of a record. */
|
|
3430
|
+
readonly medians: Readonly<Record<string, number>>;
|
|
3431
|
+
/** The median time of a run, in milliseconds. */
|
|
3432
|
+
readonly ms: number;
|
|
3433
|
+
/** The number of inputs where the strategy is on the Pareto front of its input. */
|
|
3434
|
+
readonly onFront: number;
|
|
3435
|
+
}
|
|
3436
|
+
/** A prediction with the measured value. */
|
|
3437
|
+
export interface PredictionCheck extends LayoutPrediction {
|
|
3438
|
+
readonly op: PredictionOp;
|
|
3439
|
+
/** The measured value: the value of the record of the input, or the median over the set. It is absent when no record has the measure. */
|
|
3440
|
+
readonly measured?: number;
|
|
3441
|
+
/** This value is `true` when the measured value meets the prediction. It is absent when there is no measured value. */
|
|
3442
|
+
readonly met?: boolean;
|
|
3443
|
+
}
|
|
3444
|
+
/** The summary of a screen. */
|
|
3445
|
+
export interface ScreenSummary {
|
|
3446
|
+
readonly set: string;
|
|
3447
|
+
readonly step: ScreenStep;
|
|
3448
|
+
/** The number of inputs. */
|
|
3449
|
+
readonly inputs: number;
|
|
3450
|
+
/** The axes of the Pareto front, by the names of a record. */
|
|
3451
|
+
readonly objectives: readonly Objective[];
|
|
3452
|
+
/** One summary for each strategy, in the order of the registry. */
|
|
3453
|
+
readonly strategies: readonly ScreenStrategySummary[];
|
|
3454
|
+
/** The strategies on the Pareto front of the medians over the set. */
|
|
3455
|
+
readonly front: readonly string[];
|
|
3456
|
+
/** The strategies with a break over the floor, without a run or with two different outputs of one input. They do not enter the front. */
|
|
3457
|
+
readonly excluded: readonly string[];
|
|
3458
|
+
readonly predictions: readonly PredictionCheck[];
|
|
3459
|
+
}
|
|
3460
|
+
/** The result of `screen`: one record for each strategy and input, and the summary. */
|
|
3461
|
+
export interface ScreenReport {
|
|
3462
|
+
readonly records: readonly LayoutRecord[];
|
|
3463
|
+
readonly summary: ScreenSummary;
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* 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
|
+
* Each strategy runs on each input with `compareStep`, and each run gives one record of the form `layout-record/1`.
|
|
3468
|
+
* A strategy can be a name of the registry or a strategy object, for example from a prototype file. The registry does not change.
|
|
3469
|
+
*
|
|
3470
|
+
* The step `router` routes each input two times for the rule "same twice". The steps `group` and `curve` run each input two times for the same rule.
|
|
3471
|
+
*
|
|
3472
|
+
* The step `highway` makes the plan of each strategy and routes it with `follow`, two times. It also runs the routers of `baseRouters`.
|
|
3473
|
+
* An input with a `base` in the inputs also gets the measures `route.stability.base.*`: the routes on the variant against the routes on its base.
|
|
3474
|
+
* The same inputs and the same options give the same records. Only the times change.
|
|
3475
|
+
*/
|
|
3476
|
+
export declare function screen(step: ScreenStep, strategies?: readonly (Strategy<ScreenStep> | string)[], options?: ScreenOptions): ScreenReport;
|
|
3477
|
+
/** This function writes the summary of a screen as Markdown: one row for each strategy, the front and the predictions. */
|
|
3478
|
+
export declare function formatScreen(summary: ScreenSummary): string;
|
|
3479
|
+
/** This function gives a whole number from `lo` to `hi`, both included, from a generator of random numbers. */
|
|
3480
|
+
export declare function randomInt(r: () => number, lo: number, hi: number): number;
|
|
3481
|
+
/** The parameters of the generator `rect-scattered`. */
|
|
3482
|
+
export interface RectScatteredParams {
|
|
3483
|
+
/** The number of boxes. */
|
|
3484
|
+
readonly count: number;
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* This function makes the input of the shared generator `rect-scattered`, version 1: a fixed rectangle container, scattered obstacles and boxes without positions.
|
|
3488
|
+
* The repository `packing` makes the same file, byte for byte. A test in each repository pins the hashes of the seeds 1, 2 and 3.
|
|
3489
|
+
* The steps are `container`, `obstacles` and `boxes`. Each step has its own generator from `stepSeed`.
|
|
3490
|
+
*/
|
|
3491
|
+
export declare function rectScattered(seed: number, params: RectScatteredParams, set?: string): LayoutInput;
|
|
3492
|
+
/** The options of `follow`. */
|
|
3493
|
+
interface FollowOptions extends WayOptions {
|
|
3494
|
+
/**
|
|
3495
|
+
* These routes are the routes of the base router. Each edge outside the plan keeps its route from them.
|
|
3496
|
+
* Without them, or for an edge without a route in them, `follow` routes the edge as the router `corners` does.
|
|
3497
|
+
*/
|
|
3498
|
+
readonly routes?: Result;
|
|
3499
|
+
/** The lane order of the shared runs. The default is `bundle`. */
|
|
3500
|
+
readonly laneOrder?: RunOrder;
|
|
3501
|
+
}
|
|
3502
|
+
/**
|
|
3503
|
+
* This function routes the edges along a highway plan.
|
|
3504
|
+
*
|
|
3505
|
+
* An edge of a highway goes from its source plug to its merge point. Then it goes along the spine to its split point, and to its target plug.
|
|
3506
|
+
* The ramps go around the boxes through the corner graph (`WayFinder.fromPlug` and `WayFinder.toPlug`).
|
|
3507
|
+
* A spine point on the box of the node is the plug itself. When the end has a fixed plug, the point is at that plug.
|
|
3508
|
+
*
|
|
3509
|
+
* An edge on several highways takes them in the order of `seq`.
|
|
3510
|
+
* A way through the corner graph goes from each split point to the next merge point.
|
|
3511
|
+
* An edge outside the plan keeps its route from `options.routes`, or goes as in the router `corners`.
|
|
3512
|
+
*
|
|
3513
|
+
* 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.
|
|
3514
|
+
* The same graph, plan and options give the same result.
|
|
3515
|
+
*/
|
|
3516
|
+
export declare function follow(graph: Graph, plan: HighwayPlan, options?: FollowOptions): Result;
|
|
3517
|
+
/**
|
|
3518
|
+
* This function gives the highways of a result of a router: one highway for each shared run and for each trunk of a bundle.
|
|
3519
|
+
* 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.
|
|
3520
|
+
* The member `seq` is the place of the shared stretch in the route of the edge. The lanes keep the lane order of the router.
|
|
3521
|
+
*
|
|
3522
|
+
* Thus `follow` routes each edge along the shared stretches of the router. A route that does not hold its run is not a member.
|
|
3523
|
+
*/
|
|
3524
|
+
export declare function planOfResult(result: Result): HighwayPlan;
|
|
3525
|
+
/**
|
|
3526
|
+
* This function gives a router that runs a highway strategy and then `follow`. The strategy gets the graph without first routes.
|
|
3527
|
+
* The way finder of `follow` takes `margin` and `k` from the options of the strategy, and then from `followOptions`.
|
|
3528
|
+
* The router keeps the name and the `maxNodes` of the strategy.
|
|
3529
|
+
*/
|
|
3530
|
+
export declare function highwayRouter<O extends object>(strategy: Strategy<"highway", O>, options?: Partial<O>, followOptions?: FollowOptions): Router;
|
|
3531
|
+
/**
|
|
3532
|
+
* This function gives a router strategy that runs a highway strategy and then `follow`.
|
|
3533
|
+
* The router strategy has the name, the options and the schema of the highway strategy.
|
|
3534
|
+
* The benchmark and the screen race such a router with the other routers.
|
|
3535
|
+
*/
|
|
3536
|
+
export declare function highwayRouterStrategy<O extends object>(strategy: Strategy<"highway", O>): Strategy<"router", O>;
|
|
3537
|
+
export type { ArcOptions, ClothoidOptions, CornersOptions, CorridorOptions, CurveSpace, CutObjective, CutOptions, FollowOptions, Highway, HighwayInput, HighwayMember, HighwayOptions, HighwayPlan, JogStyle, KdAxis, KdLine, KdOptions, KeyOptions, KeysOptions, LaneCurve, NodeKey, RoomBends, RoundedOptions, SectionsOptions, SharedOptions, SharedWaysOptions, SmoothOptions, SplineOptions, TrunksOptions };
|
|
2852
3538
|
//# sourceMappingURL=index.d.ts.map
|