CHE2033IU:
Simulation and Optimization
Spring 2021 (Sem-II)
International University-HCMC
Department of Chemical Engineering
Lecturer: Khanh B. Vu
1
Simplex algorithm/graphical method: comparison
2x1 + x2 = 18 max z = 3x1 + 2x2
s.t.
2x1 + x2 18
3x1 + x2 24
2x1 + 3x2 42
3x1 + x2 = 24
x1 , x 2 0
2x1 + 3x2 = 42
Feasible region: O-F-H-G-C
2
Simplex algorithm/graphical method:
comparison
Extreme Coordinates Objective value
point (x1, x2) (Z)
O (0,0) 0
C (0,14) 28
G (3,12) 33
H (6,6) 30
F (8,0) 24
Since G-point provides the greatest value to the Z-
function and the objective is to maximize, this point is
the optimal solution: Z = 33 with x1 = 3 and x2 = 12.
3
Simplex algorithm/graphical method:
comparison
The Simplex Algorithm Procedure for maximization
LPs
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
Step 4 If the current bfs is not optimal, determine which
non-basic variable should become a basic
variable and which basic variable should
become a non-basic variable to find a bfs with a
better objective function value.
Step 5 Use ratio’s to find a new bfs with a better
objective function value. Go back to Step 3.
5
Simplex algorithm/graphical method:
comparison max z = 3x + 2x
1 2
s.t.
2x1 + x2 18
2x1 + 3x2 42
3x1 + x2 24
x1 , x 2 0
Step 1: Convert the LP to canonical form:
Row 0: z - 3x1 - 2x2 = 0
Row 1: 2x1 + x2 + s1 = 18
Row 2: x1 + 3x2 + s2 = 42
Row 3: 3x1 + x2 + s3 = 24
6
Simplex algorithm/graphical method:
comparison
Row 0: z - 3x1 - 2x2 = 0
Row 1: 2x1 + x2 + s1 = 18
Row 2: x1 + 3x2 + s2 = 42
Row 3: 3x1 + x2 + s3 = 24
Tableau-0
row z x1 x2 s1 s2 s3 rhs
0 1 -3 -2 0 0 0 0
1 0 2 1 1 0 0 18
2 0 1* 3 0 1 0 42
3 0 3 1 0 0 1 24
7
Simplex algorithm/graphical method:
comparison
Step 2: Obtain a Basic Feasible Solution
Set m – n = 6 – 4 = 2 non-basic variables (NBV) to
zero to obtain a basic feasible solution.
The basic variables are the variables corresponding to
the identity matrix. BV = {z, s1, s2, s3)
The non-basic variables are the remaining variables.
NBV = {x1, x2}
Identity matrix
Basic feasible solution {z, s1, s2, s3} = {0, 18, 42, 24}
8
Simplex algorithm/graphical method:
comparison
Step 2: Obtain a Basic Feasible Solution
Basic feasible solution {z, s1, s2, s3} = {0, 18, 42, 24}
Coordinates Objective
Extreme
value (Z)
point
(x1, x2)
O (0,0) 0
C (0,14) 28
G (3,12) 33
H (6,6) 30
F (8,0) 24 O
Basic feasible solution
9
Simplex algorithm/graphical method:
comparison
Step 3: Determine if the Current BFS is Optimal
if there is any way z can be increased by increasing
some non-basic variable from its current value of zero
while holding all other non-basic variables at their
current values of zero?
Solving for z in row 0 yields: z = 3x1 + 2x2
Increasing any of the non-basic variables will cause an
increase in z.
The current BFS {z, s1, s2, s3} = {0, 18, 42, 24}
is NOT optimal* since z can be increased by x 1 and x2
10
Simplex algorithm/graphical method:
comparison
Step 4: Determine entering variable and ratio test
to decide which BV becomes NBV
Increasing x1 causes the greatest rate of increase in
z. If x1 increases from its current value of zero, it
will have to become a basic variable. For this
reason, x1 is called the entering variable
We desire to make x1 as large as possible but as we
do, the current basic variables {z, s1, s2, s3} will
change value. Thus, increasing x1 may cause a
basic variable to become negative.
11
Simplex algorithm/graphical method:
comparison
Step 4: Determine entering variable and ratio test
to decide which BV becomes NBV
Tableau-0 Row z x1 x2 s1 s2 s3 rhs
0 1 -3 -2 0 0 0 0
1 0 2 1 1 0 0 18
2 0 1* 3 0 1 0 42
RATIO TEST 3 0 3 1 0 0 1 24
From row 1 we see that s1=18–2x1. Since s1 ≥ 0, x1 ≤ 18/2=9
From row 2 we see that s2=42–x1. Since s2 ≥ 0, x1 ≤ 42/1=42
From row 3 we see that s3=24–3x1. Since s3 ≥ 0, x1 ≤ 24/3=8
(*)
To keep all the basic variables non-negative,
the largest we can make x1 is min {9, 42, 8} = 8.
12
Simplex algorithm/graphical method:
comparison
Step 4: Determine entering variable and
ratio test to decide which BV becomes NBV
Tableau-0 row z x1 x2 s1 s2 s3 rhs
0 1 -3 -2 0 0 0 0
1 0 2 1 1 0 0 18
winner of the
ratio test row 3 2 0 1* 3 0 1 0 42
3 0 3 1 0 0 1 24
Make the entering variable x1 a BV in row 3 since this
row (constraint) was the winner of the ratio test (8*).
x1 has a coefficient of 1 in row 3 and a coefficient of 0 in
Goal
all other rows: pivoting on row 3; row 3 is called the
pivot row
13
Simplex algorithm/graphical method:
comparison
Step 5: Find a new bfs w/ a better z
row z x1 x2 s1 s2 s3 rhs Tableau-1
0 1 -3 -2 0 0 0 0
1 0 2 1 1 0 0 18
2 0 2 3 0 1 0 42
3’ 0 1 1/3 0 0 1/3 8 row 3*(1/3)=row3
row z x1 x2 s1 s2 s3 rhs Tableau-1
0 1 0 -1 0 0 1 24 row0+3*row3’
1 0 0 1/3 1 0 -2/3 2 row1-2*row3’
2 0 0 7/3 0 1 -2/3 26 row2-2*row3’
3 0 1 1/3 0 0 1/3 8
14
Simplex algorithm/graphical method:
comparison
Tableau-1
row z x1 x2 s1 s2 s3 rhs
0 1 0 -1 0 0 1 24
1 0 0 1/3 1 0 -2/3 2
2 0 0 7/3 0 1 -2/3 26
3 0 1 1/3 0 0 1/3 8
BV = {z, s1, s2, x1}
Old bfs {z, s1, s2, s3}
NBV = {x2, s3}
Basic feasible solution {z, s1, s2, x1} = {24, 2, 26, 8}
15
Simplex algorithm/graphical method:
comparison
Step 2: Obtain a Basic Feasible Solution
New bfs {z, s1, s2, x1} = {24, 2, 26, 8}
Coordinates Objective
Extreme
value (Z)
point
(x1, x2)
O (0,0) 0
C (0,14) 28
G (3,12) 33
H (6,6) 30
F (8,0) 24 O
1st bfs at O moves to
adjacent bfs at F 1st bfs 2nd bfs
16
Simplex algorithm/graphical method:
comparison
Tableau-1
row z x1 x2 s1 s2 s3 rhs
0 1 0 -1 0 0 1 24
1 0 0 1/3 1 0 -2/3 2
2 0 0 7/3 0 1 -2/3 26
3 0 1 1/3 0 0 1/3 8
BV = {z, s1, s2, x1}
NBV = {x2, s3}
Basic feasible solution {z, s1, s2, x1} = {24, 2, 26, 8}
Back to step 3: Determine if the Current BFS is Optimal
17
Simplex algorithm/graphical method:
comparison
Step 3: Determine if the Current BFS is Optimal
if there is any way z can be increased by increasing
some non-basic variable from its current value of zero
while holding all other non-basic variables at their
current values of zero?
Solving for z in row 0 yields: z = 24 + x2 – s3
Increasing x2 (while holding the other non-basic variable
to zero) will cause an increase in z.
The current BFS {z, s1, s2, x1} = {24, 2, 26, 8}
is NOT optimal since z can be increased x2
18
Simplex algorithm/graphical method:
comparison
Step 4: Determine entering variable and ratio test
to decide which BV becomes NBV
If x2 increases from its current value of zero, it will
have to become a basic variable. For this reason,
x2 is called the entering variable
We desire to make x2 as large as possible but as we
do, the current basic variables {z, s1, s2, x1} will
change value. Thus, increasing x2 may cause a
basic variable to become negative.
19
Simplex algorithm/graphical method:
comparison
Step 4: Determine entering variable and ratio test
to decide which BV becomes NBV
row Z X1 x2 s1 s2 s3 rhs
Tableau-1
0 1 0 -1 0 0 1 24
1 0 0 1/3 1 0 -2/3 2
2 0 0 7/3 0 1 -2/3 26
3 0 1 1/3 0 0 1/3 8
RATIO TEST
From row 1 we see that s1=2–x2/3. Since s1 ≥ 0, x2 ≤ 6
From row 2 we see that s2=26–7x2/3. Since s2 ≥ 0, x2 ≤ 78/7
From row 3, we see that x1=8–x2/3. Since x1 ≥ 0, x2 ≤ 24
To keep all the basic variables non-negative,
the largest we can make x2 is min {6, 78/7, 24} = 6.
20
Simplex algorithm/graphical method:
comparison
Step 4: Determine entering variable and ratio test
to decide which BV becomes NBV
row z x1 x2 s1 s2 s3 rhs
Tableau-1 0 1 0 -1 0 0 1 24
1 0 0 1/3 1 0 -2/3 2
winner of the 2 0 0 7/3 0 1 -2/3 26
ratio test row 1
3 0 1 1/3 0 0 1/3 8
Make the entering variable x2 a BV in row 1 since this
row (constraint) was the winner of the ratio test.
x2 have a coefficient of 1 in row 1 and a coefficient of 0
Goal
in all other rows: pivoting on row 1; row 1 is called the
pivot row
21
Simplex algorithm/graphical method:
comparison
row z x1 x2 s1 s2 s3 Rhs Tableau-1
0 1 0 -1 0 0 1 24 row0
1 0 0 1 3 0 -2 6 row1*(3) = row1’
2 0 0 7/3 0 1 -2/3 26
row2
3 0 1 1/3 0 0 1/3 8 row3
Tableau-2
row z x1 x2 s1 s2 s3 rhs
0 1 0 0 3 0 -1 30 row0 + row1’
1 0 0 1 3 0 -2 6
row1’
2 0 0 0 -3 3/7 12/7 36/7 (3/7)row2 –
row1’
3 0 3 0 -3 0 3 18 3*row3 – row1’
22
Simplex algorithm/graphical method:
comparison
row z x1 x2 s1 s2 s3 rhs
Tableau-1
0 1 0 0 3 0 -1 30
1 0 0 1 3 0 -2 6
2 0 0 0 -3 3/7 12/7 36/7
3 0 3 0 -3 0 3 18
row z x1 x2 s1 s2 s3 rhs Tableau-2
0 1 0 0 3 0 -1 30
1 0 0 1 3 0 -2 6
2 0 0 0 -7 1 4 12 (7/3)*row2’
3 0 1 0 -1 0 1 6 (1/3)*row3’
23
Simplex algorithm/graphical method:
comparison
Tableau-2
row z x1 x2 s1 s2 s3 rhs
0 1 0 0 3 0 -1 30
1 0 0 1 3 0 -2 6
2 0 0 0 -7 1 4 12
3 0 1 0 -1 0 1 6
BV = {z, x1, x2, s2}
NBV = {s1, s3}
Basic feasible solution {z, x1, x2, s2} = {30, 6, 6, 12}
24
Simplex algorithm/graphical method:
comparison
Step 2: Obtain a Basic Feasible Solution
New bfs {z, x1, x2, s2} = {30, 6, 6, 12}
Extreme Coordinates Objective
point (x1, x2) value (Z)
O (0,0) 0 3rd bfs
C (0,14) 28
G (3,12) 33
H (6,6) 30
F (8,0) 24
O
2st bfs at F moves to
1st bfs 2nd bfs
adjacent bfs at H
25
Simplex algorithm/graphical method:
comparison
Step 3: Determine if the Current BFS is Optimal
if there is any way z can be increased by increasing
some non-basic variable from its current value of zero
while holding all other non-basic variables at their
current values of zero?
Solving for z in row 0 yields: z = 30 - 3s1 + s3
Increasing s3 (while holding the other nonbasic variable
to zero) will cause an increase in z.
The current BFS {z, x1, x2, s2}
is NOT optimal since z can be increased s3
26
Simplex algorithm/graphical method:
comparison
Tableau-2
row z x1 x2 s1 s2 s3 rhs
0 1 0 0 3 0 -1 30
1 0 0 1 3 0 -2 6
2 0 0 0 -7 1 4 12
3 0 1 0 -1 0 1 6
RATIO TEST
From row 1 we see that x2 -2s3 = 6, x2 = 6 + 2s3 0, s3 -3
From row 2 we see that s2 + 4s3 = 12, s2 = 12 – 4s3 0, s3
3
From row 3 we see that x1 + s3 = 6, x1 = 6 – s3 0, s3 6
27
Simplex algorithm/graphical method:
comparison
Tableau-2
Row z x1 x2 s1 s2 s3 rhs
0 1 0 0 3 0 -1 30
1 0 0 1 3 0 -2 6
2 0 0 0 -7/4 1/4 1 3
(1/4)*row2 = row2’
3 0 1 0 -1 0 1 6
Tableau-3
row z x1 x2 s1 s2 s3 rhs
0 1 0 0 5/4 1/4 0 33
Row0 + row2’
1 0 0 1 -1/2 1/2 0 12
Row1 + 2*row2’
2 0 0 0 -7/4 1/4 1 3
row2’
3 0 1 0 3/4 -1/4 0 3
Row3 – row2’
28
Simplex algorithm/graphical method:
comparison
Tableau-3
row z x1 x2 s1 S2 S3 rhs
0 1 0 0 5/4 ¼ 0 33
1 0 0 1 -1/2 ½ 0 12
2 0 0 0 -7/4 ¼ 1 3
3 0 1 0 3/4 -1/4 0 3
BV = {z, x1, x2, s3}
NBV = {s1, s2}
Basic feasible solution {z, x1, x2, s3} = {33, 3, 12, 3}
29
Simplex algorithm/graphical method:
comparison
Step 2: Obtain a Basic Feasible Solution
New bfs {z, x1, x2, s2} = {30, 6, 6, 12}
optimal bfs
Coordina Objective
Extreme
tes value (Z)
point
(x1, x2)
3rd bfs
O (0,0) 0
C (0,14) 28
G (3,12) 33
H (6,6) 30
F (8,0) 24 O
3rd bfs at H moves to
1st bfs 2nd bfs
adjacent bfs at G
30
Simplex algorithm/graphical method:
comparison
Step 3: Determine if the Current BFS is Optimal
if there is any way z can be increased by increasing
some non-basic variable from its current value of zero
while holding all other non-basic variables at their
current values of zero?
Solving for z in row 0 yields: z = 33 – (5/4)s1 – (1/4)s2
Increasing any variables will not cause an increase in z.
The current BSF {z, x1, x2, s3} = {33, 3, 12, 3} is optimal
31