Shadow price sensitivity analysis

Supply Chain Analytics in Python

Aaren Stubberfield

Supply Chain Analytics Mgr.

Define shadow price

Modeling in issues:

  • Input for model constraints are often estimates
  • Will changes to input change our solution?

Shadow Prices:

  • The change in optimal value of the objective function per unit increase in the right-hand-side for a constraint, given everything else remain unchanged.
Supply Chain Analytics in Python

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:

  • Production Capacity Hours ≤ 60
  • Warehouse Capacity ≤ 150 sq. ft.
  • Max Production of A ≤ 8
Supply Chain Analytics in Python

Code example

# 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)
Supply Chain Analytics in Python

Example solution

Solution:

Products Prod. A Prod. B Prod. C
Production Cases 6.667 4 0

Objective value is $5133.33

Supply Chain Analytics in Python

Review constraints

Decision Variable:

  • A through C = Number of cases of respective A through C products

Constraints:

  • 6A + 5B + 8C ≤ 60 (limited production capacity)
  • 10A + 20B + 10C ≤ 150 (limited warehouse capacity)
  • A ≤ 8 (max production of A)
Supply Chain Analytics in Python

Print shadow price

Python Code:

o = [{'name':name, 'shadow price':c.pi} 
     for name, c in model.constraints.items()]
print(pd.DataFrame(o))
Supply Chain Analytics in Python

Shadow prices explained

Output:

  name  shadow price
   _C1     78.148148
   _C2      2.962963
   _C3     -0.000000

Remember the Constraints:

  1. limited production capacity
  2. limited warehouse capacity
  3. max production of A
Supply Chain Analytics in Python

Constraint slack

slack:

  • The amount of a resource that is unused.

Python:

o = [{'name':name, 'shadow price':c.pi, 'slack': c.slack} 
     for name, c in model.constraints.items()]
print(pd.DataFrame(o))
Supply Chain Analytics in Python

Constraint slack explained

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 binding
  • Changing binding constraint, changes solution

Remember the Constraints:

  1. limited production capacity
  2. limited warehouse capacity
  3. max production of A
Supply Chain Analytics in Python

Summary

  • How to compute:
    • shadow prices
    • constraint slack
  • Identify Binding Constraints
    • slack = 0, then binding
    • slack > 0, then not-binding
Supply Chain Analytics in Python

Try it out!

Supply Chain Analytics in Python

Preparing Video For Download...