Paris to London¶
Ten million grains of sand are spread along the streets of Paris, and ten million along the streets of London. Which grain of Paris should go to which point of London so that the grains travel the least, in the squared distance sense? With \(x_i\) the grains of Paris and \(y_j\) the points of London, \(n = 10^7\), this is the assignment problem
over the \(n!\) permutations \(\sigma\): \(n^2 = 10^{14}\) candidate pairs, solved exactly.
Ctrl + scroll (or pinch) zooms on a street, a drag pans. Open the viewer in full screen or watch the film (MP4, 12 s).
Every grain moves in a straight line from its place in Paris to the place in London that the optimal assignment gives it: this is the displacement interpolation between the two cities. The viewer runs in your browser and loads the assignment itself (20 MB), not a rendering of it.
The problem¶
Both maps are squares of 6 km, north up, centered on the Seine by the Pont Neuf and on the Thames by Waterloo Bridge. The streets come from OpenStreetMap; each street segment receives grains in proportion to its length times a width set by the class of the road (motorway, primary, residential, ...), spread along the segment and across that width. Each city gets exactly \(10^7\) grains of unit mass, so the optimal plan is a permutation.
The two clouds are far from the random point clouds of the performance page: the points lie on lines, in dense clusters, with large empty blocks in between, and the two street networks have nothing in common. Many plans have nearly the same cost, which makes the problem hard for any exact solver.
The result¶
| Grains per city | 10,000,000 |
| Status | optimal, primal and dual values equal |
| Root mean square displacement \(\sqrt{\tfrac1n \sum_i \lvert x_i - y_{\sigma(i)} \rvert^2}\) | 201.87 m |
| The same, with the grains matched cell by cell on a \(256 \times 256\) grid | 203.12 m |
| Solver time | 5,078 s (1 h 25 min) on 2 × AMD EPYC 9655, 192 threads |
| Peak memory | 31 GB |
The assignment was computed by the solver deblais grew from (same algorithm, before the auctions on assignment problems), and checked independently: every point of London is used once, and the cost recomputed from the coordinates matches the reported one.
Reproduce it¶
examples/paris_london.py rebuilds the two
clouds from the data of the viewer and solves the assignment with deblais.
Keeping one grain in 100 gives a problem of \(10^5\) points per city:
$ python examples/paris_london.py --stride 100
100,000 grains per city, 4 threads
optimal in 3.31 s (decomposition), rms displacement 201.93 m
$ python examples/paris_london.py --check
published assignment: mean squared displacement 4.861826e+06, rms 201.87 m
--stride 1 solves the full problem; it needs about 30 GB of memory and a
large machine.
Data¶
The street networks and the data derived from them (the grains and the assignment) are distributed under the Open Database License 1.0. © OpenStreetMap contributors, via OpenFreeMap and OpenMapTiles. The fonts of the viewer, Instrument Serif and IBM Plex Mono, are under the SIL Open Font License 1.1.