Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin...

41
Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11, 2005

Transcript of Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin...

Page 1: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Using Spreadsheets for

Linear Programming with

The Simplex Method

A sample problem

By: Jeffrey Bivin

Lake Zurich High School

Last Updated: October 11, 2005

Page 2: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

A landscaper can buy three types of 100-pound bags of fertilizer, type A, type B, and type C. Each 100-pound bag of type A fertilizer costs $20 and contains 40 pounds of nitrogen, 30 pounds of phosphoric acid, and 10 pounds of potash. Each 100-pound bag of type B fertilizer costs $30 and contains 20 pounds of nitrogen, 20 pounds of phosphoric acid, and 55 pounds of potash. Each 100-pound bag of type C fertilizer costs $20 and contains no nitrogen, 30 pounds of phosphoric acid, and 40 pounds of potash. The landscaper requires 4000 pounds of nitrogen. 2000 pounds of phosphoric acid, and 2000 pounds of potash. How many bags of each type of fertilizer should the landscaper buy in order to minimize the cost? Also, find the minimum cost.

Jeff Bivin -- LZHS

Page 3: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Analyzing the problem

NitrogenPhos. Acid potash

Type A x1 $20 40 30 10

Type B x2 $30 20 20 55

Type C x3 $20 0 30 40

needs 4000 2000 2000

Jeff Bivin -- LZHS

Page 4: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Define the Constraints

40x1 + 20x2 > 4000

30x1 + 20x2 + 30x3 > 2000

10x1 + 55x2 + 40x3 > 2000

x1 > 0

x2 > 0

x3 > 0

Jeff Bivin -- LZHS

Page 5: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Function to minimize

z = 20x1 + 30x2 + 20x3

Jeff Bivin -- LZHS

Page 6: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Initial Tableau

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000

30 20 30 0 -1 0 0 2000

10 55 40 0 0 -1 0 2000

20 30 20 0 0 0 1 0

Jeff Bivin -- LZHS

Page 7: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Initial Tableau Analysis

Jeff Bivin -- LZHS

Page 8: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

A negative basic variable in s1

leads us to use column x1 as the pivot column.

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000

30 20 30 0 -1 0 0 2000

10 55 40 0 0 -1 0 2000

20 30 20 0 0 0 1 0

Jeff Bivin -- LZHS

Page 9: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

A negative basic variable in s1

leads us to use column x1 as the pivot column.

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000

30 20 30 0 -1 0 0 2000

10 55 40 0 0 -1 0 2000

20 30 20 0 0 0 1 0

s1 is a basic variable because it has only one non-zero element in the

columnJeff Bivin -- LZHS

Page 10: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

A negative basic variable in s1

leads us to use column x1 as the pivot column.

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000

30 20 30 0 -1 0 0 2000

10 55 40 0 0 -1 0 2000

20 30 20 0 0 0 1 0

We use Column x1 as the pivot column because the 40 in column x1 is the left most positive number in the row with the

-1 value (negative basic variable).

Jeff Bivin -- LZHS

Page 11: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Divide the value column by the pivot column.This adds an additional column at the right.

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000 100

30 20 30 0 -1 0 0 2000 66.667

10 55 40 0 0 -1 0 2000 200

20 30 20 0 0 0 1 0

Jeff Bivin -- LZHS

Page 12: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

66.667 is the lowest non-negative quotient.

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000 100

30 20 30 0 -1 0 0 2000 66.667

10 55 40 0 0 -1 0 2000 200

20 30 20 0 0 0 1 0

Jeff Bivin -- LZHS

Page 13: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

66.667 is the lowest non-negative quotient.Therefore, 30 is determined to be the pivot point.

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000 100

30 20 30 0 -1 0 0 2000 66.667

10 55 40 0 0 -1 0 2000 200

20 30 20 0 0 0 1 0

Jeff Bivin -- LZHS

Page 14: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Determine the row operations:row1 = 3 x row1 – 4 x row2

row3 = 3 x row3 – row2row4 = 3 x row4 – 2 x row2

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000 100

30 20 30 0 -1 0 0 2000 66.667

10 55 40 0 0 -1 0 2000 200

20 30 20 0 0 0 1 0

Jeff Bivin -- LZHS

Page 15: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Perform the row operations to determine Tableau 2

x1 x2 x3 s1 s2 s3 z Values

r1=3r1-4r2 0 -20 -120 -3 4 0 0 4000

r2 30 20 30 0 -1 0 0 2000

r3=3r3-r2 0 145 90 0 1 -3 0 4000

r4=3r4-2r2 0 50 0 0 2 0 3 -4000

Jeff Bivin -- LZHS

Page 16: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

2nd Tableau Analysis

Jeff Bivin -- LZHS

Page 17: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

A negative basic variable in s1

leads us to use column s2 as the pivot column.

x1 x2 x3 s1 s2 s3 z Values

0 -20 -120 -3 4 0 0 4000

30 20 30 0 -1 0 0 2000

0 145 90 0 1 -3 0 4000

0 50 0 0 2 0 3 -4000

Jeff Bivin -- LZHS

Page 18: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Divide the value column by the pivot column.This adds an additional column at the right.

x1 x2 x3 s1 s2 s3 z Values

0 -20 -120 -3 4 0 0 4000 1000

30 20 30 0 -1 0 0 2000 -2000

0 145 90 0 1 -3 0 4000 4000

0 50 0 0 2 0 3 -4000

Jeff Bivin -- LZHS

Page 19: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

1000 is the lowest non-negative quotient.

x1 x2 x3 s1 s2 s3 z Values

0 -20 -120 -3 4 0 0 4000 1000

30 20 30 0 -1 0 0 2000 -2000

0 145 90 0 1 -3 0 4000 4000

0 50 0 0 2 0 3 -4000

Jeff Bivin -- LZHS

Page 20: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

1000 is the lowest non-negative quotient.Therefore, 4 is determined to be the pivot point.

x1 x2 x3 s1 s2 s3 z Values

0 -20 -120 -3 4 0 0 4000 1000

30 20 30 0 -1 0 0 2000 -2000

0 145 90 0 1 -3 0 4000 4000

0 50 0 0 2 0 3 -4000

Jeff Bivin -- LZHS

Page 21: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Determine the row operations:row2 = 4 x row2 + row1row3 = 4 x row3 – row1row4 = 2 x row4 – row1

x1 x2 x3 s1 s2 s3 z Values

0 -20 -120 -3 4 0 0 4000

30 20 30 0 -1 0 0 2000

0 145 90 0 1 -3 0 4000

0 50 0 0 2 0 3 -4000

Jeff Bivin -- LZHS

Page 22: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Perform the row operations to determine Tableau 3

x1 x2 x3 s1 s2 s3 z Values

r1 0 -20 -120 -3 4 0 0 4000

r2=4r2+r1 120 60 0 -3 0 0 0 12000

r3=4r3-r1 0 600 480 3 0 -12 0 12000

r4=2r4-r1 0 120 120 3 0 0 6 -12000

Jeff Bivin -- LZHS

Page 23: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

3rd Tableau Analysis

Jeff Bivin -- LZHS

Page 24: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

A negative basic variable in s3

leads us to use column x2 as the pivot column.

x1 x2 x3 s1 s2 s3 z Values

r1 0 -20 -120 -3 4 0 0 4000

r2=4r2+r1 120 60 0 -3 0 0 0 12000

r3=4r3-r1 0 600 480 3 0 -12 0 12000

r4=2r4-r1 0 120 120 3 0 0 6 -12000

Jeff Bivin -- LZHS

Page 25: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Divide the value column by the pivot column.This adds an additional column at the right.

x1 x2 x3 s1 s2 s3 z Values

r1 0 -20 -120 -3 4 0 0 4000 -200

r2=4r2+r1 120 60 0 -3 0 0 0 12000 200

r3=4r3-r1 0 600 480 3 0 -12 0 12000 20

r4=2r4-r1 0 120 120 3 0 0 6 -12000

Jeff Bivin -- LZHS

Page 26: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

66.667 is the lowest non-negative quotient.

x1 x2 x3 s1 s2 s3 z Values

r1 0 -20 -120 -3 4 0 0 4000 -200

r2=4r2+r1 120 60 0 -3 0 0 0 12000 200

r3=4r3-r1 0 600 480 3 0 -12 0 12000 20

r4=2r4-r1 0 120 120 3 0 0 6 -12000

Jeff Bivin -- LZHS

Page 27: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

66.667 is the lowest non-negative quotient.Therefore, 30 is determined to be the pivot point.

x1 x2 x3 s1 s2 s3 z Values

r1 0 -20 -120 -3 4 0 0 4000 -200

r2=4r2+r1 120 60 0 -3 0 0 0 12000 200

r3=4r3-r1 0 600 480 3 0 -12 0 12000 20

r4=2r4-r1 0 120 120 3 0 0 6 -12000

Jeff Bivin -- LZHS

Page 28: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Determine the row operations:row1 = 30 x row1 + row3row2 = 10 x row2 – row3row4 = 5 x row4 – row3

x1 x2 x3 s1 s2 s3 z Values

0 -20 -120 -3 4 0 0 4000

120 60 0 -3 0 0 0 12000

0 600 480 3 0 -12 0 12000

0 120 120 3 0 0 6 -12000

Jeff Bivin -- LZHS

Page 29: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Perform the row operations to determine Tableau 4

x1 x2 x3 s1 s2 s3 z Values

r1=30r1+r3 0 0 -3120 -87 120 -12 0 132000

r2=10r2-r3 1200 0 -480 -33 0 12 0 108000

r3 0 600 480 3 0 -12 0 12000

r4=52r4-r3 0 0 120 12 0 12 30 -72000

Jeff Bivin -- LZHS

Page 30: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

4th Tableau Analysis

Jeff Bivin -- LZHS

Page 31: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Now we can determine the solutions

x1 x2 x3 s1 s2 s3 z Values

0 0 -3120 -87 120 -12 0 132000

1200 0 -480 -33 0 12 0 108000

0 600 480 3 0 -12 0 12000

0 0 120 12 0 12 30 -72000

Basic Variables x1, x2, and s2 are all positive and the bottom row has all

positive variable coefficientsJeff Bivin -- LZHS

Page 32: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Determining the solutions:from row 1: s2 = 132000 / 120 = 1100from row 2: x1 = 108000 / 1200 = 90

from row 3: x2 = 12000 / 600 = 20from row 4: z = -(-72000 / 30) = 2400

also: x3 = s1 = s3 = 0

x1 x2 x3 s1 s2 s3 z Values

r1=30r1+r3 0 0 -3120 -87 120 -12 0 132000

r2=10r2-r3 1200 0 -480 -33 0 12 0 108000

r3 0 600 480 3 0 -12 0 12000

r4=52r4-r3 0 0 120 12 0 12 30 -72000

Jeff Bivin -- LZHS

Page 33: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Results

x1 = 90

x2 = 20

x3 = 0

s1 = 0

s2 = 1100

s3 = 0

z = 2400

Jeff Bivin -- LZHS

Page 34: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Process CompleteAnswer the Question

• The minimum cost is $2400 when you order • 90 bags of type A fertilizer • 20 bags of type B fertilizer• 0 bags of type C fertilizer

Jeff Bivin -- LZHS

Page 35: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

A Quick Recap

Jeff Bivin -- LZHS

Page 36: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Initial Tableau

x1 x2 x3 s1 s2 s3 z Values

40 20 0 -1 0 0 0 4000 100

30 20 30 0 -1 0 0 2000 66.667

10 55 40 0 0 -1 0 2000 200

20 30 20 0 0 0 1 0

Jeff Bivin -- LZHS

Page 37: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Perform the row operations to determine Tableau 2

x1 x2 x3 s1 s2 s3 z Values

r1=3r1-4r2 0 -20 -120 -3 4 0 0 4000 1000

r2 30 20 30 0 -1 0 0 2000 -2000

r3=3r3-r2 0 145 90 0 1 -3 0 4000 4000

r4=3r4-2r2 0 50 0 0 2 0 3 -4000

Jeff Bivin -- LZHS

Page 38: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Perform the row operations to determine Tableau 3

x1 x2 x3 s1 s2 s3 z Values

r1 0 -20 -120 -3 4 0 0 4000 -200

r2=4r2+r1 120 60 0 -3 0 0 0 12000 200

r3=4r3-r1 0 600 480 3 0 -12 0 12000 20

r4=2r4-r1 0 120 120 3 0 0 6 -12000

Jeff Bivin -- LZHS

Page 39: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Perform the row operations to determine Tableau 4

x1 x2 x3 s1 s2 s3 z Values

r1=30r1+r3 0 0 -3120 -87 120 -12 0 132000

r2=10r2-r3 1200 0 -480 -33 0 12 0 108000

r3 0 600 480 3 0 -12 0 12000

r4=52r4-r3 0 0 120 12 0 12 30 -72000

Jeff Bivin -- LZHS

Page 40: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

x1 x2 x3 s1 s2 s3 z Values

r1=30r1+r3 0 0 -3120 -87 120 -12 0 132000

r2=10r2-r3 1200 0 -480 -33 0 12 0 108000

r3 0 600 480 3 0 -12 0 12000

r4=52r4-r3 0 0 120 12 0 12 30 -72000

Determine the solutions from the 4th Tableau

from row 1: s2 = 132000 / 120 = 1100from row 2: x1 = 108000 / 1200 = 90

from row 3: x2 = 12000 / 600 = 20from row 4: z = -(-72000 / 30) = 2400

also: x3 = s1 = s3 = 0

Jeff Bivin -- LZHS

Page 41: Using Spreadsheets for Linear Programming with The Simplex Method A sample problem By: Jeffrey Bivin Lake Zurich High School Last Updated: October 11,

Process CompleteAnswer the Question

• The minimum cost is $2400 when you order • 90 bags of type A fertilizer • 20 bags of type B fertilizer• 0 bags of type C fertilizer

Jeff Bivin -- LZHS