Simplex Method - 4th Semester - Numerical Programming
Simplex Method - 4th Semester - Numerical Programming
com
Simplex Method
In the previous chapter, we discussed about the graphical method for solving linear programming
problems. Although the graphical method is an invaluable aid to understand the properties of
linear programming models, it provides very little help in handling practical problems. In this
chapter, we concentrate on the simplex method for solving linear programming problems with a
larger number of variables.
Many different methods have been proposed to solve linear programming problems, but simplex
method has proved to be the most effective. This technique will nurture your insight needed for a
sound understanding of several approaches to other programming models, which will be studied
in subsequent chapters. This method is applicable to any problem that can be formulated in terms
of linear objective function, subject to a set of linear constraints. Often, this method is termed
Dantzig's simplex method, in honour of the mathematician who devised the approach.
In the following section, we introduce you to the standard vocabulary of the simplex method.
Basic Terminology
Slack variable
It is a variable that is added to the left-hand side of a less than or equal to type constraint to
convert the constraint into an equality. In economic terms, slack variables represent left-over or
unused capacity.
Specifically:
ai1x1 + ai2x2 + ai3x3 + .........+ ainxn ≤ bi can be written as
ai1x1 + ai2x2 + ai3x3 + .........+ ainxn + si = bi
Where i = 1, 2, ..., m
Surplus variable
It is a variable subtracted from the left-hand side of a greater than or equal to type constraint to
convert the constraint into an equality. It is also known as negative slack variable. In economic
terms, surplus variables represent overfulfillment of the requirement.
Specifically:
ai1x1 + ai2x2 + ai3x3 + .........+ ainxn ≥ bi can be written as
ai1x1 + ai2x2 + ai3x3 + .........+ ainxn - si = bi
Where i = 1, 2, ..., m
1
mywbut.com
Artificial variable
It is a non negative variable introduced to facilitate the computation of an initial basic feasible
solution. In other words, a variable added to the left-hand side of a greater than or equal to type
constraint to convert the constraint into an equality is called an artificial variable.
subject to
Where:
cj (j = 1, 2, ...., n) in the objective function are called the cost or profit coefficients.
bi (i = 1, 2, ...., m) are called resources.
aij (i = 1, 2, ...., m; j = 1, 2, ...., n) are called technological coefficients or input-output
coefficients.
The initial simplex table is formed by writing out the coefficients and constraints of a LPP in a
systematic tabular form. The following table shows the structure of a simplex table.
2
mywbut.com
Where:
cj = coefficients of the variables (m + n) in the objective function.
cB = coefficients of the current basic variables in the objective function.
B = basic variables in the basis.
XB = solution values of the basic variables.
zj-cj = index row.
Unquestionably, the simplex technique has proved to be the most effective in solving linear
programming problems. In the simplex method, we first find an initial basic solution (extreme
point). Then, we proceed to an adjacent extreme point. We continue this process until we reach
an optimal solution.
3
mywbut.com
• Convert every inequality constraint in the L.P. problem into an equality constraint by adding a
slack variable to each constraint.
• Calculate the initial basic feasible solution by assigning zero value to the decision variables. This
solution is shown in the initial simplex table.
• Divide the values under XB column by the corresponding positive coefficient (aij) in the key
column, and compare the ratios. The row that indicates the minimum ratio is called the key row.
However, division by zero or negative coefficients in the key column is not allowed. In the case
of a tie, break the tie arbitrarily.
• The number that lies at the intersection of the key column and key row of a given table is called
the key element. It is always a non-zero positive number.
• The numbers in the replacing row may be obtained by dividing the key row elements by the
pivot element. The numbers in the remaining rows may be calculated by using the following
formula:
• Go to step 3 and repeat the procedure until all the values of zj – cj are either zero or positive.
4
mywbut.com
For the time being we assume that a feasible solution exists and the optimal value of the
objective function is finite. Later in the chapter, we will remove these restrictive
assumptions and consider several special cases like unbounded solution, multiple
optimum solution, no feasible solution, and degeneracy.
Example 1
subject to
-x1 + 2x2 ≤ 4
3x1 + 2x2 ≤ 14
x1 – x2 ≤ 3
x1, x2 ≥ 0
Solution.
First, convert every inequality constraints in the LPP into an equality constraint, so that the
problem can be written in a standard from. This can be accomplished by adding a slack variable
to each constraint. Slack variables are always added to the less than type constraints.
-x1 + 2x2 + x3 = 4
3x1 + 2x2 + x4 = 14
x1 – x2 + x5 = 3
x1, x2, x3, x4, x5 ≥ 0
Since slack variables represent unused resources, their contribution in the objective function is
zero. Including these slack variables in the objective function, we get
5
mywbut.com
Now we assume that nothing can be produced. Therefore, the values of the decision variables are
zero.
x1 = 0, x2 = 0, z = 0
When we are not producing anything, obviously we are left with unused capacity
x3 = 4, x4 = 14, x5 = 3
We note that the current solution has three variables (slack variables x3, x4 and x5) with non-zero
solution values and two variables (decision variables x1 and x2) with zero values. Variables with
non-zero values are called basic variables. Variables with zero values are called non-basic
variables.
Table 1
Working
z1 – c1 = (0 X (-1) + 0 X 3 + 0 X 1) - 3 = -3
z2 – c2 = (0 X 2 + 0 X 2 + 0 X (-1)) - 2 = -2
z3 – c3 = (0 X 1 + 0 X 0 + 0 X 0) - 0 = 0
z4 – c4 = (0 X 0 + 0 X 1 + 0 X 0) - 0 = 0
z5 – c5 = (0 X 0 + 0 X 0 + 0 X 1) – 0 = 0
Choose the smallest negative value from zj – cj (i.e., – 3). So column under x1 is the key
column.
Now find out the minimum positive value
Minimum (14/3, 3/1) = 3
So row x5 is the key row.
6
mywbut.com
Here, the pivot (key) element = 1 (the value at the point of intersection).
Therefore, x5 departs and x1 enters.
We obtain the elements of the next table using the following rules:
1. If the values of zj – cj are positive, the inclusion of any basic variable will not increase the value of
the objective function. Hence, the present solution maximizes the objective function. If there
are more than one negative values, we choose the variable as a basic variable corresponding to
which the value of zj – cj is least (most negative) as this will maximize the profit.
2. The numbers in the replacing row may be obtained by dividing the key row elements by the
pivot element and the numbers in the other two rows may be calculated by using the formula:
x3 row
a11 = -1 – 1 X ((-1)/1) = 0
a12 = 2 – (-1) X ((-1)/1) = 1
a13 = 1 – 0 X ((-1)/1) = 1
a14 = 0 – 0 X ((-1)/1) = 0
a15 = 0 – 1 X ((-1)/1) = 1
b1 = 4 – 3 X ((-1)/1) = 7
x4 row
a21 = 3 – 1 X (3/1) = 0
a22 = 2 – (-1) X (3/1) = 5
a23 = 0 – 0 X (3/1) = 0
a24 = 1 – 0 X (3/1) = 1
a25 = 0 – 1 X (3/1) = -3
b2 = 14 – 3 X (3/1) = 5
x1 row
a31 = 1/1 = 1
a32 = -1/1 = -1
a33 = 0/1 = 0
a34 = 0/1 = 0
7
mywbut.com
a35 = 1/1 = 1
b3 = 3/1 = 3
Table 2
Working
z1 – c1 = (0 X 0 + 0 X 0 + 3 X 1) - 3 = 0
z2 – c2 = (0 X 1 + 0 X 5 + 3 X (-1)) – 2 = -5
z3 – c3 = (0 X 1 + 0 X 0 + 3 X 0) - 0 = 0
z4 – c4 = (0 X 0 + 0 X 1 + 3 X 0) - 0 = 0
z5 – c5 = (0 X 1 + 0 X (-3) + 3 X 1) – 0 = 3
x3 row
a11 = 0 – 0 X (1/5) = 0
a12 = 1 – 5 X (1/5) = 0
a13 = 1 – 0 X (1/5) = 1
a14 = 0 – 1 X (1/5) = -1/5
a15 = 1 – (-3) X (1/5) = 8/5
b1 = 7 – 5 X (1/5) = 6
8
mywbut.com
x2 row
a21 = 0/5 = 0
a22 = 5/5 = 1
a23 = 0/5 = 0
a24 = 1/5
a25 = -3/5
b2 = 5/5 = 1
x1 row
a31 = 1 – 0 X (-1/5) = 1
a32 = -1 – 5 X (-1/5) = 0
a33 = 0 – 0 X (-1/5) = 0
a34 = 0 – 1 X (-1/5) = 1/5
a35 = 1 – (-3) X (-1/5) = 2/5
b3 = 3 – 5 X (-1/5) = 4
Final Table
Since all the values of zj – cj are positive, this is the optimal solution.
x1 = 4, x2 = 1
z = 3 X 4 + 2 X 1 = 14.
The largest profit of Rs.14 is obtained, when 1 unit of x2 and 4 units of x1 are produced. The
above solution also indicates that 6 units are still unutilized, as shown by the slack variable x3 in
the XB column.
9
mywbut.com
electronic computer
Example 2
Luminous Lamps produces three types of lamps - A, B, and C. These lamps are processed on
three machines - X, Y, and Z. The full technology and input restrictions are given in the
following table.
Machine
Product Profit per unit
X Y Z
A 10 7 2 12
B 2 3 4 3
C 1 2 1 1
Solution.
subject to
x1, x2, x3 ≥ 0
10
mywbut.com
2x1+ 4x2 + x3 + x6 = 80
x1, x2, x3, x4, x5, x6 ≥ 0
x1 = 0, x2 = 0, x3 = 0, z = 0
x4 = 100, x5 = 77, x6 = 80
Table 1
cj 12 3 1 0 0 0
0 x4 10 2 1 1 0 0 100
0 x5 7 3 2 0 1 0 77
0 x6 2 4 1 0 0 1 80
zj-cj -12 -3 -1 0 0 0
Now we are assuming that you can easily calculate the values yourself.
11
mywbut.com
Table 2
cj 12 3 1 0 0 0
Final Table
cj 12 3 1 0 0 0
Minimization Case
In the previous section, the simplex method was applied to linear programming problems where
the objective was to maximize the profit with less than or equal to type constraints. In many
cases, however, constraints may of type ≥ or = and the objective may be minimization (e.g., cost,
time, etc.). Thus, in such cases, simplex method must be modified to obtain an optimal policy.
12
mywbut.com
subject to
Any linear minimization problem can be viewed as an equivalent linear maximization problem,
and vice versa.
It can be written as
Max. z = -(c1x1 + c2x2 + c3x3 + .........+ cnxn)
which is not feasible because it violates the non-negativity stipulation, (i.e., s1 ≥ 0). Therefore,
we need artificial variables.
13
mywbut.com
Now, an initial basic feasible solution can be obtained by setting all the decision and surplus
variables to zero. Thus, an initial basic feasible solution to LPP is
A1 = b1 , A2 = b2, ....., Am = bm
Now to obtain an optimal solution, we must drive out the artificial variables. Following are the
two methods to solve linear programming problems in such cases.
In this method, the whole procedure of solving a linear programming problem involving artificial
variables is divided into two phases. In phase I, we form a new objective function by assigning
zero to every original variable (including slack and surplus variables) and -1 to each of the
artificial variables. Then we try to eliminate the artificial varibles from the basis. The solution at
the end of phase I serves as a basic feasible solution for phase II. In phase II, the original
objective function is introduced and the usual simplex algorithm is used to find an optimal
solution.
Example 1
subject to
14
mywbut.com
x1 + 3x2 + x3 ≤ 5
2x1 – x2 + x3 ≥ 2
4x1 + 3x2 - 2x3 = 5
x1, x2, x3 ≥ 0
Solution.
Any linear minimization problem can be viewed as an equivalent linear maximization problem,
and vice versa. Specifically:
subject to
x1 + 3x2 + x3 ≤ 5
2x1 – x2 + x3 ≥ 2
4x1 + 3x2 - 2x3 = 5
x1, x2, x3 ≥ 0
x1 + 3x2 + x3 + x4 = 5
2x1 – x2 + x3 – x5 = 2
4x1 + 3x2 - 2x3 = 5
Where:
x4 is a slack variable
x5 is a surplus variable
15
mywbut.com
Now, if we let x1, x2 and x3 equal to zero in the initial solution, we will have x4 = 5 and x5 = -2,
which is not possible because a surplus variable cannot be negative. Therefore, we need
artificial variables.
x1 + 3x2 + x3 + x4 = 5
2x1 – x2 + x3 – x5 + A1 = 2
4x1 + 3x2 - 2x3 + A2 = 5
Phase 1
In this phase, we remove the artificial variables and find an initial feasible solution of the
original problem. Now the objective function can be expressed as
subject to
x1 + 3x2 + x3 + x4 = 5
2x1 – x2 + x3 – x5 + A1 = 2
4x1 + 3x2 - 2x3 + A2 = 5
Table 1
cj 0 0 0 0 0 -1 -1
0 x4 1 3 1 1 0 0 0 5
16
mywbut.com
-1 A1 2 -1 1 0 -1 1 0 2
-1 A2 4 3 -2 0 0 0 1 5
zj–cj -6 -2 1 0 1 0 0
Table 2
cj 0 0 0 0 0 -1
-1 A2 0 5 -4 0 2 1 1
zj-cj 0 -5 4 0 -2 0
Phase 2
The basic feasible solution at the end of Phase 1 computation is used as the initial basic feasible
solution of the problem. The original objective function is introduced in Phase 2 computation
and the usual simplex procedure is used to solve the problem.
Table 3
cj 3 -1 2 0 0
17
mywbut.com
Table 4
cj 3 -1 2 0 0
0 x5 0 5/2 -2 0 1 1/2
Table 5
cj 3 -1 2 0 0
18
mywbut.com
An optimal policy is x1 = 5/2, x2 = 0, x3 = 5/2. The associated optimal value of the objective
function is z = 3 X (5/2) – 0 + 2 X (5/2) = 25/2.
Example 2
subject to
x1, x2, x3 ≥ 0
Solution.
Where:
x4 is a slack variable.
x5 is a surplus variable.
A1& A2 are artificial variables.
Phase 1
subject to
19
mywbut.com
Table 1
cj 0 0 0 0 0 -1 -1
0 x4 8 16 12 1 0 0 0 250
-1 A1 4 8 10 0 -1 1 0 80
-1 A2 7 9 8 0 0 0 1 105
Table 2
cj 0 0 0 0 0 -1
Here, Phase 1 terminates because both the artificial variables have been removed from the
basis.
Phase 2
Table 3
cj 12 15 9 0 0
20
mywbut.com
Table 4
cj 12 15 9 0 0
0 x4 0 0 -8 1 2 90
15 x2 0 1 19/10 0 -7/20 7
12 x1 1 0 -13/10 0 9/20 6
21
mywbut.com
It is a modified version of the simplex method, in which we assign a very large value (M) to each
of the artificial variables. We illustrate this method with the help of following examples.
Example 1
Maximize z = x1 + 5x2
subject to
3x1 + 4x2 ≤ 6
x1 + 3x2 ≥ 2
x1, x2 ≥ 0
Solution.
By introducing surplus variables, slack variables and artificial variables, the standard form of
LPP becomes
subject to
3x1 + 4x2 + x3 = 6
x1 + 3x2 – x4 + A1 = 2
x1 ≥ 0, x2 ≥ 0, x3 ≥ 0, x4 ≥ 0, A1 ≥ 0
Where:
x3 is a slack variable
x4 is a surplus variable.
A1 is an artificial variable.
22
mywbut.com
x1 = x2 = x4 = 0
A1 = 2, x3 = 6
Table 1
cj 1 5 0 0 –M
0 x3 3 4 1 0 0 6
–M A1 1 3 0 –1 1 2
Working
z1 – c1 = 0 X 3 + (–M) X 1 – 1 = –M – 1
z2 – c2 = 0 X 4 + (–M) X 3 – 5 = –3M – 5
z3 – c3 = 0 X 1 + (–M) X 0 – 0 = 0
z4 – c4 = 0 X 0 + (–M) X (–1) – 0 = M
z5 – c5 = 0 X 0 + (–M) X 1 – (–M) = 0
As M is a large positive number, the coefficient of M in the zj–cj row would decide the
incoming basic variable.
As -3M < -M, x2 becomes a basic variable in the next iteration.
Key column = x2 column.
Minimum (6/4, 2/3) = 2/3
Key row = A1 row
Pivot element = 3.
A1 departs and x2 enters.
Note that in the iteration just completed, artificial variable A1 was eliminated from the
basis. The new solution is shown in the following table.
23
mywbut.com
Table 2
cj 1 5 0 0
Table 3
cj 1 5 0 0
x1 = 0, x2 = 3/2
z = 0 + 5 X 3/2 =15/2
Example 2
subject to
3x1 + x2 ≥ 27
x1 + x2 ≥ 21
x1 + 2x2 ≥ 30
x1, x2 ≥ 0
24
mywbut.com
Solution.
By introducing surplus and artificial variables, the standard form of LPP becomes
3x1 + x2 - x3 + A1 = 27
x1 + x2 - x4 + A2 = 21
x1 + 2x2 - x5 + A3 = 30
Where:
x4 and x5 are surplus variables
A1 and A2 are artificial variables.
Table 1
cj -4 -2 0 0 0 –M –M –M
–M A1 3 1 -1 0 0 1 0 0 27
-M A2 1 1 0 -1 0 0 1 0 21
–M A3 1 2 0 0 -1 0 0 1 30
Table 2
cj -4 -2 0 0 0 –M –M
–4 x1 1 1/3 -1/3 0 0 0 0 9
25
mywbut.com
-M A2 0 2/3 1/3 -1 0 1 0 12
–M A3 0 5/3 1/3 0 -1 0 1 21
Table 3
cj -4 -2 0 0 0 –M
Table 4
cj -4 -2 0 0 0
–4 x1 1 0 -1/2 1/2 0 3
0 x5 0 0 1/2 -5/2 1 9
-2 x2 0 1 1/2 -3/2 0 18
zj–cj 0 0 1 1 0
x1 = 3, x2 = 18
z = -4 X 3 - 2 X 18 = -48
26
mywbut.com
• Unrestricted Variables
• Unbounded Solution
• No Feasible Solution
• Multiple Optimum Solutions
• Degeneracy
Sometimes decision variables are unrestricted in sign (positive, negative or zero). In all such
cases, the decision variables can be expressed as the difference between two non-negative
variables. For example, if x1 is unrestricted in sign, then
Example
subject to
-x1 + 2x2 ≤ 4
x1 + x2 ≤ 6
x1 + 3x2 ≤ 9
Solution.
Since x1 and x2 are unrestricted in sign, we can replace them by non-negative variables x1' , x1'',
x2' , x2'' .
27
mywbut.com
subject to
subject to
Table 1
cj 2 -2 3 -3 0 0 0
0 x3 -1 1 2 -2 1 0 0 4
0 x4 1 -1 1 -1 0 1 0 6
0 x5 1 -1 3 -3 0 0 1 9
zj-cj -2 2 -3 3 0 0 0
Table 2
cj 2 -2 3 -3 0 0 0
28
mywbut.com
Table 3
cj 2 -2 3 -3 0 0 0
Table 4
cj 2 -2 3 -3 0 0 0
29
mywbut.com
2. Unbounded Solution
If in course of simplex computation zj - cj < 0, but minimum positive value is ≤ 0 then the
problem has an unbounded solution.
Example
subject to
x1 ≤ 7
x1 - x2 ≤ 8
x1, x2 ≥ 0.
Solution.
x1 + x3 = 7
x1 - x2 + x4 = 8
x1, x2, x3, x4 ≥ 0.
Table 1
cj 5 4 0 0
0 x3 1 0 1 0 7
0 x4 1 -1 0 1 8
zj-cj -5 -4 0 0
30
mywbut.com
Table 2
cj 5 4 0 0
5 x1 1 0 1 0 7
0 x4 0 -1 -1 1 1
zj-cj 0 -4 5 0
Since minimum positive value is infinity, it is not possible to proceed with the simplex
computation any further. This is the criterion for unbounded solution.
3. No Feasible Solution
If in course of simplex computation, one or more artificial variables remain in the basis at positive level
at the end of phase 1 computation, the problem has no feasible solution. For example, let us consider
the following problem.
Example
subject to
x1, x2 ≥ 0
Solution.
After introducing slack, surplus and artificial variables the problem can be presented as
subject to
31
mywbut.com
Where:
A1 and A2 are artificial variables.
x4 is a slack variable.
x3 and x5 are surplus variables.
Phase 1
Maximise – A1 – A2
subject to
Table 1
cj 0 0 0 0 0 -1 -1
-1 A1 2 3 -1 0 0 1 0 1200
0 x4 1 1 0 1 0 0 0 400
-1 A2 2 3/2 0 0 -1 0 1 900
zj-cj -4 -9/2 1 0 1 0 0
Table 2
cj 0 0 0 0 0 -1
0 x4 1/3 0 1/3 1 0 0 0
-1 A2 1 0 1/2 0 -1 1 300
32
mywbut.com
zj-cj -1 0 -1/2 0 1 0
Table 3
cj 0 0 0 0 0 -1
0 x2 0 1 -1 -2 0 0 400
0 x1 1 0 1 3 0 0 0
-1 A2 0 0 -1/2 -3 -1 1 300
zj-cj 0 0 1/2 3 1 0
In the above table, the optimum solution still contains the artificial variable A2 in the basis at
positive level, this indicates that the problem has no feasible solution.
The optimal solution may not be unique, if the non basic variables have a zero coefficient in the
index row (zj-cj). This implies that bringing the non basic variable into the basis will neither
increase nor decrease the value of the objective function. Thus, the problem has multiple
optimal solutions (Alternative optimal solutions).
Example
subject to
x1, x2 ≥ 0
Solution.
33
mywbut.com
Table 1
cj 2000 3000 0 0
0 x3 6 9 1 0 100
0 x4 2 1 0 1 20
Table 2
cj 2000 3000 0 0
zj-cj 0 0 3000/9 0
Since zj-cj ≥ 0 for all variables, x1 = 0, x2 = 100/9 is an optimum solution of the problem. The
maximum value of the objective function is 100000/3. However, the zj-cj value corresponding to
the non basic variable x1 is zero. This indicates that there is more than one optimal solution of the
problem. Thus, by entering x1 into the basis we may obtain another alternative optimal solution.
cj 2000 3000 0 0
34
mywbut.com
zj-cj 0 0 1000/3 0
However, the value of the objective function will not be improved, although the present solution
x1 = 0, x2 = 100/9 is shifted to x1 = 20/3 and x2 = 20/3.
5. Degeneracy
In some cases, there may be ambiguity in selecting the variable that should be introduced into the
basis, i.e., there is a tie between the replacement ratio of two variables. To resolve degeneracy,
we select one of them arbitrarily.
Example
subject to
x1 + 4x2 ≤ 8
x1 + 2x2 ≤ 4
x1, x2 ≥ 0
Solution.
x1 + 4x2 + x3 = 8
x1 + 2x2 + x4 = 4
x1, x2, x3, x4 ≥ 0
Table 1
cj 3 9 0 0
0 x3 1 4 1 0 8
35
mywbut.com
0 x4 1 2 0 1 4
zj-cj -3 -9 0 0
There is a tie between the two values. So you are at liberty to break the tie arbitrarily.
Case I
Table 2
cj 3 9 0 0
0 x3 -1 0 1 -2 0
9 x2 1/2 1 0 1/2 2
x1 = 0, x2 = 2, z = 18
Case II
Table 2
cj 3 9 0 0
9 x2 1/4 1 1/4 0 2
0 x4 1/2 0 -1/2 1 0
36
mywbut.com
Table 3
cj 3 9 0 0
9 x2 0 1 1/2 -1/2 2
3 x1 1 0 -1 2 0
x1 = 0, x2 = 2, z = 18
37