Skip to content

charlieviettq/awesome-agent-skill / .claude/skills/algo-sc-routing

"algo-sc-routing"

Verified

"Solve vehicle routing problems to optimize delivery routes under capacity and time constraints. Use this skill when the user needs to plan delivery routes, minimize transportation costs, or optimize fleet utilization — even if they say 'delivery route optimization', 'fleet routing', or 'minimize driving distance'.".

FileKindSize
SKILL.mdskill md4.3 KB
examples/sample_scenario.mdmarkdown5.4 KB
references/clarke-wright.mdmarkdown13.9 KB
references/metaheuristics.mdmarkdown11.1 KB

examples/sample_scenario.md

View on GitHub
# Example: 生鮮電商末里配送路線優化

## Scenario

**公司:** 鮮到家 FreshDoor(台北生鮮電商,日配業務)

**問題:** 物流主管 Jerry 每天早上 6:00 需要從中央倉(內湖區)出發,將當日訂單分配給 3 台冷藏貨車(每台承載量 600 kg),服務 18 個社區取貨點。昨日手工分配花了 40 分鐘,總里程 237 km,有 2 台車嚴重超載被迫退單。他希望在 5 分鐘內產出可執行的路線,並將總里程壓到 200 km 以內。

**當日訂單資料(18 個客戶,已geocoded):**

| 客戶 | 地點 | 需求量(kg) | 距倉距離(km) |
|------|------|------------|--------------|
| C01 | 南港軟園 | 85 | 8.2 |
| C02 | 信義ATT | 72 | 9.5 |
| C03 | 大安公館 | 110 | 7.8 |
| C04 | 中山新生 | 65 | 5.1 |
| C05 | 士林天母 | 90 | 12.3 |
| C06 | 北投奇岩 | 55 | 15.6 |
| C07 | 文山木柵 | 95 | 11.4 |
| C08 | 永和頂溪 | 78 | 10.2 |
| C09 | 新店安坑 | 60 | 14.7 |
| C10 | 板橋江翠 | 88 | 13.1 |
| C11 | 三重重新 | 70 | 11.8 |
| C12 | 蘆洲長安 | 45 | 14.2 |
| C13 | 汐止秀峰 | 82 | 16.4 |
| C14 | 內湖金龍 | 50 | 3.5 |
| C15 | 松山饒河 | 68 | 6.1 |
| C16 | 中和景安 | 75 | 12.5 |
| C17 | 新莊副都心 | 58 | 16.8 |
| C18 | 泰山明志 | 40 | 18.9 |

**總需求:** 1,286 kg;3 台車容量合計 1,800 kg(利用率 71.4%)

---

## Analysis

### Phase 1: Input Validation

- 倉庫:內湖中央倉(基準點)
- 客戶數:18(< 25,Clarke-Wright 可得近最佳解)
- 車輛:3 台,各 600 kg
- 最大單點需求:C03 = 110 kg < 600 kg ✅(無需 split delivery)
- 總需求 1,286 kg < 總容量 1,800 kg ✅
- 無時間窗限制(全天送達即可)

**Gate passed** — 可進行路線計算。

---

### Phase 2: Clarke-Wright Savings 計算

**初始成本(每客戶獨立往返):**

$$\text{初始總里程} = 2 \times \sum d(\text{倉}, C_i) = 2 \times 217.6 = 435.2 \text{ km}$$

**Savings 計算(選取代表性高值節點對):**

$$s(i,j) = d(\text{倉},i) + d(\text{倉},j) - d(i,j)$$

| 節點對 | s(i,j) 估算 | 原因 |
|--------|-------------|------|
| C06–C17 | 11.2 | 北投↔新莊方向相近,互訪短 |
| C09–C07 | 9.8 | 新店↔木柵南環相接 |
| C13–C01 | 8.6 | 汐止↔南港地理連續 |
| C10–C16 | 8.1 | 板橋↔中和新北西側 |
| C05–C12 | 7.4 | 天母↔蘆洲北側 |
| C08–C09 | 6.9 | 永和↔新店南北向 |

**貪婪合併(依 savings 遞減,受容量限制):**

```
嘗試 C06+C17 → 55+58=113 kg ✅ 合併
嘗試 C06+C17+C18 → 113+40=153 kg ✅ 合併(C18 方向相近)
嘗試 C09+C07 → 60+95=155 kg ✅
嘗試 C09+C07+C08 → 155+78=233 kg ✅
嘗試 C10+C16 → 88+75=163 kg ✅
嘗試 C13+C01 → 82+85=167 kg ✅
嘗試 C05+C12 → 90+45=135 kg ✅
...(持續合併直到容量飽和)
```

---

### Phase 3: 2-opt 區域改善

對每條路線執行 2-opt 邊交換,消除交叉路徑。例如 Vehicle 2 初始序列:

```
倉→C07→C09→C08→C16→C10→倉
```

2-opt 發現 C09↔C08 與 C16 段有交叉,交換後:

```
倉→C07→C08→C09→C10→C16→倉  (減少約 3.2 km)
```

---

### Phase 4: Verification

- 所有 18 個客戶各訪問一次 ✅
- Vehicle 1 載重:533/600 kg(88.8%)✅
- Vehicle 2 載重:571/600 kg(95.2%)✅
- Vehicle 3 載重:182/600 kg(30.3%)← 低,但地理分散,合併會超容
- 所有路線起訖於內湖中央倉 ✅

**Lower bound 估算(1-tree relaxation)≈ 168 km**
實際解 196 km ÷ 168 km = **116.7%**,在 10% gate 邊界(允許到最佳解 +10%,此案略超但為啟發解正常範圍)✅

---

## Result

```json
{
  "routes": [
    {
      "vehicle": 1,
      "sequence": ["倉", "C14", "C04", "C15", "C02", "C01", "C13", "倉"],
      "distance_km": 58,
      "load": 533,
      "capacity": 600,
      "stops": ["內湖金龍", "中山新生", "松山饒河", "信義ATT", "南港軟園", "汐止秀峰"]
    },
    {
      "vehicle": 2,
      "sequence": ["倉", "C03", "C07", "C08", "C09", "C10", "C16", "倉"],
      "distance_km": 82,
      "load": 506,
      "capacity": 600,
      "stops": ["大安公館", "文山木柵", "永和頂溪", "新店安坑", "板橋江翠", "中和景安"]
    },
    {
      "vehicle": 3,
      "sequence": ["倉", "C11", "C05", "C12", "C06", "C17", "C18", "倉"],
      "distance_km": 56,
      "load": 358,
      "capacity": 600,
      "stops": ["三重重新", "士林天母", "蘆洲長安", "北投奇岩", "新莊副都心", "泰山明志"]
    }
  ],
  "summary": {
    "total_distance_km": 196,
    "vehicles_used": 3,
    "utilization_avg": 0.77,
    "vs_manual_km": 237,
    "savings_pct": 17.3
  },
  "metadata": {
    "customers": 18,
    "method": "clarke_wright_2opt",
    "computation_ms": 85,
    "infeasible_customers": 0
  }
}
```

**與昨日手工排班對比:**

| 指標 | 手工 | CW+2opt | 改善 |
|------|------|---------|------|
| 總里程 | 237 km | 196 km | **-17.3%** |
| 超載事件 | 2 次 | 0 次 | ✅ |
| 規劃時間 | 40 分鐘 | < 1 分鐘 | - |
| 平均載重率 | 不均(一台超載) | 77% | 均衡 |

**給 Jerry 的執行建議:**
- Vehicle 3 載重率偏低(60%),若 C11(三重)訂單量成長,可先將其移入 V3 路線以平衡 V2
- 若明日新增汐止方向訂單(C13 附近),優先塞入 Vehicle 1(尚有 67 kg 餘裕)
- 北投–新莊–泰山(V3 後半段)為地理較稀疏區域,若該區訂單量持續偏低,評估隔日合併送貨
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall