Python으로 배우는 Optimization 입문
Jasmin Ludolf
Content Developer
수요:
가운 생산:


$C$: 원단비 + Mr. S 임금 + Ms. T 기회비용
기회비용: 재봉을 선택해 다른 일을 못 하는 비용
$C=110g+240g+105g+75t+160t+35t$
$C=455g+270t$
| 비용 | 원단 | Mr. S | Ms. T |
|---|---|---|---|
| 가운 | $\$110$ | $\$40/h \times 6h = \$240$ | $\$35/h \times 3h = \$105$ |
| 턱시도 | $\$75$ | $\$40/h \times 4h = \$160$ | $\$35/h \times 1h = \$35$ |
제약식:
수요: $g\leq20$, $t\leq12$
공급: $6g+4t\leq40$, $3g+t\leq20$
from scipy.optimize import milp, Bounds, LinearConstraintresult = milp([-545, -330],integrality=[1, 1],bounds=Bounds([0, 0], [20, 12]),constraints=LinearConstraint([[6, 4], [3, 1]], ub=[40, 20]))
print(result.message)
print(f'The optimal number of gowns produced is: {result.x[0]:.2f}')
print(f'The optimal number of tuxedos produced is: {result.x[1]:.2f}')
Optimization terminated successfully. (HiGHS Status 7: Optimal)
The optimal number of gowns produced is: 6.00
The optimal number of tuxedos produced is: 1.00
result = milp([-545, -330],
bounds=Bounds([0, 0], [20, 12]),
constraints=LinearConstraint([[6, 4], [3, 1]], ub=[40, 20]))
...
The optimal number of gowns produced is: 6.67
The optimal number of tuxedos produced is: 0.00
제안 해: 가운 6.67, 턱시도 0.00 $\rightarrow$
반올림: 가운 7, 턱시도 0
내림: 가운 6, 턱시도 0
Python으로 배우는 Optimization 입문