A 169-Weight Neural Network Restores A*'s Rush-Hour Advantage Over Dijkstra: From 2.5x Back to 11.7x
On a map of Moscow, A* expands 11 times fewer intersections than Dijkstra at night, but only 2.5 times fewer at 8:30 because of traffic. The author added a time-of-day correction to the A* path estimate, in two forms: a table of 96 numbers or a network with 169 weights. The network restored the rush-hour gain to 11.7x, while routes came out 1% longer than optimal on average. If your heuristic breaks when load changes, a tiny model can patch it.
AI-processed from Хабр: Машинное обучение; edited by Hamidun News
A navigation app plans a route across a huge city in a fraction of a second because it does not examine every road. Classic Dijkstra's algorithm spreads out from the start in circles and knows nothing about the destination. Its improved version, A*, gets a hint of roughly how much farther there is to go and stays out of irrelevant districts.
In heavy traffic, though, that hint goes stale. A developer built a simplified navigator on a map of Moscow and found that at 3:00 at night, A* expands 11 times fewer intersections than Dijkstra. At 8:30 in the morning, on the same queries, the gain drops to 2.
5x. The algorithm is the same; the roads are simply congested. Two corrections, a table of 96 numbers and a network with 169 parameters, raised the rush-hour gain to 10–12x, with routes coming out 1–2% longer than ideal on average.
Why A goes blind in traffic
The map is turned into a graph: intersections are vertices, road segments are edges, and each edge has a travel time. Picture a trip from Tushino to Maryino. Dijkstra will also sweep through Khovrino, even though it lies in the opposite direction, simply because it is closer. A adds an estimate of the remaining trip to the time already spent. Such intersections get a larger sum and are discarded. As long as the estimate never overestimates, A is guaranteed to find the fastest route.
For roads, an honest estimate comes from the ALT technique: 16 landmarks are chosen at the edges of the graph, and the travel time from every intersection to each of them is computed in advance. The problem is that these times are computed on empty night-time roads. At eight in the morning a segment takes 2.4 times longer to drive, but the estimate is still the night-time one. All intersections look equally promising, and the search sprawls across the city almost like Dijkstra's.
The test model is Moscow inside the MKAD ring road, taken from OpenStreetMap: 19 473 intersections and 40 229 segments. The author tuned the traffic profiles to public figures: highways near the MKAD run at 38 km/h in the morning (Yandex says 37), and the average evening speed across the city is 21.8 km/h (the Moscow Department of Transport says 21). This is a model, not real traffic data.
Two corrections: a table and a network
The idea is to multiply the ALT estimate by a coefficient: how many times longer the real road is than the estimate at that moment. A parameter α from 0 to 1 sets how aggressive the correction is. At zero it is ordinary A* with a guarantee of optimality. At one the correction works at full strength and sometimes overestimates, so the route comes out slightly worse.
The first option is a table of 96 numbers, one for every 15 minutes of the day. At night the real path is only 10–15% longer than the ALT estimate, in the morning peak 2.4 times longer, and in the evening peak about 2.8 times.
The second option is a small neural network: 10 input numbers, two hidden layers of 8 neurons each, and one output, for a total of 169 weights. It sees the coordinates of the intersection and the destination, the distance from the center, the straight-line distance, the ALT estimate, and the time of day. The table knows only the time, so it cannot tell a trip into the center from a trip out of it. The network inferred the direction of traffic flow from examples on its own: at 8:30 it treats a trip into the center as 3 times longer than the estimate, and a trip out of the center as 2.25 times longer.
The training data came almost for free. If Dijkstra is not stopped at a single target, one pass computes the exact time to all 19 473 intersections. 2500 such passes over 240 targets yielded 600 thousand examples in 34 seconds on a laptop. The network trained through scikit-learn in 4 seconds and 36 epochs. On starts it had not seen, in half of the cases its error in the multiplier is under 5.3%; for the table it is under 8.2%. A 64×64 network with 4.9 thousand weights is more accurate (4.4%), but it needs about 4800 multiplications per intersection versus roughly 150, so the author chose the small one.
What 1800 queries showed
The test used 50 starts for each of four times (3:00, 8:30, 13:00, 18:30) and targets ranked from 64th to 16 384th by intersection order; at the peak, these are trips from two minutes to an hour and a half.
At rush hour, the network with α = 1 expands 11.7 times fewer intersections than Dijkstra, and the route is 1% longer than the best one on average. The table gives 10.3x but errs twice as much, at 1.9%. Weighted A*, where the estimate is multiplied by a single constant, gains only about 8x at the same 1% error. One multiplier cannot fit all cases: at 3:00 the estimate barely needs touching, while at 8:30 it must be doubled.
What to do in practice
The lesson reaches beyond navigation. If you have a heuristic or cost estimate that breaks when the regime changes, for example with the time of day or with load, a tiny regression on cheap features can restore its accuracy. Training data can be obtained as a by-product of the exact algorithm, and the guarantee can be kept by setting α = 0. The price is the loss of strict optimality: a percent or two of route length. One caveat: the test covered a single city and simulated traffic, so before deploying this in a real service, the solution should be checked against real speed data.
- Oct 28, 2026Can You Teach a Language Model While It's Reading? Researchers Tested Every Architecture
- Oct 27, 2026JetBrains Compiled Maven's Logic Into a Neural Network: The Build Runs 1.49× Slower Than Python
- Dec 2, 2026N-gram Speculation Pushes Qwen3-14B on a Home RTX 5070 Ti from 78 to 129 Tokens per Second
- Oct 27, 2026KAIST drops calibration from MoE decoding, speeds up blocks by up to 2.69× over vLLM
Key Questions Answered
Why A goes blind in traffic?
The map is turned into a graph: intersections are vertices, road segments are edges, and each edge has a travel time. Picture a trip from Tushino to Maryino. Dijkstra will also sweep through Khovrino, even though it lies in the opposite direction, simply because it is closer. A adds an estimate of the remaining trip to the time already spent. Such intersections get a larger sum and are discarded. As long as the estimate never overestimates, A is guaranteed to find the fastest route.
What are the key details on Two corrections: a table and a network?
The idea is to multiply the ALT estimate by a coefficient: how many times longer the real road is than the estimate at that moment. A parameter α from 0 to 1 sets how aggressive the correction is. At zero it is ordinary A with a guarantee of optimality. At one the correction works at full strength and sometimes overestimates, so the route comes out slightly worse. The first option is a table of 96 numbers, one for every 15 minutes of the day.
What 1800 queries showed?
The test used 50 starts for each of four times (3:00, 8:30, 13:00, 18:30) and targets ranked from 64th to 16 384th by intersection order; at the peak, these are trips from two minutes to an hour and a half. At rush hour, the network with α = 1 expands 11.7 times fewer intersections than Dijkstra, and the route is 1% longer than the best one on average. The table gives 10.3x but errs twice as much, at 1.9%. Weighted A, where the estimate is multiplied by a single constant, gains only about 8x at the same 1% error.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
