ECE LP Duality 1 ECE 665 Spring 2005 ECE 665 Spring 2005 Computer Algorithms with Applications to VLSI CAD Linear Programming Duality
ECE LP Duality 2 Linear Program Dual – Example1 Primal LP (original)Primal LP (original) max 100x x 2 s.to: 10x 1 + 5x 2 50 5x 1 + 5x 2 35 5x x 2 80 Primal solution: x 1 =3, x 2 =4, F p = 620 max c T x s.to: A x b x 0 Dual LP (original)Dual LP (original) min 50w w w 3 s.to: 10w 1 + 5w 2 + 5w 3 100 5w 1 + 5w w 3 80 Dual solution: w 1 =4, w 2 =12, w 3 =0 F d = 620 max w T b s.to: w T A c T w 0 w1w1 w2w2 w3w3
ECE LP Duality 3 Example 2: Longest Path Problem Formulate it as a Linear Program (LP) – –Assign variables x i to each edge e i x i = 1 if edge e i is in the longest path x i = 0 otherwise – –Write the objective function – –Write the constraint set x1 x2 x3 x4 x5 x6 x9 x8 x7
ECE LP Duality 4 Example 2: Longest Path Problem (2) Primal Problem x1 x2 x3 x4 x5 x6 x9 x8 x 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 LP Duality 5 Example 2: Longest Path Problem (3) Primal Problem - solution x1 x2 x3 x4 x5 x6 x9 x8 x 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 LP OPTIMUM FOUND AT STEP 2 OBJECTIVE FUNCTION VALUE 1) VARIABLE VALUE REDUCED COST X X X X X X X X X
ECE LP Duality 6 Example 2: Longest Path Problem (4) Dual Problem formulation + solution min -w1 + w6 st -w1 + w2 > 4 -w1 + w3 > 5 -w1 + w4 > 2 -w2 + w3 > 2 -w3 + w5 > 2 -w4 + w5 > 3 -w2 + w6 > 5 -w5 + w6 > 3 -w4 + w6 > 6 end LP OPTIMUM FOUND AT STEP 7 OBJECTIVE FUNCTION VALUE 1) VARIABLE VALUE REDUCED COST W W W W W W Interpretation of dual variables: w i = distance of node I from source w6= w2=4 w1=0 w4=5 w3=6 w5=8 Note: This is still a longest path problem (Critical Path or Scheduling problem): Find a minimum distance from sink to source that satisfies all edge-length constraints.
ECE LP Duality 7 Example3: Max-Flow Min-Cut Primal Problem max x0 st -x1-x2+x0 = 0 x1-x3-x4 = 0 x2-x5-x6 = 0 x3+x5-x7 = 0 x4+x6-x8 = 0 x7+x8-x0 = 0 x1 <= 12 x2 <= 9 x3 <= 10 x4 <= 3 x5 <= 4 x6 <= 10 x7 <= 7 x8 <= 13 end x1 x2 x3 x4 x6 x8 x7 x0 x5 x0 Edge capacities Flow variables Max flow
ECE LP Duality 8 Example3: Max-Flow Min-Cut (2) Primal Problem - Solution X1=10 X2=9 X3=7 X4=3 X6=9 X8=12 X7=7 X0=19 X5=0 X0=19 LP OPTIMUM FOUND AT STEP 3 OBJECTIVE FUNCTION VALUE 1) VARIABLE VALUE REDUCED COST X X X X X X X X X Saturated edges: x2=9 x4=3 x7=7 Max flow = 19 = min cut of forward saturated eges min cut
ECE LP Duality 9 Example3: Max-Flow Min-Cut (3) Dual Problem - formulation x1 x2 x3 x4 x6 x8 x7 x0 x5 x0 Edge constraints: dual variables w w1 w8 Node constraints: dual variables z z1 z6 Dual objective vector: [z1,…, z6, w1,…,w8] Dual objective cost: [ 0, …, 0, c1, …, c8] Edge capacities ( 12,9,10,3,4,10,7,13 ) Convert primal problem : Dual obj function: F dual = 0 z1+…+0 z w12 +… + 13 w8 max x0 st -x1-x2+x0 = 0 x1-x3-x4 = 0 x2-x5-x6 = 0 x3+x5-x7 = 0 x4+x6-x8 = 0 x7+x8-x0 = 0 x1 <= 12 x2 <= 9 x3 <= 10 x4 <= 3 x5 <= 4 x6 <= 10 x7 <= 7 x8 <= 13 end
ECE LP Duality 10 Example3: Max-Flow Min-Cut (4) Dual Problem min 12w1 +9w2 +10w3 +3w4 +4w5 +10w6 +7w7 +13w8 st z1-z6 >= 1 -z1+z2+w1 >= 0 -z1+z3+w2 >= 0 -z2+z4+w3 >= 0 -z2+z5+w4 >= 0 -z3+z4+w5 >= 0 -z3+z5+w6 >= 0 -z4+z6+w7 >= 0 -z5+z6+w8 >= 0 end z = node variables w = edge variables z3 w6 z2 w1 w2 w3 w4 w5 w7 w8 z4 z6 z5 z1
ECE LP Duality 11 Example3: Max-Flow Min-Cut (5) Dual Problem - solution z3=0 w6=0 z2=1 w1=0 w2=1 w3=0 w4=1w5=0 w7=1 w8=0 z4=1 z6=0 z5=0 z1=1 LP OPTIMUM FOUND AT STEP 9 OBJECTIVE FUNCTION VALUE 1) VARIABLE VALUE REDUCED COST W W W W W W W W Z Z Z Z Z Z S T min cut Interpretation of dual variables z i = 1 if node i is in set S 0 if it is in set T w i = 1 if edge i is in the min-cut 0 otherwise