07 December, 2017 Simplex Algorithm 1
Linear Programming
Simplex Algorithm
Yunus Hatipoğlu
201671209
Çankaya University
CENG511 – Advanced Algorithm
07 December, 2017 The Simplex Algorithm 2
Content
• Linear Programming– what is that?
• The Simplex Algorithm – background
• Usage Areas in real life
• How it works (Pseudo)
• Example Question – Maximize
07 December, 2017 The Simplex Algorithm 3
Linear Programming– what is
that? A technique to
achieve optimal
distribution of
resources,
minimize costs and
maximize profits.
07 December, 2017 The Simplex Algorithm 4
The Simplex Algorithm
• based on algebraic
iteration.
• the initial simplex
table is edited
• then the operations
are continued until
it reaches the
optimal solution
07 December, 2017 The Simplex Algorithm 5
The Simplex Algorithm
• Simplex algorithm visits all 2n vertices in
worst case and this turns out to be true for
and deterministic pivot rule.
• Pivot rule takes exponential time in worst
case.
• The performance of simplex algorithm
depend on the specific pivot rule used.
07 December, 2017 The Simplex Algorithm 6
Usage Areas in real life
• limited use of resources (capacity, raw
material, labor force, etc.) and maximizing
profits or minimizing costs.
Determination of optimum
production schedule:
07 December, 2017 The Simplex Algorithm 7
Usage Areas in real life
• tries to ensure optimum application in
determining the sales, storage or purchases
of the warehouse capacity determined
within a certain time to maximize profits (or
minimize costs).
Storage problems:
07 December, 2017 The Simplex Algorithm 8
How it works?
07 December, 2017 The Simplex Algorithm 9
Maximize & Minimize
• Subjected to constraints :
• 0<= ax + by + cz + ... <= P1
• 0<= dx + ey + fz + ... <= P2
• ...
To maximize:
To minimize:
f = c1x+c2y+c3z ...
We maximize
g = -f = -(c1x+c2y+c3z ...)
07 December, 2017 The Simplex Algorithm 10
Example Question
• Constraints:
2x1 + x2 <= 14
5x1 + 5x2 <=40
x1 + 3x2 <= 18
Maximize the following
n= 50x1 + 30x2
x1, x2 >= 0
07 December, 2017 The Simplex Algorithm 11
Example Question(Cont.)
• 1. Create simplex table
– transform them into equations by adding
increasing variables to the inequalities
2x1 + x2 + s1 = 14
5x1 + 5x2+ s2 = 40
x1 + 3x2 + s3 = 18
Maximize the following
n= 50x1 + 30x2
07 December, 2017 The Simplex Algorithm 12
Example Question(Cont.)
– Write constraint equations in matrix form
2 1 1 0 0
5 5 0 1 0 =
1 3 0 0 1
Maximize the following
n= 50x1 + 30x2
x1
x2
s1
s2
s3
14
40
18
07 December, 2017 The Simplex Algorithm 13
Example Question(Cont.)
x1 x2 s1 s2 s3
2 1 1 0 0 14
5 5 0 1 0 40
1 3 0 0 1 18
-50 -30 0 0 0 0
having the greatest absolute value of negative value
indicates pivot column --> -50
Fixed values are divided
to pivot line and minimum
value determines pivot
line
14/2 = 7 which is minumum
40/5 = 8
18/1 = 18
So 2 is pivot line
07 December, 2017 The Simplex Algorithm 14
Example Question(Cont.)
x1 x2 s1 s2 s3
2 1 1 0 0 14
5 5 0 1 0 40
1 3 0 0 1 18
-50 -30 0 0 0 0
multiply the first line by 1/2 and make the pivot line 1
x1 x2 s1 s2 s3
1 1/2 1/2 0 0 7
5 5 0 1 0 40
1 3 0 0 1 18
-50 -30 0 0 0 0
07 December, 2017 The Simplex Algorithm 15
Example Question(Cont.)
• Multiply the first line by 5 and subtract from the
second line
• Substract first line from 3. line
• First line multiplied by 50 and added to forth line
• Clean pivot column.
x1 x2 s1 s2 s3
1 1/2 1/2 0 0 7
0 5/2 -5/2 1 0 5
0 5/2 -1/2 0 1 11
0 -5 25 0 0 350
x1 x2 s1 s2 s3
1 1/2 1/2 0 0 7
5 5 0 1 0 40
1 3 0 0 1 18
-50 -30 0 0 0 0
07 December, 2017 The Simplex Algorithm 16
Example Question(Cont.)
• Change basis and repeat pivotting.
• Second column pivot
• Second line pivot line
x1 x2 s1 s2 s3
1 1/2 1/2 0 0 7
0 5/2 -5/2 1 0 5
0 5/2 -1/2 0 1 11
0 -5 25 0 0 350
7 / 1/2 = 14
5 / 5/2 = 2
11 / 5/2 = 4.4
So pivot element is 5/2 which is
in second line
07 December, 2017 The Simplex Algorithm 17
Example Question(Cont.)
multiply the second line by 2/5 and make the pivot
line 1
x1 x2 s1 s2 s3
1 1/2 1/2 0 0 7
0 1 -1 2/5 0 2
0 5/2 -1.2 0 1 11
0 -5 25 0 0 350
x1 x2 s1 s2 s3
1 1/2 1/2 0 0 7
0 5/2 -5/2 1 0 5
0 5/2 -1/2 0 1 11
0 -5 25 0 0 350
07 December, 2017 The Simplex Algorithm 18
Example Question(Cont.)
• Multiply the second line by 1/2 and subtract from
the first line
• Multiply the second line by 5/2 and subtract from
third line
• Second line is multiplied by 5 and added to forth
line
x1 x2 s1 s2 s3
1 0 1 -1/5 0 6
0 1 -1 2/5 0 2
0 0 2 -1 1 6
0 0 20 2 0 360
x1 x2 s1 s2 s3
1 1/2 1/2 0 0 7
0 1 -1 2/5 0 2
0 5/2 -1/2 0 1 11
0 -5 25 0 0 350
07 December, 2017 The Simplex Algorithm 19
Example Question(Cont.)
• Since there are no negative indicators left, this is
the last table
x1 x2 s1 s2 s3
1 0 1 -1/5 0 6
0 1 -1 2/5 0 2
0 0 2 -1 1 6
0 0 20 2 0 360
x1 = 6
x2 = 2
s3 = 6
n = 360
07 December, 2017 The Simplex Algorithm 20
Question
• What is worst case complexity of Simplex Algorithm
and what kind of areas complexity algorithm can be
used?

Linear Programming - Simplex Algorithm by Yunus Hatipoglu

  • 1.
    07 December, 2017Simplex Algorithm 1 Linear Programming Simplex Algorithm Yunus Hatipoğlu 201671209 Çankaya University CENG511 – Advanced Algorithm
  • 2.
    07 December, 2017The Simplex Algorithm 2 Content • Linear Programming– what is that? • The Simplex Algorithm – background • Usage Areas in real life • How it works (Pseudo) • Example Question – Maximize
  • 3.
    07 December, 2017The Simplex Algorithm 3 Linear Programming– what is that? A technique to achieve optimal distribution of resources, minimize costs and maximize profits.
  • 4.
    07 December, 2017The Simplex Algorithm 4 The Simplex Algorithm • based on algebraic iteration. • the initial simplex table is edited • then the operations are continued until it reaches the optimal solution
  • 5.
    07 December, 2017The Simplex Algorithm 5 The Simplex Algorithm • Simplex algorithm visits all 2n vertices in worst case and this turns out to be true for and deterministic pivot rule. • Pivot rule takes exponential time in worst case. • The performance of simplex algorithm depend on the specific pivot rule used.
  • 6.
    07 December, 2017The Simplex Algorithm 6 Usage Areas in real life • limited use of resources (capacity, raw material, labor force, etc.) and maximizing profits or minimizing costs. Determination of optimum production schedule:
  • 7.
    07 December, 2017The Simplex Algorithm 7 Usage Areas in real life • tries to ensure optimum application in determining the sales, storage or purchases of the warehouse capacity determined within a certain time to maximize profits (or minimize costs). Storage problems:
  • 8.
    07 December, 2017The Simplex Algorithm 8 How it works?
  • 9.
    07 December, 2017The Simplex Algorithm 9 Maximize & Minimize • Subjected to constraints : • 0<= ax + by + cz + ... <= P1 • 0<= dx + ey + fz + ... <= P2 • ... To maximize: To minimize: f = c1x+c2y+c3z ... We maximize g = -f = -(c1x+c2y+c3z ...)
  • 10.
    07 December, 2017The Simplex Algorithm 10 Example Question • Constraints: 2x1 + x2 <= 14 5x1 + 5x2 <=40 x1 + 3x2 <= 18 Maximize the following n= 50x1 + 30x2 x1, x2 >= 0
  • 11.
    07 December, 2017The Simplex Algorithm 11 Example Question(Cont.) • 1. Create simplex table – transform them into equations by adding increasing variables to the inequalities 2x1 + x2 + s1 = 14 5x1 + 5x2+ s2 = 40 x1 + 3x2 + s3 = 18 Maximize the following n= 50x1 + 30x2
  • 12.
    07 December, 2017The Simplex Algorithm 12 Example Question(Cont.) – Write constraint equations in matrix form 2 1 1 0 0 5 5 0 1 0 = 1 3 0 0 1 Maximize the following n= 50x1 + 30x2 x1 x2 s1 s2 s3 14 40 18
  • 13.
    07 December, 2017The Simplex Algorithm 13 Example Question(Cont.) x1 x2 s1 s2 s3 2 1 1 0 0 14 5 5 0 1 0 40 1 3 0 0 1 18 -50 -30 0 0 0 0 having the greatest absolute value of negative value indicates pivot column --> -50 Fixed values are divided to pivot line and minimum value determines pivot line 14/2 = 7 which is minumum 40/5 = 8 18/1 = 18 So 2 is pivot line
  • 14.
    07 December, 2017The Simplex Algorithm 14 Example Question(Cont.) x1 x2 s1 s2 s3 2 1 1 0 0 14 5 5 0 1 0 40 1 3 0 0 1 18 -50 -30 0 0 0 0 multiply the first line by 1/2 and make the pivot line 1 x1 x2 s1 s2 s3 1 1/2 1/2 0 0 7 5 5 0 1 0 40 1 3 0 0 1 18 -50 -30 0 0 0 0
  • 15.
    07 December, 2017The Simplex Algorithm 15 Example Question(Cont.) • Multiply the first line by 5 and subtract from the second line • Substract first line from 3. line • First line multiplied by 50 and added to forth line • Clean pivot column. x1 x2 s1 s2 s3 1 1/2 1/2 0 0 7 0 5/2 -5/2 1 0 5 0 5/2 -1/2 0 1 11 0 -5 25 0 0 350 x1 x2 s1 s2 s3 1 1/2 1/2 0 0 7 5 5 0 1 0 40 1 3 0 0 1 18 -50 -30 0 0 0 0
  • 16.
    07 December, 2017The Simplex Algorithm 16 Example Question(Cont.) • Change basis and repeat pivotting. • Second column pivot • Second line pivot line x1 x2 s1 s2 s3 1 1/2 1/2 0 0 7 0 5/2 -5/2 1 0 5 0 5/2 -1/2 0 1 11 0 -5 25 0 0 350 7 / 1/2 = 14 5 / 5/2 = 2 11 / 5/2 = 4.4 So pivot element is 5/2 which is in second line
  • 17.
    07 December, 2017The Simplex Algorithm 17 Example Question(Cont.) multiply the second line by 2/5 and make the pivot line 1 x1 x2 s1 s2 s3 1 1/2 1/2 0 0 7 0 1 -1 2/5 0 2 0 5/2 -1.2 0 1 11 0 -5 25 0 0 350 x1 x2 s1 s2 s3 1 1/2 1/2 0 0 7 0 5/2 -5/2 1 0 5 0 5/2 -1/2 0 1 11 0 -5 25 0 0 350
  • 18.
    07 December, 2017The Simplex Algorithm 18 Example Question(Cont.) • Multiply the second line by 1/2 and subtract from the first line • Multiply the second line by 5/2 and subtract from third line • Second line is multiplied by 5 and added to forth line x1 x2 s1 s2 s3 1 0 1 -1/5 0 6 0 1 -1 2/5 0 2 0 0 2 -1 1 6 0 0 20 2 0 360 x1 x2 s1 s2 s3 1 1/2 1/2 0 0 7 0 1 -1 2/5 0 2 0 5/2 -1/2 0 1 11 0 -5 25 0 0 350
  • 19.
    07 December, 2017The Simplex Algorithm 19 Example Question(Cont.) • Since there are no negative indicators left, this is the last table x1 x2 s1 s2 s3 1 0 1 -1/5 0 6 0 1 -1 2/5 0 2 0 0 2 -1 1 6 0 0 20 2 0 360 x1 = 6 x2 = 2 s3 = 6 n = 360
  • 20.
    07 December, 2017The Simplex Algorithm 20 Question • What is worst case complexity of Simplex Algorithm and what kind of areas complexity algorithm can be used?