Lesson 1 Linear Programming
Lesson 1 Linear Programming
Lesson 1 Linear Programming
Graphical method can be used to solve only two variables problems but simplex
method can be used to solve problems with any number of variables.
Raw material M1 6 4 24
Raw material M2 1 2 6
X1 , x2 0 (non-negativity Constraint)
Maximize z = 5x1 + 4x2
Subject to 6x1 +4 x2 24
x1 + 2x2 6
x1 , x2 0
…….Linear Programming
Graphical method can be used to solve only two variables problems but simplex
method can be used solve problems with any number of variables.
Examples
Graphical Method
Determine the feasible space for each of the following independent
constraints, given that x1, x2 >=0.
How to determine feasible solutions by determining feasible space (region)
a. -3x1+x2 ≤ 6 d. x1-x2 ≤ 0
Graphical method can be used to solve only two variables problems but simplex
method can be used solve problems with any number of variables.
Examples
Graphical Method
Determine the feasible space for each of the following independent
constraints, given that x1, x2 >=0.
How to determine feasible solutions by determining feasible space (region)
a. -3x1+x2 ≤ 6 d. x1-x2 ≤ 0
Subject to 6x1 +4 x2 24
x1 + 2x2 6
x1 , x2 0
6
z=
5x
1 +4 6x1 +4x2 24
x2
3 C
B
x1 + 2x2 6
O A
0,0 4 6
Corner point X1 X2 z = 5x1+ 4x2
O 0 0 0
A 4 0 20
B 3 1.5 21
C 0 3 12
Subject to x1 + x2 9
x1 - 2x2 0
x1 + 2x2 28
3x1 - x2 0
x1 , x2 0
Steps:
Subject to x1 + x2 9
x1 - 2x2 0
x1 + 2x2 28
3x1 - x2 0
x1 , x2 0
3x1 - x2 0
14 x1 + 2x2 28 z=
3x
1 +8
x2
9 x +x 9 C
1 2
x1 - 2x2 0
D
B
A
0,0 9 28
Simplex Method
The graphical method in solving LP model cannot be applied when the number
of variables involved in the problem is more than three or rather two.
Even with three variables the graphical solution becomes more tedious as it
involves intersection of planes. The simplex method , developed by Prof. B.
Dantzig can be used to solve any LP problem.
Example 1.
A firm manufactures two products A and B on which the profit earned per unit
are Rs. 5 and Rs. 4 respectively. Each product is processed on two machines
M1 and M2. Product A requires six hours of processing time on machine M1
and one hour on M2, while B requires four hours on M1 and two hours on M2.
Machine M1 is available for not more than 24 hours while Machine M2 is
available for not more than 6 hours during one week. Find the number of units
of products A and B to be manufactured to get maximum profit.
Simplex Method of solving LP models
Example:
Maximize Z=5x1+4x2
6x1+4x2 <=24
x1+2x2 <=6
x1,x2 >=0
STEP 1
Start with a initial feasible solution assuming all the decision variables
are zero.
Then x1=0 and x2=0 and s1=24 and s2=6.
This means neither of the items are produced.
Resources available are unused.
This situation is represented by a initial simplex table. (or tableau). It
is called basic feasible solution (ibfs).
0 S1 6 4 1 0 24 24/6=4
0 S2 1 2 0 1 6 6/1=6
Zj 0 0 0 0 0
Cj-Zj 5 4 0 0
pivot column
Since all values in Cj-Zj row values are not negative or zero this solution is not
optimal. Then select the column with highest value in last row.
Then S1 row is the pivot row. Pivot element is 6.
Entering non-basic variable is X1 and departing basic variable is S1
Divide all values in pivot row by pivot element, 6 and fill same
row of new table.
5 X1 1 2/3 1/6 0 4
Calculate ratios
Next table (table2)
dividing b values by
P.C. values
Cj 5 4 0 0
Select lowest out of
Cb Basis X1 X2 S1 S2 b positive ratios.
- X1 1 2/3 1/6 0 4
pivot column
Since all values in Cj-Zj row values are not negative or zero this solution is not
optimal. Then select the column with highest value in last row.
Then S2 row is the pivot row. Pivot element is 4/3.
Entering non-basic variable is X2 and departing basic variable is S2
Divide all values in p.row by p.element, 4/3 and fill same row of
new table.
4 X2 0 1 -1/8 3/4 3/2
Cj 5 4 0 0
Cb Basis X1 X2 S1 S2 b
5 X1 1 0 1/4 -1/2 3
Cj 5 4 0 0
Cb Basis X1 X2 S1 S2 b
5 X1 1 0 1/4 -1/2 3
Since all values in Cj-Zj row values are negative or zero this solution is optimal.
STEP 1
Express the problem in standard form.
Express all of the constraints as equalities by adding new variables.
Add new variables to objective function with zero coefficients.
Maximize Z=2x1+5x2+6x3+0S1+0S2+0S3
2x1+3x2 +2x3 +S1=24
4x1+2x2 +4x3 +S2=36
2x1+3x2 +2x3 +S3=50
x1, x2, x3 S1, S2, S3 >=0
Here S1, S2 and S3 are Slack variables .
Slack variables represent unused amounts of resources.
STEP 2
x1, x2 and x3 are called non-basic variables because they are not in
solution.
S1, S2 and S3 they are basic variables.
…….Step 2 Calculate ratios
dividing b values by
Cj 2 5 P.C. values
6 0 0 0
Select lowest out of
Cb Basis X1 X2 S1 S2 positive ratios.
X3 S3 b
0 S1 2 3 2 1 0 0 24 24/2=12
0 S2 4 2 4 0 1 0 36 36/4=9 pivot row
0 S3 2 3 2 0 0 1 50 50/2=25
Zj 0 0 0 0 0 0 0
Cj-Zj 2 5 6 0 0 0
pivot column
Since all values in Cj-Zj row values are not negative or zero this solution is not
optimal. Then select the column with highest value in last row.
Then S2 row is the pivot row. Pivot element is 4.
Entering non-basic variable is X3 and departing basic variable is S2
Divide all values in pivot row by pivot element, 4 and fill same
row of new table.
6 X3 1 1/2 1 0 1/4 0 9
Cj 2 5 6 0 0 0
Cb Basis X1 X2 X3 S1 S2 S3 b
0 S1 0 2 0 1 -1/2 0 6
6 X3 1 1/2 1 0 1/4 0 9
0 S3
Zj
Cj-Zj
Calculation of 1st row (S1 row)
Write down the previous S1 row.
Multiply the pivot row by pivot column value 2 and subtract.
Previous S1 row : 2 3 2 1 0 0 24
Pivot row x 2: - 2 1 2 0 1/2 0 18
0 2 0 1 -1/2 0 6
Cj 2 5 6 0 0 0
Cb Basis X1 X2 X3 S1 S2 S3 b
0 S1 0 2 0 1 -1/2 0 6
6 X3 1 1/2 1 0 1/4 0 9
0 S3 0 2 0 0 -1/2 1 32
Zj
Cj-Zj
Calculation of 3rd row (S3 row)
Write down the previous S3 row.
Multiply the pivot row by pivot column value 2 and subtract.
Previous S3 row : 2 3 2 0 0 1 50
Pivot row x 2: - 2 1 2 0 1/2 0 18
0 2 0 0 -1/2 1 32
Calculate ratios
Cj 2 5 6 0 0 0 dividing bvalues by
P.C. values
Cb Basis X1 X2 X3 S1 S2 S3 b Select lowest out of
positive ratios.
0 S1 0 2 0 1 -1/2 0 6 6/2=3 pivot row
6 X3 1 1/2 1 0 1/4 0 9 9/(1/2)=18
0 S3 0 2 0 0 -1/2 1 32 32/2=16
Zj 6 3 6 0 3/2 0 54
Cj-Zj -4 2 0 0 -3/2 0
pivot column
Since there is a positive value, 2 in Cj-Zj row this solution is not optimal. Then
select the column with highest value in last row.
S1 row is the pivot row. Pivot element is 2.
Entering variable is X2 and departing variable is S1
Divide all values in pivot row by pivot element, 2 and fill same row of new
table.
5 X2 0 1 0 1/2 -1/4 0 3
Cj 2 5 6 0 0 0
Cb Basis X1 X2 X3 S1 S2 S3 b
5 X2 0 1 0 1/2 -1/4 0 3
0 S3 0 0 0 -1 0 1 26
Zj 6 5 6 1 1 0 60
Cj-Zj -4 0 0 -1 -1 0
Calculation of 2nd row (X3 row)
Calculation of 3rd row (S3 row)
Previous
PreviousXS3 3row
row: : 0 2 1 0 1/20 -1/2
1 0 1 1/432 0 9
(2):
Pivot row x (1/2): 0 2 0 0 1/21 0
-1/21/4 0 -1/86 0 3/2
0 0 1 0 -1
0 01 -1/4 1 3/8 26 0 15/2
Cj 2 5 6 0 0 0
Cb Basis X1 X2 X3 S1 S2 S3 b
5 X2 0 1 0 1/2 -1/4 0 3
0 S3 0 0 0 -1 0 1 26
Zj 6 5 6 1 1 0 60
Cj-Zj -4 0 0 -1 -1 0
Since there is no any positive values in Cj-Zj row this solution is optimal.
Subject to
3x1+x2+4x3 <=600
2x1+4x2+2x3 >=480
2x1+3x2+3x3 =540
x1, x2, x3 >=0
3x1+x2+4x3 <=600
As it has <= sign it can be add a slack variable, S 1.
3x1+x2+4x3 + S1 =600
But regarding 2x1+4x2+2x3 >=480 expression we have to deduct
some value (positive) from left hand side of the expression.
2x1+4x2+2x3 -S2 =480. S2 is called surplus variable.
But when x1=0, x2=0 and x3=0 then -S2 =480. Therefore S2 =-480.
To avoid S2 become negative another variable , A1 named artificial
variable is added to the RHS of the expression.
2x1+4x2+2x3 -S2 + A1 =480.
Z=2x1+3x2+ 4x3+0.s1+0.s2-MA1-MA2
Standard form
Maximize Z=2x1+3x2+ 4x3+0.s1+0.s2-MA1-MA2
Cb Basis X1 X2 X3 S1 S2 A1 A2 b
0 S1 3 1 4 1 0 0 0 600 600/1=600
-M A1 2 4 2 0 -1 1 0 480 480/4=120
-M 2 3 3 0 0 0 1 540 540/3=180
A2
Zj -4M -7M -5M 0 M -M -M -1020M
Cj-Zj 2+4M 3+7M 4+5M 0 -M 0 0
Cb Basis X1 X2 X3 S1 S2 A2 b
-M A2 180/(3/2) =120
1/2 0 3/2 0 3/4 1 180
Cb Basis X1 X2 X3 S1 S2 b
0 S1 4/3 0 0 1 -3/2 60
3 X2 1/3 1 0 0 -1/2 60
Cb Basis X1 X2 X1 S1 S2 b
0 S1 4/3 0 0 1 -3/2 60
3 X2 1/3 1 0 0 -1/2 60
Subject to
2x1+x2>= 40
x1+2x2>=50
x1+x2>= 35
x1, x2>=0
Solution
Step 1
Standard form
Minimize Z=4x1+3x2+ 0.s1+0.s2+0.s2+MA1+MA2+MA3
Cb Basis X1 X2 S1 S2 S3 A1 A2 A3 b
M A1 2 1 -1 0 0 1 0 0 40 40/1=40
M A2 1 2 0 -1 0 0 1 0 50 50/2=25
M A3 1 1 0 0 -1 0 0 1 35 35/1=35
Zj 4M 4M -M -M -M M M M 125M
Cj-Zj 4-4M 3-4M M M M 0 0 0
New pivot row: Here A2 column is not included to the new table.
3 X2 1/2 1 0 -1/2 0 0 0 25
Cj 4 3 0 0 0 M M
Cb Basis X1 X2 S1 S2 S3 A1 A3 b
Cb Basis X1 X2 S1 S2 S3 A3 b
Cb Basis X1 X2 S1 S2 S3 b
4 X1 1 0 -1 0 1 5
3 X2 0 1 1 0 -2 30
0 S2 0 0 1 1 -3 15
Zj 4 3 -1 0 -2 110
Cj-Zj 0 0 1 0 2
Cb Basis X1 X2 S1 S2 S3 b
4 X1 1 0 -1 0 1 5
3 X2 0 1 1 0 -2 30
0 S2 0 0 1 1 -3 15
Zj 4 3 -1 0 -2 110
Cj-Zj 0 0 1 0 2
Cb Basis X1 X2 X3 S1 S2 b
0 S1 8 2 8 1 0 100
0 S2 4 4 4 0 1 60
ZJ 0 0 0 0 0 0
Cj-ZJ 20 15 15 0 0
Initial Solution
Cj 20 15 15 0 0
Cb Basis X1 X2 X3 S1 S2 b
Cj 20 15 15 0 0
Cb Basis X1 X2 X3 S1 S2 b
0 X1 1 0 1 1/6 -1/12 35/3
x2 +(-1/6)s1+(1/3) s2=10/3
…….Changes of resources
x1+ x3 +1/6 s1-1/12 s2=35/3 x2 -1/6 s1+1/3 s2=10/3
Therefore new solutions are 35/3 +h/6 and 10/3-h/6. In order to remain the
solution feasible those values must be positive.
35/3+h/6 >0 h >-70 100+h >30
10/3-h/6 >0 h < 20 100+h < 120
Therefore range of first resource must be from 30 to 120.
What will be the new solutions if the first resource is increased
by 12 units ?
Another method how to find effect of change of 0
resources
S1 b
Divide the solution values by relevant resource
column values. 1/6 35/3
Example 1 Cj 4+h 6 3 1 0 0 0
b
Cb Basis X1 X2 X3 X4 S1 S2 S3
Let’s change in X2 variable as 6+h. Then recalculate all Zj and Cj-Zj row values.
Cj 4 6+h 3 1 0 0 0
Cb Basis X1 X2 X3 X4 S1 S2 S3 b
Select those Cj-Zj row values which include h value. In order to remain the
current solution un effected all those values must be less than or equal to zero.
(if it is a maximization problem)
-1/20-13h/20<0 -1/13< h
-7/2-h/2<0 -7 < h
-3/10+h/10<0 h<3 -7 -9/2 -1/13 3
Let’s change in X3 variable as 3+h. Then recalculate all Zj and Cj-Zj row values.
Cj 4 6 3+h 1 0 0 0
Cb Basis X1 X2 X3 X4 S1 S2 S3 b
Select those Cj-Zj row values which include h value. In order to remain the
current solution un effected all those values must be less than or equal to zero.
(if it is a maximization problem)
-1/20-h/20<0 -1< h
-7/2-h/2<0 -7 < h
-3/10-3h/10<0 -1< h -7 -1 9
-9/5+h/5<0 h< 9
……Changes of objective function coefficients of basic variables.
b b
0 2
12 2
5 5
Multiple Optimal Solution
3x1 - x2 0
14 x1 + 2x2 28 z=
3x
1 +6
x2
9 x +x 9 C
1 2
x1 - 2x2 0
D
B
A
0,0 9 28
If Z line is parallel to one of boundary line all the points on that boundary
give optimal solutions. ( as in the example points of line BC)
In the optimal simplex table if a non-basic variable has a zero value in the Cj –Zj
row there exist an multiple solution.
In practically it is useful because the decision makers can have flexible decision
on having more choices in their optimal solutions
Example
Cj
Cb Basis x1 b
0 S1
0 S2
Z
Cj-ZJ 0
Unbounded Solution
3x1 - x2 0
Ma
14 x :z
=3
x1 +
8x
2
9 x +x 9 C
1 2
x1 - 2x2 0
D
B
A
0,0 9 28
Example
Cj
Cb Basis b
0 S1 -4 24 -6
0 S2 -2 18 -9
Z
Cj-ZJ
Infeasible Solution
If all the constraints are not satisfied simultaneously the model has no
Infeasible solution. In simplex method when the optimal solution occurred
there exist an Artificial variable in the basis then model is infeasible.
Cj
Cb Basis x1 x2 b An optimal solution
0 S1
0 A1
Z
Cj-ZJ -3 -1 -M -6
6
4 x1
+ x1 +
x2 3x
4
2 1
8
0,0 4 18