@mark1russell7/highways 0.3.0 → 0.4.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 +66 -2
- package/build/index.d.ts +1009 -12
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4408 -195
- package/build/index.js.map +1 -1
- package/package.json +4 -1
- package/src/bench/compare.ts +41 -6
- package/src/bench/measures/bundles.ts +101 -2
- package/src/bench/measures/index.ts +1 -0
- package/src/bench/measures/order.ts +97 -0
- package/src/bench/room.ts +126 -9
- 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 +126 -0
- package/src/bench/screen/screen.ts +454 -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 +4 -0
- package/src/order/index.ts +65 -0
- package/src/plugs/justify.ts +48 -0
- package/src/plugs/side.ts +138 -0
- package/src/repair/index.ts +377 -0
- package/src/repair/walk.ts +220 -0
- package/src/room/lanes.ts +109 -10
- package/src/routers/corners.ts +73 -6
- package/src/routers/fan.ts +145 -0
- package/src/routers/index.ts +2 -2
- package/src/routers/shared.ts +107 -8
- package/src/routers/snell.ts +140 -0
- package/src/routers/trunks.ts +43 -2
- package/src/strategies/builtins.ts +82 -6
- package/src/strategies/model.ts +36 -6
- package/src/strategies/schemas.ts +66 -2
package/README.md
CHANGED
|
@@ -142,6 +142,27 @@ The error of 47.6% is on a new run of two lanes. With `split`, these lanes go on
|
|
|
142
142
|
|
|
143
143
|
The benchmark compares each curve type to the polylines of each router, on the fixtures of 100 nodes or fewer. It counts the curves that go through a box, with and without the free space. It also gives the ratio of the lengths.
|
|
144
144
|
|
|
145
|
+
### Options of the cost, the order and the merges
|
|
146
|
+
|
|
147
|
+
These options of `shared` and `trunks` are off by default. With the defaults, the routes do not change.
|
|
148
|
+
|
|
149
|
+
- `cost: flow` of `shared` sets the cost of a link with `f` edges to `len * f^alpha`. A smaller `alpha` gives more sharing and a longer stretch (EDA-029).
|
|
150
|
+
- `passes` of `shared` sets the number of passes. After the first pass, each edge finds its way again with the ways of the other edges fixed (HWY-039).
|
|
151
|
+
- `order` of `shared` sets the order of the edges of a key: `span` (the default, the longest first), `shortest`, `load` or `input` (NAT-024).
|
|
152
|
+
- `merge: snell` of `shared` moves each merge point to the angle `acos(d)` on the run (NAT-035). It cuts the sharp merges.
|
|
153
|
+
- `splitAt: gilbert` of `trunks` puts the split point where the flow cost is least, with the exponent `alpha` (EDA-030).
|
|
154
|
+
- `fan: tree` of `trunks` grows a balancing-factor tree for each group, with the factor `bf` (NAT-017). 0 gives the least ink.
|
|
155
|
+
|
|
156
|
+
The screen `screen-v1` compares the options with the defaults on the boards `small-clustered`, `dense-groups`, `hub-chain` and `many-groups`.
|
|
157
|
+
|
|
158
|
+
| Option | Router | Result |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `passes: 3` | `shared-all` | B1 rises 1% to 8%, and the B3 q95 falls or stays, on 4 boards. Crossings fall up to 28%. |
|
|
161
|
+
| `merge: snell` | `shared`, `shared-all` | The B6 max falls 8% to 27% on 6 board pairs. The ink rises 0.5% at most. Crossings rise 6% to 13%, and from 18 to 24 on `hub-chain`. |
|
|
162
|
+
| `cost: flow`, `alpha` 0.5 | `shared-all` | B1 rises 1% to 32%, but the B3 q95 rises up to 67%. |
|
|
163
|
+
| `fan: tree`, `bf` 0.2 | `trunks` | On `dense-groups`, B1 rises from 0.081 to 0.095 and the B3 q95 falls. |
|
|
164
|
+
| `splitAt: gilbert` | `trunks` | The B6 max rises. The ink changes 0.6% at most. |
|
|
165
|
+
|
|
145
166
|
## Room for the links
|
|
146
167
|
|
|
147
168
|
A host layout can pack the boxes of a far view in a grid, with no gap between them. Then the links have no channel, and they go through the boxes. The router knows the room that the links need. The room functions give that room, and they can open the gaps.
|
|
@@ -323,7 +344,8 @@ The steps of the pipeline that vary have strategies. Each step has one interface
|
|
|
323
344
|
|---|---|---|---|
|
|
324
345
|
| `group` | `Graph` | `Section`: the tree of groups of the router `sections` | `quadtree`, `keys`, `kd`, `cut` |
|
|
325
346
|
| `router` | `Graph` | `Result` | `straight`, `plugs`, `corners`, `corners-smooth`, `trunks`, `shared`, `shared-all`, `sections`, `sections-tree` |
|
|
326
|
-
| `
|
|
347
|
+
| `highway` | `HighwayInput`: the graph, and optionally the first routes of a router | `HighwayPlan`: the highways as data | `keys`, `shared-ways`, `corridors` |
|
|
348
|
+
| `curve` | `CurveInput`: the points, the normals of the plugs, the free space and the lane on its board | `CurveSegment[]` | `straight`, `rounded`, `spline`, `arc`, `smooth`, `clothoid`, `highway` |
|
|
327
349
|
| `room` | `RoomInput`: the boxes and the links of a board, and the tree of sections for `levels` | `Gap[]` | `routes`, `lines`, `levels` |
|
|
328
350
|
|
|
329
351
|
A strategy has a `step`, a `name`, a `describe` text, its `defaults` and the method `run(input, options?)`. The type of the options comes from `defaults`. Each option that a call does not give gets its default value.
|
|
@@ -333,7 +355,27 @@ A strategy has a `step`, a `name`, a `describe` text, its `defaults` and the met
|
|
|
333
355
|
- `register(registry, ...strategies)` gives a new registry. It does not change the registry before it.
|
|
334
356
|
- `listStrategies(registry, step)` gives the strategies of a step, in order. `findStrategy` and `getStrategy` give one strategy by its name.
|
|
335
357
|
- `asRouter(strategy, options?)` gives a `Router`, and `routersOf(registry)` gives the routers of a registry.
|
|
336
|
-
- `STRATEGIES` is the registry of `BUILT_IN_STRATEGIES`. The records `groupStrategies`, `routerStrategies`, `curveStrategies` and `roomStrategies` give each built-in strategy with its typed options.
|
|
358
|
+
- `STRATEGIES` is the registry of `BUILT_IN_STRATEGIES`. The records `groupStrategies`, `routerStrategies`, `highwayStrategies`, `curveStrategies` and `roomStrategies` give each built-in strategy with its typed options.
|
|
359
|
+
|
|
360
|
+
### The step `highway`
|
|
361
|
+
|
|
362
|
+
The step `highway` decides which edges share a way. It gives a plan, not routes. `follow` routes the plan.
|
|
363
|
+
|
|
364
|
+
- A `Highway` has an `id`, a `key`, a `spine`, its `lanes` and its `members`. Lane 0 is on the left of the spine.
|
|
365
|
+
- A `HighwayMember` is an edge with its merge point and its split point. `on` and `off` give their places on the spine.
|
|
366
|
+
- `checkPlan(graph, plan)` lists the problems of a plan. A good plan gives an empty list.
|
|
367
|
+
- `follow(graph, plan, options?)` routes each member from its plug to its merge point, along the spine, and from its split point to its target.
|
|
368
|
+
- `follow` routes an edge that is not a member with its first route, or with the way finder. It gives one run for each stretch that two members or more share.
|
|
369
|
+
- `highwayRouter(strategy)` and `highwayRouterStrategy(strategy)` give a router that makes the plan and then calls `follow`.
|
|
370
|
+
|
|
371
|
+
| Strategy | Decision |
|
|
372
|
+
|---|---|
|
|
373
|
+
| `keys` | The trunks and the runs of the router `trunks`. `planOfResult` reads them. The router does not change. |
|
|
374
|
+
| `shared-ways` | The runs of the router `shared`. `planOfResult` reads them. The router does not change. |
|
|
375
|
+
| `corridors` | The corridor signatures of HWY-031. The links of the first routes get a MinHash signature, and each cluster of ways gives a highway. |
|
|
376
|
+
|
|
377
|
+
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.
|
|
378
|
+
The routers `trunks` and `shared` keep their own code. A test pins their output, so the strategies `keys` and `shared-ways` read the same decision.
|
|
337
379
|
|
|
338
380
|
A registry is data. No import changes it. The benchmark and the site take their lists from `STRATEGIES`, so a new built-in strategy gets its rows and its button with no other edit. A consumer makes its own registry:
|
|
339
381
|
|
|
@@ -362,6 +404,25 @@ const rows = runBenchmark(routersOf(registry), FIXTURES.slice(0, 1)); // The row
|
|
|
362
404
|
|
|
363
405
|
The built-in strategies give the same output as their functions. `curveStrategies.rounded.run({ points, space }, { radius: 8 })` gives the segments of `curveOf(points, { type: "rounded", space, radius: 8 })`. `benchCurveStrategies` and the fourth argument of `benchRoom` take a list of strategies.
|
|
364
406
|
|
|
407
|
+
### Wrappers of a router
|
|
408
|
+
|
|
409
|
+
Two functions wrap a router strategy. The wrapped strategy has a new name, and the router does not change.
|
|
410
|
+
|
|
411
|
+
- `stableOrderStrategy(strategy)` gives `<name>+stable`. It routes the edges in a stable order: by a hash of their ids, then by the ids. Thus each order of the input edges gives the same output.
|
|
412
|
+
- `repairStrategy(strategy, repair?)` gives `<name>+repair`. After the router, `repairResult` repairs the breaks of the hard rules.
|
|
413
|
+
- It moves each free end back to its plug, and pushes each inner leg out of a box.
|
|
414
|
+
- It replaces each other leg through a box with a detour through the corner graph.
|
|
415
|
+
- When a leg does not repair, it routes the whole route again. Else it walks along the boundaries of the boxes, so boxes that touch do not block it.
|
|
416
|
+
- A route that it cannot repair keeps its base route.
|
|
417
|
+
- `withStableOrder(router)` and `withRepair(router, repair?)` wrap a `Router` in the same way.
|
|
418
|
+
|
|
419
|
+
```ts
|
|
420
|
+
import { repairStrategy, routerStrategies, stableOrderStrategy } from "@mark1russell7/highways";
|
|
421
|
+
|
|
422
|
+
const shared = stableOrderStrategy(routerStrategies.shared);
|
|
423
|
+
const result = repairStrategy(shared).run(graph); // The router `shared+stable+repair`.
|
|
424
|
+
```
|
|
425
|
+
|
|
365
426
|
### Declarations of the options
|
|
366
427
|
|
|
367
428
|
Each strategy declares its options in `schema`. A declaration tells the type, the range, the step and the meaning of one option. Tools make controls and sweeps from these declarations, with no other data.
|
|
@@ -448,10 +509,13 @@ The workflow `Bench` runs the suite in parts. Each part writes its report, and `
|
|
|
448
509
|
|
|
449
510
|
`compareStep` runs each strategy of one step on one board, with the measures of the suite. It gives one row for each strategy and the Pareto front of the step. The options give each strategy its own options. The compare page of the site uses it.
|
|
450
511
|
|
|
512
|
+
With the option `lanes`, the step `curve` opens each shared way of the routes of `curveRouter` into lanes, and each curve draws the lanes. Each input then has its `lane`, so the curve `highway` bends the lanes of a bundle as one with each of its options.
|
|
513
|
+
|
|
451
514
|
```ts
|
|
452
515
|
import { compareStep } from "@mark1russell7/highways";
|
|
453
516
|
|
|
454
517
|
const { rows, front } = compareStep("curve", graph, { options: { arc: { radius: 20 } } });
|
|
518
|
+
const lanes = compareStep("curve", graph, { curveRouter: "shared", lanes: { width: 5, maxWidth: 30 }, options: { highway: { jog: "quintic" } } });
|
|
455
519
|
```
|
|
456
520
|
|
|
457
521
|
## License
|