You are on page 1of 111

HOW TO CONVERT AN LP TO STANDARD FORM

• We have seen that an LP can have both equality and inequality


constraints.
• It also can have variables that are required to be nonnegative as
well as those allowed to be unrestricted in sign (urs).
• Before the simplex algorithm can be used to solve an LP, the LP
must be converted into an equivalent problem in which all
constraints are equalities and all variables are nonnegative. An LP
in this form is said to be in standard form.

Example:

Convert this LP to
Standard Form
HOW TO CONVERT AN LP TO STANDARD FORM

The following is the LP in standard form:

Solution:

: slack variable
: excess variable
BASIC AND NONBASIC VARIABLES

• We would like to solve in vector notation

• Consider the system of linear equations and variables


• Assume and has rows and columns.
• Every column of corresponds to a decision variable.
• A basic solution to is obtained by setting variables equal to 0 (nonbasic
variables) and solving the system for the values of the of the remaining
variables (basic variables).
BASIC AND NONBASIC VARIABLES
• Consider the following LP

• Here, n=3, m=2.


• If NBV=, then BV={} and the corresponding basic solution is
.
• If NBV=, then BV={} and the corresponding basic solution is
.
• If NBV=, then BV={} and the corresponding basic solution is
.
• The first and the third solutions are basic feasible solutions; the second
solution is not feasible.
• In the simplex method, we will focus on basic feasible solutions (bfs).
WHY IS BFS IMPORTANT?

 A set of points S is a convex set if the line segment joining any pair of points in
S is wholly contained in S.
 For any convex set S, a point P in S is an extreme point if P is an endpoint of all
line segents containing P and contained in S.
 The feasible region of an LP is a convex set, and an extreme point is actually a
corner point of the feasible region.
 Extreme points are important because if an LP has an optimal solution, it has an
optimal extreme point suffices
 It is sufficient to focus on extreme points to find the optimal solution.
WHY IS BFS IMPORTANT?
 A point in the feasible region of an LP is an extreme point if and only if it is a basic
feasible solution to the LP.
 Consider the following example:

𝑀𝑎𝑥𝑧=4𝑥1+3𝑥2 Convert to
Standart Form
𝑀𝑎𝑥𝑧=4𝑥 1+3𝑥 2
Nonbasic
Basic Var BFS Corner Point
Var
x1,x2 s1,s2 s1=s2=0, x1=x2=20 E
x1,s1 x2,s2 x2=s2=0, x1=30, s1=10 C
x1,s2 x2,s1 x2=s1=0, x1=40, s2=-20 not a bfs
x2,s1 x1,s2 x1=s2=0, x2=60, s1=-20 not a bfs
x2,s2 x1,s1 x1=s1=0, x2=40, s2=20 B
s1,s2 x1,x2 x1=x2=0, s1=40, s2=60 F
WHY IS BFS IMPORTANT?

 A point in the feasible region of an LP is an extreme point if and only if it is a basic


feasible solution to the LP.
 Thus, if an LP has an optimal solution, then it has an optimal bfs.
 It is sufficient to focus on basic feasible solutions to find the optimal solution.
 Any LP has a finite number of bfs.
 If an LP in standart form has n variables and m constraints, the maximum number
of basic feasible solutions is .
 Even though the feasible region of an LP has infinite number of points, we can find the
optimal solution by searching only finite number of basic feasible solutions.
 This is what the simplex algorithm does in an intelligent way.
THE SIMPLEX ALGORITHM
• We now describe how the simplex algorithm can be used to solve LPs in which
the goal is to maximize the objective function.
• The solution of minimization problems will be discussed later.
• Step 1 Convert the LP to standard form.
• Step 2 Obtain a bfs (if possible) from the standard form.
• Step 3 Determine whether the current bfs is optimal. In this step, the table
must be in canonical form.
• Step 4 If the current bfs is not optimal, then determine which nonbasic
variable should become a basic variable and which basic variable should
become a nonbasic variable to find a new bfs with a better objective
function value.
• Step 5 Use EROs to find the new bfs with the better objective function
value. Go back to step 3.

In performing the simplex algorithm, write the objective function in row 0 version
DAKOTA FURNITURE COMPANY

• The Dakota Furniture Company manufactures desks, tables, and chairs.


The manufacture of each type of furniture requires lumber and two types
of skilled labor: finishing and carpentry. The amount of each resource
needed to make each type of furniture is given in the following table.
Currently, 48 board feet of lumber, 20 finishing hours, and 8 carpentry
hours are available. A desk sells for $60, a table for $30, and a chair for
$20. Dakota believes that demand for desks and chairs is unlimited, but
at most five tables can be sold. Because the available resources have
already been purchased, Dakota wants to maximize total revenue.

Resource Desk Table Chair


Lumber (board ft) 8 6 1
Finishing hours 4 2 1.5
Carpentry hours 2 1.5 0.5
DAKOTA FURNITURE COMPANY

• Decision variables:
number of desks produced
number of tables produced
number of chairs produced
• The resulting model is
CONVERT THE LP TO STANDARD FORM

• The model in standard form is


OBTAIN THE CANONICAL FORM AND FIND A
BFS
• See the canonical form (including identity matrix)
• A system of linear equations in which each equation has a variable
with a coefficient of 1 in that equation (and a zero coefficient in all
other equations) is said to be in canonical form.

Row
0 =0
1 =48
2 =20
3 =8

4 =5
OBTAIN THE CANONICAL FORM AND FIND A
BFS

• See the canonical form (including identity matrix)


• A system of linear equations in which each equation has a variable
with a coefficient of 1 in that equation (and a zero coefficient in all
other equations) is said to be in canonical form.

Canonical Form in Table Format

z x1 x2 x3 s1 s2 s3 s4 rhs
1 -60 -30 -20 0 0 0 0 0
0 8 6 1 1 0 0 0 48
0 4 2 1.5 0 1 0 0 20
0 2 1.5 0.5 0 0 1 0 8
0 0 1 0 0 0 0 1 5
OBTAIN THE CANONICAL FORM AND FIND A
BFS
• When all constraints are and their right-hand sides are nonnegative,
obtaining the canonical form and finding an initial bfs is easy.
• Note that we need a basic variable for each row. The variables having
unit vectors in their columns can be used.
NBV={}, BV={}

Basic feasible solution:

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 -60 -30 -20 0 0 0 0 0 z=0
0 8 6 1 1 0 0 0 48 s1=48
0 4 2 1.5 0 1 0 0 20 s2=20
0 2 1.5 0.5 0 0 1 0 8 s3=8
0 0 1 0 0 0 0 1 5 s4=5
IS THE CURRENT BFS OPTIMAL?
• Answer this question: Is there a way that can be increased by increasing
some nonbasic variable from its current value of zero while holding all
other nonbasic variables at their current values of zero.
• This question has to be answered by checking a canonical form.
Yes, increasing or or without changing the others increases . Thus, the
current solution is not optimal.
We choose since it has the most negative coefficient in row 0.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 -60 -30 -20 0 0 0 0 0 z=0
0 8 6 1 1 0 0 0 48 s1=48
0 4 2 1.5 0 1 0 0 20 s2=20
0 2 1.5 0.5 0 0 1 0 8 s3=8
0 0 1 0 0 0 0 1 5 s4=5
DETERMINE THE ENTERING AND LEAVING
VARIABLES
• is the entering variable. It will enter the basis. Now we should determine
the leaving variable.
• We wil increase as much as possible. Increasing will decrease some
basic variables which are nonnegative. Thus,

for all values of (no limit). can be at most 4.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 -60 -30 -20 0 0 0 0 0 z=0
0 8 6 1 1 0 0 0 48 s1=48
0 4 2 1.5 0 1 0 0 20 s2=20
0 2 1.5 0.5 0 0 1 0 8 s3=8
0 0 1 0 0 0 0 1 5 s4=5
DETERMINE THE ENTERING AND LEAVING VARIABLES

• In the previous slide we applied ratio test and the winner was row 3.
Row 3 will determine the maximum value of .
• Apply ratio test for the rows where the coefficient of the entering
variable is strictly positive. The row having the minimum ratio is the
winner.
• will enter the basis in row 3 and, therefore, will leave the basis and
become nonbasic variable.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 -60 -30 -20 0 0 0 0 0 z=0
0 8 6 1 1 0 0 0 48 s1=48
0 4 2 1.5 0 1 0 0 20 s2=20
0 2 1.5 0.5 0 0 1 0 8 s3=8
0 0 1 0 0 0 0 1 5 s4=5
FIND A NEW BFS - 1
• Note that the columns of basic variables are unit vector.
• will enter the basis in row 3. Therefore, in row 3, its coefficient will be
one, and in the other rows, its coefficients will be 0.
• By applying elementary row operations (ERO) obtain the bfs.
• NBV={}, BV={}

• Divide row 3 by 2.
z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.
1 -60 -30 -20 0 0 0 0 0
0 8 6 1 1 0 0 0 48
0 4 2 1.5 0 1 0 0 20
0 1 0.75 0.25 0 0 0.5 0 4

0 0 1 0 0 0 0 1 5
FIND A NEW BFS - 2
• will enter the basis in row 3. Therefore, in row 3, its coefficient will be
zero, and in the other rows, its coefficients will be 0.
• By applying elementary row operations obtain the bfs.
• NBV={}, BV={}

• Multiply row 3 by -4 and add it to row 2.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 -60 -30 -20 0 0 0 0 0
0 8 6 1 1 0 0 0 48
0 0 -1 0.5 0 1 -2 0 4
0 1 0.75 0.25 0 0 0.5 0 4

0 0 1 0 0 0 0 1 5
FIND A NEW BFS - 3
• will enter the basis in row 3. Therefore, in row 3, its coefficient will be
zero, and in the other rows, its coefficients will be 0.
• By applying elementary row operations obtain the bfs.
• NBV={}, BV={}

• Multiply row 3 by -8 and add it to row 1.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 -60 -30 -20 0 0 0 0 0
0 0 0 -1 1 0 -4 0 16
0 0 -1 0.5 0 1 -2 0 4
0 1 0.75 0.25 0 0 0.5 0 4

0 0 1 0 0 0 0 1 5
FIND A NEW BFS - 4
• will enter the basis in row 3. Therefore, in row 3, its coefficient will be
zero, and in the other rows, its coefficients will be 0.
• By applying elementary row operations obtain the bfs.
• NBV={}, BV={}

• Multiply row 3 by 60 and add it to row 0.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 15 -5 0 0 30 0 240
0 0 0 -1 1 0 -4 0 16
0 0 -1 0.5 0 1 -2 0 4
0 1 0.75 0.25 0 0 0.5 0 4

0 0 1 0 0 0 0 1 5
FIND A NEW BFS - 5
• will enter the basis in row 3. Therefore, in row 3, its coefficient will be
zero, and in the other rows, its coefficients will be 0.
• By applying elementary row operations obtain the bfs.
• NBV={}, BV={}

• We have obtained the new bfs.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 15 -5 0 0 30 0 240 z=240
0 0 0 -1 1 0 -4 0 16 s1=16
0 0 -1 0.5 0 1 -2 0 4 s2=4
0 1 0.75 0.25 0 0 0.5 0 4 x1=4

0 0 1 0 0 0 0 1 5 s4=5
FIND A NEW BFS - 6
• Now, we have a new bfs and a new canonical table.
• Again, check the optimality of this bfs. Since we have a negative
coefficient in row 0, this solution is not optimal. Therefore, repeat all
steps to find a better bfs...

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 15 -5 0 0 30 0 240 z=240
0 0 0 -1 1 0 -4 0 16 s1=16
0 0 -1 0.5 0 1 -2 0 4 s2=4
0 1 0.75 0.25 0 0 0.5 0 4 x1=4

0 0 1 0 0 0 0 1 5 s4=5
NEXT ITERATION

• is the entering variable


• Ratio test for rows 2 and 3 (4/0.5, 4/0.25). Take the minimum. Winner is
row 2. So is the leaving variable.
• We need to find the new bfs.
• EROs yield the following table:

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 5 0 0 10 10 0 280 z=280
0 0 -2 0 1 2 -8 0 24 s1=24
0 0 -2 1 0 2 -4 0 8 x3=8
0 1 1.25 0 0 -0.5 1.5 0 2 x1=2

0 0 1 0 0 0 0 1 5 s4=5
NEXT ITERATION
• We have a new bfs and a new canonical table.
• Check the optimality.
• Since all coefficients in row 0 are nonnegative, this bfs is optimal.

A canonical form is optimal (for a max problem) if each nonbasic variable has
a nonnegative coefficient in the canonical form’s row 0.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 5 0 0 10 10 0 280 z=280
0 0 -2 0 1 2 -8 0 24 s1=24
0 0 -2 1 0 2 -4 0 8 x3=8
0 1 1.25 0 0 -0.5 1.5 0 2 x1=2

0 0 1 0 0 0 0 1 5 s4=5
RESULT
• The optimal solution to the problem
• .
• The maximum value of the profit is 280.

The following is called optimal table.


z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.
1 0 5 0 0 10 10 0 280 z=280
0 0 -2 0 1 2 -8 0 24 s1=24
0 0 -2 1 0 2 -4 0 8 x3=8
0 1 1.25 0 0 -0.5 1.5 0 2 x1=2

0 0 1 0 0 0 0 1 5 s4=5
SUMMARY OF THE SIMPLEX ALGORITHM FOR
A MAX PROBLEM
• Step 1 Convert the LP to standard form.
• Step 2 Find a basic feasible solution. This is easy if all the constraints are ≤ with
nonnegative right-hand sides. Then the slack variable may be used as the basic
variable for row . If no bfs is readily apparent, how you can find a bfs will be
discussed later.
• Step 3 If all nonbasic variables have nonnegative coefficients in row 0, then the
current bfs is optimal. If any variables in row 0 have negative coefficients, then
choose the variable with the most negative coefficient in row 0 to enter the
basis.
• Step 4 Use EROs to make the entering variable the basic variable in any row
that wins the ratio test (ties may be broken arbitrarily). After the EROs have
been used to create a new canonical form, return to step 3, using the current
canonical form.
ALTERNATIVE OPTIMAL SOLUTIONS
• Consider the Dacota example assuming that tables sell for $35 instead of
$30.

Initial table

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 -60 -35 -20 0 0 0 0 0 z=0
0 8 6 1 1 0 0 0 48 s1=48
0 4 2 1.5 0 1 0 0 20 s2=20
0 2 1.5 0.5 0 0 1 0 8 s3=8
0 0 1 0 0 0 0 1 5 s4=5
ALTERNATIVE OPTIMAL SOLUTIONS
• Consider the Dacota example assuming that tables sell for $35 instead of
$30.

Next table

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 10 -5 0 0 30 0 240 z=240
0 0 0 -1 1 0 -4 0 16 s1=16
0 0 -1 0.5 0 1 -2 0 4 s2=4
0 1 0.75 0.25 0 0 0.5 0 4 x1=4
0 0 1 0 0 0 0 1 5 s4=5
ALTERNATIVE OPTIMAL SOLUTIONS
This table gives the optimal solution: .

In this table is a nonbasic variable and its coefficient is 0 in row 0. This


means that if enters the basis, value will not change. Therefore, we will
obtain another alternative optimal solution.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 0 0 0 10 10 0 280 z=280
0 0 -2 0 1 2 -8 0 24 s1=24
0 0 -2 1 0 2 -4 0 8 x3=8
0 1 1.25 0 0 -0.5 1.5 0 2 x1=2
0 0 1 0 0 0 0 1 5 s4=5
ALTERNATIVE OPTIMAL SOLUTIONS

Let’s find the alternative optima solution by doing one more iteration for to
enter the basis.

z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.


1 0 0 0 0 10 10 0 280 z=280
0 0 -2 0 1 2 -8 0 24 s1=24
0 0 -2 1 0 2 -4 0 8 x3=8
0 1 1.25 0 0 -0.5 1.5 0 2 x1=2
0 0 1 0 0 0 0 1 5 s4=5
ALTERNATIVE OPTIMAL SOLUTIONS
The alternative optimal solution is:
.

Alternative optimal table


z x1 x2 x3 s1 s2 s3 s4 rhs Basic var.
1 0 0 0 0 10 10 0 280 z=280
0 1.6 0 0 1 1.2 -5.6 0 27.2 s1=27.2
0 1.6 0 1 0 1.2 -1.6 0 11.2 x3=11.2
0 0.8 1 0 0 -0.4 1.2 0 1.6 x2=1.6
0 -0.8 0 0 0 0.4 -1.2 1 3.4 s4=3.4
ALTERNATIVE OPTIMAL SOLUTIONS
We have two alternative optimal solutions:

It is known that any point on the line segment joining two optimal solutions
is also optimal. Therefore, is optimal for any . Verify this!

If , then (0.2,1.44,10.88) is optimal.


If , then (1.6,0.32,8.64) is optimal.
USING THE SIMPLEX ALGORITHM TO SOLVE
MIN PROBLEMS
• Example:

Method 1: Instead of minimizing z, maximize –z:


USING THE SIMPLEX ALGORITHMTO SOLVE
MIN PROBLEMS METHOD 1
Standard Form

Initial table

-z x1 x2 s1 s2 rhs Basic var.


1 2 -3 0 0 0 -z=0
0 1 1 1 0 4 s1=4
0 1 -1 0 1 6 s2=6
USING THE SIMPLEX ALGORITHMTO SOLVE
MIN PROBLEMS METHOD 1

Standard Form

Final table, optimal solution:

-z x1 x2 s1 s2 rhs Basic var.


1 5 0 3 0 12 -z=12
0 1 1 1 0 4 x2=4
0 2 0 1 1 10 s2=10
USING THE SIMPLEX ALGORITHM TO SOLVE MIN
PROBLEMS

• Example:

Method 2: Modify Step 3 of the simplex as follows: If all nonbasic variables in


row 0 have nonpositive coefficients, then the current bfs is optimal. If any nonbasic
variable in row 0 has a positive coefficient, choose the variable with the “most
positive” coefficient in row to enter the basis.
USING THE SIMPLEX ALGORITHMTO SOLVE MIN
PROBLEMS METHOD 2

Standard Form

Initial table

z x1 x2 s1 s2 rhs Basic var.


1 -2 3 0 0 0 z=0
0 1 1 1 0 4 s1=4
0 1 -1 0 1 6 s2=6
USING THE SIMPLEX ALGORITHMTO SOLVE MIN
PROBLEMS METHOD 2

Standard Form

Final table, optimal solution:

-z x1 x2 s1 s2 rhs Basic var.


1 -5 0 -3 0 -12 z=-12
0 1 1 1 0 4 x2=4
0 2 0 1 1 10 s2=10
UNBOUNDED LP

Breadco Bakeries bakes two kinds of bread: French and sourdough. Each
loaf of French bread can be sold for 36¢, and each loaf of sourdough bread
for 30¢. A loaf of French bread requires 1 yeast packet and 6 oz of flour;
sourdough requires 1 yeast packet and 5 oz of flour. At present, Breadco has
5 yeast packets and 10 oz of flour. Additional yeast packets can be
purchased at 3¢ each, and additional flour at 4¢/oz. Formulate and solve an
LP that can be used to maximize Breadco’s profits ( revenues - costs).
UNBOUNDED LP

Decision variables:
number of loaves of French bread baked
number of loaves of sourdough bread baked
number of packets of yeast purchased
number of ounces of flour baked

The model is
UNBOUNDED LP

The model in standard form is

Initial table

z x1 x2 x3 x4 s1 s2 rhs Basic var.

1 -36 -30 3 4 0 0 0 z=0


0 1 1 -1 0 1 0 5 s1=5
0 6 5 0 -1 0 1 10 s2=10
UNBOUNDED LP
The model in standard form is

Next table

z x1 x2 x3 x4 s1 s2 rhs Basic var.

1 0 0 3 -2 0 6 60 z=60
0 0 1/6 -1 1/6 1 -1/6 20/6 s1=20/6
0 1 5/6 0 -1/6 0 1/6 10/6 x1=10/6
UNBOUNDED LP
The model in standard form is

Next table; Ratio test is not possible, no limit for .

z x1 x2 x3 x4 s1 s2 rhs Basic var.

1 0 2 -9 0 12 4 100 z=100
0 0 1 -6 1 6 -1 20 x4=20
0 1 1 -1 0 1 0 5 x1=5
UNBOUNDED LP
can be increased as much as we like. Since increasing by 1 will increase z
by 9, we can increase as much as we like. Therefore, this LP is unbounded.
Can we make equal to 1000?
must be 100. Then will be ; will be

Please check that is feasible and has an objective function value of 1000.

z x1 x2 x3 x4 s1 s2 rhs Basic var.

1 0 2 -9 0 12 4 100 z=100
0 0 1 -6 1 6 -1 20 x4=20
0 1 1 -1 0 1 0 5 x1=5
UNBOUNDED LP
RULE: an unbounded LP for a max problem occurs when a variable
with a strictly negative coefficient in row 0 has a nonpositive
coefficient in each constraint.
DEGENERACY AND THE CONVERGENCE
OF THE SIMPLEX ALGORITHM
• Theoretically, the simplex algorithm may fail to find the optimal
solution.
• However, LPs arising from actual applications seldom exhibit this un-
pleasant behavior.
• We now discuss the situation in which the simplex can fail.
• Our discussion depends crucially on the following relationship (for a
max problem):
• z-value for new bfs=z-value of current bfs-(value of entering
variable in new bfs)(coefficient of entering variable in row 0 of
current bfs)
• The facts:
• Fact 1: If (value of entering variable in new bfs)>0, then (z-value for
new bfs)>(z-value for current bfs).
• Fact 2: If (value of entering variable in new bfs)=0, then (z-value for
new bfs)=(z-value for current bfs).
DEGENERACY AND THE CONVERGENCE
OF THE SIMPLEX ALGORITHM
• If in each of the LP’s basic feasible solutions, all of the basic variables
are strictly positive, then this LP is called nondegenerate.
• The simplex algorithm can solve nondegenerate LPs in a finite number
of iterations.
• Fact 1 implies that in every iteration of the simplex method, z will
increase. Therefore, the simplex algorithm cannot visit the same bfs
twice.
• Since an LP always has always finite bfs, the simplex algorithm will
terminate after a finite number of iterations.
• If a nondegenerate LP has 10 variables and 4 constraints, then it has at
most bfs.
• Since we will never repeat a bfs, the simplex method solve this LP
after at most 210 iterations.
DEGENERACY AND THE CONVERGENCE
OF THE SIMPLEX ALGORITHM
• However, the simplex may fail for a degenerate LP.
• An LP is degenerate if it has at least one bfs in which a basic variable is
equal to zero.
• Consider the following LP:

Initial table:

-z x1 x2 s1 s2 rhs
1 -5 -2 0 0 0
0 1 1 1 0 6
0 1 -1 0 1 0 Degenerate bfs.
DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• However, the simplex may fail for a degenerate LP.
• An LP is degenerate if it has at least one bfs in which a basic variable is
equal to zero.
• Consider the following LP:

The table after 1 iteration:

-z x1 x2 s1 s2 rhs
1 0 -7 0 5 0
Degenerate bfs.
0 0 2 1 -1 6
z did not change.
0 1 -1 0 1 0
DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• However, the simplex may fail for a degenerate LP.
• An LP is degenerate if it has at least one bfs in which a basic variable is
equal to zero.
• Consider the following LP:

The table after 2 iterations:

-z x1 x2 s1 s2 rhs
1 0 0 7/2 3/2 21
0 0 1 1/2 -1/2 3 The optimal solution
0 1 0 1/2 1/2 3 has been reached.
DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• In the previous example, the simplex method has achieved to find the
optimal solution (since the third bfs is not degenerate). However, we
have observed that in a degenerate LP, an iteration of the simplex method
may leave the value of z unchanged.
• The following sequence is possible:

• Initial bfs (bfs 1): z=20


• After first pivot (bfs 2): z=20
• After second pivot (bfs 3): z=20
• After third pivot (bfs 4): z=20
• After fourth pivot (bfs 1): z=20

• This is called cycling.


• If cycling occurs, the simplex may loop forever and never find the
optimal solution.
DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• If cycling occurs, the simplex may loop forever and never find the
optimal solution.
• Fortunately, the simplex algorithm can be modified to ensure that cycling
will never occur [see Bland (1977)].
• Bland showed that cycling can be avoided by applying the following
rules (assume that slack and excess variables are numbered ):

1. Choose as the entering variable (in a max problem) the variable


with a negative coefficient in row 0 that has the smallest subscript.
2. If there is a tie in the ratio test, then break the tie by choosing the
winner of the ratio test so that the variable leaving the basis has the
smallest subscript.
DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• Consider the following model: (standart Siplex method, in ratio test,
break ties in favor of lower-numbered rows)

Z X1 X2 X3 X4 S1 S2 S3 RHS
1 3 -1 6 0 0 0 0 0 Initial table
0 9 1 -9 -2 1 0 0 0
0 1 1/3 -2 -1/3 0 1 0 0
0 -9 -1 9 2 0 0 1 1

X2 now enters in Row 1 yielding the following tableau.


DEGENERACY AND THE CONVERGENCE
OF THE SIMPLEX ALGORITHM
• Consider the following model: (standart Siplex method, in ratio test,
break ties in favor of lower-numbered rows)

Z X1 X2 X3 X4 S1 S2 S3 RHS
1 12 0 -3 -2 1 0 0 0
Table 1
0 9 1 -9 -2 1 0 0 0
0 -2 0 1 1/3 -1/3 1 0 0
0 0 0 0 0 1 0 1 1
We now enter X3 into the basis in Row 2.
DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• Consider the following model: (standart Siplex method, in ratio test,
break ties in favor of lower-numbered rows)

Z X1 X2 X3 X4 S1 S2 S3 RHS
1 6 0 0 -1 0 3 0 0
Table 2
0 -9 1 0 1 -2 9 0 0
0 -2 0 1 1/3 -1/3 1 0 0
0 0 0 0 0 1 0 1 1

We now enter X4 into the basis and choose to enter X4 in Row 1.


DEGENERACY AND THE CONVERGENCE
OF THE SIMPLEX ALGORITHM
• Consider the following model: (standart Siplex method, in ratio test,
break ties in favor of lower-numbered rows)

Z X1 X2 X3 X4 S1 S2 S3 RHS
1 -3 1 0 0 -2 12 0 0
Table 3
0 -9 1 0 1 -2 9 0 0
0 1 -1/3 1 0 1/3 -2 0 0
0 0 0 0 0 1 0 1 1
X1 now enters basis in Row 2.
DEGENERACY AND THE CONVERGENCE
OF THE SIMPLEX ALGORITHM
• Consider the following model: (standart Siplex method, in ratio test,
break ties in favor of lower-numbered rows)

Z X1 X2 X3 X4 S1 S2 S3 RHS
1 0 0 3 0 -1 6 0 0
0 0 -2 9 1 1 -9 0 0
Table 4
0 1 -1/3 1 0 1/3 -2 0 0
0 0 0 0 0 1 0 1 1

We now choose to enter S1 in Row 1.


DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• Consider the following model: (standart Simplex method, in ratio test,
break ties in favor of lower-numbered rows)

Z X1 X2 X3 X4 S1 S2 S3 RHS
1 0 -2 12 1 0 -3 0 0 Table 5
0 0 -2 9 1 1 -9 0 0
0 1 1/3 -2 -1/3 0 1 0 0
0 0 2 -9 -1 0 9 1 1
S2 would now enter basis in Row 2.
This will bring us back to initial tableau, so cycling has
occurred.
DEGENERACY AND THE CONVERGENCE OF
THE SIMPLEX ALGORITHM
• Consider the following model: (standart Siplex method, in ratio test,
break ties in favor of lower-numbered rows)

Z X1 X2 X3 X4 S1 S2 S3 RHS
1 3 -1 6 0 0 0 0 0
0 9 1 -9 -2 1 0 0 0
0 1 1/3 -2 -1/3 0 1 0 0
0 -9 -1 9 2 0 0 1 1

This is the initial table. The cycling has occurred.


DEGENERACY AND THE CONVERGENCE
OF THE SIMPLEX ALGORITHM
• Now, consider the same problem by using Bland’s rule; continue from
Table 5 and observe that the cycle will be broken.

Z X1 X2 X3 X4 S1(X5) S2(X6) S3(X7


) RHS
1 0 -2 12 1 0 -3 0 0 Table 5
0 0 -2 9 1 1 -9 0 0
0 1 1/3 -2 -1/3 0 1 0 0
0 0 2 -9 -1 0 9 1 1

X2 should enter the basis in row 2 instead of S2.


DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• Now, consider the same problem by using Bland’s rule; continue from
Table 5 and observe that the cycle will be broken.

Z X1 X2 X3 X4 S1(X5) S2(X6) S3(X7 RHS


)
1 6 0 0 -1 0 3 0 0 Table 6
0 6 0 -3 -1 1 -3 0 0
0 3 1 -6 -1 0 3 0 0
0 -6 0 3 1 0 3 1 1

X4 now enters the basis in Row 3


DEGENERACY AND THE CONVERGENCE OF THE
SIMPLEX ALGORITHM
• Now, consider the same problem by using Bland’s rule; continue from
Table 5 and observe that the cycle will be broken.

Z X1 X2 X3 X4 S1(X5) S2(X6) S3(X7


) RHS
1 0 0 3 0 0 6 1 1 Table 7,
0 0 0 0 0 1 0 1 1
0 -3 1 -3 0 0 6 1 1 Optimal table!
0 -6 0 3 1 0 3 1 1
From this table, we find the optimal solution is
Z = 1, X2=X4=S1=1, X1=X3=S2=S3=0
THE BIG M METHOD
• Remember that the simplex algorithm requires a starting bfs.

• In all the problems we have solved so far, we found a starting bfs by


using the slack variables as our basic variables.

• If an LP has some ≥ or equality constraints, however, a starting bfs may


not be readily apparent.

• When a bfs is not readily apparent, the Big M method or the two-phase
simplex method may be used to solve the problem.
THE BIG M METHOD
• Example: Bevco manufactures an orange-flavored soft drink called
Oranj by combining orange soda and orange juice. Each ounce of orange
soda contains 0.5 oz of sugar and 1 mg of vitamin C. Each ounce of
orange juice contains 0.25 oz of sugar and 3 mg of vitamin C. It costs
Bevco 2¢ to produce an ounce of orange soda and 3¢ to produce an
ounce of or- ange juice. Bevco’s marketing department has decided that
each 10-oz bottle of Oranj must contain at least 20 mg of vitamin C and
at most 4 oz of sugar. Use linear programming to determine how Bevco
can meet the marketing department’s requirements at minimum cost.
THE BIG M METHOD
• Decision variables:
• : number of ounces of orange soda in a bottle of Oranj
• : number of ounces of orange juice in a bottle of Oranj
THE BIG M METHOD
• The model in standard form is the following:

In searching for a bfs, we need a basic variable for every row.


First row: =4
Second row: =-20 (Infeasible!)
Third row: no basic variable.
Apperantly, a bfs is not readily available.
THE BIG M METHOD
• We add some artificial variables to obtain a bfs as follows

We now have a bfs: . To obtain the equivalenve, we must guarantee that in


the optimal solution .

Trick: In a MIN problem, add to the objectie function. In a MAX problem,


add to the objectie function.
THE BIG M METHOD
• Modifying the objective function in this way makes it extremely costly
for an artificial variable to be positive.

• With this modified objective function, the optimal solution will have .

• Sometimes, it may happen that some of the artificial variables have


strictly positive values in the optimal solution. If this occurs, the original
problem is infeasible.
THE BIG M METHOD
• Step 1 Modify the constraints so that the right-hand side of each
constraint is non- negative.
• Step 1’ Identify each constraint that is now (after step 1) an = or ≥
constraint.
• Step 2 Convert each inequality constraint to standard form.
• Step 3 If constraint is a ≥ or = constraint, add an artificial variable . Also
add the sign restriction .
• Step 4 Let denote a very large positive number. If the LP is a min
problem, add (for each artificial variable) to the objective function. If
the LP is a max problem, add (for each artificial variable) to the
objective function.
• Step 5 Because each artificial variable will be in the starting basis, all
artificial variables must be eliminated from row 0 before beginning the
simplex. This ensures that we begin with a canonical form.
THE BIG M METHOD
• In choosing the entering variable, remember that M is a very large positive number. For
example, 4M-2 is more positive than 3M+900, and -6M-5 is more negative than -5M-
40.

• Now solve the transformed problem by the simplex.

• If all artificial variables are equal to zero in the optimal solution, then we have found the
optimal solution to the original problem.

• If any artificial variables are positive in the optimal solution, then the original problem is
infeasible.

• If the final table indicates the LP is unbounded and all artificial variables in this tableau
equal zero, then the original LP is unbounded.

• If the final table indicates that the LP is unbounded and at least one artificial variable is
strictly positive, then the original LP is infeasible.
THE BIG M METHOD
• We have already applied first 4 steps. Now, continue with Step 5.

z rhs
Note that this table
1 -2 -3 0 0 -M -M 0 is not in canonical
0 1/2 1/4 1 0 0 0 4 form.
0 1 3 0 -1 1 0 20
0 1 1 0 0 0 1 10
THE BIG M METHOD
• Now, we have the canonical form. Apply simplex method
z rhs
1 -2+2M -3+4M 0 -M 0 0 30M
0 1/2 1/4 1 0 0 0 4
0 1 3 0 -1 1 0 20
0 1 1 0 0 0 1 10

z rhs
1 (2M-3)/3 0 0 (M-3)/3 (3-4M)/3 0 (10M+60)/3
0 5/12 0 1 1/12 -1/12 0 7/3
0 1/3 1 0 -1/3 1/3 0 20/3
0 2/3 0 0 1/3 -1/3 1 10/3
THE BIG M METHOD
• Now, we have the canonical form. Apply simplex method
z rhs
1 0 0 0 -1/2 (1-2M)/2 (3-2M)/2 25
0 0 0 1 -1/8 1/8 -5/8 1/4
0 0 1 0 -1/2 1/2 -1/2 5
0 1 0 0 1/2 -1/2 3/2 5

Optimal solution: .
THE BIG M METHOD
• Example 2:

z rhs
1 -2 -3 0 0 -M -M 0
0 1/2 1/4 1 0 0 0 4
0 1 3 0 -1 1 0 36
0 1 1 0 0 0 1 10
THE BIG M METHOD
• Now, we have the canonical form. Apply simplex method
z rhs
1 -2+2M -3+4M 0 -M 0 0 46M
0 1/2 1/4 1 0 0 0 4
0 1 3 0 -1 1 0 36
0 1 1 0 0 0 1 10

z rhs Optimal Table


1 1-2M 0 0 -M 0 3-4M 30+6M The artificial variable
0 1/4 0 1 0 0 -1/4 3/2 is in the basis ().
Therefore, we can
0 -2 0 0 -1 1 -3 6 conclude that the
0 1 1 0 0 0 1 10 original model is
infeasible.
THE BIG M METHOD
• In the applications, is chosen to be very large. The introduction of such
large numbers into the problem can cause roundoff errors and other
computational difficulties. For this reason, most computer codes solve
LPs by using the two-phase simplex method.
UNRESTRICTED-IN-SIGN VARIABLES
• In this section, we show how an LP with unrestricted-in-sign variables
(urs) can be transformed into an LP in which all variables are required to
be nonnegative.

• For each urs variable , we begin by defining two new variables and .
Then substitute for in each constraint and in the objective function.
Also add the sign restrictions and .

• We will soon see that in a bfs, it is not possible to have and .

• Therefore, we have three cases

• Case 1: and , then .


• Case 2: and , then .
• Case 3: and , then .
UNRESTRICTED-IN-SIGN VARIABLES
• Example: A baker has 30 oz of flour and 5 packages of yeast. Baking a
loaf of bread requires 5 oz of flour and 1 package of yeast. Each loaf of
bread can be sold for 30¢. The baker may purchase additional flour at
4¢/oz or sell leftover flour at the same price. Formulate and solve an LP
to help the baker maximize profits (revenues-costs).
UNRESTRICTED-IN-SIGN VARIABLES
• Decision Variables:
• : number of loaves of bread baked
• : number of ounces of flour by which flour supply is increased or
decreased
UNRESTRICTED-IN-SIGN VARIABLES
• Since is urs, we substitute for . The resulting formulation is the
following:

Now, we can apply the simplex algorithm. Note that when we convert the
model to the standard form, the initial bfs is readily available.
UNRESTRICTED-IN-SIGN VARIABLES

z rhs
1 -30 4 -4 0 0 0
0 5 -1 1 1 0 30
0 1 0 0 0 1 5
UNRESTRICTED-IN-SIGN VARIABLES
z rhs
1 0 4 -4 0 30 150
0 0 -1 1 1 -5 5
0 1 0 0 0 1 5

z rhs Optimal table:


1 0 0 0 4 10 170
The optimal solution:
0 0 -1 1 1 -5 5
0 1 0 0 0 1 5

No matter how many pivots we make, the column will always be the negative of the
column. Therefore, (in a max problem) if one of these variables will enter the basis
(negative row 0 coefficient), the other one cannot since its row 0 coeficient will be
positive.
THE TWO-PHASE SIMPLEX METHOD
• When a basic feasible solution is not readily available, the two-phase
simplex method may be used as an alternative to the Big M method.

• In the two-phase simplex method, we add artificial variables to the same


constraints as we did in the Big M method.

• Then we find a bfs to the original LP by solving the Phase-1 LP. In the
Phase-1 LP, the objective function is to minimize the sum of all artificial
variables.

• At the completion of Phase-1, we reintroduce the original LP’s objective


function and determine the optimal solution to the original LP. This is
called Phase-2.
THE TWO-PHASE SIMPLEX METHOD
• Step 1 Modify the constraints so that the right-hand side of each
constraint is nonnegative.
• Step 2 Convert each inequality constraint to the standard form. If
constraint is a constraint, then add a nonnegative slack variable . If
constraint is a constraint, subtract a nonnegative excess variable .
• At the end of this step, all variables in the model are called original
variables.
• Step 3 If constraint is a or = constraint, add an artificial variable . Also
add the sign restriction .
• Step 4 For now, ignore the original LP’s objective function. Instead
solve an LP whose objective function is (sum of all artificial variables).
This is called the Phase-1 LP. The act of solving the Phase I LP will
force the artificial variables to get out of the basis.
THE TWO-PHASE SIMPLEX METHOD
• Solving Phase-1 LP will result in one of the following three cases:

• Case 1: The optimal value of w is strictly greater than zero. In this case,
the original LP is infeasible.

• Case 2: The optimal value of w is equal to zero, and no artificial


variables are in the optimal basis. Drop all columns corresponding to the
artificial variables. Combine the original objective function with the
constraints from the optimal Phase-1 tableau. This yields the Phase II LP.
The optimal solution to the Phase II LP is the optimal solution to the
original LP.
THE TWO-PHASE SIMPLEX METHOD
• Case 3: The optimal value of w is equal to zero and at least one artificial
variable is in the optimal basis. In this case, by doing additional (little
modified) simplex iterations, try to remove all artificial variables form
the basis. Then, drop all columns corresponding to the artificial variables
and continue simplex algorithm with the original row 0.

• Choose the entering variable as the original variable having a non-


zero coefficient in the row corresponding to the artificial variable
that you want to remove from the basis.

• In the row corresponding to an artificial variables included in the


optimal basis if the coefficients of all original variables are zero, you
can delete this row.
THE TWO-PHASE SIMPLEX METHOD
• Example 1:
THE TWO-PHASE SIMPLEX METHOD
• Example 1: Apply steps 1-3
THE TWO-PHASE SIMPLEX METHOD
• Example 1: Apply step 4: Solve the following Phase-1 LP

w rhs
1 0 0 0 0 -1 -1 0 Bfs is ok, but we
must obtain canonical
0 1/2 1/4 1 0 0 0 4
form.
0 1 3 0 -1 1 0 20
0 1 1 0 0 0 1 10
THE TWO-PHASE SIMPLEX METHOD
• Example 1: Apply step 4: Solve the following Phase-1 LP

w rhs
1 2 4 0 -1 0 0 30 Bfs and canonical
form are ok.
0 1/2 1/4 1 0 0 0 4
Table 1
0 1 3 0 -1 1 0 20
0 1 1 0 0 0 1 10
THE TWO-PHASE SIMPLEX METHOD
• Example 1: Apply step 4: Solve the following Phase-1 LP

w rhs
1 2/3 0 0 1/3 -4/3 0 10/3 Table 2
0 5/12 0 1 1/12 -1/12 0 7/3
0 1/3 1 0 -1/3 1/3 0 20/3
0 2/3 0 0 1/3 -1/3 1 10/3
THE TWO-PHASE SIMPLEX METHOD
• Example 1: Apply step 4: Solve the following Phase-1 LP

w rhs Table 3
Optimal table
1 0 0 0 0 -1 -1 0 Case 2
0 0 0 1 -1/8 1/8 -5/8 1/4 Remove artificial
0 0 1 0 -1/2 1/2 -1/2 5 variables and get
back to the original
0 1 0 0 1/2 -1/2 3/2 5 row 0.
THE TWO-PHASE SIMPLEX METHOD
• Example 1: Solve Phase-2 LP, remember it was minimization.

z rhs Bfs is ok but we must


1 -2 -3 0 0 0 obtain canonical form
0 0 0 1 -1/8 1/4
0 0 1 0 -1/2 5
0 1 0 0 1/2 5
THE TWO-PHASE SIMPLEX METHOD
• Example 1: Solve Phase-2 LP, remember it was minimization.

z rhs Bfs and canonical form


1 0 0 0 -1/2 25 are ok. This table is
optimal.
0 0 0 1 -1/8 1/4 So the optimal solution is
0 0 1 0 -1/2 5 .
0 1 0 0 1/2 5
THE TWO-PHASE SIMPLEX METHOD
• Example 2:
THE TWO-PHASE SIMPLEX METHOD
• Example 2: Apply steps 1-3
THE TWO-PHASE SIMPLEX METHOD
• Example 2: Apply step 4: Solve the following Phase-1 LP

w rhs
1 0 0 0 0 -1 -1 0 Bfs is ok, but we
must obtain canonical
0 1/2 1/4 1 0 0 0 4 form.
0 1 3 0 -1 1 0 36
0 1 1 0 0 0 1 10
THE TWO-PHASE SIMPLEX METHOD
• Example 2: Apply step 4: Solve the following Phase-1 LP

w rhs Bfs and canonical


1 2 4 0 -1 0 0 46 form are ok.
0 1/2 1/4 1 0 0 0 4 Table 1

0 1 3 0 -1 1 0 36
0 1 1 0 0 0 1 10
THE TWO-PHASE SIMPLEX METHOD
• Example 2: Apply step 4: Solve the following Phase-1 LP

w rhs This table is optimal.


1 -2 0 0 -1 0 -4 6 Note that and
0 1/4 0 1 0 0 -1/4 3/2 artificial variable is
in the basis.
0 -2 0 0 -1 1 -3 6 Case 1
0 1 1 0 0 0 1 10 Original LP is
infeasible!
THE TWO-PHASE SIMPLEX METHOD
• Example 3:
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Apply steps 1-3
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Apply step 4

w rhs
1 0 0 0 0 0 -1 -1 -1 0 0
Bfs is ok but we
0 1 -1 0 2 0 1 0 0 0 0 must obtain
0 -2 1 0 -2 0 0 1 0 0 0 canonical form.
0 1 0 1 1 -1 0 0 1 0 3
0 0 2 1 2 1 0 0 0 1 4
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Apply step 4

w rhs
1 0 0 1 1 -1 0 0 0 0 3 Bfs and canonical
0 1 -1 0 2 0 1 0 0 0 0 form are ok.
0 -2 1 0 -2 0 0 1 0 0 0 Table 1
0 1 0 1 1 -1 0 0 1 0 3
0 0 2 1 2 1 0 0 0 1 4
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Apply step 4

w rhs
1 -1 0 0 0 0 0 0 -1 0 0
0 1 -1 0 2 0 1 0 0 0 0
0 -2 1 0 -2 0 0 1 0 0 0
0 1 0 1 1 -1 0 0 1 0 3
0 -1 2 0 1 2 0 0 -1 1 1

Table 2
This table is optimal. Note that but and are in the basis.

Case 3
First, I will remove from the basis. I choose to enter the basis.
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Apply step 4

w rhs
1 -1 0 0 0 0 0 0 -1 0 0
0 -1 1 0 -2 0 -1 0 0 0 0
0 -1 0 0 0 0 1 1 0 0 0
0 1 0 1 1 -1 0 0 1 0 3
0 1 0 0 5 2 2 0 -1 1 1

Table 3
This table is optimal. Note that but is in the basis.

Case 3
Now, I will remove from the basis. The only original variable having a nonzero coefficient
in the row corresponding is . That is why I choose .
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Apply step 4

w rhs
1 0 0 0 0 0 -1 -1 -1 0 0
0 0 1 0 -2 0 -2 -1 0 0 0
0 1 0 0 0 0 -1 -1 0 0 0
0 0 0 1 1 -1 1 1 1 0 3
0 0 0 0 5 2 3 1 -1 1 1

Table 4
This table is optimal. Note that and all artificial variables are out of the basis.

Case 2
Get back to the original row 0, Phase-2 LP.
THE TWO-PHASE SIMPLEX METHOD

• Example 3: Phase-2 LP – Table 1

z rhs
1 -40 -10 0 -7 -14 0 0
0 0 1 0 -2 0 0 0
0 1 0 0 0 0 0 0
0 0 0 1 1 -1 0 3
0 0 0 0 5 2 1 1

I will obtain the canonical form!


THE TWO-PHASE SIMPLEX METHOD
• Example 3: Phase-2 LP – Table 2

z rhs
1 0 0 0 -27 -14 0 0
0 0 1 0 -2 0 0 0
0 1 0 0 0 0 0 0
0 0 0 1 1 -1 0 3
0 0 0 0 5 2 1 1
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Phase-2 LP – Table 3
z rhs
1 0 0 0 0 -16/5 27/5 27/5
0 0 1 0 0 4/5 2/5 2/5
0 1 0 0 0 0 0 0
0 0 0 1 0 -7/5 -1/5 14/5
0 0 0 0 1 2/5 1/5 1/5
THE TWO-PHASE SIMPLEX METHOD
• Example 3: Phase-2 LP – Table 4

z rhs
1 0 4 0 0 0 7 7
0 0 5/4 0 0 1 1/2 1/2
0 1 0 0 0 0 0 0
0 0 7/4 1 0 0 1/2 7/2
0 0 -1/2 0 1 0 0 0

This table is optimal. So the optimal solution is

You might also like