Supply Chain Analytics in Python
Aaren Stubberfield
Supply Chain Analytics Mgr.
PuLP
is a modeling framework for Linear (LP) and Integer Programing (IP) problems written in Python
Maintained by COIN-OR Foundation (Computational Infrastructure for Operations Research)
PuLP
interfaces with Solvers
CPLEX
COIN
Gurobi
Cake A | Cake B | |
---|---|---|
Oven | 0.5 days | 1 day |
Bakers | 1 day | 2.5 days |
Packers | 1 day | 2 days |
.
Cake A | Cake B | |
---|---|---|
Profit | $20.00 | $40.00 |
LpProblem(name='NoName', sense=LpMinimize)
name
= Name of the problem used in the output .lp file, i.e. "My LP Problem"sense
= Maximize or minimize the objective functionLpMinimize
(default)LpMaximize
from pulp import *
# Initialize Class
model = LpProblem("Maximize Bakery Profits", LpMaximize)
LpVariable(name, lowBound=None, upBound=None, cat='Continuous', e=None)
name
= Name of the variable used in the output .lp filelowBound
= Lower boundupBound
= Upper boundcat
= The type of variable this ise
= Used for column based modeling# Define Decision Variables
A = LpVariable('A', lowBound=0, cat='Integer')
B = LpVariable('B', lowBound=0, cat='Integer')
# Define Objective Function
model += 20 * A + 40 * B
# Define Constraints
model += 0.5 * A + 1 * B <= 30
model += 1 * A + 2.5 * B <= 60
model += 1 * A + 2 * B <= 22
# Solve Model
model.solve()
print("Produce {} Cake A".format(A.varValue))
print("Produce {} Cake B".format(B.varValue))
from pulp import *
# Initialize Class
model = LpProblem("Maximize Bakery Profits",
LpMaximize)
# Define Decision Variables
A = LpVariable('A', lowBound=0,
cat='Integer')
B = LpVariable('B', lowBound=0,
cat='Integer')
# Define Objective Function
model += 20 * A + 40 * B
# Define Constraints
model += 0.5 * A + 1 * B <= 30
model += 1 * A + 2.5 * B <= 60
model += 1 * A + 2 * B <= 22
# Solve Model
model.solve()
print("Produce {} Cake A".format(A.varValue))
print("Produce {} Cake B".format(B.varValue))
Reviewed 5 Steps of PuLP modeling process
Completed Resource Scheduling Example
Supply Chain Analytics in Python