Linear Programming Simplex Method Complete
Linear Programming Simplex Method Complete
Example 1:
A manufactures has two resources R1 and R2 And is making two products P1 and
P2 each unit of P1 requires 1 unit of R1 and 4 units of R2. each unit of P2 requires 2
unit of R1 and 1 units of R2. Manufacturer has 8 units of R1 and 14 units of R2. The
profit for P1 is 4$ per unit and for P2 it is 7$ per unit. Find how many units of both
products should be produced to get the maximum profit.
Example 2:
A calculator company produces a scientific calculator and a graphing calculator.
Long-term projections indicate an expected demand of at least 100 scientific and
80 graphing calculators each day. Because of limitations on production capacity,
no more than 200 scientific and 170 graphing calculators can be made daily. To
satisfy a shipping contract, a total of at least 200 calculators much be shipped
each day.
If each scientific calculator sold results in a $2 loss, but each graphing calculator
produces a $5 profit, how many of each type should be made daily to maximize
net profits?
1
Linear Programming: Formulations (do it yourself)
1. A farmer has 10 acres to plant in wheat and rye. He has to plant at least 7 acres. However,
he has only $1200 to spend and each acre of wheat costs $200 to plant and each acre of rye
costs $100 to plant. Moreover, the farmer has to get the planting done in 12 hours and it takes
an hour to plant an acre of wheat and 2 hours to plant an acre of rye. If the profit is $500 per
acre of wheat and $300 per acre of rye how many acres of each should be planted to
maximize profits?
2. A gold processor has two sources of gold ore, source A and source B. In order to kep his
plant running, at least three tons of ore must be processed each day. Ore from source A
costs $20 per ton to process, and ore from source B costs $10 per ton to process. Costs
must be kept to less than $80 per day. Moreover, Federal Regulations require that the amount
of ore from source B cannot exceed twice the amount of ore from source A. If ore from
source A yields 2 oz. of gold per ton, and ore from source B yields 3 oz. of gold per ton, how
many tons of ore from both sources must be processed each day to maximize the amount of
gold extracted subject to the above constraints?
3. A publisher has orders for 600 copies of a certain text from San Francisco and 400 copies
from Sacramento. The company has 700 copies in a warehouse in Novato and 800 copies in a
warehouse in Lodi. It costs $5 to ship a text from Novato to San Francisco, but it costs $10 to
ship it to Sacramento. It costs $15 to ship a text from Lodi to San Francisco, but it costs $4 to
ship it from Lodi to Sacramento. How many copies should the company ship from each
warehouse to San Francisco and Sacramento to fill the order at the least cost?
2
Linear Programming: Simplex Method
3
Simplex Method: Theoretical Basis
4
Simplex Method: Theoretical Basis
5
Simplex Method: Tabular Form
Problem 1: Maximize z: 6X1+5x2
s.t.
x1+x2 ≤ 5
3x1+2x2 ≤ 12
x1,x2 ≥ 0
Introduce slack variables to convert it into equality,
x1+x2 +s1 = 5
3x1+2x2 +s2 =12
x1,x2 ,s1,s2≥ 0
In objective function, contribution of s1 and s2 are 0.
6
Simplex Method: Problem 1 contd.
Corresponding contribution of
variables in Z, objective Cj 6 5 0 0
function
X1 X2 s1 s2 RHS L (leaving)
0 s1 1 1 1 0 5
3 2 0 1 12
0 s2
Zj 0 0 0 0 0
Cj - Zj 6 5 0 0 0
7
Simplex Method: Problem 1 contd.
Corresponding contribution of
variables in Z, objective Cj 6 5 0 0
function
X1 X2 s1 s2 RHS L (leaving)
0 s1 1 1 1 0 5 5/1 = 5 R1
3 2 0 1 12 12/3 =4 R2
0 s2
Zj 0 0 0 0 0
s1
Cj - Zj 6 5 0 0 0
s2
Entering variable is the one with highest positive Cj – Zj values, in this step it is X1. The leaving variable is the one with
lowest corresponding (RHS/corresponding coefficient) of entering variable, in this case 1 and 3 are those coefficients.
Thus S2 leaves. Corresponding element, 3 (circled in the table) in this case is the pivot element and Row R2 is pivot Row.
8
Simplex Method: Problem 1 contd.
Corresponding contribution of
variables in Z, objective Cj 6 5 0 0
function
X1 X2 s1 s2 RHS L (leaving)
1 1 1 0 5 5/1 = 1 R1
0 s1
3 2 0 1 12 12/3 =4 R2
0 s2
Zj 0 0 0 0 0
Cj - Zj 6 5 0 0
0 s1 0 1/3 1 -1/3 R3
1 2/3 0 1/3 R4
6 X1
X1 enters the basis and s2 leaves. We divide the R2 by pivot element to get the value corresponding to X1 1
Next, Now we have to get a 0 above the corresponding 1 in the last step, to achieve that, we subtract R 4 From R1 to get R3
9
Simplex Method: Problem 1 contd.
Cj 6 5 0 0
X1 X2 s1 s2 RHS L (leaving)
0 s1 1 1 1 0 5 5/1 = 1 R1
0 s2 3 2 0 1 12 12/3 =4 R2
Zj 0 0 0 0 0
Cj - Zj 6 5 0 0
0 s1 0 1/3 1 -1/3 1 1/1/3=3 R3
1 2/3 0 1/3 4 4/2/3 = 6 R4
6 X1
Zj 6 4 0 2 24
Cj-Zj 0 1 0 -2
We computer corresponding Zj and Cj – Zj values. Like in the last step we identify entering variable as X2 since corresponding
Cj-Zj value is highest positive among all. To identify leaving variable we divide corresponding RHS value by corresponding
column coefficient values of entering variable. So variable X2 enters and variable S1 leaves. Pivot element becomes 1/3 and
pivot row is R3
10
Simplex Method: Problem 1 contd.
Cj 6 5 0 0
X1 X2 s1 s2 RHS L (leaving)
0 s1 1 1 1 0 5 5/1 = 1 R1
0 s2 3 2 0 1 12 12/3 =4 R2
Zj 0 0 0 0 0
Cj – Zj 6 5 0 0
0 s1 0 1/3 1 -1/3 1 1/1/3=3 R3
1 2/3 0 1/3 4 4/2/3 = 6 R4
6 X1
Zj 6 4 0 2 24
Cj-Zj 0 1 0 -2
5 X2 0 1 3 -1 3 R5
1 0 -2 1 2 R6
6 X1
Zj 6 5 3 1 27
Cj-Zj 0 0 -3 -1
We get value 1 corresponding to entering variable X2 by dividng the pivot row by pivot element. Therefore, R 5 = R3/(1/3)
Now we need 0 above the corresponding X2 values, to get R6, therefore, R6 = R4 – (2/3)R5. Next we compute Zj and Cj - Zj
11
Simplex Method: Problem 1 contd.
Cj 6 5 0 0
X1 X2 s1 s2 RHS L (leaving)
0 s1 1 1 1 0 5 5/1 = 1 R1
0 s2 3 2 0 1 12 12/3 =4 R2
Zj 0 0 0 0 0
Cj – Zj 6 5 0 0
0 s1 0 1/3 1 -1/3 1 1/1/3=3 R3
1 2/3 0 1/3 4 4/2/3 = 6 R4
6 X1
Zj 6 4 0 2 24
Cj-Zj 0 1 0 -2
5 X2 0 1 3 -1 3 R5
1 0 -2 1 2 R6
6 X1
Zj 6 5 3 1 27
Cj-Zj 0 0 -3 -1
All Cj – Zj values are either zero or negative, therefore, we found our solution. The maximum Z is the final Z j value, in this case
27 and corresponding values for X2 and X1 are corresponding RHS values, in this case they are 2 and 3.
12
Simplex Method: Tabular Form (Problem 2)
Problem 1: Minimize z: 3X1+4x2
s.t.
2x1+x2 ≥ 5
x1+3x2 ≥ 12
Introduce slack variables to convert it into equality,
x1+x2 - s1 = 5
3x1+2x2 - s2 =12
We need to convert this problem into maximization problem.
Recall that minimization of z is same as maximization of –z
(negative z). Therefore, our problem becomes,
Maximize z: -3X1- 4x2
s.t.
2x1+x2 ≥ 5
x1+3x2 ≥ 12
13
Simplex Method: Problem 2 contd..
Now we introduce slack variables to convert inequality into
equality.
2x1+x2 –s1 = 5
x1+3x2 –s2 = 12
x1,x2 ,s1,s2≥ 0
Notice the coefficient of slack variable is negative because of
greater than inequality.
Notice in this case first basic feasible solution is possible by setting all
non artificial variables to 0, we get positive feasible values of artificial
variables.
15
Simplex Method: Problem 2 contd..
Notice the contribution of slack variables and artificial variables to
objective function z is 0.
This problem will be solved in two phases, in the first phase we will
get first basic feasible solution without artificial variable.
16
Simplex Method: Problem 2, phase 1
Cj 0 0 0 0 -1 -1
X1 X2 s1 s2 a1 a2 RHS L
-1 a1 2 1 -1 0 1 0 8 8
-1 a2 1 3 0 -1 0 1 12 4
Zj -3 -4 1 1 -1 -1 -20
Cj - Zj 3 4 -1 -1 0 0
-1 a1 5/3 0 -1 1/3 1 -1/3 4 12/5
0 X2 1/3 1 0 -1/3 0 1/3 4 12
Zj -5/3 0 1 -1/3 -1 1/3
Cj - Zj 5/3 0 -1 1/3 0 -4/3
0 X1 1 0 -3/5 1/5 3/5 -1/5 12/5
0 X2 0 1 1/5 -2/5 -1/5 -4/5 16/5
Entering variables, leaving variables are shown with arrows and pivot elements are showing with circles. We performed the
same steps as the last problem.
Notice now we have a basic solution without artificial variable. Therefore, we import this solution to the next phase.
17
Simplex Method: Problem 2, phase 2.
We will use this basic solution in the original objective function (the one with -z). We
import the basic solution by dropping columns corresponding to artificial variables
and continue
Cj -3 -4 0 0
X1 X2 s1 s2 RHS L
-3 X1 1 0 -3/5 1/5 12/5
-4 X2 0 1 1/5 -2/5 16/5
Zj -3 -4 1 1 -20
Cj - Zj 0 0 -1 -1
Notice all the Cj-Zj values are negative or zero, therefore, we are done. -20 is the
maximum value of –z therefore, the minimum value of z is 20 for X1 = 12/5 and
X2 = 16/5.
18