Two parameters

A placement after the traffic moved

Four landmarks fitted to twenty queries that all end at one cell expand two thirds of the corners' cells there. Move the destination ten cells and the advantage is gone; move it thirty and the fitted placement expands nearly twice the corners' cells. Choosing again costs 317,000 cells of search — the saving of 8,600 queries — so on streams whose destination drifts, a policy that refits on a counter never beats fitting once and keeping the result, and past a drift of about ten cells nothing fitted beats the corners.

Where the landmarks stand turned a weak straight-line estimate — an estimate borrowed from an easier problem — into a strong one with four tables of exact distances, each from a chosen cell. A search guided by the tables expands a fraction of the cells. Which cells hold the tables matters a great deal: the map’s four corners beat four cells near the centre by more than three to one.

What the queries know that the map does not asked whether a system’s own query log could choose better. It chose greedily, adding whichever candidate cell most reduced the cells a sample of past queries expanded. On uniform traffic the log converged on the corners and never beat them. When every query headed for one destination, twenty queries were enough to beat the corners by 29%.

It ended on the question a real system would ask next. A placement fitted to one destination is worth something at that destination, and traffic moves. How much is the placement worth after it has moved, and when should the system choose again?

The placement being moved

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. 1 One weighted map of 50 by 50 cells. Filled circles are four landmarks a greedy selection chose from 20 queries that all end at the boxed cell (12, 7); open rings are the corners. On 150 fresh queries to that cell the chosen tables expand 93.7 cells a query and the corner tables 113.3.

The selection moves two landmarks off the corners and towards the destination. That is what a landmark near a destination is for. The estimate of the distance to the goal is strongest when some landmark lies behind the goal, as seen from where the search starts, and a landmark next to the goal is behind it from almost everywhere.

The plates below use eight such maps with a different destination each, and a fitted placement for each. On its own destination, averaged over the eight, the fitted placement expands 73.1 cells a query where the corners expand 109.9: two thirds.

How quickly the advantage goes

Move the destination, keep the landmarks, and run fresh queries to the new destination with both placements.

Fitted to one destination, four landmarks expand 0.665 of the corners' cells there, draw level about 10 cells away, and expand 1.92 times as many 32 cells awayFour landmarks chosen greedily from 20 queries that all end at one cell, on each of 8 weighted terrain maps of 2,500 cells, then run on 40 fresh queries to a destination moved a stated distance in 6 directions, against the four corners on the same queries. At the fitted destination: 0.665 of the corners' cells, worse than the corners in 0 of 8 cases. Moved 2.5 cells: 0.754 of the corners' cells, worse than the corners in 7 of 48 cases. Moved 5.1 cells: 0.834 of the corners' cells, worse than the corners in 11 of 48 cases. Moved 9.9 cells: 1.005 of the corners' cells, worse than the corners in 25 of 48 cases. Moved 14.5 cells: 1.161 of the corners' cells, worse than the corners in 32 of 48 cases. Moved 18.9 cells: 1.343 of the corners' cells, worse than the corners in 34 of 48 cases. Moved 26.0 cells: 1.672 of the corners' cells, worse than the corners in 41 of 48 cases. Moved 31.7 cells: 1.923 of the corners' cells, worse than the corners in 42 of 48 cases. The line at one is the corners.0.50011.5020102030cells the destination moved from the one the landmarks were fitted tocells expanded, fitted placement ÷ cornersthe corners0/87/4811/4825/4832/4834/4841/4842/48digits: cases worsethan the corners8 maps, 6 directions a distancebelow one the fit is still worth having
Fig. 2 Cells expanded by the fitted placement as a share of the corners’, on queries to a destination moved a stated distance from the one the landmarks were fitted to, over 8 maps and 6 directions a distance. At the fitted destination: 0.665. Moved 2.5 cells: 0.754. Moved 5.1: 0.834. Moved 9.9: 1.005 — level. Moved 18.9: 1.343. Moved 31.7: 1.923, worse than the corners in 42 of 48 cases.

The advantage halves in about five cells and is gone at ten. A fifth of the map’s width is enough to make the fitted placement exactly as good as the corners, averaged over directions. At that distance it is worse than the corners in half the cases, because a landmark that stood behind the old destination may stand in front of the new one. Past ten cells the fitted placement is worse on average, and at thirty cells it expands nearly twice the corners’ cells.

That is steeper than the fitting suggested. The selection chose landmarks that make the estimate to one particular cell sharp, and sharpness at one cell is bought by leaving the rest of the map to the two landmarks the selection did not move. The corners are a hedge: they are never the best placement for any one destination and never far from the best for any.

What choosing again costs

A system whose destination has moved can choose again, from the queries it has seen since. The previous essay measured what a greedy selection costs to run, and the same cost is the one that decides everything here.

Choosing four landmarks from twenty queries expands 317,383 cells on average; at its own destination the choice saves 36.8 cells a query, so it repays itself after 8,630 queriesThe cells a greedy selection expands while choosing four landmarks — every remaining candidate of twenty-five, tried against all twenty observed queries, four rounds — on each of 8 maps: map 1, 245,153; map 2, 225,208; map 3, 443,228; map 4, 276,772; map 5, 345,810; map 6, 336,775; map 7, 458,345; map 8, 207,772. At the destination it was fitted to, the fitted placement expands 73.1 cells a query against the corners' 109.9, a saving of 36.8. The selection is repaid after 8,630 queries to that destination, and only if the destination has not moved in the meantime.map 1245,153map 2225,208map 3443,228map 4276,772map 5345,810map 6336,775map 7458,345map 8207,772cells expanded choosing four landmarksrepaid after 8,630 queries at a saving of 36.8 cells each25 candidates × 20 queries × 4 roundsthe candidates' tables are not charged
Fig. 3 Cells expanded by one greedy selection of four landmarks from twenty observed queries — every remaining candidate of twenty-five tried against every observed query, four rounds — on each of 8 maps: from 207,772 to 458,345, 317,383 on average. At its own destination the choice saves 36.8 cells a query over the corners, so it is repaid after 8,630 queries.

A selection expands about 317,000 cells, which is the work of answering some 2,900 queries with the corners. It is the trade the rule that pays on a long enough text measured for string matchers — a preparation repaid only if enough work follows it — except that here the preparation has to be paid for again whenever the traffic moves. At the destination it was fitted to, it saves 36.8 cells a query over the corners, so it needs 8,630 queries at that destination to pay for itself. The decay plate says how long that is likely to take. The saving halves when the destination has moved five cells, so a selection is repaid only if the destination stays within a few cells for something like ten thousand queries.

The cost is almost all in trying candidates. Each of four rounds tries every remaining candidate against every one of the twenty sample queries: about 1,900 searches, at about 170 cells each. The tables themselves are not charged here, and neither is their memory, the second axis measuring what an algorithm keeps argued a structure should be priced on. A table is a full search from a candidate cell, and the twenty-five candidates’ tables are computed once and kept, so only the first selection on a map would pay for them. Charging them would make every selection dearer by the same amount and would not change the ranking below.

Four policies on streams that drift

The destination now drifts. Before each query it steps to a random neighbouring cell with a stated probability, so over 30,000 queries it wanders a distance that grows with that probability. Four policies share the same queries.

  • The corners, never fitted and never charged anything.
  • Fitted once, kept: fitted to the first twenty queries, never refitted.
  • Refitted every 10,000 queries, to the twenty most recent.
  • Refitted on a counter: after each fit it measures the mean cells of the next 2,000 queries, then refits whenever the mean of the last 2,000 exceeds that baseline by half.

Every policy is charged the cells its queries expand and the cells each of its selections expands.

On streams of 30,000 queries, fitting once and keeping the result is cheapest until the destination drifts about 10 cells; past that the corners are; refitting is never cheapestCells expanded per query, including the cells every landmark selection expanded, for four policies on streams of 30,000 queries whose destination steps to a neighbouring cell with a stated chance before each query, averaged over 4 maps and walks. At 0 (the destination ends 0.0 cells from its start): the corners, never fitted 120.3, fitted once, kept 83.1, refitted every 10,000 104.5, refitted on a counter 83.1; the counter refitted 1.00 times on average. At 0.001 (the destination ends 3.3 cells from its start): the corners, never fitted 139.3, fitted once, kept 103.3, refitted every 10,000 131.8, refitted on a counter 128.4; the counter refitted 2.25 times on average. At 0.003 (the destination ends 4.8 cells from its start): the corners, never fitted 150.9, fitted once, kept 114.6, refitted every 10,000 140.4, refitted on a counter 126.9; the counter refitted 2.00 times on average. At 0.01 (the destination ends 9.8 cells from its start): the corners, never fitted 143.9, fitted once, kept 108.5, refitted every 10,000 141.3, refitted on a counter 125.2; the counter refitted 2.25 times on average. At 0.03 (the destination ends 23.3 cells from its start): the corners, never fitted 153.2, fitted once, kept 195.6, refitted every 10,000 158.3, refitted on a counter 190.6; the counter refitted 3.25 times on average.050100150200cells a query, selections included00.0010.0030.010.030.0 cells3.3 cells4.8 cells9.8 cells23.3 cellschance the destination steps to a neighbouring cell before each querythe corners, never fittedfitted once, keptrefitted every 10,000refitted on a counter4 maps, 30,000 queries a streamsecond row: how far the destination ended up
Fig. 4 Cells per query, selections included, over streams of 30,000 queries, averaged over 4 maps, against the chance the destination steps before each query — with how far it ended up from its start beneath. With no drift: corners 120.3, one fit 83.1, periodic refits 104.5, the counter 83.1. At 0.01, ending 9.8 cells away: 143.9, 108.5, 141.3 and 125.2. At 0.03, ending 23.3 cells away: 153.2, 195.6, 158.3 and 190.6.

At no drift rate does a policy that chooses again come out cheapest. Up to a drift of 0.01, which takes the destination about ten cells over the stream, fitting once and keeping the result is the cheapest policy: 83.1 cells a query with no drift and 108.5 at 0.01, against the corners’ 120.3 and 143.9. At 0.03 the destination wanders more than twenty cells and the one fit is far out of place. It then costs 195.6 against the corners’ 153.2, and the corners are cheapest. The periodic policy and the counter lie between the two at every rate, except that with no drift the counter matches the one fit.

Why one fit survives so much drift is worth a sentence, because the decay plate seems to say it should not. At a drift of 0.01 the destination ends about ten cells from where it started, which is exactly where the decay plate puts the fitted placement level with the corners. But it gets there gradually. For most of the stream it is a few cells away, where the fit is still clearly ahead, and the average over the stream is dominated by those queries. A random walk covers distance slowly: in two dimensions a displacement of dd cells takes on the order of d2d^2 steps. So at 0.01 steps a query, five cells of drift takes a couple of thousand queries, and ten cells ten thousand.

The periodic policy is the worst of the four at every drift rate but the last, and for a plain reason. It pays for three selections a stream whether or not anything has changed, about ten cells a query each. Its queries are not even cheaper than the one fit’s at 0.01 — 107.7 against 98.7 — because a refit to the twenty most recent queries of a moving destination fits a place the destination is about to leave.

With no drift at all the counter never fires. Its baseline after the first fit is the stream’s own level, nothing raises it, and the counter costs exactly what fitting once costs. That is the one row where it is as good as the best.

Where the counter’s cost goes

The counter does what it was built to do. It notices that its queries have become dearer and it restores them. It pays for that at a price the stream cannot repay.

At a drift of 0.01, the counter's queries cost 97.2 cells against keeping one fit's 98.7, and its selections add 27.9 a queryCells per query split into what the queries expanded and what the landmark selections expanded, for each policy, at a drift of 0.01 — the destination ends 9.8 cells from its start over 30,000 queries — averaged over 4 maps. The corners, never fitted: queries 143.9, selections 0.0, 0.00 selections a stream; Fitted once, kept: queries 98.7, selections 9.8, 1.00 selections a stream; Refitted every 10,000: queries 107.7, selections 33.6, 3.00 selections a stream; Refitted on a counter: queries 97.2, selections 27.9, 2.25 selections a stream.the corners, never fitted143.9fitted once, kept108.5refitted every 10,000141.3refitted on a counter125.2the querieschoosing the landmarksdrift 0.01, 4 mapscells a query
Fig. 5 Cells per query at a drift of 0.01, split into what the queries expanded and what the selections expanded, averaged over 4 maps. The corners: 143.9 and nothing. One fit kept: 98.7 and 9.8, for one selection. Refitted every 10,000: 107.7 and 33.6, for three. Refitted on a counter: 97.2 and 27.9, for 2.25 selections a stream.

The counter’s queries are the cheapest of the four, 97.2 cells a query against the one fit’s 98.7. Its refits did keep the landmarks near the traffic. But each refit costs about 10 cells a query spread over a 30,000-query stream, and the counter made more than two of them on average. What the refits recovered on the queries, one and a half cells a query, is a sixth of what one refit costs.

The arithmetic is the price plate’s arithmetic in another form. A refit costs as much as 8,630 queries at the full saving, and the saving it restores is partial and decays within a few cells. For a refit to pay, the destination must move far enough to spoil the old fit and then stay put long enough to repay the new one. On these streams it does neither for long.

One stream, drawn

One stream at a drift of 0.01: the counter refitted 4 times after its first fit, and the destination ended 8 cells from where it beganCells expanded per query on one map, as the mean of each block of 500 queries, for the corners, for one fit kept, and for the counter policy, which refits when the mean of its last 2,000 queries exceeds by half the mean it measured after its last fit. Its fits came at queries 20, 6,819, 10,391, 13,932, 24,069. The destination's distance from its starting cell, every 500 queries, reached 11 cells and ended at 8. Over the stream: corners 113.9, one fit 96.4, the counter 151.1 cells a query, selections included.050100150200queries into the streamcells a query, mean of each 500010,00020,00030,000the cornersfitted oncerefitted on a counterdrift 0.01, one map, dashed: the counter's fitsdestination ended 8 cells away
Fig. 6 One map at a drift of 0.01, cells a query as the mean of each 500 queries: the corners, one fit kept, and the counter policy with its fits dashed — at queries 20, 6,819, 10,391, 13,932 and 24,069. The destination wandered up to 11 cells and ended 8 from its start. Over the stream, selections included: corners 113.9, one fit 96.4, the counter 151.1.

This is the stream that shows the counter at its worst, and it is worth seeing why. The destination wanders away and partly back. Each time it wanders, the counter’s rolling mean rises past its threshold, and it refits to the twenty most recent queries. Twenty queries is a small sample, and some of those refits are fitted to where the destination happened to be for a few hundred queries. Four refits after the first fit left it 55 cells a query dearer over the whole stream than the one fit kept. The one fit kept was never updated, and it is close enough to wherever the destination wanders here to beat the corners over the stream as a whole.

The refits are not bad because their samples are bad. Twenty queries was the sample the earlier essay found enough to beat the corners at a fixed destination. At a drift of 0.01 the destination moves once every hundred queries or so, so the twenty most recent queries almost always share one destination, and each refit is a good fit to where the traffic was. The trouble is only that the traffic does not stay there. A refit is a bet on the destination’s future, placed with evidence about its present.

The counter needs no model of how the traffic drifts, which was the reason for proposing it. What it lacks is a model of what it costs to act. A rise in cost of a half says that the landmarks are no longer where the traffic is. It says nothing about whether the new traffic will stay put long enough to repay 317,000 cells.

What the rule needs to know

The measurements point to the rule a system actually needs, and it is not a better detector. It is a price. A refit should happen when the saving it is expected to recover, summed over the queries until the next refit, exceeds what it costs. Both halves are measurable from the log a system already keeps. The saving is the gap between the current mean and the mean just after the last fit. The horizon is how long the destination has stayed put in the past, which a system can read from the same log.

Against a price of 317,000 cells, that rule would refit rarely on these streams, if at all. The decay plate puts the useful life of a fit at a few cells of movement. At a drift of 0.01 a few cells take a couple of thousand queries, well short of the 8,630 a refit needs. At 0.001 they take tens of thousands, but on those streams the destination never moved far enough to spoil the first fit, so there was nothing for a refit to recover.

The numbers make the rule concrete. A fresh fit saves about 37 cells a query at its own destination, and the saving halves once the destination has moved five cells. At a drift of 0.03 steps a query, five cells of random walk take roughly 25 steps, about 800 queries. A refit therefore recovers something like 37 cells over 800 queries before its advantage halves, around 30,000 cells, against a price of 317,000. It cannot pay, however well it is timed. At 0.001 steps a query the same five cells take about 25,000 queries, and a refit made at the right moment would recover several times its price. At that rate, though, the first fit is still good by the end of a 30,000-query stream, and there is nothing to refit for.

Between those rates is a band where a well-timed refit could pay, and the counter is not a way of finding it. It measures whether the current landmarks have got worse. The rule needs to know whether new ones would stay good for long enough, and that is a question about the traffic’s future, answerable only from how the traffic has moved in the past.

That also points to the other lever, the price itself. The selection tries twenty-five candidates against twenty queries four times over. A selection that tried only the candidates near the new destination, or reused the three landmarks that are still useful and re-chose one, would cost a fraction of that. Everything on the policy plate would then move. The finding here is not that refitting is wrong. It is that at this selection’s price, on this traffic, refitting does not pay, and the counter cannot tell.

The same trade, one layer down

A potential mended where it broke met the same shape of problem in a different structure. A stored reweighting on a graph with negative arcs is a preparation that makes every later query cheaper, and updates to the graph spoil it. How long a reweighting stays true priced the rebuild. There the cure was not to rebuild but to mend: relax only the arcs that broke and propagate from them, at a small fraction of a rebuild. That turned a stored potential from something that stopped paying once half a per cent of arcs changed into one that stayed at about two thirds of the per-query cost at every rate of change measured.

The landmark selection has no mend yet. Every refit on this page starts from nothing: it forgets the four landmarks it had, including the two corners it kept, and re-derives them at full price. That is the equivalent of rebuilding the reweighting from the virtual source every time one arc fell. The earlier essay’s lesson was that the price of a repair is a design choice, and a preparation whose repair costs as much as its construction is one whose maintenance question has already been answered.

The limits of the measurement

One kind of drift. The destination takes a random walk. A destination that jumps — a new popular place replacing an old one — spoils a fit at once and then stays put, which is exactly the case where a refit pays. The counter would catch the jump within 2,000 queries. Nothing here measures it.

One destination at a time. Real traffic has several, with weights that shift. The previous essay found that a handful of destinations still lets a fitted placement beat the corners, and a drifting mixture is the natural extension.

The selection’s own choices. Twenty sample queries, twenty-five candidates, four landmarks, and a threshold of a half on a window of 2,000. Each is a constant somebody chose, in the sense of the threshold somebody chose. The threshold and the window decide how often the counter fires, and the sample size decides how good each refit is, and none of them was swept here.

Cells, not time. The unit throughout is cells expanded, which the cells are not the cost warned is not the same as time.

Checked answers. On the decay plate every search’s result is checked against the exact distance. The stream plates run the same search without the check, which is admissible whatever the placement, so a wrong landmark table would change the cells expanded and not the answers.

Still open: a refit that re-chooses one landmark

The selection is expensive because it starts from nothing. After a drift, some of the old landmarks are still useful — the corners the selection kept are useful to every destination — and only the ones that were moved towards the old destination have gone stale.

The measurement that follows gives the counter a cheaper action. When it fires, it keeps three of the four landmarks and re-chooses only the one whose removal costs the recent queries least, trying each candidate against the recent sample once. That is a twelfth of a full selection’s searches. It measures the same four policies with this incremental refit alongside, on the same drifting streams and on a stream whose destination jumps. The prediction is that an incremental refit pays at drifts where a full one does not, because its price falls below the saving it recovers within a few thousand queries. On the jumping stream a counter with an incremental refit should beat fitting once. What the drifting streams will show is less certain, and it is the part worth measuring.

Named alongside this one

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

The objects this essay names

Each one links to every other essay that touches it.

Break-evenHeuristic searchHonest limitLandmarkMeasurement designOverfittingParameter choicePreprocessingQuery distributionRegimeSamplingShortest path