Two parameters

Where the landmarks stand

Four tables of exact distances, each from a chosen cell, turn a straight-line estimate that barely helps on rough terrain into one that cuts a search by a factor of six. Averaged over 1,200 queries on eight maps, the same four tables expand 126 cells a query when their cells are the map's corners and 423 when they are near its centre. The standard choice, each landmark as far as possible from the ones before, expands 141 and loses to the corners on all eight maps. Moving four landmarks to the right places buys more than doubling their number.

An estimate borrowed from an easier problem measured why A*'s usual estimate fails on rough ground. The straight-line count of cells to the goal is admissible on a grid where steps cost between one and nine, because every step costs at least one, and it is nearly useless there, because it believes every step costs one. Guided by it, a search across a weighted grid expanded 1,550 cells where Dijkstra, with no estimate, expanded 1,572.

The repair measured in that essay is a table. Pick a few cells as landmarks, and store the exact distance from each landmark to every cell. For any cell vv and goal tt, the triangle inequality says the distance from vv to tt is at least the difference between their distances from any landmark LL, so

h(v)=maxLd(L,t)d(L,v)h(v) = \max_L \bigl|\,d(L, t) - d(L, v)\,\bigr|

is an estimate that never overestimates and, unlike the straight-line count, knows what the terrain costs. With four landmark tables the same search expanded 252 cells.

That essay chose its landmarks one way — each as far as possible from those already chosen — and did not ask whether the choice mattered. The estimate’s quality depends entirely on where the landmarks stand relative to the cells being searched between, so the choice should matter a great deal. This page measures how much.

The estimate that was already measured

3 searches on one grid: from 1,572 cells expanded down to 252One 50 × 50 grid with 28% of its cells removed, every step costing between one and nine, searched from corner to corner. The shortest path costs 356. No estimate: 1,572 expanded · path 356. Straight-line estimate: 1,550 expanded · path 356. A*, landmarks: 252 expanded · path 356 · 6,328 reads to build.cells expandedNo estimate1,572 expanded · path 356Straight-line estimate1,550 expanded · path 356A*, landmarks252 expanded · path 356 · 6,328 reads to buildV = 2,500, steps cost one to nine, seed 20260910shortest path 356
Fig. 1 The result being built on: one 50 by 50 grid with 28% of its cells removed and steps costing one to nine, searched from corner to corner, shortest path 356. Dijkstra expands 1,572 cells. A* with the straight-line estimate expands 1,550. A* with four landmark tables expands 252, and building the tables costs 6,328 reads.

The landmark estimate cut the search by a factor of six, and it charged for it before the first query: four full searches, one from each landmark, 6,328 cell reads between them. Those tables are then reused for every query, which is what makes the trade worth considering at all — a preparation that costs four complete searches of the map, repaid by every later query that expands a sixth of what it otherwise would. The precondition on a function the caller writes measured the first estimate supplied to this search, and found that its guarantee holds only while the function never overestimates. A landmark estimate meets that condition by construction, whatever cells are chosen, so the choice of cells is free to be made for speed alone — and speed is all this page measures.

A query from corner to corner is also the easiest kind for landmarks placed far apart, since the two ends of the query are themselves near the edges of the map. The rest of this page asks random queries — each a pair of reachable cells drawn uniformly — so that the placements are compared on the queries a system would actually receive.

Why placement should matter

The estimate for a cell vv is good when some landmark makes d(L,t)d(L,v)|d(L,t) - d(L,v)| close to the true distance from vv to tt. That happens when LL lies roughly behind tt as seen from vv, or behind vv as seen from tt — when the shortest route from LL to one of them passes close to the other, so the two distances from LL differ by nearly the whole distance between them.

A landmark near the centre of the map is behind almost nothing. For most pairs of cells, the centre is somewhere between them or off to one side, and the distances from the centre to the two cells are similar, so the difference is small and the estimate is weak. A landmark in a corner is behind every pair of cells lined up with that corner, and four corners cover pairs lined up in four directions.

That argument predicts an order — corners best, centre worst — and not the size of the gap.

The query a landmark is exact for

The argument has an extreme case that makes it concrete. Put a landmark exactly on the goal. Then d(L,t)d(L, t) is zero and the estimate for every cell is its exact distance to the goal — the best estimate there can be. A* with an exact estimate expands only cells that lie on a shortest route and stops; there is nothing left to search.

Move the landmark a little beyond the goal, so that the goal lies between the landmark and most of the map. For a cell vv whose shortest route to the landmark passes through or near tt, the difference d(L,v)d(L,t)d(L, v) - d(L, t) is almost exactly the distance from vv to tt, and the estimate is nearly exact again. Move the landmark to one side of the line from vv to tt, and the two distances from it grow similar, and the estimate shrinks towards zero.

So a landmark is a partial answer to “how far is everything from the goal”, correct for the goals that lie between it and the cells being searched. Four landmarks at the corners answer that question well for every query that runs roughly towards one of the corners, which on a square map is nearly every long query. Four near the centre answer it only for queries that run towards the middle and stop there. The first plate’s corner-to-corner query is the friendliest case of all for farthest-first, whose first landmark is placed at the far corner — right behind that query’s goal.

Four landmarks placed four ways

The placements compared are: no landmarks, which is Dijkstra; four near the centre, the open cells nearest four points a few cells from the middle; four at random, open cells drawn from a seed; farthest-first, the standard construction, starting from the cell farthest from the origin and adding each time the cell farthest from every landmark so far; and the corners, the open cells nearest the four corners of the map. On each of eight maps, the same 150 random queries are asked of every placement, and every search is checked to stop on the true distance.

Four landmarks on 8 maps: no landmarks 897, four near the centre 423, four at random 209, farthest-first 141, the corners 126 cells a query — and the corners beat farthest-first on 8 of 8Mean cells A* expands per query over 150 random queries on each of 8 weighted maps of 2,500 cells, with estimates from four landmark tables placed by each rule; every table is one full search from its landmark. no landmarks: mean 897.0, maps 856, 884, 921, 827, 926, 962, 912, 888. four near the centre: mean 423.4, maps 416, 407, 444, 392, 388, 479, 433, 429. four at random: mean 208.8, maps 239, 176, 194, 191, 252, 199, 226, 194. farthest-first: mean 141.4, maps 133, 143, 150, 128, 148, 150, 148, 131. the corners: mean 126.3, maps 129, 122, 131, 114, 129, 147, 121, 119.0200400600800cells expanded per query, meanno landmarks897four near the centre423four at random209farthest-first141the corners1268 maps × 150 queriesdots: each map's mean
Fig. 2 Mean cells A* expands per query over 150 random queries on each of eight weighted maps of 2,500 cells, with estimates from four landmark tables placed by each rule; the dots are the eight maps’ means. No landmarks: 897. Four near the centre: 423. Four at random: 209. Farthest-first: 141. The corners: 126. The corners expand fewer cells than farthest-first on all eight maps.

The order is the predicted one, and the spread is a factor of 3.4 between the best and worst placements of the same number of tables at the same preparation cost. Four landmarks near the centre still halve Dijkstra’s work — any table knows something about the terrain — but four at the corners cut it by a factor of seven.

The dots show that the ranking is not an average hiding disagreement. On every one of the eight maps the corners beat farthest-first, farthest-first beats random, and random beats the centre. The per-map means for the corners run from 114 to 147 and for farthest-first from 128 to 150; the two ranges overlap, but on each individual map the corners come out ahead.

What farthest-first actually chooses

Farthest-point selection is designed to spread landmarks out, and the corners are as spread out as a square map allows, so the result that they beat it needs an explanation. The map shows it.

Where four landmarks stand under each rule, on one 50 × 50 mapOne weighted map of 50 × 50 cells with 28% removed, drawn with its removed cells dark, and the four landmark cells each placement rule chooses. four near the centre: (22, 22), (28, 22), (22, 28), (28, 28). four at random: (2, 40), (34, 27), (18, 27), (49, 0). farthest-first: (48, 49), (10, 49), (49, 0), (23, 29). the corners: (0, 0), (49, 0), (0, 49), (49, 49).four near the centrefour at randomfarthest-firstthe cornersmap 11, 50 × 50dark: removed cells
Fig. 3 One weighted 50 by 50 map with its removed cells drawn dark, and the four landmarks each rule chooses. Near the centre: (22, 22), (28, 22), (22, 28), (28, 28). At random: (2, 40), (34, 27), (18, 27), (49, 0). Farthest-first: (48, 49), (10, 49), (49, 0), (23, 29). The corners: (0, 0), (49, 0), (0, 49), (49, 49).

Farthest-first’s first three landmarks are on the edges of the map: the far corner from the origin, a point along the bottom edge, and the top-right corner. Its fourth is at (23, 29) — near the middle. That is not a malfunction. After three landmarks along the edges, the cell farthest from all three, measured in weighted distance around the obstacles, is an interior cell that the three edge landmarks are all some way from. Farthest-first adds it, because it is designed to cover the map, and an interior landmark is exactly the kind that helps least.

The rule optimises the wrong quantity. Coverage — no cell far from every landmark — is what a nearest-landmark scheme needs. The landmark estimate does not use the nearest landmark; it uses the one behind the query, and a landmark is useful in proportion to how many queries it lies behind, which favours the periphery regardless of coverage. The corners have no coverage argument at all and they win because every one of them is peripheral.

The random placement’s spread tells the same story from the other direction. Its four landmarks on this map include (49, 0), a corner, and (2, 40), near an edge, alongside two interior cells, and its mean of 209 sits between the placements that are all peripheral and the one that is all central.

More landmarks, or better-placed ones

Landmarks added against landmarks placed: farthest-first 400 → 209 → 141 → 101; the corners 405 → 221 → 126 → 92 cells for 1, 2, 4 and 8Mean cells A* expands over 150 random queries on each of 8 weighted maps, with 1, 2, 4 and 8 landmarks. Corner placement takes the corners first and then the midpoints of the edges. farthest-first: 399.6 with 1, 209.3 with 2, 141.4 with 4, 100.8 with 8. the corners: 405.2 with 1, 220.8 with 2, 126.3 with 4, 92.5 with 8.1248100landmarkscells expanded, meanfarthest-firstthe corners8 maps × 150 querieseach table costs one full search to build
Fig. 4 Mean cells expanded per query over the same eight maps and 150 queries each, with one, two, four and eight landmarks. Farthest-first: 399.6, 209.3, 141.4 and 100.8. The corners, taken first and then the midpoints of the edges: 405.2, 220.8, 126.3 and 92.5.

With a single landmark the two rules are almost the same — farthest-first’s first choice is itself a corner, the one opposite the origin, and the corner rule’s first choice is the origin’s own corner — and they expand 400 and 405 cells. With two, farthest-first is slightly ahead. From four onwards the corners and edge midpoints are ahead, because that is where farthest-first starts placing landmarks in the interior.

The plate also prices the alternative to placing landmarks well, which is placing more of them. Doubling farthest-first’s landmarks from four to eight takes it from 141 cells to 101, a saving of 29%, and doubles the preparation and the memory. Moving four random landmarks to the corners takes 209 cells to 126, a saving of 40%, at no cost at all. Moving four central landmarks to the corners saves 70%.

Where the tables stand is worth more than how many there are, over the whole range drawn. That matters because the number of landmarks is the parameter a system exposes and tunes, and their placement is usually a fixed rule inside the implementation that nobody revisits.

What each table costs

3 searches on one grid: from 1,572 cells expanded down to 237One 50 × 50 grid with 28% of its cells removed, every step costing between one and nine, searched from corner to corner. The shortest path costs 356. No estimate: 1,572 expanded · path 356. Straight-line estimate: 1,550 expanded · path 356. A*, landmarks: 237 expanded · path 356 · 12,656 reads to build. Each bar includes the reads spent building the estimate before the search began.cells expandedreads building the estimateNo estimate1,572 expanded · path 356Straight-line estimate1,550 expanded · path 356A*, landmarks237 expanded · path 356 · 12,656 reads to buildV = 2,500, steps cost one to nine, seed 20260910shortest path 356
Fig. 5 The corner-to-corner query again, with eight farthest-first landmark tables and the reads spent building them charged to the bar: Dijkstra expands 1,572 cells, the straight-line estimate 1,550, and eight landmark tables 237 — after 12,656 reads to build them.

Doubling the landmarks on this query saves fifteen cells, from 252 to 237, and doubles the preparation, from 6,328 reads to 12,656. That is the same diminishing return the count plate showed across many queries, seen on one: each table adds a bound that the estimate takes the maximum over, and once a query already has a landmark behind it, another landmark behind it adds almost nothing.

There are two further costs no plate on this page charges. Memory: each table holds a distance for every cell, so eight tables are eight copies of the map’s size, and on a road network of millions of junctions that is the binding constraint. The space the model does not see is the site’s general warning about a cost a count of operations never shows, and landmark tables are a clean case: they appear in no count of expanded cells.

Evaluation: the estimate is a maximum over every table, recomputed for every cell the search considers, so a search with eight tables does twice the arithmetic per cell of one with four. The plates give enough to price that roughly, as cells expanded times tables consulted. Farthest-first comes to about 400 table lookups a query with one table, 419 with two, 566 with four and 806 with eight: going from four to eight saves 29% of the cells and spends 42% more lookups. The corners come to 405, 442, 505 and 740. Every table added costs more arithmetic than the cells it saves, at every count on the plate.

That does not make one table the right number, because a lookup is not the whole cost of a cell. Expanding a cell also reads up to four neighbours, evaluates the estimate for each one it reaches, and moves entries in the queue, so the rough price above undercounts lookups and ignores everything else a cell costs. Cells saved are worth more than a table’s lookups while that other work dominates. Where the balance falls depends on that ratio, which is a property of the implementation and the machine rather than of the map. What does not depend on it is the comparison at a fixed count: at four tables, the corners expand 11% fewer cells than farthest-first for exactly the same lookups per cell, and no ratio can make that a worse trade.

The frontier between time and space is the site’s standing picture of this shape of trade, with time on one axis and memory on the other. Better placement is a move towards the corner of that picture that costs nothing on either axis, which is the rarest kind of move the frontier has.

The estimate is a potential, and placement shapes it

An estimate is a reweighting showed that A* with a consistent estimate is Dijkstra on arcs repriced by it. A landmark estimate is consistent — the difference of two distances from one landmark changes by at most an arc’s cost across that arc, and a maximum of consistent functions is consistent — so every search on this page is Dijkstra on a repriced map, and the placements are four different repricings of the same terrain.

A good repricing makes arcs leading towards the goal cost nearly nothing and arcs leading away cost nearly double, so the search runs downhill to the goal. A landmark behind the goal as seen from a cell makes the route towards the goal cheap in exactly that way; a landmark beside the route prices both directions nearly the same and leaves the terrain nearly as it was. The cells-expanded counts are therefore a measure of how steep each placement makes the repriced map along the routes random queries take, and the corners make it steepest.

That view also says what to expect when landmarks combine with the other speed-up measured on these grids. Where two searches should stop showed two-ended search saving about a third of the cells on these grids with no estimate at all. Two estimates that must agree found that searching from both ends needs a single potential shared by both searches, built from the forward and backward estimates. With landmark tables both estimates come from the same tables, and a placement good for one direction is good for the other, since a landmark behind the goal as seen from the source is behind the source as seen from the goal.

What the model leaves out

Square maps with random obstacles. A map whose corners are unreachable, or whose useful routes all run along one corridor, would favour a different placement, and the corner rule has no way to notice. The finding is that placement matters by a factor of 3.4 on these maps and that the periphery is where good landmarks stand, not that corners are always right.

Uniform random queries. A system whose queries cluster — most from one district, most to one hub — would do best with landmarks behind the clusters, and could learn where those are from its query log. None of the four rules here uses the queries.

No placement search. Better rules exist in the literature on this estimate, which chooses landmarks to avoid regions already well covered by the landmarks so far, measured on sample queries. They are more expensive to compute and are not measured here.

Terrain that does not change. A table is exact only for the costs it was built on. If a stretch of terrain becomes dearer, every table’s distances through it are too small — still admissible, since a lower bound on a cheaper map is a lower bound on a dearer one — and the estimate quietly weakens. If a stretch becomes cheaper, the tables can overestimate, and A* stops guaranteeing a shortest path. Which placements degrade most gracefully under updates is a question these plates do not reach.

A rule is a constant somebody chose. Farthest-first selection is written into implementations as a fixed rule, and the threshold somebody chose found that fixed constants in sorting code were not optima when swept. The placement rule is the same kind of object, and the corner rule beating it on every map here is the same kind of finding.

Still open: landmarks chosen from the queries

Every rule on this page chooses landmarks from the map alone. But the quantity that decides whether a landmark is useful — how many queries it lies behind — depends on the queries, and a system that has answered some queries knows something about the ones to come.

The measurement that follows chooses landmarks greedily from a sample of past queries: start with none, and repeatedly add the candidate cell whose table most reduces the total cells expanded on the sample, stopping at four. It then asks how many sample queries the greedy choice needs before it beats the corners on fresh queries, how far below 126 cells it can go, and what the choice costs to compute — since each candidate must be evaluated by rerunning the sample, the preparation is a search over searches, and it may cost more than the queries it saves.

What this makes readable

Essays that name this one as a prerequisite.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the concept index makes visible.

What links here

Every essay whose body links to this one.

The objects this essay names

Each one links to every other essay that touches it.

AdmissibilityBreak-evenHeuristic searchLandmarkParameter choicePotential functionPreprocessingRegimeSearch frontierShortest pathSpace time tradeTriangle inequality