Simplex Method - Linear Programming Problems
Simplex Method - Linear Programming Problems
::: :::
:::
am1 x1 + am2x2 + : : : + amn xn = bm
x1 0; : : :xn 0
where the objective is maximized, the constraints are equalities and the variables are all nonnegative.
This is done as follows:
If the problem is min z , convert it to max ,z .
If a constraint is ai1 x1 +ai2 x2 +: : :+ain xn bi , convert it into an equality constraint by adding
a nonnegative slack variable si . The resulting constraint is ai1 x1 + ai2 x2 + : : : + ain xn + si = bi,
where si 0.
If a constraint is ai1 x1 + ai2 x2 + : : : + ain xn bi , convert it into an equality constraint by
subtracting a nonnegative surplus variable si . The resulting constraint is ai1x1 + ai2 x2 + : : : +
ain xn , si = bi , where si 0.
If some variable xj is unrestricted in sign, replace it everywhere in the formulation by xj , xj ,
where xj 0 and xj 0.
0
00
87
00
88
Example 7.1.1 Transform the following linear program into standard form.
Min ,2x1 +3x2
x1 ,3x2 +2x3 3
,x1 +2x2
2
x1 urs; x2 0; x3 0
Let us rst turn the objective into a max and the constraints into equalities.
Max
2x1 ,3x2
x1 ,3x2 +2x3 +s1
= 3
,x1 +2x2
,s2 = 2
x1 urs; x2 0; x3 0 s1 0 s2 0
The last step is to convert the unrestricted variable x1 into two nonnegative variables: x1 =
x1 , x1 .
0
00
Max
,2x1 ,3x2
x1
,x1 ,3x2 +2x3 +s1
= 3
,x1 +x1 +2x2
,s2 = 2
x1 0; x1 0; x2 0; x3 0 s1 0 s2 0
2x1
0
00
00
00
00
x1 +x2
2x1 +x2 4
x1 +2x2 3
x1 0; x2 0
First, we convert the problem into standard form by adding slack variables x3 0 and x4 0.
max
x1 +x2
2x1 +x2
+x3
= 4
x1 +2x2
+x4 = 3
x1 0; x2 0 x3 0; x4 0
Let z denote the objective function value. Here, z = x1 + x2 or, equivalently,
z , x1 , x2 = 0:
Putting this equation together with the constraints, we get the following system of linear equations.
z ,x1 ,x2
= 0
2x1 +x2 +x3
= 4
x1 +2x2
+x4 = 3
Row 0
Row 1
Row 2
7.1
89
x1 = x2 = 0 x3 = 4 x4 = 3 z = 0:
Is this an optimal solution or can we increase z ? Our goal
By looking at Row 0 above, we see that we can increase z by increasing x1 or x2 . This is
because these variables have a negative coe cient in Row 0. If all coe cients in Row 0 had been
nonnegative, we could have concluded that the current basic solution is optimum, since there would
be no way to increase z remember that all variables xi must remain 0. We have just discovered
the rst rule of the simplex method.
Rule 1 If all variables have a nonnegative coe cient in Row 0, the current basic solution is
optimal.
Otherwise, pick a variable xj with a negative coe cient in Row 0.
The variable chosen by Rule 1 is called the entering variable. Here let us choose, say, x1 as our
entering variable. It really does not matter which variable we choose as long as it has a negative
coe cient in Row 0. The idea is to pivot in order to make the nonbasic variable x1 become a basic
variable. In the process, some basic variable will become nonbasic the leaving variable. This
change of basis is done using the Gauss-Jordan procedure. What is needed next is to choose the
pivot element. It will be found using Rule 2 of the simplex method. In order to better understand
the rationale behing this second rule, let us try both possible pivots and see why only one is
acceptable.
First, try the pivot element in Row 1.
z ,x1 ,x2
= 0
Row 0
2x1 +x2 +x3
= 4
Row 1
x1 +2x2
+x4 = 3
Row 2
This yields
, 12 x2 + 13 x3
x1 + 21 x2 + 12 x3
1
3
2 x2 , 2 x3 +x4
with basic solution x2 = x3 = 0
z
= 2
Row 0
= 2
Row 1
= 1
Row 2
x1 = 2 x4 = 1 z = 2:
Now, try the pivot element in Row 2.
z ,x1 ,x2
= 0
Row 0
2x1 +x2 +x3
= 4
Row 1
x1 +2x2
+x4 = 3
Row 2
This yields
90
+x2
+x4
,3x2 +x3 ,2x4
x1 +2x2
+x4
with basic solution x2 = x4 = 0
= 3
Row 0
= ,2
Row 1
= 3
Row 2
x1 = 3 x3 = ,2
z = 3:
Which pivot should we choose? The rst one, of course, since the second yields an infeasible
basic solution! Indeed, remember that we must keep all variables 0. With the second pivot, we
get x3 = ,2 which is infeasible. How could we have known this ahead of time, before actually
Right Hand Side
performing the pivots? The answer is, by comparing the ratios Entering
Variable Coe cient in
Rows 1 and 2 of 7.1. Here we get 42 in Row 1 and 31 in Row 2. If you pivot in a row with minimum
ratio, you will end up with a feasible basic solution i.e. you will not introduce negative entries in
the Right Hand Side, whereas if you pivot in a row with a ratio which is not minimum you will
always end up with an infeasible basic solution. Just simple algebra! A negative pivot element
would not be good either, for the same reason. We have just discovered the second rule of the
simplex method.
Rule 2 For each Row i, i 1, where there is a strictly positive entering variable coe cient",
compute the ratio of the Right Hand Side to the entering variable coe cient". Choose the pivot
row as being the one with MINIMUM ratio.
Once you have idendi ed the pivot element by Rule 2, you perform a Gauss-Jordan pivot. This
gives you a new basic solution. Is it an optimal solution? This question is addressed by Rule 1, so
we have closed the loop. The simplex method iterates between Rules 1, 2 and pivoting until Rule
1 guarantees that the current basic solution is optimal. That's all there is to the simplex method.
After our rst pivot, we obtained the following system of equations.
= 2
Row 0
z
, 21 x2 + 13 x3
x1 + 21 x2 + 12 x3
= 2
Row 1
3x
1
Row 2
2 2 , 2 x3 +x4 = 1
with basic solution x2 = x3 = 0 x1 = 2 x4 = 1 z = 2:
Is this solution optimal? No, Rule 1 tells us to choose x2 as entering variable. Where should
we pivot? Rule 2 tells us to pivot in Row 2, since the ratios are 1=22 = 4 for Row 1, and 31=2 = 23 for
Row 2, and the minimum occurs in Row 2. So we pivot on 23 x2 in the above system of equations.
This yields
Row 0
z
+ 13 x3 + 31 x4 = 73
x1
+ 32 x3 , 31 x4 = 53
Row 1
x2 , 31 x3 + 32 x4 = 23
Row 2
with basic solution x3 = x4 = 0 x1 = 35 x2 = 23 z = 73 :
Now Rule 1 tells us that this basic solution is optimal, since there are no more negative entries
in Row 0.
All the above computations can be represented very compactly in tableau form.
2 1 1 0
1 2 0 1
0 , 12 12 0
1 12 12 0
0 32 , 12 1
0 0 13 13
1 0 23 , 13
0 1 , 13 23
4
3
2
2
1
7
3
5
3
2
3
basic
nonbasic
z=0
basic
nonbasic
z=2
basic
nonbasic
z = 37
91
Basic solution
x3 = 4 x4 = 3
x1 = x2 = 0
x1 = 2 x4 = 1
x2 = x3 = 0
x1 = 53 x2 = 23
x3 = x4 = 0
Since the above example has only two variables, it is interesting to interpret the steps of the
simplex method graphically. See Figure 7.1. The simplex method starts in the corner point x1 =
0; x2 = 0 with z = 0. Then it discovers that z can increase by increasing, say, x1. Since we keep
x2 = 0, this means we move along the x1 axis. How far can we go? Only until we hit a constraint:
if we went any further, the solution would become infeasible. That's exactly what Rule 2 of the
simplex method does: the minimum ratio rule identi es the rst constraint that will be encountered.
And when the constraint is reached, its slack x3 becomes zero. So, after the rst pivot, we are at
the point x1 = 2; x2 = 0. Rule 1 discovers that z can be increased by increasing x2 while keeping
x3 = 0. This means that we move along the boundary of the feasible region 2x1 + x2 = 4 until we
reach another constraint! After pivoting, we reach the optimal point x1 = 53 ; x2 = 23 .
x
2
z=7/3
z=0
z=2
x
1
92
Let us solve a small variation of the earlier example, with the same constraints but a slightly
di erent objective:
max
x1 + 21 x2
2x1 +x2 4
x1 +2x2 3
x1 0; x2 0
As before, we add slacks x3 and x4, and we solve by the simplex method, using tableau representation.
z x1 x2 x3 x4 RHS
Basic solution
1 ,1 , 12 0 0 0
basic
x3 = 4 x4 = 3
0 2 1 1 0 4
nonbasic x1 = x2 = 0
0 1 2 0 1 3
z=0
1
1 0 0 2 0 2
basic
x1 = 2 x4 = 1
0 1 12 12 0 2
nonbasic x2 = x3 = 0
0 0 32 , 12 1 1
z=2
Now Rule 1 shows that this is an optimal solution. Interestingly, the coe cient of the nonbasic
variable x2 in Row 0 happens to be equal to 0. Going back to the rationale that allowed us to
derive Rule 1, we observe that, if we increase x2 from its current value of 0, this will not e ect the
value of z . Increasing x2 produces changes in the other variables, of course, through the equations
in Rows 1 and 2. In fact, we can use Rule 2 and pivot to get a di erent basic solution with the
same objective value z = 2.
z x1 x2 x3 x4 RHS
1
0
0
0
1
0
0
0
1 ,
1
2
2
3
1
3
, 13
2
3
2
5
3
2
3
Basic solution
basic
x1 = 53 x2 = 32
nonbasic x3 = x4 = 0
z=2
Note that the coe cient of the nonbasic variable x4 in Row 0 is equal to 0. Using x4 as entering
variable and pivoting, we would recover the previous solution!
Degeneracy
Example 7.3.1
+x2
+x2 6
x1 ,x2 2
x2 3
x1 0; x2 0
Let us solve this problem using the by now familiar simplex method. In the initial tableau,
we can choose x1 as the entering variable Rule 1 and Row 2 as the pivot row the minimum ratio
in Rule 2 is a tie, and ties are broken arbitrarily. We pivot and this yields the second tableau
below.
z x1 x2 x3 x4 x5 RHS
Basic solution
1 ,2 ,1 0 0 0 0
basic
x3 = 6 x4 = 2 x5 = 3
0 3 1 1 0 0 6
nonbasic x1 = x2 = 0
0 1 ,1 0 1 0 2
z=0
0 0 1 0 0 1 3
1 0 ,3 0 2 0 4
basic
x1 = 2 x3 = 0 x5 = 3
0 0 4 1 ,3 0 0
nonbasic x2 = x4 = 0
0 1 ,1 0 1 0 2
z=4
0 0 1 0 0 1 3
max
2x1
3x1
Note that this basic solution has a basic variable namely x3 which is equal to zero. When this
occurs, we say that the basic solution is degenerate. Should this be of concern? Let us continue the
steps of the simplex method. Rule 1 indicates that x2 is the entering variable. Now let us apply
Rule 2. The ratios to consider are 04 in Row 1 and 13 in Row 3. The minimum ratio occurs in Row
1, so let us perform the corresponding pivot.
z x1 x2 x3 x4 x5 RHS
Basic solution
3
1
1 0 0 4 ,4 0 4
basic
x1 = 2 x2 = 0 x5 = 3
0 0 1 41 , 34 0 0
nonbasic x3 = x4 = 0
0 1 0 41 14 0 2
z=4
0 0 0 , 14 34 1 3
We get exactly the same solution! The only di erence is that we have interchanged the names
of a nonbasic variable with that of a degenerate basic variable x2 and x3 . Rule 1 tells us the
solution is not optimal, so let us continue the steps of the simplex method. Variable x4 is the
entering variable and the last row wins the minimum ratio test. After pivoting, we get the tableau:
z x1 x2 x3 x4 x5 RHS
Basic solution
2
1
1 0 0 3 0 3 5
basic
x1 = 1 x2 = 3 x4 = 4
0 0 1 0 0 1 3
nonbasic x3 = x5 = 0
0 1 0 31 0 , 13 1
z=5
0 0 0 , 13 1 43 4
By Rule 1, this is the optimal solution. So, after all, degeneracy did not prevent the simplex
method to nd the optimal solution in this example. It just slowed things down a little. Unfortunately, on other examples, degeneracy may lead to cycling, i.e. a sequence of pivots that goes
94
through the same tableaus and repeats itself inde nitely. In theory, cycling can be avoided by
choosing the entering variable with smallest index in Rule 1, among all those with a negative coefcient in Row 0, and by breaking ties in the minimum ratio test by choosing the leaving variable
with smallest index this is known as Bland's rule. This rule, although it guaranties that cycling
will never occur, turns out to be somewhat ine cient. Actually, in commercial codes, no e ort is
made to avoid cycling. This may come as a surprise, since degeneracy is a frequent occurence. But
there are two reasons for this:
Although degeneracy is frequent, cycling is extremely rare.
The precision of computer arithmetic takes care of cycling by itself: round o errors accumulate and eventually gets the method out of cycling.
Our example of degeneracy is a 2-variable problem, so you might want to draw the constraint
set in the plane and interpret degeneracy graphically.
Unbounded Optimum
Example 7.3.2
max
2x1
+x2
,x1 +x2 1
x1 ,2x2 2
x1 0; x2 0
z x1 x2
1 ,2 ,1
0 ,1 1
0 1 ,2
1 0 ,5
0 0 ,1
0 1 ,2
x3 x4 RHS
0
1
0
0
1
0
0
0
1
2
1
1
0
1
2
4
3
2
Basic solution
basic
x3 = 1 x4 = 2
nonbasic x1 = x2 = 0
z=0
basic
x1 = 2 x3 = 3
nonbasic x2 = x4 = 0
z=4
At this stage, Rule 1 chooses x2 as the entering variable, but there is no ratio to compute, since
there is no positive entry in the column of x2 . As we start increasing x2 , the value of z increases
from Row 0 and the values of the basic variables increase as well from Rows 1 and 2. There is
nothing to stop them going o to in nity. So the problem is unbounded.
Interpret the steps of the simplex method graphically for this example.
Exercise 63 The following tableaus were obtained in the course of solving linear programs with 2
nonnegative variables x1 and x2 and 2 inequality constraints the objective function z is maximized.
Slack variables s1 and s2 were added. In each case, indicate whether the linear program
i is unbounded
ii has a unique optimum solution
iii has an alternate optimum solution
iv is degenerate in this case, indicate whether any of the above holds.
z x1 x2 s1 s2 RHS
a 10
0
0 3 2 0
1 ,2 ,1 0
0 ,1 0 1
20
4
2
z x1 x2 s1 s2 RHS
b 10 00 ,10 01 ,22 20
5
0 1 ,2 0 3 6
z x1 x2 s1 s2 RHS
c 10 23
0 ,2
0 0 1
1 0 ,2
0 1 1
8
4
0
z x1 x2 s1 s2 RHS
d 10
0
0 0 2 0
0 ,1 1 1
1 1 ,1 0
5
4
4
Exercise 64 Suppose the following tableau was obtained in the course of solving a linear program
with nonnegative variables x1; x2; x3 and two inequalities. The objective function is maximized and
slack variables s1 and s2 were added.
z x1 x2 x3
1 0 a b
0 0 ,2 2
0 1 ,1 3
s1 s2 RHS
0 4 82
1 3 c
0 ,5 3
Give conditions on a, b and c that are required for the following statements to be true:
i The current basic solution is a feasible basic solution.
Assume that the condition found in i holds in the rest of the exercise.
ii The current basic solution is optimal.
96
iii The linear program is unbounded for this question, assume that b 0.
iv The currrent basic solution is optimal and there are alternate optimal solutions for this
question, assume a 0.
Exercise 65 A plant can manufacture ve products P1, P2, P3, P4 and P5. The plant consists
of two work areas: the job shop area A1 and the assembly area A2 . The time required to process
one unit of product Pj in work area Ai is pij in hours, for i = 1; 2 and j = 1; : : :; 5. The weekly
capacity of work area Ai is Ci in hours. The company can sell all it produces of product Pj at a
pro t of sj , for i = 1; : : :; 5.
The plant manager thought of writing a linear program to maximize pro ts, but never actually
did for the following reason: From past experience, he observed that the plant operates best when
at most two products are manufactured at a time. He believes that if he uses linear programming,
the optimal solution will consist of producing all ve products. Do you agree with him? Explain,
based on your knowledge of linear programming.
z x1 x2
x3 s1 s2 RHS
1 0 0
5 0 1 15
0 0 .4 -0.2 1 -.2 3
0 1 .6 1.2 0 .2 3
a What basic solution does this tableau represent? Is this solution optimal? Why or why not?
b Does this tableau represent a unique optimum. If not, nd an alternative optimal solution.
Answer:
a The solution is x1 = 3, x2 ; x3 = 0, objective 15. It is optimal since cost row is all at least 0.
b It is not unique since x2 has reduced cost 0 but is not basic. Alternative found by pivoting
in x2 question could have asked for details on such a pivot for solution x2 = 5, x1 ; x3 = 0,
objective 15.