Supply Chain Analytics in Python
Aaren Stubberfield
Supply Chain Analytics Mgr.
Modeling in issues:
Shadow Prices:
Context - Glass Company - Resource Planning:
Resource | Prod. A | Prod. B | Prod. C |
---|---|---|---|
Production hours | 6 | 5 | 8 |
WH Capacity sq. ft. | 10.5 | 20 | 10 |
Profit $US | $500 | $450 | $600 |
Constraints:
# Initialize Class, Define Vars., and Objective
model = LpProblem("Max Glass Co. Profits",
LpMaximize)
A = LpVariable('A', lowBound=0)
B = LpVariable('B', lowBound=0)
C = LpVariable('C', lowBound=0)
model += 500 * A + 450 * B + 600 * C
# Constraint 1
model += 6 * A + 5 * B + 8 * C <= 60
# Constraint 2
model += 10.5 * A + 20 * B + 10 * C <= 150
# Constraint 3
model += A <= 8
# Solve Model
model.solve()
print("Model Status:
{}".format(LpStatus[model.status]))
print("Objective = ", value(model.objective))
for v in model.variables():
print(v.name, "=", v.varValue)
Solution:
Products | Prod. A | Prod. B | Prod. C |
---|---|---|---|
Production Cases | 6.667 | 4 | 0 |
Objective value is $5133.33
Decision Variable:
Constraints:
Python Code:
o = [{'name':name, 'shadow price':c.pi}
for name, c in model.constraints.items()]
print(pd.DataFrame(o))
Output:
name shadow price
_C1 78.148148
_C2 2.962963
_C3 -0.000000
Remember the Constraints:
slack
:
Python:
o = [{'name':name, 'shadow price':c.pi, 'slack': c.slack}
for name, c in model.constraints.items()]
print(pd.DataFrame(o))
Output:
name shadow price slack
_C1 78.148148 -0.000000
_C2 2.962963 -0.000000
_C3 -0.000000 1.333333
More About Binding
slack
= 0, then bindingRemember the Constraints:
shadow prices
slack
slack
= 0, then bindingslack
> 0, then not-bindingSupply Chain Analytics in Python