Supply Chain Analytics in Python
Aaren Stubberfield
Supply Chain Analytics Mgr.
Modeling
What should we expected for values of our decision variables?
Production Quantities:
Production Plant Open Or Closed:
Total Production = Total Demand:
shadow prices
= Represent changes in total cost per increase in demand for a regionslack
= Should be zeroTotal Production ≤ Total Production Capacity:
shadow prices
= Represent changes in total costs per increase in production capacityslack
= Regions which have excess production capacityfrom pulp import *
import pandas as pd
# Initialize Class
model =
LpProblem("Capacitated Plant Location Model",
LpMinimize)
# Define Decision Variables
loc = ['A', 'B', 'C', 'D', 'E']
size = ['Low_Cap','High_Cap']
x = LpVariable.dicts(
"production_",
[(i,j) for i in loc for j in loc],
lowBound=0, upBound=None,
cat='Continuous')
y = LpVariable.dicts(
"plant_",
[(i,s) for s in size for i in loc],
cat='Binary')
# Define Objective Function
model +=
(lpSum([fix_cost.loc[i,s]*y[(i,s)]
for s in size for i in loc])
+ lpSum([var_cost.loc[i,j]*x[(i,j)]
for i in loc for j in loc]))
# Define the Constraints
for j in loc: model +=
lpSum([x[(i, j)]
for i in loc]) == demand.loc[j,'Dmd']
for i in loc: model +=
lpSum([x[(i, j)] for j in loc]) <= lpSum(
[cap.loc[i,s]*y[(i,s)]for s in size])
# Solve model.solve()
# Print Decision Variables and Objective Value print(LpStatus[model.status]) o = [{'prod':"{} to {}".format(i,j), 'quant':x[(i,j)].varValue} for i in loc for j in loc] print(pd.DataFrame(o)) o = [{'loc':i, 'lc':y[(i,size[0])].varValue, 'hc':y[(i,size[1])].varValue} for i in loc] print(pd.DataFrame(o)) print("Objective = ", value(model.objective))
# Print Shadow Price and Slack o = [{'name':name, 'shadow price':c.pi, 'slack': c.slack} for name, c in model.constraints.items()] print(pd.DataFrame(o))
Likely Questions:
What is the expected cost of this supply chain network model?
If demand increases in a region how much profit is needed to cover the costs of production and shipping to that region?
Which regions still have production capacity for future demand increase?
Reviewed:
shadow prices
and slack
)Supply Chain Analytics in Python