Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3160 Design and Analysis of Algorithms Tutorial 6 Fei Chen.

Similar presentations


Presentation on theme: "CSCI 3160 Design and Analysis of Algorithms Tutorial 6 Fei Chen."— Presentation transcript:

1 CSCI 3160 Design and Analysis of Algorithms Tutorial 6 Fei Chen

2 Outline Linear Programming – Standard form – Problem modeling – Algorithm Duality Application

3 Linear Programming Constraint Optimization – Linear constraints – Linear objective function Example max subject to x 1 + 2x 2 + 3x 3 80x 1 + 60x 2 ≤ 7173 75x 2 + 50x 3 ≤ 2131 80x 3 ≤ 9366 x 1 +x 2 +x 3 ≤ 200 x 1, x 2, x 3 ≥ 0

4 Linear Programming In LP, the feasible region is a convex polytope bounded by many half planes (constraints) By linearity, the optimal solution must locate at the extreme points – There are finite number of points to try

5 Simplex method Start from any vertex of the polytope look for a better neighbor and move to it. Until the current vertex is better than all of its neighbors For LP local optimal ⇔ global optimal – because the feasible region is convex

6 Want to build the strongest army for the 3160 Empires. Resources we have: 9366 wood, 7173 food, 2131 gold Soldiers we can produce: How to maximize the power of our army? Example 80 food Power: 1 80 wood 50 gold Power: 3 60 food 75 gold Power: 2

7 80 food Power: 1 80 wood 50 gold Power: 3 60 food 75 gold Power: 2 Linear Program max subject to x 1 + 2x 2 + 3x 3 80x 1 + 60x 2 ≤ 7173 75x 2 + 50x 3 ≤ 2131 80x 3 ≤ 9366 x 1 +x 2 +x 3 ≤ 200 x 1, x 2, x 3 ≥ 0 Variables: – x 1 units – x 2 units – x 3 units Constraints – Food supply is 7173 – Wood supply is 9366 – Gold supply is 2131 – Max population is 200 Objective – Maximize the power of the army

8 Standard form max subject to cTxcTx Ax ≤ b x ≥ 0 x 1, x 2, …, x n ≥ 0 a 11 x 1 + … + a 1n x n ≤ b 1 a 21 x 1 + … + a 2n x n ≤ b 2 … a m1 x 1 + … + a mn x n ≤ b m c 1 x 1 + … + c n x n

9 Converting into standard form Constraints a 11 x 1 + … + a 1n x n ≥ b 1 is equivalent to -a 11 x 1 - … - a 1n x n ≤ -b 1 a 11 x 1 + … + a 1n x n = b 1 is equivalent to -a 11 x 1 - … - a 1n x n ≤ -b 1 and a 11 x 1 + … + a 1n x n ≤ b 1

10 Converting into standard form Constraints x free (free variables) is equivalent to x = x + - x - and x +, x - ≥ 0

11 Converting into standard form Objective function min z is equivalent to max -z

12 Objective function Non-linear objective function – Can sometimes be converted into linear objective function with extra linear constraints e.g. max min i x i is equivalent to z xi ≥ zxi ≥ z max subject to

13 Objective function Non-linear objective function – Can sometimes be converted into linear objective function with extra linear constraints e.g. max c|x i – x j | is equivalent to cy - cz x i – x j = y - z y, z ≥ 0 max subject to

14 Duality max subject to cTxcTx Ax ≤ b x ≥ 0 min subject to bTybTy A T y ≥ c y ≥ 0 Primal Program Dual Program max subject to cTxcTx Ax = b x ≥ 0 min subject to bTybTy A T y ≥ c Primal Program Dual Program y is free The dual of a dual program is the primal program!

15 Example Primal Program subject to 40x 1 + 20x 2 + 2x 3 3x 1 - 3x 2 + 5x 3 ≤ 50 x 1 + x 3 ≤ 10 x 1 - x 2 + 4x 3 ≤ 2 x 1, x 2 ≥ 0, x 3 is free max subject to 50y 1 + 10y 2 + 2y 3 3y 1 + y 2 + y 3 ≥ 40 -3y 1 - y 3 ≥ 20 5y 1 + y 2 + 4y 3 = 2 y 1, y 2, y 3 ≥ 0 min Dual Program

16 Duality Weak duality theorem – The primal gives lower bounds for the dual – The dual gives upper bounds for the primal Let x and y be feasible solutions of the primal and dual respectively, then c T x ≤ b T y.

17 Duality Strong duality theorem – optimal primal value = optimal dual value – If both exist, then they are equal – If one is infinity, then the other is infeasible

18 Application of duality theorem Max-flow min-cut theorem – A special case of duality theorem – you will see this in the future!

19 End Questions?


Download ppt "CSCI 3160 Design and Analysis of Algorithms Tutorial 6 Fei Chen."

Similar presentations


Ads by Google