Two parameters

What the queries know that the map does not

A greedy rule that chooses landmark cells by rerunning a sample of past queries needs two hundred of them to draw level with a rule that reads only the map — and what it finally chooses, on map after map, is the four corners. Give the queries a destination instead of scattering them, and twenty are enough to beat the corners by 29% on eight maps out of eight. A query log is worth reading exactly to the extent that it is not uniform.

Where the landmarks stand measured four rules for choosing the cells a landmark estimate is built from, and found that the choice is worth more than the number: four landmarks at a map’s corners expanded 126 cells a query where four near its centre expanded 423, and the standard rule — each landmark as far as possible from the ones before — lost to the corners on all eight maps.

Every one of those rules reads the map and nothing else. That is a strange thing for them to do, because the quantity deciding whether a landmark is useful is not a property of the map at all. A landmark helps a query when it lies behind the goal as seen from the source, so that the difference of two exact distances is nearly the whole route; a landmark beside the route helps nothing. Which landmarks lie behind which routes depends on where the routes run, and where the routes run is a property of the queries.

A system that has answered some queries has that property written down. This page gives a selection rule the query log and asks what it is worth.

The rule, and what it costs to run

The rule is the obvious greedy one. Start with no landmarks. For each candidate cell, build its table of exact distances, add it to the set already chosen, and rerun the whole sample of past queries with the resulting estimate, counting the cells expanded. Keep whichever candidate lowers that total most. Repeat until four landmarks have been chosen.

The candidates are the open cells nearest an evenly spaced lattice of twenty-five points across the map, and the lattice includes both ends of each axis. Including the ends is not a detail. The rule being measured against puts its landmarks in the corners, and a candidate set that stopped short of the far edge would be a handicap dressed up as a finding.

Each landmark the selection adds: 360 → 192 → 149 → 121 cells a sample query, and the fourth is still payingMean cells expanded over the 200 sample queries after each landmark the greedy selection adds, on map 1. 1 landmark: 360.0. 2 landmarks: 191.6. 3 landmarks: 148.9. 4 landmarks: 121.5. On 150 fresh queries the four tables expand 128.9 cells a query against the corner rule's 128.9.1 landmark360.02 landmarks191.63 landmarks148.94 landmarks121.5cells expanded per sample query, meanmap 1, 200 sample queriesgreedy: add whichever candidate helps the sample most
Fig. 1 Mean cells expanded over the 200 sample queries after each landmark the greedy rule adds, on one map. The first landmark takes the sample from a search with no estimate at all to 360 cells a query, the second to 192, the third to 149 and the fourth to 122. Each step is chosen by evaluating all twenty-five candidates against the whole sample, so the four rounds together run 18,800 searches.

The shape of that descent is the usual one for a greedy set: the first choice buys most, and the fourth is still buying something. Nothing here says four is the right number, and where the landmarks stand found that doubling four to eight bought less than moving four to better cells, so the interesting question was never how many.

The cost is the part worth naming early. Each round evaluates every remaining candidate by rerunning the whole sample, so the preparation runs rounds × candidates × sample searches — four times twenty-five times two hundred, which is eighteen thousand eight hundred A* searches to place four landmarks. The corner rule runs none. A selection procedure whose unit of work is the same as the unit of work it is trying to reduce is a search over searches, and the arithmetic below takes that seriously rather than reporting the placement and stopping.

There is no cheaper way to score a candidate, and that is a property of the estimate rather than an omission. The estimate is a maximum over the landmark tables, so what one landmark contributes depends on what the others already contribute: a cell whose table is excellent on its own adds nothing if a chosen landmark already bounds the same routes tightly. A score computed for a candidate in isolation would therefore be a score for a different rule. The greedy structure is the cheapest thing that respects that dependence, and it still has to run the sample once per candidate per round.

Greedy is also not optimal, and the gap is not bounded here. Choosing the four cells that together minimise the sample’s cost would mean scoring every four-subset of twenty-five candidates — 12,650 of them — at the same cost per score, which is thirteen times the preparation for a placement that is better by an unmeasured amount. Everything below is therefore a statement about the greedy rule and not about what a query log is worth in principle.

Uniform queries: two hundred observations to draw level

The first measurement gives the rule what a query log usually looks like in these experiments — source and goal drawn uniformly from the open cells — and sweeps how many of them it sees. The landmarks it chooses are then judged on 150 fresh queries it has never seen, on each of eight maps.

Landmarks chosen from the queries draw level with the corners at about 200 observed queries, and the gap between the sample and fresh queries closes at the same rateMean cells A* expands on 150 fresh queries, against the number of past queries a greedy landmark selection was allowed to see, on logarithmic axes, averaged over 8 weighted maps of 2,500 cells. The lower solid line is the same tables on the sample they were chosen from, and the distance between the two is what the choice has fitted to the sample rather than to the map. The corner rule and farthest-first read no queries and so are flat. 1 sample queries: 210.7 fresh against 43.3 on the sample, better than the corners on 0 of 8 maps. 2 sample queries: 192.5 fresh against 70.9 on the sample, better than the corners on 0 of 8 maps. 5 sample queries: 183.0 fresh against 89.5 on the sample, better than the corners on 0 of 8 maps. 10 sample queries: 149.3 fresh against 94.3 on the sample, better than the corners on 0 of 8 maps. 20 sample queries: 141.3 fresh against 113.3 on the sample, better than the corners on 0 of 8 maps. 50 sample queries: 130.8 fresh against 114.2 on the sample, better than the corners on 2 of 8 maps. 100 sample queries: 130.1 fresh against 124.0 on the sample, better than the corners on 2 of 8 maps. 200 sample queries: 125.7 fresh against 124.4 on the sample, better than the corners on 3 of 8 maps. Corners 126.3; farthest-first 141.4.125102050100200100observed queries the selection sawcells expanded, meanon fresh querieson the sample it was chosen fromthe cornersfarthest-first8 maps × 150 fresh queriesflat lines read no queries
Fig. 2 Mean cells expanded against the number of past queries the greedy rule saw, on logarithmic axes, averaged over eight weighted maps of 2,500 cells. The upper solid line is 150 fresh queries: 211 cells from one observation, 149 from ten, 131 from fifty, 126 from two hundred. The lower solid line is the same tables on the sample they were chosen from: 43, 94, 114, 124. The two meet as the sample grows, and the corner rule — which sees no queries at all — is the dashed line at 126.3.

The upper curve falls steadily and lands on the corner rule’s line. At one observed query the greedy choice expands 211 cells against the corners’ 126 — two thirds worse than a rule with no information at all — and it is still 12% worse at twenty. It first beats the corners on any map at fifty observations, on two maps of eight, and at two hundred it is at 125.7 against 126.3 and ahead on three maps of eight. That is not a win; it is a draw inside the spread between maps.

The lower curve is why. It is the same four tables, measured on the queries they were chosen to be good at, and at one observation it reads 43 cells against the 211 the same tables cost on queries they have not seen. A landmark chosen to make one route cheap makes that route very cheap indeed: on one map the single sample query cost 8.0 cells with the tables fitted to it and the fresh queries cost 201.9 with the same tables, a factor of twenty-five between what the sample reported and what the rule delivered.

That gap is overfitting with a number on it, and the sweep measures the gap closing rather than taking it on trust. At twenty observations it is 113.3 against 141.3 — the sample still claims a quarter more than the queries deliver. At two hundred it is 124.4 against 125.7, and at that point the sample has stopped being a small set of particular routes and started being a description of the distribution. Anyone choosing a placement from a log and reporting what it cost on the log is reading the lower line and will ship the upper one.

The mechanism is visible in the choices themselves. On one map at five observations the rule picked (10, 0), (1, 36), (49, 37) and (12, 12) — a set with one landmark in the interior and no two of them opposite. Those four cells are behind the five sample routes; they are behind an ordinary share of everything else. At two hundred observations the same map’s rule picked (0, 0), (49, 0), (49, 49) and (0, 49). Nothing in the rule changed between those two runs except how much evidence it had, and the evidence it needed was enough to stop the particular routes from mattering.

What it converges to

The convergence is not approximate.

Landmarks chosen from 200 observed queries land on the corners the map alone would have chosenOne weighted map of 50 × 50 cells with its removed cells dark. Filled circles are the four cells a greedy selection chose after seeing 200 queries, evaluating every one of its 25 candidates against the whole sample at each of four rounds; open rings are the four cells the corner rule picks from the map alone. Greedy: (0, 0), (49, 0), (49, 49), (0, 49). Corners: (0, 0), (49, 0), (0, 49), (49, 49). On 150 fresh queries the greedy tables expand 128.9 cells a query and the corner tables 128.9.chosen from 200 querieschosen from the mapmap 1, 50 × 50dark: removed cells
Fig. 3 One map of 50 × 50 cells with its removed cells dark. Filled circles are the four cells the greedy rule chose after seeing 200 uniformly drawn queries; open rings are the four the corner rule takes from the map alone. The two sets coincide: the greedy rule chose (0, 0), (49, 0), (49, 49) and (0, 49), and on 150 fresh queries its tables and the corner rule’s tables both expand 128.9 cells a query.

Given enough uniform queries, the rule picks the four corners — the same four cells, in a different order, at the same cost per query to the last tenth. Eighteen thousand eight hundred searches were spent discovering a fact about the shape of the map, and the map was available for free.

That is worth stating as a claim about the queries rather than about the rule. A uniform query distribution carries no information the map does not carry, because “uniform over the open cells” is a description of the map. The greedy rule is not failing; it is being asked to extract something from a sample that has nothing in it, and the best it can do is recover what the sample is a sample of. An estimate is a reweighting is the reason the corners are that answer: a landmark repriced map runs downhill to the goal in proportion to how much of the route the landmark sits behind, and on a square with uniform traffic the cells that sit behind the most routes are its extremes.

Queries with a destination

The interesting case is the one a real system is in. Traffic does not scatter. It runs to a station, a depot, a small number of hubs, and a query log then records something about the world that no amount of looking at the map will reveal.

The queries are worth reading only when they are not uniform: 1 destination lets 20 of them beat the corners by 29%, while 20 uniform ones leave the search 12% worseMean cells expanded on 150 fresh queries by four landmarks chosen greedily from 20 observed queries, and by four landmarks at the map's corners, as the queries' destinations are drawn from a shrinking set of cells rather than uniformly. Zero destinations means uniform. Averaged over 8 weighted maps of 2,500 cells. uniform: chosen from the queries 141.3, the corners 126.3, better on 0 of 8 maps. 1 destination: chosen from the queries 105.7, the corners 148.5, better on 8 of 8 maps. 2 destinations: chosen from the queries 98.0, the corners 138.2, better on 8 of 8 maps. 4 destinations: chosen from the queries 123.5, the corners 142.7, better on 6 of 8 maps. 8 destinations: chosen from the queries 142.0, the corners 147.0, better on 5 of 8 maps.050100150uniform1248destinations the queries are drawn fromcells expanded, meanchosen from the queriesthe corners8 maps × 150 queries20 observed queries per selection
Fig. 4 Mean cells expanded on 150 fresh queries by four landmarks chosen from twenty observed queries, and by four landmarks at the corners, as the queries’ destinations are drawn from a shrinking set of cells rather than uniformly, averaged over eight maps. Uniform: 141.3 against the corners’ 126.3, better on none of eight maps. One destination: 105.7 against 148.5, better on all eight. Two: 98.0 against 138.2, all eight. Four: 123.5 against 142.7, six of eight. Eight: 142.0 against 147.0, five of eight.

Twenty queries — the sample size that was 12% worse than the corners under uniform traffic — beats the corners by 29% when every query heads for one cell, and does it on eight maps out of eight. Two destinations is better still, at 98.0 against 138.2. Four destinations begins to give the advantage back, and eight has nearly returned to the uniform case, because eight destinations scattered over a map is most of the way to no destination at all.

Two things move at once across that plate and both matter. The greedy rule improves as the traffic concentrates, which is the expected half. The corner rule gets worse — from 126.3 to 148.5, seventeen per cent — which is the half worth noticing. A rule that reads only the map is not merely uninformed about concentrated traffic; it is mispriced for it, because its landmarks are placed to be behind the average route and concentrated traffic has no average route. The two effects are of similar size, so about half the 29% advantage is the learned rule getting better and about half is the fixed rule getting worse.

The overfitting gap closes at the same time, and that is what makes twenty observations enough. Under uniform traffic twenty queries chosen from left the sample reading 113.3 against a delivered 141.3. Under one destination the same twenty leave the sample reading 100.0 against a delivered 105.7 — a gap of six per cent rather than twenty-five. A sample of twenty routes that all end in the same cell is not twenty accidents; it is twenty draws from a distribution narrow enough that twenty of them describe it, and the rule stops fitting noise because there is much less noise to fit.

With every query heading for one cell, the chosen landmarks leave the corners and stand behind the trafficOne weighted map of 50 × 50 cells with its removed cells dark. Filled circles are the four cells a greedy selection chose after seeing 20 queries, evaluating every one of its 25 candidates against the whole sample at each of four rounds; open rings are the four cells the corner rule picks from the map alone. Greedy: (10, 0), (0, 0), (49, 25), (25, 24). Corners: (0, 0), (49, 0), (0, 49), (49, 49). Every query's destination is one of (12, 7), boxed. On 150 fresh queries the greedy tables expand 93.7 cells a query and the corner tables 113.3.chosen from 20 querieschosen from the mapwhere the queries gomap 1, 50 × 50dark: removed cells
Fig. 5 The same map with every query’s destination drawn from one cell, boxed at (12, 7). The four cells the greedy rule chose after twenty queries are (10, 0), (0, 0), (49, 25) and (25, 24); the corner rule’s four are unchanged. Two of the four now stand on the far side of the destination from most sources, and one has moved into the interior — the placement the rules reading only the map were right to avoid. On 150 fresh queries these tables expand 93.7 cells against the corner tables’ 113.3.

The interior landmark is the detail that makes the point. Where the landmarks stand found that farthest-first selection’s fourth landmark lands in the interior and that this is why it loses on every map, and it is right about uniform traffic. With one destination, a cell near the middle of the map lies behind a large share of the routes that actually occur, and a placement rule that has been told what the routes are can use it. The old finding is not overturned; its precondition has been named.

What the preparation costs, in the unit it saves

A placement is worth what it saves, less what it cost to find. Both are cells expanded, so no exchange rate has to be invented — which is the situation the exchange rate nobody wrote down had to construct by hand for sorting, and which arrives here for free.

The selection costs 18,800 searches at 200 sample queries, to save 0.7 cells a query against a rule that costs noneA* searches spent choosing landmarks, against the number of observed queries the selection is given, on logarithmic axes, averaged over 8 maps. Each round evaluates every one of the 25 candidate cells by rerunning the whole sample, so the count is four rounds times candidates times sample. 1 sample queries: 94 searches, then 84.4 cells a query worse than the corners. 2 sample queries: 188 searches, then 66.2 cells a query worse than the corners. 5 sample queries: 470 searches, then 56.7 cells a query worse than the corners. 10 sample queries: 940 searches, then 23.0 cells a query worse than the corners. 20 sample queries: 1,880 searches, then 15.0 cells a query worse than the corners. 50 sample queries: 4,700 searches, then 4.4 cells a query worse than the corners. 100 sample queries: 9,400 searches, then 3.8 cells a query worse than the corners. 200 sample queries: 18,800 searches, then 0.7 cells a query better than the corners.12510205010020010010³10⁴observed queries in the sampleA* searches spent choosingsearches spent choosing8 maps · 4 rounds × 25 candidateseach candidate is judged by rerunning the sample
Fig. 6 A* searches spent choosing landmarks, against the number of observed queries the rule is given, on logarithmic axes, averaged over eight maps: 94 searches from one observed query, 940 from ten, 9,400 from a hundred and 18,800 from two hundred. The count is four rounds times twenty-five candidates times the sample. The corner rule spends none.

The preparation is linear in the sample and the sample is what the rule needs to stop overfitting, so the two requirements pull against each other. Counting the searches understates it, because a search during selection expands cells like any other; counted in cells the same selections cost between 47,000 and 4.9 million.

Choosing landmarks from twenty queries to one destination pays for itself after 9,700 queries; from two hundred uniform ones, after 7,506,664Cells expanded during the greedy selection, divided by the cells it saves per fresh query against the corner rule — the number of queries after which the choice has paid for itself, in the unit it saves. Averaged over 8 maps. uniform, 200 observed: 4,941,887 cells spent choosing, 0.7 saved a query, paid back after 7,506,664 queries. 1 destination, 20 observed: 415,099 cells spent choosing, 42.8 saved a query, paid back after 9,700 queries. 1 destination, 200 observed: 4,020,655 cells spent choosing, 45.9 saved a query, paid back after 87,628 queries. 2 destinations, 20 observed: 409,846 cells spent choosing, 40.2 saved a query, paid back after 10,202 queries.uniform, 200 observed7,506,6641 destination, 20 observed9,7001 destination, 200 observed87,6282 destinations, 20 observed10,202queries before the choice has paid for itself8 maps × 150 fresh queriesboth sides counted in cells expanded
Fig. 7 Cells expanded during the greedy selection, divided by the cells it saves per fresh query against the corner rule — the number of queries after which the choice has paid for itself. Uniform traffic, 200 observed queries: 4,941,887 cells spent, 0.7 saved a query, paid back after 7,506,664 queries. One destination, 20 observed: 415,099 spent, 42.8 saved, paid back after 9,700. One destination, 200 observed: 4,020,655 spent, 45.9 saved, paid back after 87,628. Two destinations, 20 observed: 409,846 spent, 40.2 saved, paid back after 10,202.

The two numbers at the ends of that plate are three orders of magnitude apart, and they are the answer to the question the placement essay left open. Under uniform traffic the rule is not merely a draw; it is a draw that costs seven and a half million queries to reach, which for any system that answers fewer than that is a permanent loss. Under concentrated traffic it pays for itself after ten thousand queries, which a routing service reaches in an afternoon.

And the sample size that pays best is not the largest affordable one. Twenty observed queries to one destination pay back after 9,700 queries; two hundred pay back after 87,628, and buy 3.1 cells a query for ten times the preparation. The threshold somebody chose found the same shape in four tuning constants written into real sorting code: the curve near the optimum is flat, so the setting that matters is the one on the steep side, and here the steep side is the small sample.

Why the corners are hard to beat and easy to beat

The two halves of this page look contradictory and are not. An estimate is a reweighting gives the account that covers both. A landmark estimate is a potential, A* under it is Dijkstra on repriced arcs, and a placement is good to the degree that it makes the arcs along the routes that occur run downhill.

Under uniform traffic “the routes that occur” is every route, so the best placement is the one that makes the map steepest on average, and that is a question about the map’s geometry with a known answer. Under traffic to one destination, “the routes that occur” is a pencil of routes converging on one cell, and the steepest repricing for that pencil is a different placement — one that a rule looking at the geometry cannot name, because the geometry does not contain the destination.

So the amount a query log is worth is the amount by which the traffic differs from the map’s own symmetry. That quantity is measurable before any landmark is placed, and it is the thing a system should look at first. The plate against destinations is a crude sweep of it: at eight destinations the traffic has nearly recovered the map’s symmetry and the query log has nearly stopped being worth reading.

It also explains why the advantage is not monotone in how much is known. The greedy rule at two hundred uniform observations knows the query distribution almost exactly, and what it knows is worthless, because the distribution it has learned is the one the map already implies. Information is worth what it adds to what is already held, and a landmark rule already holds the map. The count somebody chose made the same point about measurement rather than about estimation: six counts of the same run rank ten sorting algorithms six different ways, and the count worth taking is the one that distinguishes the cases at hand rather than the one that is most precise.

What a system with a log should actually do

Three of the numbers above are enough for a decision, and none of them requires placing a landmark.

Measure the concentration first. Sampling the query log and looking at how far the destinations spread costs nothing next to a single selection round. If the destinations are as spread as the open cells, the plate against destinations says the log is worth nothing here and the corners are the answer — free, immediate, and better than the alternative by a margin no sample size recovers.

If the traffic is concentrated, take a small sample. Twenty observed queries to one destination beat the corners by 29% and repay their preparation after 9,700 queries. Two hundred beat them by 31% and repay after 87,628. The extra 3.1 cells a query cost nine times the preparation, which is the flat-bottom shape the flat bottom of a shallow curve found in a different parameter entirely: near the optimum the objective barely moves, so the setting to argue about is the one on the steep side, and here that is the difference between one observation and twenty rather than between twenty and two hundred.

Report the cost on queries the choice has not seen. The lower line on the first plate is the number a selection procedure hands back if it is asked what it achieved, and it is 25% optimistic at twenty observations and a factor of twenty-five optimistic at one. A placement is worth reporting only against queries it was not fitted to.

What is not measured here

One family of maps. Every map is 50 × 50 with 28% of its cells removed and step costs from one to nine. A map with a genuine road network — long corridors, few junctions — would change what a corner is worth and probably narrow the gap, since a corridor map has few distinct routes whatever the query distribution.

A destination set that does not move. The hubs are fixed for the whole run, so the sample and the fresh queries are drawn from the same distribution. A system whose traffic shifts between morning and evening is choosing landmarks from a log that describes a distribution it will not face, and the preparation would have to be repaid each time it shifted. The break-even figures above are therefore best cases for the learned rule.

Four landmarks and twenty-five candidates. The candidate lattice is coarse enough that the greedy rule is choosing between twenty-five cells, not 1,800. A finer lattice would find better placements and multiply the preparation by the same factor, which moves both numbers in the payback calculation in the same direction and makes the break-even worse, not better.

Greedy, not optimal. Nothing here computes the best four cells. A greedy set can be arbitrarily worse than the best set, and the plate showing each round’s gain is consistent with a fourth landmark that a different first choice would have made redundant.

Cells expanded, not time. The unit throughout is cells expanded, as the cells are not the cost argued it should not be taken to be. Four landmark tables over 2,500 cells are 10,000 exact distances held in memory, and measuring what an algorithm keeps is the argument for reporting that second axis: every placement on this page holds exactly the same amount, so the comparison is fair, and the comparison with a system holding no tables at all is not made here.

Still open: a rule that knows when to stop reading the log

The break-even arithmetic assumes the selection runs once and the placement is kept. A system whose traffic drifts faces a schedule instead: reread the log, rechoose, pay the preparation again. The plate against destinations says what is at stake — a placement fitted to one destination is worth 29% on that destination and is presumably worth less than the corners on a different one — but nothing here measures what it is worth after the traffic has moved.

The measurement that follows fixes a placement from a log with one destination, then moves the destination by a stated distance and asks how the advantage over the corners decays with that distance; and then, on a stream whose destination drifts continuously, prices two policies against each other — rechoose every so many queries, and rechoose when the mean cells expanded rises by a stated fraction above what the placement achieved when it was new. The second needs no drift model and costs one counter, and the question is how much of the first’s advantage it keeps. That is the question a system with a query log actually has, and neither plate on this page answers it.

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.

Break-evenGreedy algorithmHeuristic searchLandmarkOverfittingParameter choicePotential functionPreprocessingQuery distributionSamplingShortest pathTriangle inequality