Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

4 LP - Simplex Algorithm

The simplex algorithm is an efficient method for solving linear programming problems. It works by: 1. Finding an initial feasible solution and calculating the objective function value (z). 2. Selecting the variable whose increase would most improve z, and determining which variable must decrease to allow the increase. 3. Calculating the new solution and repeating until no further improvements to z can be made, indicating an optimal solution. The algorithm proceeds through iterations, maintaining a "basis" of basic variables that define the current solution. In each iteration, a non-basic variable enters the basis replacing a basic variable, generating a new feasible solution. The process ends when the objective can no longer be improved.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

4 LP - Simplex Algorithm

The simplex algorithm is an efficient method for solving linear programming problems. It works by: 1. Finding an initial feasible solution and calculating the objective function value (z). 2. Selecting the variable whose increase would most improve z, and determining which variable must decrease to allow the increase. 3. Calculating the new solution and repeating until no further improvements to z can be made, indicating an optimal solution. The algorithm proceeds through iterations, maintaining a "basis" of basic variables that define the current solution. In each iteration, a non-basic variable enters the basis replacing a basic variable, generating a new feasible solution. The process ends when the objective can no longer be improved.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Linear

Programming
Simplex Algorithm
Simplex algorithm outline

Find some feasible corner points and calculate z

Select the adjacent corner


point giving the greater rate
While z can be improved by
of improvement in z
moving to an adjacent corner
Calculate the coordinates of
point the new point and new z
value

Stop
Simplex algorithm
• Simplex algorithm works on LP in a
standard form
Find a basic • All constraints should be in the
feasible solution form of equalities
• Steps of simplex algorithms:
1. Convert all inequality
constraints into equality
Generate a new
Is current No constraints by adding slack
basic feasible
solution
solution to
variables
optimal? 2. Find a basic feasible solution
improve z
3. Evaluate whether current
Yes solution is optimal
4. If current solution is not
Stop optimal, generate a new basic
feasible solution
Use simplex table to perform step 2
to 4
Simplex algorithm – example 1
max z = 7x1+ 10x2
subject to
5x1+ 4x2 ≤ 24
2x1+ 5x2 ≤ 13 Two variables in simplex algorithm:
• Basic variables: variables that exist on one
x1 , x2 ≥ 0
equation only and has zero coefficient in
other equations
Convert the inequalities into equations form • In this example s1, s2
• Non-basic variables: variables that have
max z = 7x1+ 10x2
non-zero coefficients in more than one
subject to equation
5x1+ 4x2 + s1 = 24 • In this example x1, x2
2x1+ 5x2 + s2 = 13 • In each iteration there will be a set of basic
variables and a set of non-basic variables
x1, x2, s1, s2 ≥ 0 • A set of basic variables represents a basic
feasible solutions
s1, s2 are slack variables that represent unused resources
Simplex algorithm – example (cont’d)

Solution # 1 (initial feasible solution): x1= 0, x2 = 0, s1 = 24, s2 = 13, z = 0


• Can z be improved by making x1 > 0 ?
• Yes, if x1 > 0, then for each unit increase in x1 , z goes up 7
• Can z be improved by making x2> 0 ?
• Yes, if x2 > 0, then for each unit increase in x2 , z goes up 10
• Which variable should be solved for in the next solution?
• Since by making x2> 0 , it gives the greatest rate of improvement, this variable should be chosen
to enter the basic.
• x2 becomes an entering variable
Simplex algorithm – example (cont’d)

Which variable should leave the basic?


This can be determined as follows:
• For the constraint c1: 5x1+ 4x2 + s1 = 24, max x2 can increase is 6 (i.e. when x1=0)
• For the constraint c2: 2x1+ 5x2 + s2 = 13, max x2 can increase is 2.6 (i.e. when x1=0).
• Thus, max x2 can increase is 2.6 (satisfy both constraints), in this case s2 = 0
• s2 becomes a leaving variable

We obtain the following solution:


Solution # 2: s1 = 13.6, x2 = 2.6, x1= 0, s2 = 0, z = 26
Simplex algorithm – example (cont’d)
The above solution procedures can be carried out in the following Simplex tableau form:
Initial Simplex Tableau
Iteration 0: Pivot column

Basic x1 x2 s1 s2 RHS Ratio Entering variable: x2


S1 5 4 1 0 24 24/4=6 Leaving variable: s2

S2 2 5 0 1 13 13/5=2.6
Pivot row
Z -7 -10 0 0 0

Pivot element
Note:
• For maximization problem, pivot column is chosen based on the most negative value in row Z. For
minimization, choose the largest positive value.
• Pivot row is chosen based the smallest positive ratio (apply both for maximization and minimization)
Simplex algorithm – example (cont’d)
From initial simplex table, Entering variable: x2, Leaving variable: s2.
Iteration 1:
Set 0 to cells in the pivot column except
pivot element

• Current solution:
Basic x1 x2 s1 s2 RHS Ratio s1=68/5
x2=13/5
S1 17/5 0 1 -4/5 68/5 (68/5)/(17/5)=4 Z=26
X2 2/5 1 0 1/5 13/5 (13/5)/(2/5)=6.5 • Current solution is
not optimal solution
Z -3 0 0 2 26
since there is still
negative value in row
Apply Gauss-Jourdan Z
All elements in the pivot row are divided elimination to other cells • For the next iteration,
by pivot element entering variable: x1,
leaving variable: s1
• New value = old value – (new value of element in
the pivot row in the respective column)(old value
of the pivot column in the respective row)
Gauss-Jordan
Elimination • Example: cell s1 – x1
new value = 5 – (2/5)(4)
= 17/5
Simplex algorithm – example (cont’d)
From simplex table iteration 1, Entering variable: x1, Leaving variable: s1.
Iteration 2:

Basic x1 x2 s1 s2 RHS • Optimal solution:


x1= 4
X1 1 0 5/17 -4/17 4 x2= 1
Z= 38
X2 0 1 -2/17 5/17 1

Z 0 0 15/17 22/17 38

Since all the coefficients in Row Z are now all non-negative, the current solution is optimal

Note: for minimization, solution is optimal when all coefficient of Row Z are all non-positive
Simplex summary
• The optimum solution can always be associated with a
feasible extreme (corner) point in the solution space
x2 • In each iteration, all variables are portioned into basic
variables and non basic variables
6 • Basic variables represent the solution in each
iteration
• All non-basic variables are set to zero
Leaving variable
Iteration 1 13/5
(4,1)
Iteration 2

Iteration 0 24/5 13/2 Non-


x1 Basic
basic
variable
variable

Entering variable
Simplex algorithm:
two-phase method
Simplex method for solving a general LP problem
Consider the following LP model:
n
max z = cjxj
j =1

Subject to :
n

a x
j =1
ij j + si = bi i = 1,2,..., m

x j  0, j = 1,..., n

If bi are all ≥ 0, then an initial feasible solution can be obtained as follows:


xj = 0, j=1,…,n
si = bi, i=1,…,m
What happens if bi < 0 for some i?
→ Initial solution (xj = 0, j=1,…,n) lies in infeasible region
Two-phase method
• Use when initial solution does not lie in feasible region
• Require artificial variable, r, in converting inequalities into equalities
• The existence of r indicates the current condition is infeasible
• Phase 1
• Objective: arrive at feasible region
• Set temporary objective to “remove” artificial variables
• When optimal is reached, artificial variables become non-basic variables → current solution lies in
feasible region
• Phase 2
• Objective: optimization
• Continue Phase 1 but recall the original LP problem
Simplex algorithm – example 2
max z = 7x1+ 10x2

subject to
5x1+ 4x2 ≥ 24 (1)
2x1+ 5x2 ≤ 13 (2)
x1 , x2 ≥ 0

When x1=0 and x2=0 (initial solution), constraint (1) is violated → initial solution
lies in infeasible region
→ Use two-phase method
Simplex method: example 2

Phase 1
• Step 1: Define an artificial variable ri for each of the ≥ or = type constraint and add them to the LP model
max z = -r1 (1) Note:
subject to For minimization, min 𝑧 = σ𝑖 𝑟𝑖
5x1+ 4x2 - s1 + r1 = 24 (2)
2x1+ 5x2 + s2 = 13 (3)
x1, x2, s1, s2, r1 ≥ 0
• Step 2:
• Set artificial variable as basic variable by eliminating r1 from the objective function (eq. 1) by
substituting eq. (2) so that r1 only has value in one of the constraints. Thus eq. (1) becomes
z - 5x1 - 4x2 + s1 = -24
Simplex method: example 2
Phase 1
Iteration 0
Basic x1 x2 s1 s2 r1 RHS Ratio

r1 5 4 -1 0 1 24 24/5=4.8
S2 2 5 0 1 0 13 13/2=6.5
Z -5 -4 1 0 0 -24

Iteration 1
Basic x1 x2 s1 s2 r1 RHS
x1 1 4/5 -1/5 0 1/5 24/5
S2 0 17/5 2/5 1 -2/5 3.4
Z 0 0 0 0 1 0

The solution to the Phase-I LP problem is now optimal. Hence we have obtained a basic feasible solution
to the original LP problem → r1 is a non-basic variable
Simplex method: example 2
Phase 2
• Step 1: Drop the artificial column and optimize the original objective function
Based on the last Simplex tableu Phase 1, the LP formulation is as follows.
max z = 7x1+ 10x2 (4)
subject to
x1+ (4/5)x2 – (1/5)s1 = 4.8 (5)
(17/5)x2 + (2/5)s1 + s2 = 3.4 (6)
x1, x2, s1, s2 ≥ 0
An initial basic feasible solution is:
x1 = 4.8, s2 = 3.4 → basic variable: x1 and s2
Since x1 and s2 are basic variables, x1 should be eliminated from the objective function
• Step 2: Eliminate x1 from objective function (eq. 4) by substituting eq. (5). Thus, eq. (4) becomes
z – (22/5)x2 – (7/5)s1 = 33.6
Simplex method: example 2
Phase 2
Iteration 2

Basic x1 x2 s1 s2 RHS Ratio


x1 1 4/5 -1/5 0 4.8 4.8/0.8=6
S2 0 17/5 2/5 1 3.4 3.4/3.4=1
Z 0 -22/5 -7/5 0 33.6
Iteration 3
Basic x1 x2 s1 s2 RHS Ratio
x1 1 0 -5/17 -4/17 4 -
x2 0 1 2/17 5/17 1 17/2
Z 0 0 -15/17 22/17 38
Simplex method: example 2
Phase 2
Iteration 3

Basic x1 x2 s1 s2 RHS • Optimal solution:


x1 1 5/2 0 ½ 6½ x1= 6 ½
S1= 17/2
s1 0 17/2 1 5/2 17/2 Z= 45.5
Z 0 15/2 0 7/2 45.5

Since all the coefficients in Row Z are now all nonnegative, the current solution to the Phase 2 LP problem is optimal.
Special cases of LP solution
1. If there is a tie
1. For entering non-basic variables: Choose any one of them.
2. For leaving basic variables: Choose any one of them.
2. What if when you solve for basic variables, one of them has a value of zero?
It does not matter, it is only theoretical important. The name given to this kind of solution is
degenerate.
3. How can you tell if the LP problem has no solution (that is, the model is inconsistent)?
This can be detected if some artificial variables have positive values when the LP solution is optimal.
4. How can you tell if the LP solution is unbounded?
This can be detected if an entering variable can be increased without limit. That is, the pivot column
has no positive coefficients.
5. How can you tell if there is more than one optimal solution?
This can be detected if there exists a non-basic variable which has a coefficient of zero in the final
objective function row. Note that if P1and P2 are two optimal corner points then λP1+(1- λ )P2 are
equally good solution, for any 0 ≤ λ ≤ 1.
Thank you

You might also like