Optimizing Warehouse Layout with Demand Modeling
Where you put things in a warehouse matters. A pick agent — human or robot — walks from a pack station to each item on an order and back again. If popular items are buried at the far end of the warehouse, every order costs more travel. If items frequently ordered together sit far apart, the agent zigzags unnecessarily.
This post explores a simulated 2D warehouse with a pick agent using A* pathfinding. I model realistic demand (a power-law distribution where a few items drive most orders) and product family co-occurrence (items in the same category tend to appear together). Three slot-assignment strategies are compared across both a small and a large warehouse layout — each scenario run across 1,000 orders for statistically stable results.
The Simulation
Two warehouse layouts are used throughout:
| Layout | Size | Rack slots | Description |
|---|---|---|---|
| Small | 12×19 grid | 120 | Single-zone warehouse with 6 symmetric rack bands |
| Large | 24×38 grid | 480 | Four identical small layouts arranged in a 2×2 quad |
Cells are either rack slots, aisles, or the pack station. The pick agent starts at the pack station, navigates to each item's rack slot using A* pathfinding, picks it, then returns to deposit. Travel distance is measured in grid cells (Manhattan distance). Pick and deposit are instantaneous — distance is the only variable.
Items restock after each deposit, so high-demand items can recur across many orders without running out.
Demand Modeling
Item demand follows an exponential distribution, normalised so all weights sum to 1. A demand skew parameter controls how extreme the distribution is. Items also belong to product families (6–8 per scenario). When generating an order, a theme family is chosen weighted by total family demand, and most items in that order are drawn from it. The family affinity parameter (0–1) controls what fraction comes from the same family.
The chart below shows individual item weights (top) and cumulative demand % (bottom) for two skew settings. At high skew, just a handful of items drive the majority of picks.
Placement Strategies
The physical warehouse structure — where the aisles, racks, and pack station sit — is fixed. What the strategies change is the merchandise placement: which product is stored in which rack slot. Before assignment, slots are ranked by Manhattan distance to the pack station. The strategy then decides which products get the closest slots.
For example, under random placement a high-demand item might end up in a far corner. Under demand placement, the highest-demand item always gets the nearest rack slot. Under affinity placement, items frequently ordered together are additionally clustered in adjacent slots, so the agent can pick an entire order without crossing the warehouse.
| Strategy | Assignment logic |
|---|---|
| Random | Shuffled randomly. Baseline. |
| Demand-based | Sorted by demand weight descending — highest-demand items get the closest slots. |
| Affinity-aware | Greedy: at each step, scores unplaced items by demand_weight + co-occurrence with already-placed neighbours. Places highest scorer in the next closest slot. |
The affinity strategy builds a co-occurrence matrix from the full order set before placement, so it has complete knowledge of which items are ordered together.
Results
Each scenario was run with 1,000 orders. Improvement vs Random is positive when a strategy reduces travel distance (higher is better).
Small Grid (12×19)
| Scenario | Strategy | Orders | Avg distance | Improvement vs Random |
|---|---|---|---|---|
| low-skew | Random | 1000 | 32.4 | baseline |
| low-skew | Demand-based | 1000 | 25.0 | +22.9% |
| low-skew | Affinity-aware | 1000 | 23.0 | +29.0% |
| high-skew | Random | 1000 | 32.0 | baseline |
| high-skew | Demand-based | 1000 | 22.6 | +29.3% |
| high-skew | Affinity-aware | 1000 | 19.9 | +37.8% |
| low-affinity | Random | 1000 | 32.8 | baseline |
| low-affinity | Demand-based | 1000 | 20.3 | +38.2% |
| low-affinity | Affinity-aware | 1000 | 20.2 | +38.3% |
| high-affinity | Random | 1000 | 32.6 | baseline |
| high-affinity | Demand-based | 1000 | 28.3 | +13.1% |
| high-affinity | Affinity-aware | 1000 | 21.9 | +32.9% |
| large-catalog | Random | 1000 | 51.0 | baseline |
| large-catalog | Demand-based | 1000 | 34.2 | +33.0% |
| large-catalog | Affinity-aware | 1000 | 28.3 | +44.6% |
Large Grid (24×38)
| Scenario | Strategy | Orders | Avg distance | Improvement vs Random |
|---|---|---|---|---|
| low-skew | Random | 1000 | 56.0 | baseline |
| low-skew | Demand-based | 1000 | 40.2 | +28.2% |
| low-skew | Affinity-aware | 1000 | 40.6 | +27.6% |
| high-skew | Random | 1000 | 53.0 | baseline |
| high-skew | Demand-based | 1000 | 30.5 | +42.4% |
| high-skew | Affinity-aware | 1000 | 26.3 | +50.3% |
| low-affinity | Random | 1000 | 55.7 | baseline |
| low-affinity | Demand-based | 1000 | 35.0 | +37.1% |
| low-affinity | Affinity-aware | 1000 | 34.8 | +37.5% |
| high-affinity | Random | 1000 | 55.5 | baseline |
| high-affinity | Demand-based | 1000 | 39.6 | +28.7% |
| high-affinity | Affinity-aware | 1000 | 40.6 | +26.9% |
| large-catalog | Random | 1000 | 77.6 | baseline |
| large-catalog | Demand-based | 1000 | 48.6 | +37.4% |
| large-catalog | Affinity-aware | 1000 | 46.1 | +40.7% |
Overall Score
Averaging across all five scenarios:
| Strategy | Small grid | Large grid |
|---|---|---|
| Demand-based | +27.3% | +34.8% |
| Affinity-aware | +36.5% | +36.6% |
Error bars in the chart below show the range across scenarios (dots = individual scenario values).
Sensitivity Analysis
Sensitivity sweeps used 500 orders each. Solid lines = small grid, dashed = large grid. Dark blue/orange = demand strategy, light blue/orange = affinity strategy.
Effect of Items per Order
As orders grow longer, the percentage improvement from smart placement actually decreases. With a single-item order, every pick is the agent walking to one rack and back — placing that rack close has a large proportional impact. With eight items per order, the agent visits eight racks: the few hot items near the pack station account for a smaller fraction of total travel, diluting the gain.
When Does Affinity Beat Demand-Only?
The affinity-aware strategy adds a co-occurrence optimisation step on top of demand ranking. The chart below shows its margin over the demand strategy per scenario (positive = affinity wins, negative = demand-only is sufficient).
Key Findings
- The best strategy reduced average travel distance by up to 50% vs random placement, averaging 37% across all scenarios and both grids.
- Demand-based placement captures most of the gain with minimal complexity: sort items by expected pick frequency and put the busiest ones closest to the pack station.
- Affinity-aware placement adds a meaningful further reduction when orders have strong family clustering (affinity ≥ 0.6) and order sizes are larger (≥ 5 items).
- Both strategies scale to the large grid with similar percentage improvements, confirming the approach generalises beyond small layouts.
- When demand skew or family affinity are low — meaning all items are roughly equally likely — there is no exploitable structure and all three strategies converge.
Scenario Parameters
| Scenario | Grid | Items | Families | Demand skew | Affinity | Orders |
|---|---|---|---|---|---|---|
| low-skew | 12×19 | 30 | 6 | 1.5 | 0.7 | 1000 |
| 24×38 | 120 | 6 | 1.5 | 0.7 | 1000 | |
| high-skew | 12×19 | 30 | 6 | 3.5 | 0.7 | 1000 |
| 24×38 | 120 | 6 | 3.5 | 0.7 | 1000 | |
| low-affinity | 12×19 | 30 | 6 | 2.0 | 0.3 | 1000 |
| 24×38 | 120 | 6 | 2.0 | 0.3 | 1000 | |
| high-affinity | 12×19 | 30 | 6 | 2.0 | 0.9 | 1000 |
| 24×38 | 120 | 6 | 2.0 | 0.9 | 1000 | |
| large-catalog | 12×19 | 60 | 8 | 2.5 | 0.7 | 1000 |
| 24×38 | 200 | 8 | 2.5 | 0.7 | 1000 |