Mathematical Foundation
for Computer Science 2
Linear Programming
Problem
Module-1
Syllabus
Introduction, Formulation of linear programming problem and basic
feasible solution: graphical method, Simplex method, artificial variables,
Big M method, Two Phase method.
Self Learning Topics:special cases of LPP
Introduction
Introduction (contd…)
History of OR
Linear Programming
Linear Programming
Linear Programming
Let us look at the steps of defining a Linear Programming problem generically:
1. Identify the decision variables
2. Write the objective function
3. Mention the constraints
4. Explicitly state the non-negativity restriction
For a problem to be a linear programming problem, the decision variables, objective function and
constraints all have to be linear functions.
If all the three conditions are satisfied, it is called a Linear Programming Problem.
Example
Suppose an industry is producing two types of products P1 and P2. The profit per
kg of Rs. 30 and Rs. 40 for the two products respectively. These two products
require processing in three types of machines. Following table shows the available
machine hours per day and time required on each machine to produce 1 kg of P1
and P2. Formulate the problem in LP model
Example
Problem
Consider a chocolate manufacturing company that produces only two types of chocolate – A and B. Both the chocolates require
Milk and Choco only. To manufacture each unit of A and B, the following quantities are required:
● Each unit of A requires 1 unit of Milk and 3 units of Choco
● Each unit of B requires 1 unit of Milk and 2 units of Choco
The company kitchen has a total of 5 units of Milk and 12 units of Choco. On each sale, the company makes a profit of
● Rs 6 per unit A sold
● Rs 5 per unit B sold.
Now, the company wishes to maximize its profit. Formulate LPP?
Profit: Max Z = 6X+5Y
X+Y ≤ 5
3X+2Y ≤ 12
X ≥ 0 & Y ≥ 0
Problem
A farmer has recently acquired a 110 hectares piece of land. He has decided to grow Wheat and barley on that land. Due to the
quality of the sun and the region’s excellent climate, the entire production of Wheat and Barley can be sold. He wants to know
how to plant each variety in the 110 hectares, given the costs, net profits and labor requirements according to the data shown
below:
The farmer has a budget of Rs. 10,000 and availability of 1,200 man-days during the planning horizon. Formulate the LPP.
Max Z = 50X + 120Y
100X + 200Y ≤ 10,000
10X + 30Y ≤ 1200
X + Y ≤ 110
X ≥ 0, Y ≥ 0
Graphical Method
Graphical solution is limited to linear programming models containing only two
decision variables.
Procedure
Step I: Convert each inequality as equation
Step II: Plot each equation on the graph
Step III: Shade the ‘Feasible Region’. Highlight the common Feasible region.
❑ Feasible Region: Set of all possible solutions.
Step IV: Compute the coordinates of the corner points (of the feasible region).
These corner points will represent the ‘Feasible Solution’.
❑ Feasible Solution: If it satisfies all the constraints and non negativity restrictions.
Procedure (Cont...)
Step V: Substitute the coordinates of the corner points into the objective function
to see which gives the Optimal Value. That will be the ‘Optimal Solution’.
❑ Optimal Solution: If it optimizes (maximizes or minimizes) the objective function.
❑ Unbounded Solution: If the value of the objective function can be increased or
decreased indefinitely, Such solutions are called Unbounded solution.
❑Inconsistent Solution: It means the solution of problem does not exist. This is
possible when there is no common feasible region.
Graphical Method
Convert into Standard form
Outgoing variable
Incoming variable
Final Table
Optimal Solution:
X1 = 2
X2 =2
Z = 26
Problem
Problem
Example
Cj -1 3 -2 0 0 0 Min. Ratio
CB B.V X1 X2 X3 S1 S2 S3 b
0 S1 3 -1 3 1 0 0 7 -
0 S2 -2 4 0 0 1 0 12 12/4=3
0 S3 -4 3 8 0 0 1 10 10/3=3.33
Zj 0 0 0 0 0 0
Cj - Zj -1 3 -2 0 0 0
R1
R2
R3
Cj -1 3 -2 0 0 0 Min. Ratio
CB B.V X1 X2 X3 S1 S2 S3 b
0 S1 5/2 0 3 1 1/4 0 10 4
3 X2 -1/2 1 0 0 1/4 0 3 -
0 S3 -5/2 0 8 0 -3/4 1 1 -
Zj -3/2 3 0 0 3/4 0
Cj - Zj 1/2 0 -2 0 -3/4 0
NR2= R2/4
NR1= R1 + NR2
NR3= R3- 3 NR2
R1
R3
R2
Cj -1 3 -2 0 0 0
CB B.V X1 X2 X3 S1 S2 S3 b
-1 X1 1 0 6/5 2/5 1/10 0 4
3 X2 0 1 3/5 1/5 3/10 0 5
0 S3 0 0 11 1 -1/2 1 11
Zj -1 3 3/5 1/5 4/5 0
Cj - Zj 0 0 -13/5 -1/5 -4/5 0
NR1=2R1/5
NR2= R2 + NR1/2
NR3= R3+ 5 NR2/2
All Δj are -ve or 0
so stop.
Solution
X1 =4 , X2 = 5 , X3=0
Z’ = 11
Z = -11
It is the case of degenerate solution as one of the decision variable
is equal to 0.
Example
Δ
Big M Method
Pivot row= row/key element
Example
Table -1
Pivot row= row/key element
Table -2
Table-3
MIXED CONSTRAINTS
Simplex Table II
Cj 2 3 4 0 0 -M -M
Basic
variable
solution
Value
X1 X2 X3 S1 S2 A1 A2 Min
Ratio
0 S1 480 5/2 0 7/2 1 1/4 -1/4 0 137.1
3 X2 120 1/2 1 1/2 0 -1/4 1/4 0 240
-M A2 180 1/2 0 3/2 0 3/4 -3/4 1 120
Zj 360- 180M - M/2
+3/2
3 -
3M/2
+ 3/2
0 -3M/4
-3/4
3M/4
+ 3/4
-M
Cj-Zj M/2
+1/2
0 3M/2
+ 5/2
0 3M/4+
3/4
-
7M/4-
3/4
0
NR2=R2/4
NR1=R1 - NR2
NR3= R3 - 3xNR2
Simplex Table III
Cj 2 3 4 0 0 -M -M
Basic
variable
solutio
n Value
X1 X2 X3 S1 S2 A1 A2
0 S1 20 4/3 0 0 1 -3/2 3/2 -7/3
3 X2 60 1/3 1 0 0 -1/2 1/2 -1/3
4 X3 120 1/3 0 1 0 1/2 -1/2 2/3
Zj 660 7/3 3 4 0 1/2 -1/2 5/3
Cj-Zj -1/3 0 0 0 -1/2 -M+ 1/2 -M -5/3
NR3=2xR3/3
NR1=R1 - 7xNR3/2
NR2= R2 - NR3/2
Solution:
X1=0
X2=60
X3= 120
Z= 660
Two Phase Method
Two Phase Method contd….
Example
Standard form Min Z = x1 + x2 +0.s1 +0.s2 + A1 + A2
2x1 + x2 - s1 + A1 = 4
x1 + 7x2 - s2 + A2 =7
x1,x2,s1,s2,A1,A2 >=0
Phase 1
Min Z = A1 + A2
Table 1
Cj 0 0 0 0 1 1
Basic
variable
solution
Value
X1 X2 S1 S2 A1 A2 Min.
Ratio
1 A1 4 2 1 -1 0 1 0 4
1 A2 7 1 7 0 -1 0 1 1
Zj 11 3 8 -1 -1 1 1
Cj-Zj -3 -8 1 1 -1 -1
Cj 0 0 0 0 1 1
Basic
variable
solution
Value
X1 X2 S1 S2 A1 A2 Min.
Ratio
1 A1 3 13/7 0 -1 1/7 1 -1/7 21/13
0 X2 1 1/7 1 0 -1/7 0 1/7 7
Zj 3 13/7 0 -1 1/7 1 -1/7
Cj-Zj -13/7 0 1 -1/7 0 6/7
Table 2
Cj 0 0 0 0 1 1
Basic
variable
solution
Value
X1 X2 S1 S2 A1 A2
0 X1 21/13 1 0 -7/13 1/13 7/13 -1/13
0 X2 10/13 0 1 1/13 -2/13 -1/13 2/13
Zj 0 0 0 0 0 0 0
Cj-Zj 0 0 0 0 1 1
Table 3
Cj 1 1 0 0
Basic
variable
solution
Value
X1 X2 S1 S2
1 X1 21/13 1 0 -7/13 1/13
1 X2 10/13 0 1 1/13 -2/13
Zj 31/13 1 1 -6/13 -1/13
Cj-Zj 0 0 6/13 1/13
Table 1
Phase 2
Standard form Min Z = x1 + x2 +0.s1 +0.s2
2x1 + x2 - s1 = 4
x1 + 7x2 - s2 =7
x1,x2,s1,s2,A1,A2
>=0
Solution
X1 = 21/13
X2 = 10/13
Z= 31/13
Example
Phase I
Min
Table 1
Table 2
Table 3
Phase II
Problem