Professional Documents
Culture Documents
The Simplex algorithm for solving LPs requires that all constraints are
equations (with exception of sign constraints on the variables) and all variables
be nonnegative. An LP in this form is said to be in standard form.
Example:
max z 20 x1 15 x2
s.t. x1 100
x2 100
50 x1 35 x2 6000
20 x1 15 x2 2000
x1 , x2 0
max z 20 x1 15 x2
s.t. x1 s1 100
x2 s2 100
50 x1 35 x2 s3 6000
20 x1 15 x2 e4 2000
all variables 0
1
Suppose we have an LP in standard form with n variables and m constraints.
For convenience, we label the variables x1 , x2 ,K , xn .
s.t.
a11 x1 a12 x2 L a1n xn b1
a21 x1 a22 x2 L a2 n xn b2
M
am1 x1 am 2 x2 L amn xn bm
x1 , x2 ,K , xn 0
x1
x
a11 a12 a1n 2 b1
a b2
a 22 a2 n
If we define A
21
, x , and b , then
M M
a m1 am 2 amn bm
xn
Ax b
x0
Before we can present the Simplex method for solving LPs we need to review
some fundamental definitions and results.
2
Consider here a system of equations Ax b with n variables and m constraints,
where we assume n m (i.e., more variables than equations).
The n m variables that are fixed equal to 0 are called nonbasic variables
(NBV). The remaining m variables are called basic variables (BV). Note that,
in general, different choices of nonbasic and basic variables will yield different
(basic) solutions to the system of equations Ax b .
x1 x2 3
x2 x3 1
Theorem: the basic feasible solutions of Ax b are the extreme points of the
polyhedral set defined by Ax b, x 0 .
3
Example:
x1 x2 40
2 x1 x2 60
x1 , x2 0
By drawing the polyhedron in ( x1 , x2 ) space, we see that its extreme points are:
(0,0), (30,0), (20,20), (0,40).
Now we want to identify the basic feasible solutions and see their
correspondence with the extreme points. To do this, we need to convert the
constraint into standard form by adding slacks.
x1 x2 s1 40
2 x1 x2 s2 60
x1 , x2 , s1 , s2 0
BV NBV x1 x2 s1 s2 bfs?
Definition: Two basic feasible solutions are called adjacent if their sets of basic
variables differ in only one variable.
Theorem: If a linear program has an optimal solution, then there is one that is
an extreme point.
4
The Simplex Method
5. Compute the values of the variables in the new bfs by using elementary
row operations (eros). Go back to step 3.
Example:
max z 60 x1 30 x2 20 x3
s.t.
8 x1 6 x2 x3 48
4 x1 2 x2 1.5 x3 20
2 x1 1.5 x2 0.5 x3 8
x2 5
x1 , x2 , x3 0
z 60 x1 30 x2 20 x3 0
5
Basic
variable
Row 0 z - 60 x1 - 30 x2 - 20 x3 = 0 z0
Row 1 8 x1 + 6 x2 + x3 + s1 = 48 s1 = 48
Row 2 4 x1 + 2 x2 + 1.5 x3 + s2 = 20 s2 = 20
Row 3 2 x1 + 1.5 x2 + 0.5 x3 + s3 = 8 s3 = 8
Row 4 x2 + s4 = 5 s4 = 5
The constraints in the above tabular formulation of our LP are not only in
standard form, they are also in Simplex tableau form with respect to the choice
we made of BV and NBV. Simplex tableau form means that each row is
associated to a unique basic variable which appears in its row with a coefficient
of 1 (and coefficient 0 in all other rows).
We will consider also z to be the basic variable associated with row 0 (however,
we dont require z to be nonnegative like the decision variables).
Note that, in this case, the value of z will improve if we can make x1 , x2 , or x3
positive. For a maximization LP, we will choose to increase the value of the
nonbasic variable with the most negative coefficient in row 0 (in this case, x1 ) .
We say we choose x1 to enter the set of basic variables. Note that we choose to
increase the value of only one nonbasic variable per iteration, the others will
remain fixed at value 0. This will have the effect of moving from one extreme
point of the feasible region to a (better) adjacent one.
6
We need to determine now which (currently) basic variable should become
nonbasic. Note that as we increase the value of x1 , the values of the current
basic variables must update according to:
8 x1 + s1 = 48
4 x1 + s2 = 20
2 x1 + s3 = 8
s4 = 5
That is,
s1 = 48 - 8 x1
s2 = 20 - 4 x1
s3 = 8 - 2 x1
s4 = 5
We need to maintain the nonnegativity of all variables that are currently basic:
s1 = 48 - 8 x1 0
s2 = 20 - 4 x1 0
s3 = 8 - 2 x1 0
s4 = 5 0 ( s4 is not affected here by changes in value of x1 )
48
s1 nonnegative if: x1 6
8
20
s2 nonnegative if: x1 5
4
8
s3 nonnegative if: x1 4
2
7
Ratio test:
48 20 8
The largest value we can assign to x1 now is the minimum of , , = 4.
8 4 2
Now we need to compute the values of the new bfs. In the same process we can
update our Simplex tableau to a canonical form that represents the new choice
of BV and NBV.
The row of the entering variable ( x1 ) in the new tableau will be the one of the
leaving variable ( s3 ).
x1 enters BV s3 leaves BV
Row 0 z - 60 x1 - 30 x2 - 20 x3 = 0
Row 1 8 x1 + 6 x2 + x3 + s1 = 48
Row 2 4 x1 + 2 x2 + 1.5 x3 + s2 = 20
Row 3 2 x1 + 1.5 x2 + 0.5 x3 + s3 = 8
Row 4 x2 + s4 = 5
The row of the leaving variable (in this case Row 3) is called the pivot row.
The coefficient of x1 in the pivot row is called the pivot term.
We will compute the values of the variables in the new basic feasible solution
and update the Simplex tableau to reflect the new choice of BV and NBV. We
will do this using elementary row operations (eros) on the current tableau.
8
Henceforth, we will save effort by dropping the variables from the Simplex
tableau and show only the coefficient entries:
z x1 x2 x3 s1 s2 s3 s4 rhs
Row 0 1 - 60 - 30 - 20 0 0 0 0 0 z0
Row 1 0 8 6 1 1 0 0 0 48 s1 48
Row 2 0 4 2 1.5 0 1 0 0 20 s2 20
Row 3 0 2 1.5 0.5 0 0 1 0 8 s3 8
Row 4 0 0 1 0 0 0 0 1 5 s4 5
1. Divide all entries in the pivot row (here, row 3) by the pivot term so that
the entering variable (here, x1 ) has a coefficient of 1 in the pivot row.
z x1 x2 x3 s1 s2 s3 s4 rhs
Row 0 1 - 60 - 30 - 20 0 0 0 0 0
Row 1 0 8 6 1 1 0 0 0 48
Row 2 0 4 2 1.5 0 1 0 0 20
Row 3 0 1 .75 .25 0 0 .5 0 4
Row 4 0 0 1 0 0 0 0 1 5
9
The (updated) Simplex tableau for BV={ s1 , s2 , x1 , s4 } is:
z x1 x2 x3 s1 s2 s3 s4 rhs
Row 0 1 0 15 -5 0 0 30 0 240 z 240
Row 1 0 0 0 -1 1 0 -4 0 16 s1 16
Row 2 0 0 -1 .5 0 1 -2 0 4 s2 4
Row 3 0 1 .75 .25 0 0 .5 0 4 x1 4
Row 4 0 0 1 0 0 0 0 1 5 s4 5
We do the ratio test to determine which variable leaves the basis. We only
consider rows with positive entries in the column of the entering variable ( x3 ),
since these correspond to the basic variables that decrease as x3 increases.
x3 rhs ratios
Row 0
Row 1 ( s1 ) -1 16 no
Row 2 ( s2 ) .5 4 4/.5
Row 3 ( x1 ) .25 4 4/.25
Row 4 ( s4 ) 0 5 no
New set of basic variables is: BV={ s1 , x3 , x1, s4 } . We use elementary row
operations to update the tableau (see next page).
10
z x1 x2 x3 s1 s2 s3 s4 rhs
Row 0 1 0 5 0 0 10 10 0 280 z 280
Row 1 0 0 -2 0 1 2 -8 0 24 s1 24
Row 2 0 0 -2 1 0 2 -4 0 8 x3 8
Row 3 0 1 1.25 0 0 -.5 1.5 0 2 x1 2
Row 4 0 0 1 0 0 0 0 1 5 s4 5
Since the coefficients of the decision variables in row 0 are all nonnegative, we
can conclude that the current solution is optimal.
Remaining issues:
It is easy for LPs were all original constraints are and the right hand side
data is nonnegative (as in the LP we just solved). In such case we can use
the slacks as initial BV. In the general case, finding an initial bfs is not
trivial and requires solving another LP (called the Phase I LP, for which we
find an initial bfs by construction).
Unbounded LPs:
Convergence:
n
There are at most possible basic solutions. Assuming we dont repeat a
m
basis, the Simplex method will terminate in a finite number of iterations.
Repeating a basis is called cycling and can only occur if the constraints are
degenerate. There are anti-cycling rules that can be used with the Simplex
method, but these are not implemented in commercial codes since cycling is
rarely a problem in practice.
11