Supply Chain Analytics in Python
Aaren Stubberfield
Supply Chain Analytics Mgr.
Simple Bakery Example
# Define Decision Variables
A = LpVariable('A', lowBound=0, cat='Integer')
B = LpVariable('B', lowBound=0, cat='Integer')
More Complex Bakery Example
# Define Decision Variables
A = LpVariable('A', lowBound=0, cat='Integer')
B = LpVariable('B', lowBound=0, cat='Integer')
C = LpVariable('C', lowBound=0, cat='Integer')
D = LpVariable('D', lowBound=0, cat='Integer')
E = LpVariable('E', lowBound=0, cat='Integer')
F = LpVariable('F', lowBound=0, cat='Integer')
Objective Function of Complex Bakery Example
# Define Objective Function
model += 20*A + 40*B + 33*C + 14*D + 6*E + 60*F
Need method to scale
lpSum(vector)
vector
= A list of linear expressionsTherefore ...
# Define Objective Function
model += 20*A + 40*B + 33*C + 14*D + 6*E + 60*F
Equivalent to ...
# Define Objective Function
var_list = [20*A, 40*B, 33*C, 14*D, 6*E, 60*F]
model += lpSum(var_list)
# Define Objective Function
cake_types = ["A", "B", "C", "D", "E", "F"]
profit_by_cake = {"A":20, "B":40, "C":33, "D":14, "E":6, "F":60}
var_dict = {"A":A, "B":B, "C":C, "D":D, "E":E, "F":F}
model += lpSum([profit_by_cake[type] * var_dict[type]
for type in cake_types])
lpSum()
Supply Chain Analytics in Python