Introductie tot optimalisatie in Python
Jasmin Ludolf
Content Developer
Vraag:
Productie jurk:


$C$: stofkosten + loon Mr. S + opportuniteitskost Ms. T
Opportuniteitskost: kost van kiezen voor naaien i.p.v. andere taken
$C=110g+240g+105g+75t+160t+35t$
$C=455g+270t$
| Kosten | Stof | Mr. S | Ms. T |
|---|---|---|---|
| Jurk | $\$110$ | $\$40/u \times 6u = \$240$ | $\$35/u \times 3u = \$105$ |
| Smoking | $\$75$ | $\$40/u \times 4u = \$160$ | $\$35/u \times 1u = \$35$ |
Randvoorwaarden:
Vraag: $g\leq20$, $t\leq12$
Aanbod: $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
Voorgestelde oplossing 6,67 jurken en 0,00 smokings $\rightarrow$
Afronden naar 7 jurken en 0 smokings
Afkappen naar 6 jurken en 0 smokings
Introductie tot optimalisatie in Python