CS 05: Algorithms (Grad) What is a Linear Programming Problem? A linear program (LP) is a minimization problem where we are asked to minimize a given linear function subject to one or more linear inequality constraints The linear function is also called the objective function Formulation: Minimize C i X i (where C i R and are constants and X i R and are variables) a x + a 2 x 2 + + a n x n b a 2 x + a 22 x 2 + + a 2n x n b 2 a 3 x + a 32 x 2 + + a 3n x n b 3 a n x + a n2 x 2 + + a nn x n b n Alternately, we can rewrite the above formulation as: Minimize C T X (where C, X R and are column vectors) AX b (where b R m, A R m n ) Given C, A and b the above LP can be solved in time poly(inputlength) 2 Vertex Cover Vertex Cover: A given subset of vertices of a graph G that covers all the edges in G For every edge (u, v) in the original graph, either vertices u or v or both are in the vertex cover Note: If total number of vertices is n, there are 2 n possible subsets A solution to a general LP gives: a sequence of real numbers x, x 2, x n Suppose for a moment that all x i are in the range { 0, } Note: If all x i are in the range { 0, }, there are 2 n possible assignments for x, x 2, x n So let us assign a binary value to variable x i to vertex i { i Subset x i = 0 i Subset 2 Example: From the first figure (Figure ): (x, x 2, x 3, x 4, x 5, x 6 ) = (0,,,0,0,) is not a cover but (x, x 2, x 3, x 4, x 5, x 6 ) = (0,,0,,0,) is a cover Page of 6
CS 05: Algorithms (Grad) Figure : Example graph for vertex cover calculation 2 3 4 5 22 Vertex Cover Formulation Let us require that C V be a vertex cover to requiring that (i, j) E that either i C or j C to requiring that (i, j) E, x i + x j Reformulation of problem: Vertex Cover problem can be written as Minimize x + x 2 + x 3 + + x n x i + x j (for each edge (i, j) E) x i {0, } (for each vertex i) Note: Above problem is not an LP since above statement is not a linear constraint The above problem is actually an Integer Linear Problem or IP Solving an IP is NP-Complete Let us now relax our second constraint to 0 x i for each i and allow x i R Here we are violating our original inequality direction, since x i We can easily fix this problem by restating our constraint as: Example x i 0 (for each vertex i) x i (for each vertex i) Minimize X + X 2 + X 3 + X 4 + X 5 Page 2 of 6
CS 05: Algorithms (Grad) X + X 2 X + X 3 X 2 + X 3 X 2 + X 4 X 4 + X 5 X 0 X X 2 0 X X 5 0 X 5 This can be rewritten in matrix form as: Y X Z where Y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Page 3 of 6
CS 05: Algorithms (Grad) Figure 2: Possible real valued LP solution for constraints on X X 5 in our example 09 06 04 04 09 X = Z = X X 2 X 3 X 4 X 5 t 0 0 0 Proposed Algorithm: LP Rounding Algorithm for Vertex Cover Algorithm : VertexCover(V, E) Construct LP relaxation for given instance (V, E) Invoke polynomial time LP solver to get a vector X R n that minimizes n 2 3 C 4 for i = to n do 5 if x i /2 Then C C {i}; 6 return C x i Page 4 of 6
CS 05: Algorithms (Grad) Let us now verify that the above algorithm is correct and analyze its optimality Claim : Returned set C of vertices is a Vertex Cover We know from our constraints that (i, j) E that x i + x j Therefore at least one of x i or x j /2 and so at least one of the vertices i, j from the edge (i, j) must C Hence the claim is proved Let our Cost function be: Cost(X) = X Claim 2: If C is the min cost vertex cover then the cost of (C) 2 cost(c ) In other words the LP rounding algorithm is a 2-approximation Proof: Let Z = x + x 2 + x 3 + + x n Z is the Cost of the LP s optimal solution ( This is the sum of real numbers and not the size of any set) Since X is optimal for the LP: Z Cost(C ) () The binary solution x obtained from C ie Set variables in x i as 0 or depending on the optimal solution x i x i OptimumLP Optimum IP Let x = (x, x 2, x 3,, x n ) be the IP solution implicitly produced by the algorithm x i 2x i i = x i 2 x i (2) = Cost(C) 2Z (3) From inequalities () and (3) we get = Cost(C) 2 Cost(C ) Thus proved that the LP rounding algorithm is a 2-approximation Page 5 of 6
CS 05: Algorithms (Grad) Figure 3: Possible solution considering min cost of vertex cover 9 4! 3! 6! 8 23 Vertex Cover considering cost of a vertex This technique allows us to incorporate the idea of cost of a vertex into our model and find a vertex cover of minimum total cost Inequality (2) would need to be changed from x i 2 to c i x i 2 x i c i x i Here in our example in Figure 3 our cost = 3 + 6 + 4 = 3 is minimum possible of costs of all minimum vertex covers Page 6 of 6