How the grid moved a hub in a constructed case
Fixed H3 moved one of the three hubs and raised cost by 14.77% on the original points. Spread-based refinement recovered the point-level plan. The views share the same demand input, candidate sites, and map extent. Larger demand marks carry more weight.
- Demand
- Candidate site
- Selected hub
- H3 boundary, when shown


Results for the mapped case
Split-cell fixture, seed 271. Costs and p95 are scored on all 203 original points. A solver gap applies to its own model. Scroll the table to see all columns on a narrow screen.
| Method | Buckets | Hubs | Cost (demand-unit km) | p95 (km) | Total (s) | Gap |
|---|---|---|---|---|---|---|
| Raw demand | 203 | West, North, South | 2,328.46 | 6.96 | 0.056 | 0% |
| Fixed H3 | 23 | Middle, North, South | 2,672.34 | 4.95 | 0.035 | 0% |
| Adaptive H3 | 23 | West, North, South | 2,328.46 | 6.96 | 0.016 | 0% |
| Weighted k-means | 23 | West, North, South | 2,328.46 | 6.96 | 0.110 | 0% |
| Adaptive H3 (volume) | 23 | West, North, South | 2,328.46 | 6.96 | 0.016 | 0% |

Why the constructed case moved a hub
In the mapped case, fixed H3 chose Middle where the point-level and spread-based adaptive plans chose West. Two lobes with unequal demand shared one H3 bucket. Replacing both with their weighted centroid made a candidate near that centroid attractive. On the original points, that choice moved total cost from 2,328.46 to 2,672.34 demand-unit km. The weighted p95 fell from 6.96 to 4.95 km, so the move improved the tail while increasing the objective. This is the largest fixed-H3 change among the three deliberately constructed split-cell cases.
How the comparison works
Each instance chooses three hubs from the same fixed candidates for all methods. The uncapacitated discrete p-median objective is the sum of each point’s demand weight times its straight-line distance to the closest open hub. The solver, time limit, and target gap stay fixed. Every chosen plan is then scored on the original points, including p95, the smallest distance that covers at least 95% of the demand weight. This follows the long-standing distinction between solving an aggregated location model and evaluating its decisions on disaggregated demand. Goodchild (1979) · Irawan, Salhi and Scaparra
Fixed H3 rolls resolution-8 indexes up to resolution 6 and puts one weighted centroid in each occupied bucket. Adaptive H3 starts at resolution 5 and splits selected buckets down to resolution 8. All aggregated methods get the same number of representatives as fixed H3 in each case. The volume rule splits by total demand. The spread rule splits by the sum of each point’s weighted distance to its bucket centroid. Weighted k-means gives a grid-free baseline with the same number of representatives. H3 parent-child membership is logical, so boundaries across levels are approximate on the map. H3 hierarchy · Cebecauer and Buzna (2017) · scikit-learn K-means
What held across the seven cases
- Four regional seeds. Fixed H3 matched the raw hubs in three cases. In the fourth, it changed a hub and raised cost by 0.57%.
- Three constructed split-cell seeds. Fixed H3 changed a hub in each case and raised cost by 13.06–14.77%. Spread-based adaptive H3 and weighted k-means recovered the raw hubs in all seven cases.
- Spread versus volume. At identical bucket counts, spread won four cases on point-level cost and tied three. Its median total runtime was 0.032 s, compared with 0.028 s for fixed H3, 0.147 s for weighted k-means, and 0.317 s for raw demand. These are single-machine timings and include aggregation, model construction, solving, and scoring.
All 35 solves reported a 0% solver gap for their own models. A zero gap can certify a bucket-model result while the chosen hubs still score worse on the original points. On a small instance the MILP also picked the same two hubs as exhaustive enumeration of all six candidate pairs. The seven synthetic cases use straight-line distance and a fixed set of candidate sites. They show how refinement can help when a bucket hides a lobe of demand. SciPy MILP and HiGHS
Test the idea on the Madison road model
For the separate road study, 3,473 Madison-area Census block points stand in for demand, weighted by population. Candidate sites are illustrative. Travel times come from a bidirectional road graph with assumed speeds. The road study uses the same three-hub objective with minutes in place of kilometers, two matched bucket budgets, and an exact point-level reference. 2020 Census blocks · 2024 TIGER/Line
In the historical sensitivity runs, I shifted the candidate grid 1 km east and south, slowed two highway classes by 25%, and tried a denser candidate grid. Across the four scenarios and two budgets, spread-based H3 chose the same hubs as fixed H3 and took longer each time. At 18 buckets, both raised cost by 2.82% in the original case and by 3.04% with slower highways. The cost increase disappeared after shifting the candidates. At 83 buckets, fixed H3 and weighted k-means matched the exact plan in all four scenarios. Volume refinement sometimes changed the hubs. Sensitivity protocol · Raw sensitivity results
The chart shows the initial 24-candidate run. Its raw assignment MILP hit a 20-second limit on all three attempts. Exact enumeration checked all 2,024 candidate triples and found the optimum in about the same time as the 83-bucket fixed grid. A second implementation confirmed the original optimum. Published work also uses weighted travel costs and different p-median formulations to reduce aggregation error or improve solve times. Initial raw benchmark · Current and Schilling (1987) · Irawan, Salhi and Scaparra
What changed the engineering decision
At 76 candidates there are 70,300 possible triples. I reran that pinned case with both the simple exact loop and a vectorized implementation that reuses the best service times for pairs. Each method ran three times in rotated order with the same route matrix per repetition. The medians below include routing and original-point scoring and exclude input loading and graph construction. This separate run used Windows 11, an Intel i7-8750H, and single-threaded BLAS.
| Method | Median with routing |
|---|---|
| Fixed H3, 83 buckets | 1.65 s |
| Simple exact enumeration | 5.96 s |
| Vectorized exact enumeration | 4.15 s |
All three methods selected M12, M33, and M62 in every repetition. On the original blocks, those hubs cost 2,165,118.79 resident-minutes with a weighted p95 of 13.28 minutes. The two exact implementations agreed on the objective and the hubs. The fixed-grid median was about 2.5× lower than vectorized enumeration in this run. Three-way raw results · Timing protocol and environment
For this workload, I would count the candidate combinations, try the simpler fixed grid, and score its plan on original demand before investing in adaptive refinement. At 24 sites the exact search was competitive. At 76, it gave a useful check on the quicker fixed grid. The road tests share one demand surface and use assumed speeds. Real warehouse decisions also depend on orders, truck access, parcel feasibility, and capacity.
Reproduce the figures
Run these commands from the h3-hub-placement repository. Figure regeneration reads the recorded benchmark files. To graph a rerun, pass its path with --input. The last command reproduces the new dense comparison without overwriting the historical results.
uv run --locked python -m hub_placement.benchmark --output outputs/benchmark-rerun.json
uv run --locked python -m hub_placement.figures
uv run --locked python -m hub_placement.metro --fetch --output outputs/metro-rerun.json
uv run --locked python -m hub_placement.metro_figure
uv run --locked python -m hub_placement.robustness --fetch --output outputs/robustness-rerun.json
uv run --locked python -m hub_placement.exact_baselines --fetch --output outputs/exact-baselines-rerun.json
The constructed maps and synthetic results use the fixed seeds in synthetic-v1. The Madison chart uses the recorded Census and road inputs described above. A future US ZIP-level study could allocate demand through a matching vintage of the HUD–USPS ZIP-to-tract crosswalk and assign each tract a Census representative point before H3 indexing. That approximation would need its own validation, especially for missing matches and ZIPs split across tracts. HUD–USPS crosswalk · 2024 Census Gazetteer
References
- Michael F. Goodchild, 1979. The Aggregation Problem in Location-Allocation.
- John R. Current and David A. Schilling, 1987. Elimination of Source A and B Errors in p-Median Location Problems.
- Lian Qi and Zuo-Jun Max Shen, 2010. Worst-case analysis of demand point aggregation for the Euclidean p-median problem.
- Chandra Ade Irawan, Said Salhi and Maria Paola Scaparra. An Adaptive Multiphase Approach for Large Unconditional and Conditional p-Median Problems.
- Matej Cebecauer and Ľuboš Buzna, 2017. A Versatile Adaptive Aggregation Framework for Spatially Large Discrete Location-Allocation Problems.
- Uber Engineering, 2018. H3: Uber’s Hexagonal Hierarchical Spatial Index. H3 hierarchy documentation.
- SciPy 1.15.3. Mixed-integer linear programming. HiGHS. scikit-learn 1.6. Weighted K-means API.
synthetic-v1. Original deterministic fixtures inhub_placement/fixtures.py. Download the raw benchmark data above. Postal references for separate ZIP-level work include the HUD–USPS ZIP Code Crosswalk Files, 2024 Census Gazetteer, and Census ZCTA definitions.- U.S. Census Bureau. TIGERweb 2020 Census blocks and 2024 Dane County TIGER/Line All Lines. Population proxies and road topology for the separate Madison case.