Homework Assignment 4 Solutions 1 Probabilistic Algorithm
Total Page:16
File Type:pdf, Size:1020Kb
MTAT.03.286: Advanced Methods in Algorithms University of Tartu Homework Assignment 4 Solutions 1 Probabilistic algorithm 1. Let S = fx1; x2; ··· ; xng be a set of Boolean variables of size n ≥ 1. Definitions (reminder): • An atom is a Boolean variable from S. For example, x3 is an atom (when n ≥ 3). • A literal is an atom or its negation. For example, x5 and :x2 are two literals. • A clause is a disjunction of literals. For example, (:x1 _ x3 _:x4) is a clause. • A conjunctive normal form (CNF) formula is a conjunction of some clauses. For example, (x1 _ x2 _ x3) ^ (:x1 _ x3 _:x4) ^ (x2 _ x17) is a CNF formula. Let φ(x1; x2; ··· ; xn) be a CNF formula with m clauses, where each clause contains exactly k different literals, and m and k are positive integers. (a) Propose a simple probabilistic algorithm that finds an assignment of True/False to vari- ables in S, which satisfies the formula φ. The failure probability of the proposed algo- m rithm should be at most 2k . Hint: if E1; E2; ··· ; Em are random events, then (by the union bound): m X Prob (E1 [E2 [···[Em) ≤ Prob(Ei) : i=1 (b) How many parallel runs of the algorithm are needed in order to make the probability of 1 a failure at most 2t , where t ≥ 1 is a parameter? (c) Show an example of φ, which has no satisfying assignment for m = 2k. 1.1 Algorithm The algorithm has exactly one step: • For each variable xi assign a bit value uniformly randomly. Report the obtained assignment as the satisfying assignment for φ. To analyse the probability to that for each clause there is at most one assignment of variables where it is false. There can be clauses containing both literals xi and :xi that are always true. 1 Each clause that does not contain pairs of xi and :xi contains each variable exactly once, therefore there are k different variables involved. The algorithm picks each of these variables uniformly at random, therefore the probability that for a fixed clause the algorithm finds an assignment where 1 the clause is false, is 2k . Let Ei be the event that clause i evaluates to False. The formula φ is False exactly if any of the events Ei happens and this corresponds to the case where the proposed 1 algorithm returns a wrong result. We have Prob(Ei) ≤ 2k as Prob(Ei) = 0 if the clause contains both a variable and its negation. Using union bound we get the following: m m X X 1 m Prob(error) = Prob (E [E [···[E ) ≤ Prob(E ) ≤ = ; : 1 2 m i 2k 2k i=1 i=1 1.2 Parallel runs Firstly, note that it is reasonable to consider improving the probability by parallel independent runs m k only if 2k < 1. Hence, we have that m < 2 . Furthermore, each parallel instance is independent, m ` therefore the probability that ` parallel instances all fail is 2k . Therefore, the question becomes to solve m ` 1 ≤ : 2k 2t Which can be solved by taking a logarithm to obtain t ` ≥ : k − log2 m 1.3 Example of no satisfying assignment For m = 2k we can start from the small examples, such as k = 1 and one variable where the formula x^ 6= x is always false and we can generalize this. In any formula that has k variables and m distinct clauses that have each variable exactly once, they have no satisfying assignment. This is because there are 2k different clauses of k variables (each time we either pick a variable or its negation into the clause) and then for each assignment of the variables exactly one clause will be false. 2 Maximum flow LP Consider the following flow network N . 1. Write the problem of finding maximum flow from s to t in N as a linear program. What is the value of the objective function? 2 2. Write down the dual of this linear program. There should be a dual variable for each edge of the network and for each vertex other than s and t. Now, consider a general flow network. Recall the linear program formulation for a general maximum flow problem, which was shown in the class. 3. Write down the dual of this general flow linear-programming problem, using a variable ye for each edge and xu for each vertex u 6= s; t. 4. Show that any solution to the general dual problem must satisfy the following property: for any directed path from s to t in the network, the sum of ye values along the path must be at least 1. 2.1 Maximum flow Let's use a variable fe to denote the flow in each edge e. The objective function is to maximize the incoming flow in vertex t and in this example it has no outgoing edges, therefore it is max fb;t − ft;a − ft;s. For each edge, we have to satisfy the edge rule, giving us the following constraints. fs;a ≤ 3 fa;b ≤ 6 fb;t ≤ 2 ft;a ≤ 4 ft;s ≤ 1 fs;a ≥ 0 fa;b ≥ 0 fb;t ≥ 0 ft;a ≥ 0 ft;s ≥ 0 In addition, the flow must satisfy the vertex rule for a and b. fs;a − fa;b + ft;a = 0 fa;b − fb;t = 0 3 In total the problem becomes max fb;t − ft;a − ft;s s. t. fs;a − fa;b + ft;a= 0 fa;b − fb;t = 0 fs;a ≤ 3 fa;b ≤ 6 fb;t ≤ 2 ft;a ≤ 4 ft;s ≤ 1 fs;a ≥ 0 fa;b ≥ 0 fb;t ≥ 0 ft;a ≥ 0 ft;s ≥ 0 The value of the maximum flow is 2 and we can find it either using any flow algorithms or by solving the linear program. 2.2 Dual problem To find the dual problem, let's at first reformat the primal problem to make the matrix A more explicit. In addition, let's use variable xv for each vertex rule of v and ye for each edge rule on edge e. max fb;t −ft;a −ft;s s. t. fs;a −fa;b +ft;a = 0 xa fa;b −fb;t = 0 xb fs;a ≤ 3 ys;a fa;b ≤ 6 ya;b fb;t ≤ 2 yb;t ft;a ≤ 4 yt;a ft;s ≤ 1 yt;s fs;a; fa;b; fb;t; ft;a; ft;s ≥ 0 It is straightforward to write out the dual problem using the columns for the matrix A that describes the constraints. In addition, all our initial variables have the non-negativity constraint meaning that all resulting constraints in the dual problem are inequalities. However, in the dual problem we only have non-negativity constraints for ye variables for every edge e as these correspond to inequalities of the primal problem, but the xv variables are unbounded. 4 min 3ys;a + 6ya;b + 2yb;t + 4yt;a + yt;s s. t. xa + ys;a ≥ 0 − xa + xb + ya;b ≥ 0 − xb + yb;t ≥ 1 xa + yt;a ≥ −1 yt;s ≥ −1 ys;a ≥ 0 yt;s ≥ 0 ya;b ≥ 0 yb;t ≥ 0 yt;a ≥ 0 2.3 Dual of the general problem The general linear program for a flow network N(G(V; E); s; t; c) can be written out using a variable fe for each e 2 E that denotes the flow in the corresponding edge. X X max fe − fe e2in(t) e2out(t) s. t. 8e 2 E : fe ≤ c(e) X X 8v 2 V n fs; tg : fe − fe = 0 e2in(v) e2out(v) 8e 2 E : fe ≥ 0 The initial problem has jV n fs; tgj equalities and jEj inequalities if we do not count the basic restrictions for fe ≥ 0. Hence, the dual problem will have jV nfs; tgj+jEj variables. As we have the constraint fe ≥ 0 for all initial variables then we know that all the constraints in the dual problem will be inequalities. We use a variable ye for each edge e and xu for each vertex u that is not a source or the sink. Here xu corresponds to the equality for the vertex rule of u and ye corresponds to the inequality for the edge rule of e. We assume that there are no self loops because these are not interesting for maximum flow problems. The objective function becomes minimizing X c(e) · ye : e2E The constraints will be divided based on to which edge the derived inequality corresponds to. 5 We will get one constraint for each edge in the graph. The main difference between them is if the edge is connected to the source or sink or not. For each edge that has one endpoint in the sink t we know that it was also used in the initial objective function, therefore the corresponding inequality will have the form ::: ≥ 1 or ::: ≥ −1. The rest of the equations will have the form ::: ≥ 0. The most special edges are between s and t because they are not part of any vertex rule, but participate in the objective function. Therefore, we only have some rule for the edges as y(s;t) ≥ 1 and y(t;s) ≥ −1. For each e = (u; t) 2 E, u 2 V we have −xu + ye ≥ 1. Because initially fe is used in two constraints, one for the vertex rule of u and the other for the edge rule of e. In addition it is used in the objective function with a positive sign.