110 likes | 338 Views
ECE 665 Spring 2005 Computer Algorithms with Applications to VLSI CAD. Linear Programming Duality. w 1. w 2. w 3. Linear Program Dual – Example1. Primal LP (original) max 100x 1 + 80x 2 s.to: 10x 1 + 5x 2 50 5x 1 + 5x 2 35 5x 1 + 15x 2 80 Primal solution:
E N D
ECE 665Spring 2005Computer AlgorithmswithApplications to VLSI CAD Linear Programming Duality
w1 w2 w3 Linear Program Dual – Example1 • Primal LP (original) max100x1 + 80x2 s.to: 10x1 + 5x2 50 5x1 + 5x2 35 5x1 + 15x2 80 Primal solution: x1=3, x2 =4, Fp = 620 maxcT x s.to: A x b x 0 • Dual LP (original) • min50w1 + 35w2 + 80w3 • s.to: • 10w1 + 5w2 + 5w3 100 • 5w1 + 5w2 + 15w3 80 • Dual solution: • w1=4, w2 =12, w3=0 • Fd = 620 • maxwT b • s.to:wTA cT • w 0 ECE 665 - LP Duality
Formulate it as a Linear Program (LP) Assign variables xi to each edge ei xi = 1 if edge eiis in the longest path xi = 0 otherwise Write the objective function Write the constraint set x1 x3 x2 x4 x6 x5 4 2 x7 5 x9 2 x8 1 2 3 2 5 3 3 6 5 4 6 Example 2: Longest Path Problem ECE 665 - LP Duality
Primal Problem x1 x3 4 2 x2 5 x4 2 x6 x5 3 2 x7 x9 5 x8 3 1 2 6 3 6 5 4 Example 2: Longest Path Problem (2) max 4x1 + 5x2 + 2x3 + 2x4 + 2x5 + 3x6 + 5x7 + 3x8 + 6x9 st -x1 - x2 - x3 = -1 x1 - x4 - x7 = 0 x2 + x4 - x5 = 0 x3 - x6 - x9 = 0 x5 + x6 - x8 = 0 x7 + x8 + x9 = 1 end ECE 665 - LP Duality
Primal Problem - solution x1 max 4x1 + 5x2 + 2x3 + 2x4 + 2x5 + 3x6 + 5x7 + 3x8 + 6x9 x3 st x2 -x1 - x2 - x3 = -1 x1 - x4 - x7 = 0 x4 x2 + x4 - x5 = 0 x3 - x6 - x9 = 0 x5 + x6 - x8 = 0 x6 x5 4 x7 + x8 + x9 = 1 end 2 x7 5 LP OPTIMUM FOUND AT STEP 2 x9 2 x8 1 2 OBJECTIVE FUNCTION VALUE 3 1) 11.000000 2 VARIABLE VALUE REDUCED COST X1 1.000000 0.000000 5 X2 0.000000 1.000000 3 3 4 6 5 6 X3 0.000000 0.000000 X4 1.000000 0.000000 X5 1.000000 0.000000 X6 0.000000 3.000000 X7 0.000000 2.000000 X8 1.000000 0.000000 X9 0.000000 3.000000 Example 2: Longest Path Problem (3) ECE 665 - LP Duality
Dual Problem formulation + solution w1=0 min -w1 + w6 4 w2=4 2 st 5 -w1 + w2 > 4 w4=5 -w1 + w3 > 5 2 -w1 + w4 > 2 w3=6 -w2 + w3 > 2 -w3 + w5 > 2 3 2 -w4 + w5 > 3 -w2 + w6 > 5 w5=8 -w5 + w6 > 3 5 -w4 + w6 > 6 3 1 2 6 end LP OPTIMUM FOUND AT STEP 7 w6=11 OBJECTIVE FUNCTION VALUE 1) 11.000000 3 6 5 4 VARIABLE VALUE REDUCED COST W1 0.000000 0.000000 W2 4.000000 0.000000 W3 6.000000 0.000000 W4 5.000000 0.000000 W5 8.000000 0.000000 W6 11.000000 0.000000 Example 2: Longest Path Problem (4) Interpretation of dual variables: wi = distance ofnodeI from source Note: This is still a longest path problem (Critical Path or Schedulingproblem): Find a minimumdistance from sink to source that satisfies all edge-length constraints. ECE 665 - LP Duality
Primal Problem x3 x7 x1 x4 x0 x0 max x0 st x2 x5 x8 -x1-x2+x0 = 0 x6 x1-x3-x4 = 0 Max flow x2-x5-x6 = 0 x3+x5-x7 = 0 x4+x6-x8 = 0 x7+x8-x0 = 0 Edge capacities Flow variables x1 <= 12 1 2 x2 <= 9 x3 <= 10 x4 <= 3 10 x5 <= 4 7 12 4 x6 <= 10 3 4 6 5 x7 <= 7 3 x8 <= 13 9 13 end 10 Example3: Max-Flow Min-Cut ECE 665 - LP Duality
Primal Problem - Solution X3=7 X1=10 X7=7 X4=3 X0=19 X0=19 X2=9 X8=12 X5=0 LP OPTIMUM FOUND AT STEP 3 min cut X6=9 OBJECTIVE FUNCTION VALUE 1) 19.000000 VARIABLE VALUE REDUCED COST 1 2 X0 19.000000 0.000000 X1 10.000000 0.000000 X2 9.000000 0.000000 10 7 X3 7.000000 0.000000 12 4 3 5 6 4 X4 3.000000 0.000000 3 X5 0.000000 1.000000 9 13 X6 9.000000 0.000000 10 X7 7.000000 0.000000 X8 12.000000 0.000000 Example3: Max-Flow Min-Cut (2) Saturated edges: x2=9 x4=3 x7=7 Max flow= 19 = min cut of forward saturated eges ECE 665 - LP Duality
Dual Problem - formulation x3 x7 x1 x4 x0 x0 max x0 st x2 x5 x8 z1 -x1-x2+x0 = 0 x6 x1-x3-x4 = 0 Node constraints: dual variables z x2-x5-x6 = 0 x3+x5-x7 = 0 x4+x6-x8 = 0 z6 Dual objective vector: [z1,…, z6, w1,…,w8] x7+x8-x0 = 0 w1 x1 <= 12 1 2 Dual objective cost: [ 0, … , 0, c1, …, c8] x2 <= 9 x3 <= 10 Edge constraints: dual variables w x4 <= 3 10 Edge capacities (12,9,10,3,4,10,7,13) x5 <= 4 7 12 4 x6 <= 10 3 4 6 5 x7 <= 7 3 w8 x8 <= 13 9 13 end 10 Example3: Max-Flow Min-Cut (3) Convert primal problem: Dual obj function: Fdual = 0 z1+…+0 z2 + 12 w12 +… + 13 w8 ECE 665 - LP Duality
Dual Problem st z1-z6 >= 1 -z1+z2+w1 >= 0 z2 z4 w3 -z1+z3+w2 >= 0 w7 w1 -z2+z4+w3 >= 0 z1 z6 -z2+z5+w4 >= 0 w4 -z3+z4+w5 >= 0 w5 -z3+z5+w6 >= 0 1 2 w2 w8 -z4+z6+w7 >= 0 w6 z5 -z5+z6+w8 >= 0 z3 z= node variables end w = edge variables 3 4 6 5 Example3: Max-Flow Min-Cut (4) min 12w1 +9w2 +10w3 +3w4 +4w5 +10w6 +7w7 +13w8 ECE 665 - LP Duality
Dual Problem - solution z4=1 z2=1 min cut w3=0 w1=0 w7=1 z1=1 z6=0 w4=1 w5=0 OBJECTIVE FUNCTION VALUE S T w2=1 1) 19.000000 w8=0 z3=0 w6=0 z5=0 VARIABLE VALUE REDUCED COST W1 0.000000 2.000000 W2 1.000000 0.000000 1 2 W3 0.000000 3.000000 W4 1.000000 0.000000 W5 0.000000 4.000000 zi = 1 if nodei is in set S 0 if it is in set T W6 0.000000 1.000000 W7 1.000000 0.000000 W8 0.000000 1.000000 3 4 5 6 Z1 1.000000 0.000000 Z6 0.000000 0.000000 wi = 1 if edge iis in the min-cut 0 otherwise Z2 1.000000 0.000000 Z3 0.000000 0.000000 Z4 1.000000 0.000000 Z5 0.000000 0.000000 Example3: Max-Flow Min-Cut (5) LP OPTIMUM FOUND AT STEP 9 Interpretation of dual variables ECE 665 - LP Duality