The Simplex Algorithm: Putting Linear Programs Into Standard Form Introduction To Simplex Algorithm
The Simplex Algorithm: Putting Linear Programs Into Standard Form Introduction To Simplex Algorithm
Before After
x1 + 2x2 + x3 - x4 ≤ 5 x1 + 2x2 + x3 - x4 +s1 = 5
s1 ≥ 0
To convert a “≤ ” constraint to an
equality, add a slack variable.
Converting “≥ ” constraints
Consider the inequality -2x1 - 4x2 + x3 + x4 ≤ -1;
Step 1. Eliminate the negative RHS
2x1 + 4x2 - x3 - x4 ≥ 1
Step 2. Convert to an equality
2x1 + 4x2 - x3 - x4 – s2 = 1
s2 ≥ 0
The variable added will be called a “surplus variable.”
To covert a “≥ ” constraint to an
equality, subtract a surplus variable.
More Transformations
How can one convert a maximization problem to a
minimization problem?
Example: Maximize, Z = 3W + 2P
Subject to “constraints”
Has the same optimum solution(s) as
Minimize, T = -3W -2P
Subject to “constraints”
The Last Transformations (for now)
Transforming variables that may take on negative values.
max Z = -3 y1 + 4x2 +5 x3
-2 y1 -5 x2 +2 x3 =7
y1 ≥ 0, x2 is unconstrained in sign, x3 ≥
One can recover 0x1 from y1.
Transforming variables that may take on
negative values.
max, Z = -3 y1 + 4x2 +5 x3
-2 y1 -5 x2 +2 x3 =7
y1 ≥ 0, x2 is unconstrained in sign, x3 ≥
e.g., y1 =0 1, x2 = -1, x3 = 2 is feasible.
e.g., y1 = 1, y2 = 0, y3 = 1 x3 = 2 is feasible.
Another Example
Minimize x1 + 3x2
Subject to 2x1 + 5x2 ≤ 12
x1 + x2 ≥ 1
x1 ≥ 0
Preview of the Simplex Algorithm
Consider a system Ax = b of m linear
equations in n variables (where n ≥ m).
A basic solution to Ax = b is obtained by
setting n – m variables equal to 0 and solving
for the remaining m variables.
– This assumes that setting the n – m variables
equal to 0 yields a unique value for the remaining
m variables, or equivalently, the columns for the
remaining m variables are linearly independent.
Any basic solution in which all variables are
nonnegative is called a basic feasible
solution (or bfs).
The Simplex Algorithm
The simplex algorithm can be used to solve LPs in which the goal is to
maximize the objective function.
Step 1 Convert the LP to standard form
Step 2 Obtain an initial bfs (if possible) from the standard form.
Step 3 Determine whether the current bfs is optimal.
Step 4 If the current bfs is not optimal, determine which
nonbasic variable should become a basic variable and which
basic variable should become a nonbasic variable to find a
bfs with a better objective function value.
Step 5 Use Elementary Row Operations (i.e Gauss-Jordan
Elimination Rule) to find a new bfs with a better objective
function value. Go back to Step 3.
Solve the following problem with Simplex Algorithm
Consider a firm produces three products A, B and C, each of
which passes through three departments: Fabrication, Finishing
and Packaging. Each unit of product A requires 3, 4 and 2; a unit
of product requires B requires 5, 4 and 4, while each unit of
product C requires 2, 4 and 5 hours respectively in three
departments. Everyday, 60 hours are available in the fabrication
department, 72 hours in the finishing department and 100 hours
in the packaging department.
The unit contribution of product A is Rs. 5, of product B is Rs. 10
and of product C is Rs. 8.
(i) Determine the optimal product mix and the capacity (if any)
would remain unutilised.
(ii) What would be the effect on the solution of each of the following:
(a) obtaining an order for 6 units of product A, which has to be
met.
(b) an increasing of 20 percent capacity in the fabrication
department.
Simplex Algorithm for an L.P.P
maximize z = 5x1 + 10x2 + 8x3
subject to 3x1 + 5x2 + 2x3 ≤ 60
4x1 + 4x2 + 4x3 ≤ 72
4x1 + 4x2 + 4x3 ≤ 100
x1, x2, x2 ≥ 0
Introducing slack variables, the problem can be written as
standard form
maximize z =of L.P.P
5x + 10x + 8x + 0.s + 0.s +0.s
1 2 3 1 2 3
subject to 3x1 + 5x2 + 2x3 + s1 = 60
4x1 + 4x2 + 4x3 + s2 = 72
4x1 + 4x2 + 4x3 + s3 = 100
x1, x2, x2, s1 , s2 , s3 ≥ 0
Solution
To perform the simplex algorithm, we need a initial
basic (although not necessarily nonnegative)
variables and solution.
– For this initial basic solution,
Let, x1=x2=x3=0.
Therefore, s1=60, s2= 72, s3= 100 (feasible)
And z=0.
– With this convention, the basic feasible solution
for our initial standard form has
• BV = {s1, s2, s3}
• NBV = {x1, x2, x3}.
A slack variable can be used as a basic variable if
the right hand side of the constraint is nonnegative.
j Initial Simplex Table (Table 1)
Cj 5 10 8 0 0 0
Soln.
CB Basis x1 x2 x3 s1 s2 s3
i ( b)
i
0 s1 60 3 5 2 1 0 0
0 s2 72 4 4 4 0 1 0
0 s3 100 2 4 5 0 0 1
Zj = ∑c Bi .aij
Vj = C - Z
i
j j
The values of Zj represent the amount by which the profit/contribution would be reduced if
one unit of any of the variables (represented by column head) were added to the product mix.
Each of the values in the
V
row signifies the amount of increase in objective function value
that would occur if one unit of jany of the variables (represented by column head) were
introduced in the solution.
Solution continued
Once we have obtained a initial basic feasible
solution, we need to determine whether it is optimal.
V
To do this, we try to determine Zj = ∑cB .aij and j = Cj - Zj
V
i
i
If all the elements of j row are either negative or
zero then the solution is optimal for Maximization
V
L.P.P where
j = Cj - Zj . (Optimality condition)
Otherwise, if there is any way z 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 then solution
is not optimal.
If the solution is not optimal, the we can improve our
solution which gives us larger value of z.
Solution continued
Cj 5 10 8 0 0 0
Soln.
CB Basis x1 x2 x3 s1 s2 s3
( b)
i
0 s1 60 3 5 2 1 0 0
0 s2 72 4 4 4 0 1 0
0 s3 100 2 4 5 0 0 1
Zj = ∑c
i
Bi .aij 0 0 0 0 0 0 0
Vj = Cj - Zj 5 10 8 0 0 0
Entering Variable
Outgoing variable
Non
Cj 5 10 8 0 0 0
Negative
Soln. min. ratio
CB Basis x1 x3 s1 s2 s3
( b)
i
x2 bi / a ij
0 s1 60 3 5 2 1 0 0 60/5 = 12
0 s2 72 4 4 4 0 1 0 72/4 = 18
0 s3 100 2 4 5 0 0 1 100/4 = 25
Zj = ∑c
i
Bi .aij 0 0 0 0 0 0 0
Vj = Cj - Zj 5 10 8 0 0 0
Pivot Row
Soln. min. ratio
CB Basis x1 x2 x3 s1 s2 s3
( b)
i
bi / a ij
x2
10 12 3/5 1 2/5 1/5 0 0
Zj 120 6 10 4 2 0 0
Vj = Cj - Zj -1 0 4 -2 0 0
Outgoing variable
Soln. min. ratio
CB Basis x1 x2 x3 s1 s2 s3
( b)
i
bi / a ij
x2 12 ÷ 2/5
10 12 3/5 1 2/5 1/5 0 0
= 30
s2 24 ÷ 12/5
0 24 8/5 0 12/5 -4/5 1 0
= 10
52 ÷ 17/5
0 s3 52 -2/5 0 17/5 -4/5 0 1 = 260/17
Zj 120 6 10 4 2 0 0
Vj = Cj - Zj -1 0 4 -2 0 0
Find Max (
j V
) and entering Entering Variable
j variable Incoming Var. : X3
Therefore in next Improved Simplex Table
Outgoing Var. : S2
Optimum Simplex Table
Cj 5 10 8 0 0 0
Soln.
CB Basis ( b)
x1 x2 x3 s1 s2 s3
i