Supply Chain Analytics ด้วย Python
Aaren Stubberfield
Supply Chain Analytics Mgr.
ความต้องการที่คาดการณ์ไว้
| วันในสัปดาห์ | จำนวนคนขับที่ต้องการ |
|---|---|
| 0 = จันทร์ | 11 |
| 1 = อังคาร | 14 |
| 2 = พุธ | 23 |
| 3 = พฤหัสบดี | 21 |
| 4 = ศุกร์ | 20 |
| 5 = เสาร์ | 15 |
| 6 = อาทิตย์ | 8 |
คำถาม:
ข้อจำกัด:
| ขั้นตอน | นิยาม |
|---|---|
| ตัวแปรการตัดสินใจ | X$_{\text{i}}$ = จำนวนคนขับที่ทำงานในวัน _i_ |
| วัตถุประสงค์ | minimize z = X$_{\text{0}}$ + X$_{\text{1}}$ + X$_{\text{2}}$ + X$_{\text{3}}$ + X$_{\text{4}}$ + X$_{\text{5}}$ + X$_{\text{6}}$ |
| ภายใต้เงื่อนไข | X$_{\text{0}}$ ≥ 11 |
| X$_{\text{1}}$ ≥ 14 | |
| X$_{\text{2}}$ ≥ 23 | |
| X$_{\text{3}}$ ≥ 21 | |
| X$_{\text{4}}$ ≥ 20 | |
| X$_{\text{i}}$ ≥ 0 (i = 0, ..., 6) |
| ขั้นตอน | นิยาม |
|---|---|
| ตัวแปรการตัดสินใจ | X$_{\text{i}}$ = จำนวนคนขับที่ทำงานในวัน _i_ |
| วัตถุประสงค์ | minimize z = X$_{\text{0}}$ + X$_{\text{1}}$ + X$_{\text{2}}$ + X$_{\text{3}}$ + X$_{\text{4}}$ + X$_{\text{5}}$ + X$_{\text{6}}$ |
| ภายใต้เงื่อนไข | X$_{\text{0}}$ + X$_{\text{3}}$ + X$_{\text{4}}$ + X$_{\text{5}}$ + X$_{\text{6}}$ ≥ 11 |
| X$_{\text{0}}$ + X$_{\text{1}}$ + X$_{\text{4}}$ + X$_{\text{5}}$ + X$_{\text{6}}$ ≥ 14 | |
| X$_{\text{0}}$ + X$_{\text{1}}$ + X$_{\text{2}}$ + X$_{\text{3}}$ + X$_{\text{6}}$ ≥ 23 | |
| X$_{\text{0}}$ + X$_{\text{1}}$ + X$_{\text{2}}$ + X$_{\text{3}}$ + X$_{\text{4}}$ ≥ 21 | |
| X$_{\text{1}}$ + X$_{\text{2}}$ + X$_{\text{3}}$ + X$_{\text{4}}$ + X$_{\text{5}}$ ≥ 15 | |
| X$_{\text{i}}$ ≥ 0 (i = 0, ..., 6) |
# Initialize Class
model = LpProblem("Minimize Staffing",
LpMinimize)
days = list(range(7))
# Define Decision Variables
x = LpVariable.dicts('staff_', days,
lowBound=0, cat='Integer')
# Define Objective
model += lpSum([x[i] for i in days])
# Define Constraints
model += x[0] + x[3] + x[4] + x[5] + x[6] >= 11
model += x[0] + x[1] + x[4] + x[5] + x[6] >= 14
model += x[0] + x[1] + x[2] + x[5] + x[6] >= 23
model += x[0] + x[1] + x[2] + x[3] + x[6] >= 21
model += x[0] + x[1] + x[2] + x[3] + x[4] >= 20
model += x[1] + x[2] + x[3] + x[4] + x[5] >= 15
model += x[2] + x[3] + x[4] + x[5] + x[6] >= 8
# Solve Model
model.solve()
Supply Chain Analytics ด้วย Python