🏭 Scenario: Nearest Neighbor Algorithm for Warehouse Stock Transfer
Background
A company, GrapheneTech, distributes graphene sheets across 5 regional warehouses in Southeast Asia:
Warehouse | Location | Average Daily Demand (units) | Average Lead Time (days) | Current Inventory (units) |
---|---|---|---|---|
W1 | Kuala Lumpur | 95 | 2 | 200 |
W2 | Penang | 75 | 1 | 70 |
W3 | Johor | 90 | 2 | 110 |
W4 | Singapore | 120 | 3 | 50 |
W5 | Bangkok | 60 | 5 | 300 |
Problem
-
Warehouse W4 (Singapore) is facing a stock shortage because of sudden demand increase.
-
The replenishment lead time from the supplier is 7 days, which is too slow.
-
The company wants to transfer stocks from another warehouse temporarily to maintain W4’s 95% service level.
But which warehouse should W4 get help from?
Step 1: Define the Features for Similarity
Each warehouse is described by quantitative features that influence stock movement feasibility:
Feature | Meaning |
---|---|
Average daily demand | |
Lead time from supplier | |
Current stock level | |
Transportation distance (km) from W4 |
Suppose distances from W4 are:
From → W4 | Distance (km) |
---|---|
W1 | 350 |
W2 | 600 |
W3 | 250 |
W5 | 1400 |
Step 2: Represent Each Warehouse as a Feature Vector
Each warehouse =
Warehouse | Vector |
---|---|
W1 | [95, 2, 200, 350] |
W2 | [75, 1, 70, 600] |
W3 | [90, 2, 110, 250] |
W5 | [60, 5, 300, 1400] |
W4 (Target) | [120, 3, 50, 0] |
Step 3: Apply Nearest Neighbor (Euclidean Distance)
We compute the “distance” between W4 and every other warehouse:
Let’s calculate digit by digit for clarity:
For W1:≈381.7
For W2:≈602.0
For W3:≈258.8
For W5:≈1423.4
Step 4: Find the Nearest Neighbor
Warehouse | Distance to W4 | Rank |
---|---|---|
W3 (Johor) | 258.8 | 🥇 Nearest |
W1 | 381.7 | 2 |
W2 | 602.0 | 3 |
W5 | 1423.4 | 4 |
✅ Nearest Neighbor = W3 (Johor)
Step 5: Decision and Action
Since W3 is most similar and geographically close:
-
W3 can transfer 40 units of graphene sheets to W4 immediately.
-
This transfer minimizes cost and maintains regional balance.
Step 6: Result
Warehouse | Inventory Before | Transfer | Inventory After |
---|---|---|---|
W3 | 110 | −40 | 70 |
W4 | 50 | +40 | 90 |
-
W4’s shortage problem solved.
-
W3 still has sufficient inventory for its demand.
🧠 Interpretation
The nearest neighbor algorithm here:
-
Quantifies warehouse similarity (in demand, stock, lead time, and distance).
-
Chooses the most appropriate source warehouse for emergency stock transfer.
-
Avoids manual guesswork or arbitrary selection.
No comments:
Post a Comment