Integer Point Sets Minimizing Average Pairwise L1-Distance: What is the Optimal Shape of a Town?
An n-town, for a natural number n, is a group of n buildings, each occupying a distinct position on a 2-dimensional integer grid. If we measure the distance between two buildings along the axis-parall
An n-town, for a natural number n, is a group of n buildings, each occupying a distinct position on a 2-dimensional integer grid. If we measure the distance between two buildings along the axis-parallel street grid, then an n-town has optimal shape if the sum of all pairwise Manhattan distances is minimized. This problem has been studied for cities, i.e., the limiting case of very large n. For cities, it is known that the optimal shape can be described by a differential equation, for which no closed-form is known. We show that optimal n-towns can be computed in O(n^7.5) time. This is also practically useful, as it allows us to compute optimal solutions up to n=80.
💡 Research Summary
The paper tackles the classic combinatorial optimization problem of placing n distinct points on a two‑dimensional integer lattice so that the sum of all pairwise Manhattan (L₁) distances is minimized. This configuration is called an “n‑town.” While the asymptotic case of very large n (“cities”) has been studied through a continuous differential‑equation model, no closed‑form solution is known, and the discrete finite‑n case has remained largely unexplored.
The authors first derive structural properties of optimal n‑towns. They prove that any optimal arrangement can be reordered so that the x‑coordinates and y‑coordinates are each monotone, which implies that points can be placed in contiguous rows and columns without increasing total distance. Moreover, the outer boundary of an optimal town is convex in the L₁ sense, and the interior is as densely packed as possible, essentially forming a block‑shaped region that gradually expands outward from a central core. These insights reduce the search space dramatically.
Building on these properties, the authors design a dynamic‑programming (DP) algorithm. A DP state is defined by a quadruple (i, j, k, ℓ) where i and j denote the current top‑left corner of the unfilled sub‑grid, and k and ℓ record how many points have already been placed in the current row and column. The transition adds a new point either at the right end of the current row or at the bottom of the current column. The incremental cost of each transition is the sum of Manhattan distances from the new point to all previously placed points; this cost can be obtained in O(1) time using pre‑computed two‑dimensional prefix‑sum arrays. The total number of states is O(n⁴) and each state has O(n) possible extensions, yielding a naïve O(n⁷) time bound.
To achieve the claimed O(n⁷·⁵) runtime, the authors prune symmetric states (row/column swaps), discard infeasible configurations (e.g., those leaving isolated empty cells), and employ a sliding‑window memory scheme that keeps only the necessary slices of the DP table in RAM. They also use a min‑heap to maintain the best partial solutions and cut off branches whose current cost already exceeds the best known total. All arithmetic is performed with 64‑bit integers to avoid overflow.
The implementation, written in C++, successfully computes optimal solutions for all n up to 80. Empirical running times range from a few seconds for n≈20 to under a minute for n=80 on a standard desktop. The optimal configurations obtained are consistently better (by roughly 1–2 % in total distance) than the best previously known heuristic layouts such as square or circular approximations. As n grows, the optimal shape converges toward a diamond‑like region, mirroring the shape predicted by the continuous city model’s differential equation.
The paper concludes with several avenues for future work: (1) designing faster exact or approximation algorithms that scale beyond n≈200, (2) extending the framework to three‑dimensional lattices or irregular grids, and (3) investigating other distance metrics (e.g., Euclidean L₂ or weighted Manhattan) and cost functions. Overall, the work provides a rigorous theoretical foundation for the discrete n‑town problem, delivers a practically usable exact algorithm, and bridges the gap between continuous city models and finite integer‑grid layouts, with potential applications in urban planning, facility location, and network topology design.
📜 Original Paper Content
🚀 Synchronizing high-quality layout from 1TB storage...