Simplex Algorithm
Simplex Algorithm
1
Linear Programming: The Simplex Method
2
How To Set Up The Initial Simplex Solution
3
Cont.
The inequality constraints must be converted into equations
Less-than-or-equal-to constraints (≤) are converted to
equations by adding a slack variable to each
− Slack variables represent unused resources
For the Firew Furniture problem, the slacks are:
S1 = slack representing unused hours in the painting department
S2 = slack representing unused hours in the carpentry department
The constraints may now be written as
2X + 1Y + S1 = 100
4X + 3Y + S2 = 240
Each slack variable must appear in every constraint equation
4
Cont.
Slack variables not actually needed for an equation have a
coefficient of 0.
2X + 1Y + 1S1 + 0S2 = 100
4X + 3Y + 0S1 + 1S2 = 240
X, Y, S1, S2 ≥ 0
As unused hours result in no profit, the slack variables can
be included in the objective function with zero coefficients:
The objective function becomes:
Maximize profit = $70X + $50Y + $0S1 + $0S2
The simplex method starts with an initial feasible solution
where all real variables are set to 0.
Starting from this point, the simplex method will move to the
corner point that yields the most improved profit
− It repeats the process until it can further improve
the solution
5
The First Simplex Tableau
The first tableau is called a simplex tableau
ix
s
s
le
t
m
ni
le
b
n s i ab
n ru
n on
ns ria
n t
m e
m ti
m n
m a
m r
lu it p
lu l va
l u uc
lu k v
lu sta
co od
co lac
co rof
co on
co ea
Pr
C
R
P
S
Cj SOLUTION $70 $50 $0 $0 Profit per
QUANTITY unit row
MIX X Y S1 S2
$0 S1 2 1 1 0 100 Constraint
equation rows
$0 S2 4 3 0 1 240
Gross
Zj $0 $0 $0 $0 $0 profit row
Cj - Zj $70 $50 $0 $0 $0
Net profit row
6
Cont.
The numbers in the first row represent the coefficients in the first
constraint and the numbers in the second row the 2nd constraint.
At the initial solution, X = 0 and Y = 0, so S1 = 100 and S2 = 240
The initial solution assumes that all available hours are unused.
The two slack variables are the initial solution mix
− The values are found in the QUANTITY column
The initial solution is a basic feasible solution
X 0 The slack variables take the
Y 0 largest possible values.
S1 = 100
S2 240
Variables in the solution mix are called basic variables. Each basic
variables has a column consisting of all 0’s except for a single 1.
Variables not in the solution mix or basis (value of 0) are called
non-basic variables
7
Cont.
Substitution rates
− The numbers in the body of the tableau are the coefficients of
the constraint equations.
− These can also be thought of as substitution rates
− Using the variable X as an example, if Firew were to produce 1
table (X = 1), 2 units of S1 and 4 units of S2 would have to be
removed from the solution.
− Similarly, the substitution rates for Y are 1 unit of S1 and 3
units of S2
− Also, for a variable to appear in the solution mix, it must have
a 1 someplace in its column and 0s in every other place in that
column.
8
Cont.
Adding the objective function
− We add a row to the tableau to reflect the objective function
values for each variable
− These contribution rates are called Cj and appear just above
each respective variable
− In the leftmost column, Cj indicates the unit profit for each
variable currently in the solution mix.
Cj $70 $50 $0 $0
SOLUTION QUANTITY
MIX X Y S1 S2
$0 S1 2 1 1 0 100
$0 S2 4 3 0 1 240
The Zj values in the other columns represent the gross profit given
up Zj =adding
by (Profitone
per unit
unit of
of this
S1) variable
(Substitution rate
into the in rowsolution.
current 1)
+ (profit per unit of S2) (Substitution rate in row 2)
10
Cont.
Thus,
Zj (for column X) = ($0)(2) + ($0)(4) = $0
Zj (for column Y) = ($0)(1) + ($0)(3) = $0
Zj (for column S1) = ($0)(1) + ($0)(0) = $0
Zj (for column S2) = ($0)(0) + ($0)(1) = $0
We can see that no profit is lost by adding one unit of either
X (tables), Y (chairs), S1, or S2
The Cj – Zj number in each column represents the net profit
that will result from introducing 1 unit of each product or
variable into the solution.
It is computed by subtracting the Zj total for each column
from the Cj value at the very top of that variable’s column.
11
Cont.
COLUMN
X Y S1 S2
Cj for column $70 $50
$0 $0
Zj for column 0 0
0 0
Cj – Zj for column $70 $50
$0 $0
Obviously with a profit of $0, the initial solution is not optimal
By examining the numbers in the Cj – Zj row in Table, we can
see that the total profits can be increased by $70 for each
unit of X and $50 for each unit of Y.
A negative number in the number in the Cj – Zj row would tell
us that the profits would decrease if the corresponding
variable were added to the solution mix.
− An optimal solution is reached when all the numbers in
the Cj – Zj row are 0 or negative (no positive numbers).
12
Five Steps of the Simplex Method for
Maximization Problems
1. Determine the variable to enter the solution mix next. One
way of doing this is by identifying the column, and hence the
variable, with the largest positive number in the Cj - Zj row of
the preceding tableau.
− The column identified in this step is called the pivot
column.
2. Determine which variable to replace. This is done by dividing
the quantity column by the corresponding number in the
column selected in step 1.
− The row with the smallest nonnegative number calculated in
this fashion will be replaced in the next tableau.
− This row is often referred to as the pivot row.
− The number at the intersection of the pivot row and pivot
column is the pivot number.
13
Cont.
3. Compute new values for the pivot row. To do this, we simply
divide every number in the pivot row by the pivot number.
4. Compute the new values for each remaining row. All
remaining rows are calculated as follows:
(New row numbers) = (Numbers in old row)
Number above Corresponding number in
– or below x the new row, that is, the
pivot number row replaced in step 3
15
Cont.
For the S2 row
240(hours of carpentry time available)
60 tables
4(hours required per table)
We choose the smaller ratio (50) and this determines the S1
variable is to be replaced(Leaving Variable).
Cj $70 $50 $0 $0
SOLUTION QUANTITY
MIX X Y S1 S2 (RHS)
$0 S1 2 1 1 0 100
$0 S2 4 3 0 1 240
Pivot number Pivot row
Zj $0 $0 $0 $0 $0
Cj - Zj $70 $50 $0 $0
Pivot column
16
Cont.
Step 3. We can now begin to develop the second, improved simplex
tableau. We have to compute a replacement for the pivot row.
This is done by dividing every number in the pivot row by the
pivot number. The new version of the pivot row is below.
2 1 1*
0 100
1 0.5 0 .5 0 50
2 2 2 2 2
17
Cont.
Step 4. Completing the rest of the tableau, the S2 row, is slightly more
complicated. The right of the following expression is used to
find the left side.
Number in
Number in Number Corresponding
= – Below Pivot Number in the New X
New S2 Row Old S2 Number Row
Row
0 = 4 – (4) (1)
1 = 3 – (4) (0.5)
–2 = 0 – (4) (0.5)
1 = 1 – (4) (0)
40 = 240 – (4) (50)
18
Cont.
The X column contains 1 and the S2 column
0
contains 0 , necessary conditions for variables to be in the solution.
1
The manipulations of steps 3 and 4 were designed to produce 0s and 1s in
the appropriate positions.
Step 5. The final step of the second iteration is to introduce the effect
of the objective function. This involves computing the Cj - Zj
rows. The Zj for the quantity row gives us the gross profit and the
other Zj represent the gross profit given up by adding one unit of
each variable into the solution.
Zj (for X column) = ($70)(1) + ($0)(0) = $70
Zj (for Y column) = ($70)(0.5) + ($0)(1) = $35
Zj (for S1 column) = ($70)(0.5) + ($0)(–2) = $35
Zj (for S2 column) = ($70)(0) + ($0)(1) = $0
Zj (for total profit) = ($70)(50) + ($0)(40) = $3,500
19
Cont.
COLUMN
X Y S1 S2
Cj for column $70 $50
$0 $0
Zj for column $70 $35
$35 $0
Cj – Zj for column $0 $15 –
Completed second simplex tableau $35 $0
Cj $70 $50 $0 $0
SOLUTION QUANTITY
MIX X Y S1 S2 (RHS)
$70 X 1 0.5 0.5 0 50
$0 S2 0 1 –2 1 40
Zj $70 $35 $35 $0 $3,500
Cj - Zj $0 $15 –$35 $0
20
Interpreting the Second Tableau
Current solution
− The solution point of 50 tables and 0 chairs
(X = 50, Y = 0) generates a profit of $3,500.
− X is a basic variable and Y is a non-basic variable.
Resource information
− Slack variable S2 is the unused time in the carpentry
department and is in the basis. Its value implies there
is 40 hours of unused carpentry time remaining.
− Slack variable S1 is non-basic and has a value of 0
meaning there is no slack time in the painting
department.
Since the previous tableau is not optimal(since positive number
exist), we repeat the five simplex steps.
21
Developing the Third Tableau
40
For the S2 row : 40 chairs
1
The S2 row has the smallest ratio so S2 will leave the basis
and will be replaced by Y.
22
Cont.
Cj $70 $50 $0 $0
SOLUTION MIX X Y S1 S2 QUANTITY
$70 X 1 0.5 0.5 0 50
$0 S2 0 1 –2 1 40
Pivot number Pivot row
Zj $70 $35 $35 $0 $3,500
Cj - Zj $0 $15 –$35 $0
Pivot column
$50 Y 0 1 –2 1 40
23
Cont.
Step 4. The new values for the X row may now be computed
Number in
Number in Number above Corresponding
= –
new X row old X row pivot number number in new Y row
1 = 1 – (0.5) (0)
0 = 0.5 – (0.5) (1)
1.5 = 0.5 – (0.5) (–2)
–0.5 = 0 – (0.5) (1)
30 = 50 – (0.5) (40)
SOLUTION X Y QUANTITY
Cj MIX S1 S2
$70 X 1 0 1.5 –0.5 30
$50 Y 0 1 –2 1 40
24
Cont.
Step 5. The Zj and Cj - Zj rows can now be calculated
Zj (for X column) = ($70)(1) + ($50)(0) = $70
Zj (for Y column) = ($70)(0) + ($50)(1) = $50
Zj (for S1 column) = ($70)(1.5) + ($50)(–2) = $5
Zj (for S2 column) = ($70)(–0.5) + ($50)(1) = $15
Zj (for total profit) = ($70)(30) + ($50)(40) = $4,100
And the net profit per unit row is now
COLUMN
X Y S1 S2
Cj for column $70 $50
$0 $0
Zj for column $70 $50
$5 $15
Cj – Zj for column $0 $0 – –
$5 $15
25
Cont.
Note that every number in the Cj - Zj row is 0 or negative
indicating an optimal solution has been reached. The optimal
solution is: X = 30 tables
Y = 40 chairs
S1 = 0 slack hours in the painting department
S2 = 0 slack hours in the carpentry department
Profit = $4,100 for the optimal solution
The final simplex tableau for the Firew Furniture
Cj $70 $50 $0 $0
SOLUTION
MIX X Y S1 S2 QUANTITY
$70 X 1 0 1.5 –0.5 30
$50 Y 0 1 –2 1 40
Zj $70 $50 $5 $15 $4,100
Cj - Zj $0 $0 –$5 –$15
26
Solving Minimization Problems Example
27
Example: Cont’d…
Surplus variables
− Greater-than-or-equal-to (≥) constraints require a different
approach than the less-than-or-equal-to (≤) constraints.
− They involve the subtraction of a surplus variable rather than
the addition of a slack variable.
− The surplus variable tells us how much the solution exceeds
the constraint amount. This is sometimes called negative slack.
To convert the first constraint we subtract a surplus variable, S1,
to create an equality.
Constraint 1 Re-written: 2X1 + 4X2 – S1 = 16
Artificial variables
− If a surplus variable is added by itself, it would have a negative
value in the initial tableau where all real variables are set to zero.
2(0) + 4(0) – S1 = 16
S1 = – 16
But all variables in LP problems must be nonnegative at all times.
28
Example: Cont’d…
29
Example: Cont’d…
Surplus and artificial variables in the objective function
− Both types of variables must be included in the objective
function
− Surplus variables, like slack variables, carry a $0 cost coefficient
− Since artificial variables must be forced out of the solution, we
assign an arbitrarily high cost.
− By convention we use the coefficient M which simply represents
a very large number.
And the constraint equations we saw before would appear as:
31
Procedures for Solving LP
Minimization Problems
I. Formulate the LP problem’s objective function and
constraints
II. Include slack variables to each less-than-or-equal-to
constraint and both surplus and artificial variables to
greater-than-or-equal-to constraints and add all variables
to the objective function
III. Develop and initial simplex tableau with artificial and
slack variables in the basis and the other variables set
equal to 0. compute the Zj and
Cj - Zj values for this tableau.
IV. Follow the five steps until an optimal solution has been
reached
32
Steps for Simplex Minimization Problems
33
First Simplex Tableau for the Farmer
Fertilizer Purchase Example
The initial tableau is set up in the same manner as the in the
maximization problem.
Note the costs for the artificial variables are $M
We simply treat this as a very large number which forces the
artificial variables out of the solution quickly.
The first two rows are:
34
Cont.
Zj (for X1 column) = $M(2) + $M(4) = 6M
Zj (for X2 column) = $M(4) + $M(3) = 7M
Zj (for S1 column) = $M(–1) + $M(0) = –M
Zj (for S2 column) = $M(0) + $M(–1) = –M
Zj (for A1 column) = $M(1) + $M(0) = M
Zj (for A2 column) = $M(0) + $M(1) = M
Zj (for
The Cj –total cost) are
Zj entires = $M(16) + $M(24)
determined = $40M
as follows:
COLUMN
X1 X2 S1 S2 A1 A2
Cj for column 6 3 0 0 M M
Zj for column 6M 7M –M –M M M
Cj – Zj for column 6 – 6M 3 – 7M M M 0 0
35
Cont.
36
Cont.
Cj $6 $3 $0 $0 $M $M
SOLUTION
MIX X1 X2 S1 S2 A1 A2 QUANTITY
$M A1 2 4 –1 0 1 0 16
$M A2 4 3 0 –1 0 1 24 Pivot row
Pivot number
Zj 6M 7M –M –M M M $ 40M
Cj – Zj 6 – 6M 3 – 7M M M 0 0
Pivot column
37
Developing the Second Tableau
In the Cj – Zj row there are two entries with negative values, X1 and X2
− This means an optimal solution does not yet exist.
The negative entry for X2 indicates it has the will result in the largest
improvement, which means it will enter the solution next.
To find the variable that will leave the solution, we divide the
elements in the quantity column by the respective pivot column
substitution rates:
16 (smallest quotient,
For the A1 row 4 indicating pivot row)
4
24
For the A2 row 8
3
Hence the pivot row is the A1 row and the pivot number is at the
intersection of the X2 column and the A1 row.
The entering row for the next tableau is found by dividing each
element in the pivot row by the pivot number.
38
Cont.
The new X2 Row:
2 4 1 0 0 16
0. 5 1 0.25 0 0 4
4 4 4 4 4 4
39
Cont.
40
Cont.
Cj $6 $3 $0 $0 $M
SOLUTION
MIX X1 X2 S1 S2 A2 QUANTITY
3 X2 0.5 1 –0.25 0 0 4
Pivot number
M A2 2.5 0 0.75 –1 1 12 Pivot row
Zj 1.5 +2.5M 3 –.75+.75M –M M 12+ 12M
41
Developing a Third Tableau
The new pivot column is the X1 column and we check the
quantity column-to-pivot column ratio.
4
For the X2 row = =8
0.5
Hence variable A2 will be
12 replaced by X1
For the A2 row =
2.5 = 4.8
The new X1 Row:
2.5 = 1 0 0.75 –1 12
=0 = 0.3 = –0.4 = 4.8
2.5 2.5 2.5 2.5 2.5
42
Cont.
43
Cont.
44
Cont.
Cj $6 $3 $0 $0
SOLUTION
MIX X1 X2 S1 S2 QUANTITY
Pivot number
$6 X2 0 1 –0.4 0.2 1.6
$3 X1 1 0 0.3 –0.4 4.8 Pivot row
Zj 6 3 0.6 – 1.8 $33.6
Cj – Zj 0 0 – 0.6 1.8
Pivot column
45
Fourth Tableau for Farmer Fertilizer
The new pivot column is the S1 column: and we check the
quantity column-to-pivot column ratio.
1.6
For the X2 row = = – 4 (not considered because it is negative)
–0.4
4.8 (row to be replaced by S1)
For the X1 row = = 16
3
46
Cont.
47
Cont.
48
Cont.
Fourth tableau for the Farmer Fertilizer Purchase problem
Cj $6 $3 $0 $0
SOLUTION QUANTITY
MIX X1 X2 S1 S2
$3 X2 1.33 1 0 –0.33 8
$0 S1 3.33 0 1 –1.33 16
Zj 3.99 3 0 –0.99 24
C j – Zj 2.01 0 0 0.99
This is the optimal simplex tableau because the Cj – Zj row
contains no negative values. The optimal solution is:
Z = $24, total cost of purchasing fertilizer
S2 = 0 extra lb. of phosphate
X1 = 0 bags of Super-gro
X2 = 8 bags of Crop-quick
S1 = 16 extra lb. of nitrogen
49
Special Cases
We have seen how special cases arise when solving
LP problems graphically
They also apply to the simplex method
You remember the four cases are
− Infeasibility
− Unbounded Solutions
− Degeneracy
− Multiple Optimal Solutions
50
Infeasibility
Infeasibility comes about when there is no solution that satisfies
all of the problem’s constraints.
All Cj - Zj row entries will be of the proper sign to imply optimality,
but an artificial variable will still be in the solution mix.
− No feasible solution is possible if an artificial variable(A2)
remains in the solution mix
A situation with no feasible solution may exist if the problem was
formulated improperly.
Cj $5 $8 $0 $0 $M $M
SOLUTION
MIX X1 X2 S1 S2 A1 A2 QUANTITY
$5 X1 1 0 –2 3 –1 0 200
$8 X2 0 1 1 2 –2 0 100
$M A2 0 0 0 –1 –1 1 20
Zj $5 $8 –$2 $31 – M –$21 – M $M $1,800 + 20M
Cj – Zj $0 $0 $2 $M – 31 $2M + 21 $0
51
Unbounded Solutions
Un-boundedness describes linear programs that do not have
finite solutions. It occurs in maximization problems when a
solution variable can be made infinitely large without violating a
constraint. In the simplex method this will be discovered prior to
reaching the final tableau.
It will be manifested when trying to decide which variable to
remove from the solution mix. If all the ratios turn out to be
negative or undefined, it indicates that the problem is unbounded
Cj $6 $9 $0 $0
SOLUTION MIX X1 X2 S1 S2 QUANTITY
$9 X2 –1 1 2 0 30
$0 S2 –2 0 –1 1 10
Zj –$9 $9 $18 $0 $270
Cj - Z j $15 $0 –$18 $0
Pivot column
52
Degeneracy
Degeneracy develops when three constraints pass through a
single point.
For example, suppose a problem has only these three
constraints X1 ≤ 10, X2 ≤ 10, and X1 + X2 < 20.
All three constraint lines will pass through the point (10, 10)
Degeneracy is first recognized when the ratio calculations
are made.
If there is a tie for the smallest ratio, this is a signal that
degeneracy exists.
As a result of this, when the next tableau is developed, one
of the variables in the solution mix will have a value of zero
Degeneracy could lead to a situation known as cycling in
which the simplex algorithm alternates back and forth
between the same non-optimal solutions.
53
Cont.
One simple way of dealing with the issue is to select either
row in question arbitrarily.
If unlucky and cycling does occur, simply go back and
select the other row. Tie for the smallest ratio
Problem illustrating degeneracy. indicates degeneracy
Cj $5 $8 $2 $0 $0 $0
SOLUTION QUANTITY
MIX X1 X2 X3 S1 S2 S3
$8 X2 0.25 1
10/0.25 =140 –2 0 0 10
$0 S2 4 20/4
0 = 50.33 –1 1 0 20
$0 S3 2 10/2
0 = 52 0.4 0 1 10
Zj $2 $8 $8 $16 $0 $0 $80
Cj - Zj $3 $0 –$6 –$16 $0 $0
Pivot column
54
Multiple Optimal Solutions
In the simplex method, multiple, or alternate, optimal
solutions can be spotted by looking at the final tableau
If the Cj – Zj value is equal to 0 for a variable that is not in the
solution mix, more than one optimal solution exists
A problem with alternate optimal solutions.
Cj $3 $2 $0 $0
SOLUTION MIX X1 X2 S1 S2 QUANTITY
$2 X2 1.5 1 1 0 6
$0 S2 1 0 0.5 1 3
Zj $3 $2 $2 $0 $12
Cj - Z j $0 $0 –$2 $0
55
Any Query