Basics of optimi z ation SU P P LY C H AIN AN ALYTIC S IN P YTH ON - - PowerPoint PPT Presentation

basics of optimi z ation
SMART_READER_LITE
LIVE PREVIEW

Basics of optimi z ation SU P P LY C H AIN AN ALYTIC S IN P YTH ON - - PowerPoint PPT Presentation

Basics of optimi z ation SU P P LY C H AIN AN ALYTIC S IN P YTH ON Aaren St u bber eld S u ppl y Chain Anal y tics Mgr . What is a s u ppl y chain A S u ppl y Chain consist of all parties in v ol v ed , directl y or indirectl y, in f u l


slide-1
SLIDE 1

Basics of

  • ptimization

SU P P LY C H AIN AN ALYTIC S IN P YTH ON

Aaren Stubbereld

Supply Chain Analytics Mgr.

slide-2
SLIDE 2

SUPPLY CHAIN ANALYTICS IN PYTHON

What is a supply chain

A Supply Chain consist of all parties involved, directly or indirectly, in fullling a customer’s request.¹ Includes: Suppliers Internal Manufacturing Outsourced Logistics Suppliers (i.e. Third Party Suppliers)

Chopra, Sunil, and Peter Meindl. _Supply Chain Management: Strategy, Planning, and Operations._ Pearson Prentice-Hall, 2007.

1

slide-3
SLIDE 3

SUPPLY CHAIN ANALYTICS IN PYTHON

What is a supply chain optimization

Involves nding the best path to achieve an objective based on constraints

slide-4
SLIDE 4

SUPPLY CHAIN ANALYTICS IN PYTHON

Crash course in LP

Linear Programing (LP) is a Powerful Modeling Tool for Optimization Optimization method using a mathematical model whose requirements are linear relationships There are 3 Basic Components in LP: Decision Variables - what you can control Objective Function - math expression that uses variables to express goal Constraints - math expression that describe the limits of a solutions

slide-5
SLIDE 5

SUPPLY CHAIN ANALYTICS IN PYTHON

Introductory example

Use LP to decide on an exercise routine to burn as many calories as possible. Pushup Running Minutes 0.2 per pushup 10 per mile Calories 3 per pushup 130 per mile Constraint - only 10 minutes to exercise

slide-6
SLIDE 6

SUPPLY CHAIN ANALYTICS IN PYTHON

Basic components of an LP

Decision Variables - What we can control: Number of Pushups & Number of Miles Ran Objective Function - Math expression that uses variables to express goal: Max (3 * Number of Pushups + 130 * Number of Miles) Constraints - Math expression that describe the limits of a solutions: 0.2 * Number of Pushups + 10 * Number of Miles ≤ 10 Number of Pushups ≥ 0 Number of Miles ≥ 0

slide-7
SLIDE 7

SUPPLY CHAIN ANALYTICS IN PYTHON

Example solution

Optimal Solution: 50 Pushups 0 Miles Ran Calories Burned: 150

slide-8
SLIDE 8

SUPPLY CHAIN ANALYTICS IN PYTHON

LP vs IP vs MIP

Terms Decision Variables Linear Programing (LP) Only Continuous Integer Programing (IP) Only Discrete or Integers Mixed Integer Programing (MIP) Mix of Continuous and Discrete

slide-9
SLIDE 9

SUPPLY CHAIN ANALYTICS IN PYTHON

Summary

Dened Supply Chain Optimization Dened Linear Programing and Basic Components Decision Variables Objective Function Constraints Dened LP vs IP vs MIP

slide-10
SLIDE 10

Let's practice!

SU P P LY C H AIN AN ALYTIC S IN P YTH ON

slide-11
SLIDE 11

Basics of PuLP modeling

SU P P LY C H AIN AN ALYTIC S IN P YTH ON

Aaren Stubbereld

Supply Chain Analytics Mgr.

slide-12
SLIDE 12

SUPPLY CHAIN ANALYTICS IN PYTHON

What is PuLP

PuLP is a modeling framework for Linear (LP) and Integer Programing (IP) problems wrien

in Python Maintained by COIN-OR Foundation (Computational Infrastructure for Operations Research)

PuLP interfaces with Solvers CPLEX COIN Gurobi

etc…

slide-13
SLIDE 13

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

Consultant for boutique cake bakery that sell 2 types of cakes 30 day month There is: 1 oven 2 bakers 1 packaging packer – only works 22 days

slide-14
SLIDE 14

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

Dierent resource needs for the 2 types of cakes: 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 Prot $20.00 $40.00

slide-15
SLIDE 15

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

Objective is to Maximize Prot Prot = 20*A + 40*B Subject to: A ≥ 0 B ≥ 0 0.5A + 1B ≤ 30 1A + 2.5B ≤ 60 1A + 2B ≤ 22

slide-16
SLIDE 16

SUPPLY CHAIN ANALYTICS IN PYTHON

Common modeling process for PuLP

  • 1. Initialize Model
  • 2. Dene Decision Variables
  • 3. Dene the Objective Function
  • 4. Dene the Constraints
  • 5. Solve Model
slide-17
SLIDE 17

SUPPLY CHAIN ANALYTICS IN PYTHON

Initializing model - LpProblem()

LpProblem(name='NoName', sense=LpMinimize) name = Name of the problem used in the output .lp le, i.e. "My LP Problem" sense = Maximize or minimize the objective function

Minimize = LpMinimize (default) Maximize = LpMaximize

slide-18
SLIDE 18

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

  • 1. Initialize Model

from pulp import * # Initialize Class model = LpProblem("Maximize Bakery Profits", LpMaximize)

slide-19
SLIDE 19

SUPPLY CHAIN ANALYTICS IN PYTHON

Define decision variables - LpVariable()

LpVariable(name, lowBound=None, upBound=None, cat='Continuous', e=None) name = Name of the variable used in the output .lp le lowBound = Lower bound upBound = Upper bound cat = The type of variable this is

Integer Binary Continuous (default)

e = Used for column based modeling

slide-20
SLIDE 20

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

  • 1. Initialize Class
  • 2. Dene Variables

# Define Decision Variables A = LpVariable('A', lowBound=0, cat='Integer') B = LpVariable('B', lowBound=0, cat='Integer')

slide-21
SLIDE 21

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

  • 1. Initialize Class
  • 2. Dene Variables
  • 3. Dene Objective Function

# Define Objective Function model += 20 * A + 40 * B

slide-22
SLIDE 22

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

  • 1. Initialize Class
  • 2. Dene Variables
  • 3. Dene Objective Function
  • 4. Dene Constraints

# Define Constraints model += 0.5 * A + 1 * B <= 30 model += 1 * A + 2.5 * B <= 60 model += 1 * A + 2 * B <= 22

slide-23
SLIDE 23

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

  • 1. Initialize Class
  • 2. Dene Variables
  • 3. Dene Objective Function
  • 4. Dene Constraints
  • 5. Solve Model

# Solve Model model.solve() print("Produce {} Cake A".format(A.varValue)) print("Produce {} Cake B".format(B.varValue))

slide-24
SLIDE 24

SUPPLY CHAIN ANALYTICS IN PYTHON

PuLP example – resource scheduling

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))

slide-25
SLIDE 25

SUPPLY CHAIN ANALYTICS IN PYTHON

Summary

PuLP is a Python LP / IP modeler Reviewed 5 Steps of PuLP modeling process

  • 1. Initialize Model
  • 2. Dene Decision Variables
  • 3. Dene the Objective Function
  • 4. Dene the Constraints
  • 5. Solve Model

Completed Resource Scheduling Example

slide-26
SLIDE 26

Let's practice!

SU P P LY C H AIN AN ALYTIC S IN P YTH ON

slide-27
SLIDE 27

Using lpSum

SU P P LY C H AIN AN ALYTIC S IN P YTH ON

Aaren Stubbereld

Supply Chain Analytics Mgr.

slide-28
SLIDE 28

SUPPLY CHAIN ANALYTICS IN PYTHON

Moving from simple to complex

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')

slide-29
SLIDE 29

SUPPLY CHAIN ANALYTICS IN PYTHON

Moving from simple to complex

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

slide-30
SLIDE 30

SUPPLY CHAIN ANALYTICS IN PYTHON

Using lpSum()

lpSum(vector)

vector = A list of linear expressions

Therefore ...

# 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)

slide-31
SLIDE 31

SUPPLY CHAIN ANALYTICS IN PYTHON

lpSum with list comprehension

# 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])

slide-32
SLIDE 32

SUPPLY CHAIN ANALYTICS IN PYTHON

Summary

Need way to sum many variables

lpSum()

Used in list comprehension

slide-33
SLIDE 33

Practice time!

SU P P LY C H AIN AN ALYTIC S IN P YTH ON