45
EXAMPLES ON SIMPLEX ALGORITHM Dr. KRISHAN K. PANDEY ASSISTANT PROFESSOR CMES, UNIVERSITY OF PETROLEUM & ENERGY STUDIES, DEHRADUN (U.K.), INDIA

Examples on Simplex Algorithm

Embed Size (px)

Citation preview

Page 1: Examples on Simplex Algorithm

EXAMPLES ON SIMPLEX ALGORITHM

Dr. KRISHAN K. PANDEY

ASSISTANT PROFESSOR

CMES, UNIVERSITY OF PETROLEUM & ENERGY STUDIES,

DEHRADUN (U.K.), INDIA

Page 2: Examples on Simplex Algorithm

Example 1

A manufacturer of leather belts makes three types of belts A,B and C which

are processed on three machines M1, M 2 and M3. Belt A requires 2 hours

on Machine M1 and 3 hours on machine M3. Belt B requires 3 hours on

Machine M1 , 2 hours on machine M2 and 2 hours on machine M3; and

Belt C requires 5 hours on Machine M2 and4 hours on machine M3.There

are 8 hours of time per day available on machine M1 , 10 hours of time

per day available on machine M2 and 15 hours of time per day available

on machine M3.The profit gained from belt A is Rs. 3 per unit, from belt B

is Rs. 5 per unit , from belt C is Rs. 4 per unit . What should be the daily

production of each type of belts so that the profit is maximum.

Page 3: Examples on Simplex Algorithm

Mathematical Form :

Maximize z = 3x1+5x2+4x3

S.t. 2x1+3x2 ≤ 8,

2x2+5x3 ≤ 10,

3x1+2x2+4x3 ≤ 15,

x1,x2,x3 ≥ 0.

Page 4: Examples on Simplex Algorithm

I Simplex Table

C j 3 5 4 0 0 0

CB Basic Variable(B)

Solution

Values xB

x1 x2 x3S1 S2 S3

0 S18 2 3 0 1 0 0

0 S210 0 2 5 0 1 0

0 S315 3 2 4 0 0 1

Z j – C j 0

- 3 - 5 - 4 0 0 0

3

Page 5: Examples on Simplex Algorithm

II Simplex Table

C j 3 5 4 0 0 0

CB Basic Variable(B)

Solution

Values xB

x1 x2 x3S1 S2 S3

5 x28/ 3 2 / 3 1 0 1 / 3 0 0

0 S214 / 3 - 4 / 3 0 5 - 2/ 3 1 0

0 S329 / 3 5 / 3 0 4 - 2/ 3 0 1

Z j – C j 40 / 3 1 / 3 0 - 4 5 / 3 0 0

5

Page 6: Examples on Simplex Algorithm

III Simplex Table

C j 3 5 4 0 0 0

CB Basic Variable(B)

Solution

Values xB

x1 x2 x3S1 S2 S3

5 x28/ 3 2 / 3 1 0 1 / 3 0 0

4 x314 / 15 - 4 / 15 0 1 - 2/ 15 1/5 0

0 S389 / 15 0 0 - 2/ 15 - 4/5 1

Z j – C j 256 / 15 - 11 / 15 0 0 17/15 4/5 0

41 / 15

Page 7: Examples on Simplex Algorithm

IV Simplex Table

C j 3 5 4 0 0 0

CB Basic Variable(B)

Solution

Values xB

x1 x2 x3S1 S2 S3

5 x250/41 0 1 0 15 /41 8/41 -10/41

4 x362 / 41 0 0 1 - 6/ 41 5/41 4/41

3 x189 / 41 1 0 0 - 2/ 41 -12/41 15/41

Z j – C j 765 / 41 0 0 0 45/41 24/41 11/41

Page 8: Examples on Simplex Algorithm

Now since all Z j – C j are non negative, therefore an

optimum basic solution is

X1= 89/41, X2= 50/41, X3= 62/41; max. z = 765/41.

Hence in order to achieve a maximum income of

Rs. 765/41, the firm should produce 89/41 units of

belt A, 50/41 units of belt B and 62/41 unit of belt C.

Page 9: Examples on Simplex Algorithm

Example 2

Maximize z = 3x1 + 2x2

subject to:

- x1 + 2x2 ≤ 43x1 + 2x2 ≤ 14

x1 - x2 ≤ 3

x1, x2 ≥ 0

Page 10: Examples on Simplex Algorithm

I Simplex Table

C j 3 2 0 0 0

CB Basic Variable

(B)

Solution

Values xB

x1 x2S1 S2 S3

0 S14 - 1 2 1 0 0

0 S214 3 2 0 1 0

0 S33 - 1 0 0 1

Z j – C j 0

- 3 - 2 0 0 0

1

Page 11: Examples on Simplex Algorithm

II Simplex Table

C j 3 2 0 0 0

CB Basic Variable(B)

Solution

Values xB

x1 x2S1 S2 S3

0 S17 0 1 1 0 1

0 S25 0 0 1 - 3

3 X13 1 - 1 0 0 1

Z j – C j 9

0 - 5 0 0 3

5

Page 12: Examples on Simplex Algorithm

III Simplex Table

C j 3 2 0 0 0

CB Basic Variable(B)

Solution

Values xB

x1 x2S1 S2 S3

0 S16 0 0 1 - 1/5 8/5

2 X21 0 1 0 1/5 - 3/5

3 X14 1 0 0 1/5 2/5

Z j – C j 14 0 0 0 1 0

Page 13: Examples on Simplex Algorithm

Since all the values of zj- cj are positive, this is the

optimal solution.

x1 = 4, x2 = 1

z = 3 * 4 + 2 * 1 = 14.

The largest profit of Rs.14 is obtained, when 1 unit of

x2 and 4 units of x1 are produced. The above solution

also indicates that 6 units are still unutilized, as

shown by the slack variable S1 in the XB column.

Page 14: Examples on Simplex Algorithm

NOTE :

Please don't convert the fractions into decimals, because

many fractions cancel out during the process while the

conversion into decimals will cause unnecessary

complications.

“Minds are like parachutes; they work best when open.”

Page 15: Examples on Simplex Algorithm

Example 3Luminous Lamps produces three types of lamps - A, B, and C.

These lamps are processed on three machines - X, Y, and Z.

The full technology and input restrictions are given in the

following table. Find out a suitable product mix so as to

maximize the profit.

Product Machine Profit per unit

X Y Z

A10 7 2 12

B2 3 4 3

C1 2 1 1

Available Time100 77 80

Page 16: Examples on Simplex Algorithm

Solution.

The decision problem can be formulated as

Maximize z = 12x1 + 3x2 + x3

subject to :

10x1 + 2x2 + x3 ≤ 100 7x1 + 3x2 + 2x3 ≤ 772x1+ 4x2 + x3 ≤ 80

x1, x2, x3 ≥ 0

Page 17: Examples on Simplex Algorithm

Converting inequalities to equalities

10x1 + 2x2 + x3 + x4 = 100 7x1 + 3x2 + 2x3 + x5 = 772x1+ 4x2 + x3 + x6 = 80x1, x2, x3, x4, x5, x6 ≥ 0

Where x4, x5 and x6 are slack variables.

Including these slack variables in the objective function, we get

• Maximize z = 12x1 + 3x2 + x3 + 0x4 + 0x5 + 0x6

• Initial basic feasible solution

• x1 = 0, x2 = 0, x3 = 0, z = 0x4 = 100, x5 = 77, x6 = 80.

Page 18: Examples on Simplex Algorithm

Table 1cj 12 3 1 0 0 0

cB Basic variable

XB

x1 x2 x3 x4 x5 x6 Solution values

b (=XB)

0 x4 10 2 1 1 0 0 100

0 x5 7 3 2 0 1 0 77

0 x6 2 4 1 0 0 1 80

zj-cj -12 -3 -1 0 0 0

Key column = x1 column, Minimum (100/10, 77/7, 80/2) = 10, Key row = x4 row,

Pivot element = 10

Page 19: Examples on Simplex Algorithm

cj 12 3 1 0 0 0

cB Basic

variables

B

x1 x2 x3 x4 x5 x6 Solution values

b (= XB)

12 x1 1 1/5 1/10 1/10 0 0 10

0 x5 0 8/513/1

0-7/10 1 0 7

0 x6 0 18/5 4/5 -1/5 0 1 60

zj-cj 0 -3/5 1/5 6/5 0 0

Table 2

Page 20: Examples on Simplex Algorithm

Final Table

cj 12 3 1 0 0 0

cB Basic variables

B

x1 x2 x3 x4 x5 x6 Solution values

b (= XB)

12 x1 1 0 -1/16 3/16 -1/8 0 73/8

3 x2 0 1 13/16 -7/16 5/8 0 35/8

0 x6 0 0 -17/8 11/8 -9/4 1 177/4

zj-cj 0 0 11/16 15/16 3/8 0

An optimal policy is x1 =73/8, x2 = 35/8, x3 = 0.

The associated optimal value of the objective function is

z = 12 * (73/8) + 3 * (35/8) + 1 * 0 = 981/8.

Page 21: Examples on Simplex Algorithm

Some Special Cases

1. Unrestricted (unconstrained) Variables:

Sometimes decision variables are unrestricted in sign (positive, negative or

zero). In all such cases, the decision variables can be expressed as the

difference between two non-negative variables. For example, if x1 is

unrestricted in sign, then Put x1 = x1' - x1'' .

Example :

Maximize z = 2x1 + 3x2

subject to,

-x1 + 2x2 ≤ 4

x1 + x2 ≤ 6

x1 + 3x2 ≤ 9

x1, x2 are unrestricted in sign

Page 22: Examples on Simplex Algorithm

Solution:

Since x1 and x2 are unrestricted in sign, we can replace them by non-

negative variables x1' , x1'', x2' , x2'' .

Put x1 = x1' - x1'‘ and x2 = x2' - x2''

The given problem can be written as

Max. z = 2(x1' - x1'') + 3(x2' - x2'')

subject to: -(x1' - x1'') + 2(x2' - x2'') ≤ 4

(x1' - x1'') + (x2' - x2'') ≤ 6

(x1' - x1'') + 3(x2' - x2'') ≤ 9

Introducing slack variables

Max. z = 2x1' - 2x1'' + 3x2' - 3x2''

subject to:

-x1' + x1'' + 2x2' - 2x2'' + x3 = 4x1' - x1'' + x2' - x2'' + x4 = 6x1' - x1'' + 3x2' - 3x2'' + x5 = 9

Where x3, x4 and x5 are slack variables.

Page 23: Examples on Simplex Algorithm

Table 1cj 2 -2 3 -3 0 0 0

cB Basic variables

B

x1' x1'' x2

' x2'' x3 x4 x5 Solution values

b (=XB)

0 x3 -1 1 2 -2 1 0 0 4

0 x4 1 -1 1 -1 0 1 0 6

0 x5 1 -1 3 -3 0 0 1 9

zj-cj -2 2 -3 3 0 0 0

Page 24: Examples on Simplex Algorithm

Key column = x2' column, Minimum (4/2, 6/1, 9/3) = 2, Key row = x3 row. Pivot element = 2

Table 2cj 2 -2 3 -3 0 0 0

cB Basic variables

B

x1' x1'' x2

' x2'' x3 x4 x5 Solution values

b (=XB)

3 x2' -1/2 1/2 1 -1 1/2 0 0 2

0 x4 3/2 -3/2 0 0 -1/2 1 0 4

0 x5 5/2 -5/2 0 0 -3/2 0 1 3

zj-cj -7/2 7/2 0 0 3/2 0 0

Page 25: Examples on Simplex Algorithm

Table 3

cj 2 -2 3 -3 0 0 0

cB Basic

variables

B

x1' x1'' x2

' x2'' x3 x4 x5 Solution values

b (=XB)

3 x2' 0 0 1 -1 1/5 0 1/5 13/5

0 x4 0 0 0 0 2/5 1 -3/5 11/5

2 x1' 1 -1 0 0 -3/5 0 2/5 6/5

zj-cj 0 0 0 0 -3/5 0 7/5

Page 26: Examples on Simplex Algorithm

Table 4cj 2 -2 3 -3 0 0 0

cB Basic variables

B

x1' x1'' x2

' x2'' x3 x4 x5 Solution values

b (=XB)

3 x2' 0 0 1 -1 0 -1/2 1/2 3/2

0 x3 0 0 0 0 1 5/2 -3/2 11/2

2 x1' 1 -1 0 0 0 3/2 -1/2 9/2

zj-cj 0 0 0 0 0 3/2 1/2

The optimal solution is:

x1' = 9/2, x1'' = 0, x2' = 3/2, x2'' = 0.

Solution of the original problem is:

x1 = x1' - x1'' = 9/2 - 0 = 9/2

x2 = x2' - x2'' = 3/2 - 0 = 3/2

z = 2 * 9/2 + 3 * 3/2 = 27/2.

Page 27: Examples on Simplex Algorithm

2. Unbounded Solution :

If in course of simplex computation zj - cj < 0, but minimum

positive value is ≤ 0 then the problem has an unbounded

solution.

Example :

Maximize 5x1 + 4x2

subject to : x1 ≤ 7

x1 - x2 ≤ 8

x1, x2 ≥ 0.

Solution.

Converting inequalities to equalities

x1 + x3 = 7

x1 - x2 + x4 = 8

x1, x2, x3, x4 ≥ 0.

Where x3 and x4 are slack variables.

Page 28: Examples on Simplex Algorithm

Table 1cj 5 4 0 0

cB Basic variables

B

x1 x2 x3 x4 Solution values

b (=XB)

0 x3 1 0 1 0 7

0 x4 1 -1 0 1 8

zj-cj -5 -4 0 0

Page 29: Examples on Simplex Algorithm

Table 2cj 5 4 0 0

cB Basic variables

B

x1 x2 x3 x4 Solution values

b (=XB)

5 x1 1 0 1 0 7

0 x4 0 -1 -1 1 1

zj-cj 0 -4 5 0

Since minimum positive value is infinity, it is not

possible to proceed with the simplex computation any

further. This is the criterion for unbounded solution.

Page 30: Examples on Simplex Algorithm

3. No Feasible Solution :

If in course of simplex computation, one or more

artificial variables remain in the basis at positive level at

the end of phase 1 computation, the problem has no

feasible solution. For example, let us consider the

following problem.

Example

Maximize -200x1 - 300x2

subject to :

2x1 + 3x2 ≥ 1200

x1 + x2 ≤ 400

2x1 + 3/2x2 ≥ 900

x1, x2 ≥ 0

Page 31: Examples on Simplex Algorithm

In this method, the whole procedure of solving a linear

programming problem involving artificial variables is divided

into two phases. In phase I, we form a new objective function

by assigning zero to every original variable (including slack

and surplus variables) and -1 to each of the artificial variables.

Then we try to eliminate the artificial varibles from the basis.

The solution at the end of phase I serves as a basic feasible

solution for phase II. In phase II, the original objective

function is introduced and the usual simplex algorithm is used

to find an optimal solution.

TWO – PHASE METHOD

Page 32: Examples on Simplex Algorithm

Example: 1

Minimize z = - 3x1 + x2 - 2x3

subject to

x1 + 3x2 + x3 ≤ 52x1 - x2 + x3 ≥ 24x1 + 3x2 - 2x3 = 5

x1, x2, x3 ≥ 0

Solution:

Maximize z = 3x1 - x2 + 2x3

subject to

x1 + 3x2 + x3 ≤ 52x1 - x2 + x3 ≥ 24x1 + 3x2 - 2x3 = 5

x1, x2, x3 ≥ 0

Page 33: Examples on Simplex Algorithm

Converting inequalities to equalities

x1 + 3x2 + x3 + x4= 5

2x1 - x2 + x3 – x5 = 2

4x1 + 3x2 - 2x3 = 5

x1, x2, x3 , x4 , x5 ≥ 0

Where:

x4 is a slack variable

x5 is a surplus variable

Now, if we let x1, x2 and x3 equal to zero in the initial solution, we will have x4 = 5

and x5 = -2, which is not possible because a surplus variable cannot be negative.

Therefore, we need artificial variables.

x1 + 3x2 + x3 + x4 = 5

2x1 - x2 + x3 - x5 + A1 = 2

4x1 + 3x2 - 2x3 + A2 = 5

x1, x2, x3, x4, x5, A1, A2 ≥ 0

Where A1 and A2 are artificial variables.

Page 34: Examples on Simplex Algorithm

PHASE 1

In this phase, we remove the artificial variables and find an initial feasible

solution of the original problem. Now the objective function can be

expressed as

Maximize 0x1 + 0x2 + 0x3 + 0x4 + 0x5 + (- A1) + (- A2)

subject to

x1 + 3x2 + x3 + x4 = 5

2x1 - x2 + x3 - x5 + A1 = 2

4x1 + 3x2 - 2x3 + A2 = 5

x1, x2, x3, x4, x5, A1, A2 ≥ 0

Initial basic feasible solution

The initial basic feasible solution is obtained by setting

x1 = x2 = x3 = x5 = 0

Then we shall have A1 = 2 , A2 = 5, x4 = 5

Page 35: Examples on Simplex Algorithm

TABLE 1

cj 0 0 0 0 0 -1 -1

cB Basic variables

B

x1 x2 x3 x4 x5 A1 A2 Solution values

b (= XB)

0 x4 1 3 1 1 0 0 0 5

-1 A1 2 -1 1 0 -1 1 0 2

-1 A2 4 3 -2 0 0 0 1 5

Zj- cj -6 -2 1 0 1 0 0

Key column = x1 column

Minimum (5/1, 2/2, 5/4) = 1

Key row = A1 row

Pivot element = 2

A1 departs and x1 enters.

Page 36: Examples on Simplex Algorithm

TABLE 2

cj 0 0 0 0 0 -1

cB Basic variables

B

x1 x2 x3 x4 x5 A2 Solution values

b (= XB)

0 x4 0 7/2 1/2 1 1/2 0 4

0 x1 1 -1/2 1/2 0 -1/2 0 1

-1 A2 0 5 -4 0 2 1 1

zj-cj 0 -5 4 0 -2 0

A2 departs and x2 enters. Here, Phase 1 terminates because both the artificial

variables have been removed from the basis.

Page 37: Examples on Simplex Algorithm

PHASE 2

The basic feasible solution at the end of Phase 1 computation is used as

the initial basic feasible solution of the problem. The original objective

function is introduced in Phase 2 computation and the usual simplex

procedure is used to solve the problem.

TABLE 3cj 3 -1 2 0 0

cB Basic variables

B

x1 x2 x3 x4 x5 Solution values

b (= XB)

0 x4 0 0 33/10 1 -9/10 33/10

3 x1 1 0 1/10 0 -3/10 11/10

-1 x2 0 1 -4/5 0 2/5 1/5

zj-cj 0 0 -9/10 0 -13/10

Page 38: Examples on Simplex Algorithm

TABLE 4

cj 3 -1 2 0 0

cB Basic variables

B

x1 x2 x3 x4 x5 Solution values

b (= XB)

0 x4 0 9/4 3/2 1 0 15/4

3 x1 1 3/4 -1/2 0 0 5/4

0 x5 0 5/2 -2 0 1 1/2

zj-cj 0 13/4 -7/2 0 0

Page 39: Examples on Simplex Algorithm

TABLE 5

cj 3 -1 2 0 0

cB Basic variables

B

x1 x2 x3 x4 x5 Solution values

b (= XB)

2 x3 0 3/2 1 2/3 0 5/2

3 x1 1 3/2 0 1/3 0 5/2

0 x5 0 11/2 0 4/3 1 11/2

zj-cj 0 17/2 0 7/3 0

An optimal policy is x1 = 5/2, x2 = 0, x3 = 5/2. The associated optimal value

of the objective function is z = 3 * (5/2) - 0 + 2 * (5/2) = 25/2.

Page 40: Examples on Simplex Algorithm

EXAMPLE 2

Maximize z = 12x1 + 15x2 + 9x3

subject to

8x1 + 16x2 + 12x3 ≤ 2504x1 + 8x2 + 10x3 ≥ 807x1 + 9x2 + 8x3 = 105

x1, x2, x3 ≥ 0

Solution.

Introducing slack, surplus & artificial variables

8x1 + 16x2 + 12x3 + x4 = 2504x1 + 8x2 + 10x3 - x5 + A1 = 807x1 + 9x2 + 8x3 + A2 = 105

Where:x4 is a slack variable.x5 is a surplus variable.A1& A2 are artificial variables.

Page 41: Examples on Simplex Algorithm

PHASE 1

Maximize 0x1 + 0x2 + 0x3 + 0x4 + 0x5 + (- A1) + (- A2)

subject to

8x1 + 16x2 + 12x3 + x4 = 2504x1 + 8x2 + 10x3 - x5 + A1 = 807x1 + 9x2 + 8x3 + A2 = 105

x1, x2, x3, x4, x5, A1, A2 ≥ 0

Equating x1, x2, x3, x5 to zero.

Initial basic feasible solution

x4 = 250, A1= 80 , A2 = 105

Page 42: Examples on Simplex Algorithm

TABLE 1

cj 0 0 0 0 0 -1 -1

cB Basic variables

B

x1 x2 x3 x4 x5 A1 A2 Solution values

b (= XB)

0 x4 8 16 12 1 0 0 0 250

-1 A1 4 8 10 0 -1 1 0 80

-1 A2 7 9 8 0 0 0 1 105

Zj-cj -11 -17 -18 0 1 0 0

Page 43: Examples on Simplex Algorithm

TABLE 2

cj 0 0 0 0 0 -1

cB Basic variables

B

x1 x2 x3 x4 x5 A2 Solution values

b (= XB)

0 x4 16/5 32/5 0 1 6/5 0 154

0 x3 2/5 4/5 1 0 -1/10 0 8

-1 A2 19/5 13/5 0 0 4/5 1 41

zj-cj -19/5 -13/5 0 0 -4/5 0

Here, Phase 1 terminates because both the artificial variables have been

removed from the basis.

Page 44: Examples on Simplex Algorithm

PHASE 2

TABLE 3

cj 12 15 9 0 0

cB Basic variables

B

x1 x2 x3 x4 x5 Solution values

b (= XB)

0 x4 0 80/19 0 1 10/19 2270/19

9 x3 0 10/19 1 0 -7/38 70/19

12 x1 1 13/19 0 0 4/19 205/19

zj-cj 0 -39/19 0 0 33/38

Page 45: Examples on Simplex Algorithm

TABLE 4

C j 12 15 9 0 0

cB Basic

variables

B

x1 x2 x3 x4 x5 Solution values

b (= XB)

0 x4 0 0 - 8 1 2 90

15 x2 0 1 19/10 0 -7/20 7

12 x1 1 0 -13/10 0 9/20 6

Zj- cj 0 0 39 /10 0 3/20

The optimal solution is:

x1 = 6, x2 = 7, x3 = 0

z = 12 *6 + 15 * 7 + 9 * 0 = 177.