Skip to content

Commit 097e264

Browse files
committed
backup - pre benchmarks
1 parent c26280e commit 097e264

39 files changed

Lines changed: 7007 additions & 2823 deletions

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ Check the live example at [https://abelvm.github.io/omt-router/example](https://
1717

1818
- **Zero backend, zero-provider** — No need for a routing backend or relying on a 3rd party API provider, `omt-router` builds the routing graph on-the-fly from **OpenMapTiles** formatted vector tiles
1919
- **Multi-engine routing** — bidirectional A*, Adaptive Barrier SSSP, Delta-Stepping, and Ultra Dijkstra
20-
- **Automatic best engine selection**using modelization based on real-world data
20+
- **Automatic best engine selection**runtime engine chooser uses benchmark-derived models and a generated selector module in `src/tuning/tuning.js`
2121
- **Three transport modes**`car`, `pedestrian`, `bicycle`; respects OpenMapTiles access tags and road class hierarchy
22-
- **Two optimizacion strategies** — route length or travel time
22+
- **Two optimization strategies** — route length or travel time
23+
- **Endpoint snapping with quality guard** — nearest-node lookup plus segment-projection snap, with `maxAcceptableSnapDistanceM` limiting distant off-road snaps
2324
- **Seamless tile stitching**[Liang-Barsky](https://en.wikipedia.org/wiki/Liang%E2%80%93Barsky_algorithm) clipping ensures road segments share bit-identical boundary nodes across neighbouring tiles with no proximity snapping
2425
- **Worker pool + tile cache** — Using [performance-helpers](https://abelvm.github.io/performance-helpers) to get the best performance always: parallel tile parsing and parallel engines execution via **PowerPool**, parsed tiles are cached with **PowerCache** so repeated queries can reuse tiles until TTL/LRU eviction
2526

@@ -43,29 +44,30 @@ Notes:
4344

4445
## ML-based engine selector
4546

46-
Engine selection is data-driven. The file `src/tuning.js` is generated from benchmark data by `benchmark/cluster_engine_selector.py`.
47+
Engine selection is data-driven and can be regenerated from benchmark results. `src/tuning/tuning.js` is built from the benchmark pipeline, and `src/tuning/model.js` is the compact runtime model artifact produced by `benchmark/train_engine_selector_ml.py`.
4748

48-
At runtime, the selector computes route/graph features such as:
49+
At runtime, the selector evaluates route and graph features such as:
4950

5051
- edge count (`E`) and node count (`N`)
5152
- beeline distance between endpoints
5253
- derived density/branch indicators (`edgesPerKm`, average out-degree)
53-
- binned signatures (`sizeBand`, `beelineBand`, `densityBand`, `branchBand`)
54+
- discrete feature bands such as `sizeBand`, `beelineBand`, `densityBand`, and `branchBand`
5455

55-
Selection flow:
56+
Selector flow:
5657

57-
1. Build selector features from `(E, N, beeline)`.
58-
2. Detect runtime capability (`SharedArrayBuffer`, Worker, cross-origin isolation) to decide `sab_on` vs `sab_off` rules for parallelization.
59-
3. Apply generated rule sets for `distance` or `travelTime` optimization.
60-
4. Optionally apply per-engine parallelization policy thresholds.
58+
1. Build the route/graph feature vector from the corridor graph and query endpoints.
59+
2. Detect runtime capability (`SharedArrayBuffer`, Worker, cross-origin isolation) to choose `sabOn` vs `sabOff` rules.
60+
3. Evaluate the generated selector in `src/tuning/tuning.js`, which uses the compact `src/tuning/model.js` artifact when available.
61+
4. Select the recommended engine and apply per-engine parallelization/correctness fallback logic.
6162

6263
Why this exists:
6364

64-
- No single engine wins every route shape.
65-
- The selector minimizes regret using offline benchmark-trained rules.
66-
- Tuning can be regenerated as your benchmark corpus grows.
65+
- No single engine is best for every route graph shape.
66+
- The selector minimizes runtime regret using offline benchmark-trained models.
67+
- The training workflow supports both serial (`sabOff`) and parallel (`sabOn`) profiles.
68+
- The model pipeline includes `runtime-linear`, `xgboost`, and a compact 2-layer `mlp` option.
6769

68-
See [benchmark/README.md](benchmark/README.md) for full benchmark, analysis, and sweep workflow.
70+
See [benchmark/README.md](benchmark/README.md) for the current benchmark and selector training workflow.
6971

7072
---
7173

@@ -105,9 +107,9 @@ You can also use other OpenMapTiles-compatible providers (for example MapTiler)
105107

106108
Route quality depends on source data quality. The better [OpenStreetMap](https://www.openstreetmap.org/) coverage and tagging are in your area, the better the result. If you find inaccuracies, consider [contributing](https://wiki.openstreetmap.org/wiki/How_to_contribute) to improve OSM data.
107109

108-
Endpoints must snap to routable nodes. If origin or destination is too far from a valid road/path for the chosen mode, routing can fail with `no_node` or `poor_snap`. For example, avoid starting a car route in pedestrian-only areas.
110+
Endpoints must snap to routable graph edges. The routing code first looks for the nearest graph node, then it may use a segment-projection snap when that improves route validity. Snapping is guarded by `maxAcceptableSnapDistanceM` (default `60` m), so points that are too far from a usable road/path will fail with `no_node` or `poor_snap` rather than producing a misleading route.
109111

110-
For bidirectional streets, the side of the road you pick might change the proposed route considerably.
112+
For bidirectional streets, the side of the road you click can still affect the computed route, especially when one-way restrictions are present.
111113

112114
Tile requests are performed in-browser from a Worker. Your tile server must include CORS headers (for example `Access-Control-Allow-Origin`) for uncached cross-origin requests. If that is not possible, route tile URLs through a same-origin proxy (see `options.tileProxyTemplate`).
113115

@@ -270,6 +272,8 @@ route()
270272

271273
In `route()`, corridor radius can auto-expand when a pass fails with `no_path`, `no_node`, `poor_snap`, or `incomplete_path`. This keeps normal requests small while still handling larger real-world detours.
272274

275+
The tile retry loop also means route failure reasons are more informative: `no_node` means no nearby graph node was found, `poor_snap` means endpoint snapping quality exceeded `maxAcceptableSnapDistanceM`, and `incomplete_path` means the selected engine produced an invalid route that will be retried or surfaced to the caller.
276+
273277
Both `zxy` (XYZ) and `tms` (TMS, Y-flipped) schemas are supported.
274278

275279
### 2. Graph construction — `graphBuilder.js`
@@ -303,7 +307,7 @@ Endpoints are snapped to graph nodes with a cached `KDBush` spatial index and a
303307

304308
### 4. Routing execution and engine selection — `chRouter.js`
305309

306-
`queryRoute` supports explicit engine IDs and an `auto` mode. In `auto`, the selector in `src/tuning.js` uses route and graph features (`E`, `N`, beeline, density and branching bands) plus runtime capability (for example SharedArrayBuffer and Worker availability) to choose the best engine for each query.
310+
`queryRoute` supports explicit engine IDs and an `auto` mode. In `auto`, the selector in `src/tuning/tuning.js` uses route and graph features (`E`, `N`, beeline, density and branching bands) plus runtime capability (for example SharedArrayBuffer and Worker availability) to choose the best engine for each query.
307311

308312
Execution flow:
309313

0 commit comments

Comments
 (0)