You are on page 1of 25

The simplex algorithm

 Putting Linear Programs into standard form


 Introduction to Simplex Algorithm
Overview of Lecture
 Getting an LP into standard form
 Transforming inequality to equality
 Preview of Simplex Algorithm
 A solution of L.P.P by Simplex Method
 Simplex Tables
Overview of Lecture
 Getting an LP into standard form
Linear Programs in Standard Form
We say that a linear program is in standard form if the
1. Non-negativity constraints for all variables are present.
2. All remaining constraints are expressed as equality
constraints.
3. The right hand side vector, b, is non-negative.

An LP not in Standard Form


Maximize, Z = 3x1 + 2x2 - x3 + x4
w.r.t x1 + 2x2 + x3 - x4 ≤ 5; not equality
-2x1 - 4x2 + x3 + x4 ≤ -1; not equality
x3 may be negative
x1 ≥ 0, x2 ≥ 0
Converting Inequalities into Equalities
Plus Non-negatives

Before After
x1 + 2x2 + x3 - x4 ≤ 5 x1 + 2x2 + x3 - x4 +s1 = 5
s1 ≥ 0

s1 is called a slack variable, which measures the


amount of “unused resource.”
Note that s1 = 5 - x1 - 2x2 - x3 + x4.

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.

maximize, W = 3x1 + 4x2 + 5 x3


subject to 2x1 - 5x2 + 2x3 = 7
other constraints
x1 ≤ 0, x2 is unconstrained in sign, x3 ≥ 0
Transforming x1: replace x1 by y1 = -x1; y1 ≥ 0.

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.

Transforming x2: replace x2 by x2 = y3 - y2; y2 ≥ 0, y3 ≥


0.
max -3 y1 + 4(y3 - y2) +5 x3
-2 y1 -5 y3 +5 y2 +2 x3 =7
all vars ≥ 0
One can recover x2 from y2, y3.

e.g., y1 = 1, y2 = 0, y3 = 1 x3 = 2 is feasible.
Another Example

 Exercise:transform the following to


standard form (maximization):

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

In our problem see the


Vj row of the initial simplex table and find that
increasing x2 causes the greatest rate of increase
in z. If x2 increases from its current value of
zero, it will have to become a basic variable.
See the initial simplex table
For this reason, x2 is called the entering variable
or pivot column. Observe x2 has the most
positive coefficient in objective function.
Initial Simplex Table (Table 1)

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

In Improved Simplex Table, Entering Variable :X2


Solution continued
 Next choose which current basic variable to be the
nonbasic variable.
 For this purpose we have to construct a new column
named Non negative minimum ratio column with
the values that determined by following formula.
 For each row i,

value on the column = bi / a ij


Where bi =solution column value (i =1,2,3,….)
j =entering column value.
 Most minimum value (positive) on the last column of
simplex table denotes the outgoing variable or
pivot row.
Initial Simplex Table (Table 1)
Now calculate Non Negative min. ratio column

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

Therefore Pivot element = 5 Entering Variable


In next Improved Simplex Table, Incoming Variable :X2
Outgoing Variable from Basis :S1
Solution continued
 Always make the entering variable a basic variable
in a row that has most minimum value (positive) on
the last column of simplex table
 To make x2 a basic variable in row 1, we use
elementary row operations (EROs) to make x2 have
a coefficient of 1 in row 1 and a coefficient of 0 in all
other rows in the column headed by x2.
– This procedure is called pivoting on row 1; and
row 1 is called the pivot row.
– The final result is that x2 replaces s1 as the basic
variable for row 1.
Improved Simplex Table (Table 2)
Non
Cj 5 10 8 0 0 0
Negative

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

0 s2 24 8/5 0 12/5 -4/5 1 0

0 s3 52 -2/5 0 17/5 -4/5 0 1

Zj 120 6 10 4 2 0 0

Vj = Cj - Zj -1 0 4 -2 0 0

In next slide we will find entering variable and outgoing variable.


Improved Simplex Table (Table 2)
Calculate Non Negative min. ratio
Non
Cj 5 10 8 0 0 0
Negative

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

10 x2 8 1/3 1 0 1/3 -1/6 0

8 x3 10 2/3 0 1 -1/3 5/12 0

0 s3 18 -8/3 0 0 1/3 -17/12 1

Zj 160 26/3 10 8 2/3 5/3 0

Vj = Cj - Zj -11/3 0 0 -2/3 -5/3 0

In the above Simplex Table we found all the elements in Vj row


are either zero or negative. Therefore the above table is optimum.
Optimum solution is x1= 0, x2 =8, x3=10
and Maximum value of Z= 160.

You might also like