@mark1russell7/highways 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +27 -1
  2. package/build/index.d.ts +642 -1
  3. package/build/index.d.ts.map +1 -1
  4. package/build/index.js +5189 -2609
  5. package/build/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/bench/measures/highways.ts +93 -0
  8. package/src/bench/measures/index.ts +1 -0
  9. package/src/bench/screen/measures.ts +5 -0
  10. package/src/bench/screen/screen.ts +14 -0
  11. package/src/highways/base.ts +126 -0
  12. package/src/highways/flow-field/index.ts +49 -0
  13. package/src/highways/gates/ambiguity/index.ts +110 -0
  14. package/src/highways/gates/breakeven/index.ts +62 -0
  15. package/src/highways/gates/hysteresis/index.ts +48 -0
  16. package/src/highways/gates/ids/index.ts +59 -0
  17. package/src/highways/gates/index.ts +6 -0
  18. package/src/highways/gates/model.ts +129 -0
  19. package/src/highways/gates/stretch/index.ts +39 -0
  20. package/src/highways/grouped.ts +123 -0
  21. package/src/highways/index.ts +15 -0
  22. package/src/highways/level-links/index.ts +114 -0
  23. package/src/highways/meet/index.ts +84 -0
  24. package/src/highways/model.ts +5 -0
  25. package/src/highways/od-cells/index.ts +50 -0
  26. package/src/highways/quickbundles/index.ts +117 -0
  27. package/src/highways/road-classes/index.ts +74 -0
  28. package/src/highways/router.ts +1 -1
  29. package/src/highways/select/index.ts +162 -0
  30. package/src/highways/stretches.ts +141 -0
  31. package/src/highways/stubs/index.ts +117 -0
  32. package/src/highways/weiszfeld/index.ts +105 -0
  33. package/src/highways/wspd/index.ts +130 -0
  34. package/src/highways/zipper/index.ts +168 -0
  35. package/src/strategies/builtins.ts +149 -7
  36. package/src/strategies/schemas.ts +120 -0
@@ -1,7 +1,20 @@
1
1
  import type { CutOptions } from "../groups/cut/index.ts";
2
2
  import type { KdOptions } from "../groups/kd/index.ts";
3
3
  import type { KeyOptions } from "../groups/keys/index.ts";
4
+ import type { HighwayBase } from "../highways/base.ts";
4
5
  import type { CorridorOptions } from "../highways/corridors/index.ts";
6
+ import type { FlowFieldOptions } from "../highways/flow-field/index.ts";
7
+ import type { GroupSpine } from "../highways/grouped.ts";
8
+ import type { LevelHighwayOptions } from "../highways/level-links/index.ts";
9
+ import type { MeetOptions } from "../highways/meet/index.ts";
10
+ import type { OdCellOptions } from "../highways/od-cells/index.ts";
11
+ import type { QuickBundlesOptions } from "../highways/quickbundles/index.ts";
12
+ import type { RoadClassOptions } from "../highways/road-classes/index.ts";
13
+ import type { SelectOptions } from "../highways/select/index.ts";
14
+ import type { StubOptions } from "../highways/stubs/index.ts";
15
+ import type { WeiszfeldOptions } from "../highways/weiszfeld/index.ts";
16
+ import type { WspdOptions } from "../highways/wspd/index.ts";
17
+ import type { ZipperOptions } from "../highways/zipper/index.ts";
5
18
  import type { CornersOptions } from "../routers/corners.ts";
6
19
  import type { SectionsOptions } from "../routers/sections.ts";
7
20
  import type { SharedOptions } from "../routers/shared.ts";
@@ -283,3 +296,110 @@ export const CUT_SCHEMA: OptionSchema<CutOptions> = {
283
296
  pull: { type: "number", min: 0, max: 4, step: 0.25, marks: [0, 0.5, 1, 2, 4], default: 0.5, describe: "The cost of a line grows with its distance from the middle of the cell, by this factor." },
284
297
  guard: { type: "boolean", default: true, describe: "With `true`, each section also tests the quadtree split, and keeps the split that cuts fewer edges." },
285
298
  };
299
+
300
+ /** The declaration of the plan that a post step of the step `highway` changes (BUILD-W2B). */
301
+ const HIGHWAY_BASE: EnumOption<HighwayBase> = {
302
+ type: "enum",
303
+ values: ["none", "shared-ways", "corridors"],
304
+ default: "shared-ways",
305
+ describe: "The plan that the strategy changes: no highway, the highways of `shared-ways`, or the highways of `corridors`.",
306
+ };
307
+
308
+ /** The declarations of the options of the highway strategy `meet` (HWY-050). */
309
+ export const MEET_SCHEMA: OptionSchema<MeetOptions> = {
310
+ from: HIGHWAY_BASE,
311
+ near: { type: "number", min: 2, max: 40, step: 2, default: 8, describe: "A first route meets the spine where it is this distance from the spine, or nearer." },
312
+ maxTurn: { type: "number", min: 10, max: 90, step: 5, default: 45, describe: "A first route meets the spine only where it runs at this angle to the spine, or less, in degrees." },
313
+ minRun: { type: "number", min: 0, max: 80, step: 5, default: 10, describe: "A member keeps its places when the stretch where its first route meets the spine is shorter than this length." },
314
+ };
315
+
316
+ /** The declarations of the options of the highway strategy `weiszfeld` (HWY-043). */
317
+ export const WEISZFELD_SCHEMA: OptionSchema<WeiszfeldOptions> = {
318
+ from: HIGHWAY_BASE,
319
+ alpha: { type: "number", min: 0, max: 1, step: 0.1, default: 0.5, describe: "The weight of the trunk is `k^alpha` for `k` members." },
320
+ steps: { type: "integer", min: 1, max: 50, step: 1, marks: [10, 20, 50], default: 20, describe: "The number of steps of Weiszfeld." },
321
+ };
322
+
323
+ /** The declarations of the options of the highway strategy `stubs` (HWY-015 with WILD-005). */
324
+ export const STUB_SCHEMA: OptionSchema<StubOptions> = {
325
+ from: HIGHWAY_BASE,
326
+ omega: { type: "number", min: 10, max: 60, step: 5, default: 30, describe: "The ends of one side of a box whose directions are in a window of this angle share a stub, in degrees." },
327
+ sigma: { type: "number", min: 0.1, max: 0.4, step: 0.05, default: 0.25, describe: "The length of a stub is this share of the distance to the nearest other end." },
328
+ ends: { type: "enum", values: ["source", "target", "both"], default: "both", describe: "The ends that get stubs." },
329
+ minSize: { type: "integer", min: 2, max: 8, step: 1, default: 2, describe: "A stub has this number of edges or more." },
330
+ };
331
+
332
+ /** The declarations of the options of the highway strategy `zipper` (NAT-022 with WILD-037). */
333
+ export const ZIPPER_SCHEMA: OptionSchema<ZipperOptions> = {
334
+ from: HIGHWAY_BASE,
335
+ near: { type: "number", min: 0.5, max: 3, step: 0.25, default: 1, describe: "Two legs zip when they are this distance apart or nearer, in units of the board." },
336
+ maxAngle: { type: "number", min: 5, max: 30, step: 5, default: 15, describe: "Two legs zip when the angle between them is this value or less, in degrees." },
337
+ adhesion: { type: "number", min: 0, max: 1, step: 0.1, default: 0.3, describe: "Two legs zip when this value times their overlap is more than the length that the zip adds." },
338
+ minOverlap: { type: "number", min: 1, max: 5, step: 0.5, default: 1, describe: "Two legs zip when they overlap along this length or more, in units of the board." },
339
+ passes: { type: "integer", min: 1, max: 5, step: 1, default: 1, describe: "The number of passes. Each pass routes the plan and zips the legs again." },
340
+ };
341
+
342
+ /** The declarations of the options of the highway strategy `level-links` (HWY-056 with WILD-034). */
343
+ export const LEVEL_HIGHWAY_SCHEMA: OptionSchema<LevelHighwayOptions> = {
344
+ from: HIGHWAY_BASE,
345
+ depth: { type: "integer", min: 1, max: 3, step: 1, default: 1, describe: "The depth of the level in the tree of sections." },
346
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A level link becomes a highway when this number of edges or more ride it." },
347
+ stretch: { type: "number", min: 1.2, max: 2, step: 0.1, default: 1.5, describe: "An edge rides the link only when its way along the link is this many times its first route, or shorter." },
348
+ };
349
+
350
+ /** The declaration of the spine of a group of edges: the shared ways of the group, or one trunk between two terminals. */
351
+ const GROUP_SPINE: EnumOption<GroupSpine> = {
352
+ type: "enum",
353
+ values: ["shared", "trunk"],
354
+ default: "shared",
355
+ describe: "With `shared`, the edges of a group share their ways through the corner graph. With `trunk`, a group gets one trunk between two terminals.",
356
+ };
357
+
358
+ /** The declarations of the options of the highway strategy `quickbundles` (HWY-026). */
359
+ export const QUICKBUNDLES_SCHEMA: OptionSchema<QuickBundlesOptions> = {
360
+ theta: { type: "number", min: 1, max: 10, step: 0.5, marks: [1.5, 3, 6], default: 3, describe: "An edge joins a cluster when its distance to the centroid is this value or less, in units of the board." },
361
+ points: { type: "integer", min: 6, max: 24, step: 2, default: 12, describe: "The number of points of each line after the resampling." },
362
+ line: { type: "enum", values: ["routes", "lines"], default: "routes", describe: "The line of each edge: its first route, or the straight line between its plugs." },
363
+ order: { type: "enum", values: ["input", "length"], default: "input", describe: "The order of the edges in the pass: the order of the graph, or the longest line first." },
364
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A cluster with this number of edges or more gets highways." },
365
+ spine: GROUP_SPINE,
366
+ };
367
+
368
+ /** The declarations of the options of the highway strategy `road-classes` (HWY-034 with EDA-050). */
369
+ export const ROAD_CLASS_SCHEMA: OptionSchema<RoadClassOptions> = {
370
+ margin: WAY_SCHEMA.margin,
371
+ k: WAY_SCHEMA.k,
372
+ quantile: { type: "number", min: 0.5, max: 0.99, step: 0.05, marks: [0.8, 0.9, 0.95], default: 0.9, describe: "A link is a highway link when its use is at this quantile of the use of the links, or higher." },
373
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway link and a highway have this number of edges or more." },
374
+ discount: { type: "number", min: 0.1, max: 0.8, step: 0.1, default: 0.5, describe: "The second pass gives each highway link this discount, as a share of its length." },
375
+ };
376
+
377
+ /** The declarations of the options of the highway strategy `flow-field` (EDA-046 with HWY-037). */
378
+ export const FLOW_FIELD_SCHEMA: OptionSchema<FlowFieldOptions> = {
379
+ margin: WAY_SCHEMA.margin,
380
+ k: WAY_SCHEMA.k,
381
+ minFanIn: { type: "integer", min: 2, max: 10, step: 1, default: 2, describe: "An end with this number of edges or more on one side of its box gets a field." },
382
+ end: { type: "enum", values: ["target", "source"], default: "target", describe: "The end that gets a field: the target of a fan-in, or the source of a fan-out." },
383
+ };
384
+
385
+ /** The declarations of the options of the highway strategy `wspd` (HWY-018). */
386
+ export const WSPD_SCHEMA: OptionSchema<WspdOptions> = {
387
+ separation: { type: "number", min: 1, max: 8, step: 0.5, marks: [1, 2, 4], default: 2, describe: "The gap between the two sets of a pair is at least this value times the radius of the larger set." },
388
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 3, describe: "A pair with this number of edges or more gets a highway." },
389
+ spine: { ...GROUP_SPINE, default: "trunk" },
390
+ };
391
+
392
+ /** The declarations of the options of the highway strategy `od-cells` (EDA-033 with WILD-032). */
393
+ export const OD_CELL_SCHEMA: OptionSchema<OdCellOptions> = {
394
+ level: { type: "integer", min: 1, max: 4, step: 1, default: 2, describe: "The depth of the cells in the tree of sections." },
395
+ minGroup: { type: "integer", min: 2, max: 8, step: 1, default: 3, describe: "A pair of cells with this number of edges or more gets a trunk." },
396
+ legMax: { type: "number", min: 0.1, max: 1, step: 0.05, marks: [0.2, 0.3, 0.4], default: 0.3, describe: "An edge rides the trunk only when each of its legs is this share of the span or shorter." },
397
+ spine: { ...GROUP_SPINE, default: "trunk" },
398
+ };
399
+
400
+ /** The declarations of the options of the highway strategy `select` (HWY-045). */
401
+ export const SELECT_SCHEMA: OptionSchema<SelectOptions> = {
402
+ generators: { type: "list", default: ["corridors", "quickbundles", "wspd", "road-classes"], describe: "The highway strategies that propose the candidates." },
403
+ lambda: { type: "number", min: 0, max: 4, step: 0.25, marks: [0.5, 1, 2], default: 1, describe: "The weight of the added length of the edges against the ink that a highway saves." },
404
+ swaps: { type: "integer", min: 0, max: 5, step: 1, default: 2, describe: "The number of passes of the local search with one swap." },
405
+ };