=========================================================================== CSC 373H / L0101 Lecture Summary for Week 10 Winter 2005 =========================================================================== Network flow examples: - Project selection (continued): See section 7.10 in textbook. ------------------ Linear Programming ------------------ "linear program" = optimization problem that consists of: - "objective function": c_1 x_1 + c_2 x_2 + ... + c_n x_n c_i constants, x_i variables (all over real numbers) - "constraints": linear, i.e., of the form a_{i,1} x_1 + a_{i,2} x_2 + ... + a_{i,n} x_n <= / = / >= b_i for i = 1, 2, ..., m. - problem: find real values of x_i's that maximize/minimize objective function and satisfy all constraints. - "Integer programming": all constants and variables are integers. NP-complete. Examples: - "Political problem" example from "Introduction to Algorithms, 2nd ed." by Cormen et al., pp. 770-772. - Shortest paths: Given graph G=(V,E) with weights w(e) for all e in E, construct linear program with variables d_v for each v in V: maximize: d_t subject to: d_v <= d_u + w(u,v) for each (u,v) in E d_s = 0 Minimizing d_t doesn't work because it allows settings of d_v smaller than true distances (e.g., d_v = 0 for all v in V). Maximizing works because constraints force d_v to be no more than shortest distance and maximization forces d_v to be at least shortest distance, for all v. - Network flows: Given network N=(V,E) with capacities c(e) for e in E, construct linear program with variables f_e for each e in E: maximize: SUM_{e in E+(s)} f_e subject to: f_e <= c(e) for all e in E SUM_{e in E-(v)} f_e = SUM_{e in E+(v)} f_e for all v in V where E-(v) = in-edges of vertex v and E+(v) = out-edges of vertex v, for all v in V. This is a direct re-statement of network flow problem. - Vertex Cover: . Problem definition: Input: Undirected graph G=(V,E). Output: Subset of vertices C that "covers" every edge (i.e., each edge has at least one endpoint in C), with minimum size. . Representing as integer program: use variable x_i for each vertex v_i in V minimize: x_1 + x_2 + ... + x_n subject to: x_i + x_j >= 1 for all (v_i,v_j) in E x_i in {0,1} for all v_i in V Integer program is completely equivalent to original problem, including NP-completeness (so no polytime algorithm). . Linear relaxation: remove restriction of x_i to integer values minimize: x_1 + x_2 + ... + x_n subject to: x_i + x_j >= 1 for all (v_i,v_j) in E 0 <= x_i <= 1 for all v_i in V Solution can be found in polytime, but may include fractional values of x_i's. Example: G=(V,E) where V={1,2,3}, E={(1,2),(2,3),(1,3)} becomes minimize: x_1 + x_2 + x_3 subject to: x_1 + x_2 >= 1 x_2 + x_3 >= 1 x_1 + x_3 >= 1 0 <= x_1, x_2, x_3 <= 1 with solution x_1 = x_2 = x_3 = 1/2. . Rounding: Compute optimal solution to linear program: x'_1, x'_2, ..., x'_n. Create cover as follows: for each v_i in V, put v_i in C iff x'_i >= 1/2. C is a cover because constraint x_i + x_j >= 1 guarantees at least one of x'_i, x'_j >= 1/2 for each edge (v_i,v_j). . 2-approximation bound: Consider minimum vertex cover C*. For i = 1,...,n, let x*_i = 1 if v_i in C*; x*_i = 0 otherwise. x*_1, ..., x*_n is a solution to linear program that satisfies all constraints with 0-1 values so SUM x'_i <= SUM x*_i = |C*| (since x'_i is optimal solution to linear program with no restriction on values). For i = 1,...,n, let x~_i = 1 if x'_i >= 1/2; x~_i = 0 othewise. Then, for each i, x~_i <= 2 x'_i so |C| = SUM x~_i <= 2 SUM x'_i <= 2 |C*| (by equation above) Hence, |C| is no more than twice the size of a minimum vertex cover. - Weighted vertex cover: section 11.6 (simple generalization).