{"title": "Near-Uniform Sampling of Combinatorial Spaces Using XOR Constraints", "book": "Advances in Neural Information Processing Systems", "page_first": 481, "page_last": 488, "abstract": null, "full_text": "Near-Uniform Sampling of Combinatorial Spaces Using XOR Constraints\nCarla P. Gomes Ashish Sabharwal Bart Selman Department of Computer Science Cornell University, Ithaca NY 14853-7501, USA {gomes,sabhar,selman}@cs.cornell.edu \n\nAbstract\nWe propose a new technique for sampling the solutions of combinatorial problems in a near-uniform manner. We focus on problems specified as a Boolean formula, i.e., on SAT instances. Sampling for SAT problems has been shown to have interesting connections with probabilistic reasoning, making practical sampling algorithms for SAT highly desirable. The best current approaches are based on Markov Chain Monte Carlo methods, which have some practical limitations. Our approach exploits combinatorial properties of random parity (X O R) constraints to prune away solutions near-uniformly. The final sample is identified amongst the remaining ones using a state-of-the-art SAT solver. The resulting sampling distribution is provably arbitrarily close to uniform. Our experiments show that our technique achieves a significantly better sampling quality than the best alternative.\n\n1\n\nIntroduction\n\nWe present a new method, XORSample, for uniformly sampling from the solutions of hard combinatorial problems. Although our method is quite general, we focus on problems expressed in the Boolean Satisfiability (SAT) framework. Our work is motivated by the fact that efficient sampling for SAT can open up a range of interesting applications in probabilistic reasoning [ 6, 7, 8, 9, 10, 11]. There has also been a growing interest in combining logical and probabilistic constraints as in the work of Koller, Russell, Domingos, Bacchus, Halpern, Darwiche, and many others (see e.g. statistical relational learning and Markov logic networks [1]), and a recently proposed Markov logic system for this task uses efficient SAT sampling as its core reasoning mechanism [ 2]. Typical approaches for sampling from combinatorial spaces are based on Markov Chain Monte Carlo (MCMC) methods, such as the Metropolis algorithm and simulated annealing [ 3, 4, 5]. These methods construct a Markov chain with a predefined stationary distribution. One can draw samples from the stationary distribution by running the Markov chain for a sufficiently long time. Unfortunately, on many combinatorial problems, the time taken by the Markov chain to reach its stationary distribution scales exponentially with the problem size. MCMC methods can also be used to find (globally optimal) solutions to combinatorial problems. For example, simulated annealing (SA) uses the Boltzmann distribution as the stationary distribution. By lowering the temperature parameter to near zero, the distribution becomes highly concentrated around the minimum energy states, which correspond to the solutions of the combinatorial problem under consideration. SA has been successfully applied to a number of combinatorial search problems. However, many combinatorial problems, especially those with intricate constraint structure, are beyond the reach of SA and related MCMC methods. Not only does problem structure make reaching the stationary distribution prohibitively long, even reaching a single (optimal) solution is often infeasible. Alternative combinatorial search techniques have been developed that are much more effective at finding solutions. These methods generally exploit clever search space pruning\nwork was supported by the Intelligent Information Systems Institute (IISI) at Cornell University (AFOSR grant F49620-01-1-0076) and DARPA (REAL grant FA8750-04-2-0216).\n This\n\n\f\ntechniques, which quickly focus the search on small, but promising, parts of the overall combinatorial space. As a consequence, these techniques tend to be highly biased, and sample the set of solutions in an extremely non-uniform way. (Many are in fact deterministic and will only return one particular solution.) In this paper, we introduce a general probabilistic technique for obtaining near-uniform samples from the set of all (globally optimal) solutions of combinatorial problems. Our method can use any state-of-the-art specialized combinatorial solver as a subroutine, without requiring any modifications to the solver. The solver can even be deterministic. Most importantly, the quality of our sampling method is not affected by the possible bias of the underlying specialized solver -- all we need is a solver that is good at finding some solution or proving that none exists. We provide theoretical guarantees for the sampling quality of our approach. We also demonstrate the practical feasibility of our approach by sampling near-uniformly from instances of hard combinatorial problems. As mentioned earlier, to make our discussion more concrete, we will discuss our method in the context of SAT. In the SAT problem, we have a set of logical constraints on a set of Boolean (True/False) variables. The challenge is to find a setting of the variables such that all logical constraints are satisfied. SAT is the prototypical NP-complete problem, and quite likely the most widely studied combinatorial problem in computer science. There have been dramatic advances in recent years in the state-of-the-art of SAT solvers [e.g. 12, 13, 14]. Current solvers are able to solve problems with millions of variables and constraints. Many practical combinatorial problems can be effectively translated into SAT. As a consequence, one of the current most successful approaches to solving hard computational problems, arising in, e.g., hardware and software verification and planning and scheduling, is to first translate the problem into SAT, and then use a state-of-the-art SAT solver to find a solution (or show that it does not exist). As stated above, these specialized solvers derive much of their power from quickly focusing their search on a very small part of the combinatorial space. Many SAT solvers are deterministic, but even when the solvers incorporate some randomization, solutions will be sampled in a highly non-uniform manner. The central idea behind our approach can be summarized as follows. Assume for simplicity that our original SAT instance on n Boolean variables has 2s solutions or satisfying assignments. How can we sample uniformly at random from the set of solutions? We add special randomly generated logical constraints to our SAT problem. Each random constraint is constructed in such a way that it rules out any given truth assignment exactly with probability 1/2 . Therefore, in expectation, after adding s such constraints, we will have a SAT instance with exactly one solution. 1 We then use a SAT solver to find the remaining satisfying assignment and output this as our first sample. We can repeat this process with a new set of s randomly generated constraints and in this way obtain another random solution. Note that to output each sample, we can use whatever off-the-shelf SAT solver is available, because all it needs to do is find the single remaining assignment.2 The randomization in the added constraints will guarantee that the assignment is selected uniformly at random. How do we implement this approach? For our added constraints, we use randomly generated parity or \"exclusive-or\" (X O R) constraints. In recent work, we introduced X O R constraints for the problem of counting the number of solutions using MBound [15]. Although the building blocks of MBound and XORSample are the same, this work relies much more heavily on the properties of X O R constraints, namely, pairwise and even 3-wise independence. As we will discuss below, an X O R constraint eliminates any given truth assignment with probability 1/2 , and therefore, in expectation, cuts the set of satisfying assignments in half. For this expected behavior to happen often, the elimination of each assignment should ideally be fully independent of the elimination of other assignments. Unfortunately, as far as is known, there are no compact (polynomial size) logical constraints that can achieve such complete independence. However, X O R constraints guarantee at least pairwise independence, i.e., if we know that an X O R constraint C eliminates assignment 1 , this provides no information as to whether C will remove any another assignment 2 . Remarkably, as we will see, such pairwise independence already leads to near-uniform sampling. Our sampling approach is inspired by earlier work in computational complexity theory by Valiant and Vazirani [16], who considered the question whether having one or more assignments affects\n1 Of course, we don't know the true value of s. In practice, we use a binary style search to obtain a rough estimate. As we will see, our algorithms work correctly even with over- and under-estimates for s. 2 The practical feasibility of our approach exploits the fact that current SAT solvers are very effective in finding such truth assignments in many real-world domains.\n\n\f\nthe hardness of combinatorial problems. They showed that, in essence, the number of solutions should not affect the hardness of the problem instances in the worst case [16]. This was received as a negative result because it shows that finding a solution to a Unique SAT problem (a SAT instance that is guaranteed to have at most one solution) is not any easier than finding a solution to an arbitrary SAT instance. Our sampling strategy turns this line of research into a positive direction by showing how a standard SAT solver, tailored to finding just one solution of a SAT problem, can now be used to sample near-uniformly from the set of solutions of an arbitrary SAT problem. In addition to introducing XORSample and deriving theoretical guarantees on the quality of the samples it generates, we also provide an empirical validation of our approach. One question that arises is whether the state-of-the-art SAT solvers will perform well on problem instances with added X O R (or parity) constraints. Fortunately, as our experiments show, a careful addition of such constraints does generally not degrade the performance of the solvers. In fact, the addition of X O R constraints can be beneficial since the constraints lead to additional propagation that can be exploited by the solvers.3 Our experiments show that we can effectively sample near-uniformly from hard practical combinatorial problems. In comparison with the best current alternative method on such instances, our sampling quality is substantially better.\n\n2\n\nPreliminaries\n\nFor the rest of this paper, fix the set of propositional variables in all formulas to be V , |V | = n. A variable assignment : V {0, 1} is a function that assigns a value in {0, 1} to each variable in V . We may think of the value 0 as FA L S E and the value 1 as T RU E. We will often abuse notation and write (i) for valuations of entities i V when the intended meaning is either already defined or is clear from the context. In particular, (1) = 1 and (0) = 0. When (i) = 1, we say that satisfies i. For x V , x denotes the corresponding negated variable; (x) = 1 - (x). Let F be a formula over variables V . (F ) denotes the valuation of F under . If satisfies F , i.e., (F ) = 1, then is a model, solution, or satisfying assignment for F . Our goal in this paper is to sample uniformly from the set of all solutions of a given formula F . An X O R constraint D over variables V is the logical \"xor\" or parity of a subset of V {1}; satisfies D if it satisfies an odd number of elements in D. The value 1 allows us to express even parity. For instance, D = {a, b, c, 1} represents the xor constraint a b c 1, which is T RU E when an even number of a, b, c are T RU E. Note that it suffices to use only positive variables. E.g., a b c and a b are equivalent to D = {a, b, c} and D = {a, b, 1}, respectively. Our focus will be on formulas which are a logical conjunction of a formula in Conjunctive Normal Form (CNF) and some X O R constraints. In all our experiments, X O R constraints are translated into CNF using additional variables so that the full formula can be fed directly to standard (CNF-based) SAT solvers. We will need basic concepts from linear algebra. Let F2 denote the field of two elements, 0 and 1, and Fn the vector space of dimension n over F. An assignment can be thought of as an element of 2 Fn . Similarly, an X O R constraint D can be seen as a linear constraint a1 x1 + a2 x2 + . . . + an xn + b = 1, 2 where ai , b {0, 1}, + denotes addition modulo 2 for F2 , ai = 1 iff D has variable i, and b = 1 iff D has the parity constant 1. In this setting, we can talk about linear transformations of F n as well as 2 linear independence of , Fn (see standard texts for details). We will use two properties: every 2 linear transformation maps the all-zeros vector to itself, and there exists a linear transformation that maps any k linearly independent vectors to any other k linearly independent vectors. Consider the set X of all X O R constraints over V . Since an X O R constraint is a subset of V {1}, |X | = 2n+1 . Our method requires choosing X O R constraints from X at random. Let X(n, q) denote the probability distribution over X defined as follows: select each v V independently at random with probability q and include the constant 1 independently with probability 1/2 . This produces X O Rs of average length nq. In particular, note that every two complementary X O R constraints involving the same subset of V (e.g., c d and c d 1) are chosen with the same probability irrespective of q. Such complementary X O R constraints have the simple but useful property that any assignment satisfies exactly one of them. Finally, when the distribution X(n,1/2 ) is used, every X O R constraint in X is chosen with probability 2-(n+1) .\nNote that there are certain classes of structured instances based on parity constraints that are designed to be hard for SAT solvers [17]. Our augmented problem instances appear to behave quite differently from these specially constructed instances because of the interaction between the constraints in the original instance and the added random parity constraints.\n3\n\n\f\nWe will be interested in the random variables which are the sum of indicator random variables: Y = Y . Linearity of expectation says that E [Y ] = E [Y ]. When various Y are pairwise independent, i.e., knowing Y2 tells us nothing about Y1 , even variance behaves linearly: Var [Y ] = Var [Y ]. We will also need conditional probabilities. Here, for a random event X , linearity of conditional expectation says that E [Y | X ] = E [Y | X ]. Let X = Y0 . When various Y are 3-wise independent, iY ., knowing Y2 anY Y3 tell.s us nothing about Y1 , even conditional variance behaves .e d = linearly: Var | Y0 Var | Y0 This will be key to the analysis of our second algorithm.\n\n3\n\nSampling using X O R constraints\n\nIn this section, we describe and analyze two randomized algorithms, XORSample and XORSample', for sampling solutions of a given Boolean formula F near-uniformly using streamlining with random X O R constraints. Both algorithms are parameterized by two quantities: a positive integer s and a real number q (0, 1), where s is the number of X O Rs added to F and X(n, q) is the distribution from which they are drawn. These parameters determine the degree of uniformity achieved by the algorithms, which we formalize as Theorems 1 and 2. The first algorithm, XORSample, uses a SAT solver as a subroutine on the randomly streamlined formula. It repeatedly performs the streamlining process until the resulting formula has a unique solution. When s is chosen appropriately, it takes XORSample a small number of iterations (on average) to successfully produce a sample. The second algorithm, XORSample', is non-iterative. Here s is chosen to be relatively small so that a moderate number of solutions survive. XORSample' then uses stronger subroutines, namely a SAT model counter and a model selector, to output one of the surviving solutions uniformly at random. 3.1\nX O R -based\n\nsampling using SAT solvers: XORSample\n\nLet F be a formula over n variables, and q and s be the parameters of XORSample. The algorithm works by adding to F , in each iteration, s random X O R constraints Qs drawn independently from the distribution X(n, q). This generates a streamlined formula Fsq whose solutions (called the surviving solutions) are a subset of the solutions of F . If there is a unique surviving solution , XORSample outputs and stops. Otherwise, it discards Qs and Fsq , and iterates the process (rejection sampling). The check for uniqueness of is done by adding the negation of as a constraint to Fsq and testing whether the resulting formula is still satisfiable. See Algorithm 1 for a full description.\nParams: q (0, 1), a positive integer s Input : A CNF formula F Output : A solution of F begin it erat ionSuccess f ul FA L S E while it erat ionSuccess f ul = FA L S E do Qs {s random constraints independently drawn from X(n, q)} q // Add s random X O R constraints to F Fs F Qs q // Solve using a SAT solver result SATSolve(Fs ) if result = T RU E then solution returned by SATSolve (Fsq ) q // Remove from the solution set F Fs { } SATSolve(F ) result if result = FA L S E then it erat ionSuccess f ul = T RU E q return // Output ; it is the unique solution of Fs end\n\nAlgorithm 1: XORSample, sampling solutions with X O Rs using a SAT solver\n\nWe now analyze how uniform the samples produced by XORSample are. For the rest of this section, fix q = 1/2 . Let F be satisfiable and have exactly 2s solutions; s [0, n]. Ideally, we would like each solution of F to be sampled with probability 2-s . Let pone,s ( ) be the probability that XORSample outputs in one iteration. This is typically much lower than 2-s , which is accounted for by rejection sampling. Nonetheless, we will show that when s is larger than s , the variation in pone,s ( ) over different is small. Let ps ( ) be the overall probability that XORSample outputs . This, we will show, is very close to 2-s , where \"closeness\" is formalized as being within a factor of c( ) which approaches 1 very fast. The proof closely follows the argument used by Valiant and\n\n\f\nVazirani [16] in their complexity theory work on unique satisfiability. However, we give a different, non-combinatorial argument for the pairwise independence property of X O Rs needed in the proof, relying on linear algebra. This approach is insightful and will come handy in Section 3.2. We describe the main idea below, deferring details to the full version of the paper. Lemma 1. Let > 0, c( ) = 1 - 2- , and s = s + . Then c( )2-s < pone,s ( ) 2-s . Proof sketch. We first prove the upper bound on pone,s ( ). Recall that for any two complementary X O Rs (e.g. c d and c d 1), satisfies exactly one X O R. Hence, the probability that satisfies an X O R chosen randomly from the distribution X(n, q) is 1/2 . By independence of the s X O Rs in Qs in XORSample, survives with probability exactly 2-s , giving the desired upper bound on pone,s ( ). For the lower bound, we resort to pairwise independence. Let = be two solutions of F . Let D be an X O R chosen randomly from X(n,1/2 ). We use linear algebra arguments to show that the probability that (D) = 1 (i.e., satisfies D) is independent of the probability that (D) = 1. Recall the interpretation of variable assignments and X O R constraints in the vector space F n (cf. 2 Section 2). First suppose that and are linearly dependent. In Fn , this can happen only if exactly 2 one of and is the all-zeros vector. Suppose = (0, 0, . . . , 0) and is non-zero. Perform a linear transformation on Fn so that = (1, 0, . . . , 0). Let D be the constraint a1 x1 + a2 x2 + . . . + an xn + b = 2 1. Then, (D) = a1 + b and (D) = b. Since a1 is chosen uniformly from {0, 1} when D is drawn from X(n,1/2 ), knowing a1 + b gives us no information about b, proving independence. A similar argument works when is non-zero and = (0, 0, . . . , 0), and also when and are linearly independent to begin with. We skip the details. This proves that (D) and (D) are independent when D is drawn from X(n,1/2 ). In particular, Pr [ (D) = 1 | (D) = 1] = 1/2 . This reasoning easily extends to s X O Rs in Qs and we have that Pr [ (Qs ) = 1 | (Qs ) = 1] = 2-s . Now, = pone,s ( ) = Pr (Qs ) = 1 and for all other solutions of F, (Qs ) = 0 1 f . Pr [ (Qs ) = 1] - Pr or some solution = , (Qs ) = 1 | (Qs ) = 1 Evaluating this using the union bound and pairwise independence shows p one,s ( ) > c( ) 2-s .\n\n\nTheorem 1. Let F be a formula with 2s solutions. Let > 0, c( ) = 1 - 2- , and s = s + . For any solution of F , the probability ps ( ) with which XORSample with parameters q = 1/2 and s outputs satisfies 1 c( ) 2-s < ps ( ) < 2-s and min { ps ( )} > c( ) max { ps ( )} . c( ) Further, the number of iterations needed to produce one sample has a geometric distribution with expectation between 2 and 2 /c( ). Proof. Let p denote the probability that XORSample finds some unique solution in any single it^ eration. pone,s ( ), as before, is the probability that is the unique surviving solution. ps ( ), the overall probability of sampling , is given by the infinite geometric series ps ( ) = pone,s ( ) + (1 - p) pone,s ( ) + (1 - p)2 pone,s ( ) + . . . ^ ^ which sums to pone,s ( )/ p. In particular, ps ( ) is proportional to pone,s ( ). ^ Lemma 1 says that for any two solutions 1 and 2 of F , pone,s (1 ) and pone,s (2 ) are strictly within a factor of c( ) of each other. By the above discussion, ps (1 ) and ps (2 ) must also be strictly within a factor of c( ) of each other, already proving the min vs. max part of the result. Further, ps ( ) = 1 because of rejection sampling. For the first part of the result, suppose for the sake of contradiction that ps (0 ) c( )2-s for some 0 , violating the claimed lower bound. By the above argument, ps ( ) is within a factor of c( ) of ps (0 ) for every , and would therefore be at most 2-s . This would make ps ( ) strictly less than one, a contradiction. A similar argument proves the upper bound on ps ( ).\n\n\nFinally, the number of iterations needed to find a unique solution (thereby successfully producing a sample) is a geometric random variable with success parameter p = pone,s ( ), and has expected ^ value 1/ p. Using the bounds on pone,s ( ) from Lemma 1 and the fact that the unique survival of each ^ ^ ^ of the 2s solutions are disjoint events, we have p 2s 2-s = 2- and p > 2s c( )2-s = c( )2- . This proves the claimed bounds on the expected number of iterations, 1/ p. ^\n\n\f\n3.2\n\nX O R -based\n\nsampling using model counters and selectors: XORSample'\n\nWe now discuss our second parameterized algorithm, XORSample', which also works by adding to F s random X O Rs Qs chosen independently from X(n, q). However, now the resulting streamlined formula Fsq is fed to an exact model counting subroutine to compute the number of surviving solutions, mc. If mc > 0, XORSample' succeeds and outputs the it h surviving solution using a model selector on Fsq , where i is chosen uniformly from {1, 2, . . . , mc}. Note that XORSample', in contrast to XORSample, is non-iterative. Also, the model counting and selecting subroutines it uses are more complex than SAT solvers; these work well in practice only because Fsq is highly streamlined.\nParams: q (0, 1), a positive integer s Input : A CNF formula F Output : A solution of F , or Failure begin Qs {s constraints randomly drawn from X(n, p)} q Fs F Qs // Add s random X O R constraints to F q q // Compute the exact model count of Fs mc SATModelCount(Fs ) if mc = 0 then i a random number chosen uniformly from {1, 2, . . . , mc} SATFindSolution(Fsq , i) // Compute the it h solution return // Sampled successfully! else return Failure end Algorithm 2: XORSample', sampling with X O Rs using a model counter and selector\n\nThe sample-quality analysis of XORSample' requires somewhat more complex ideas than that of XORSample. Let F have 2s solutions as before. We again fix q = 1/2 and prove that if the parameter s is sufficiently smaller than s , the sample-quality is provably good. The proof relies on the fact that X O Rs chosen randomly from X(n,1/2 ) act 3-wise independently on different solutions, i.e., knowing the value of an X O R constraint on two variable assignments does not tell us anything about its value on a third assignment. We state this as the following lemma, which can be proved by extending the linear algebra arguments we used in the proof of Lemma 1 (see the full version for details). Lemma 2 (3-wise independence). Let 1 , 2 , and 3 be three distinct assignments to n Boolean variables. Let D be an X O R constraint chosen at random from X(n,1/2 ). Then for i {0, 1}, Pr [1 (D) = i | 2 (D), 3 (D)] = Pr [1 (D) = i]. Recall the discussion of expectation, variance, pairwise independence, and 3-wise independence in Section 2. In particular, when a number of random variables are 3-wise independent, the conditional variance of their sum (conditioned on one of these variables) equals the sum of their individual conditional variances. We use this to compute bounds on the sampling probability of XORSample'. The idea is to show that the number of solutions surviving, given that any fixed solution survives, is independent of in expectation and is highly likely to be very close to the expected value. As a result, the probability with which is output, which is inversely proportional to the number of solutions surviving along with , will be very close to the uniform probability. Here \"closeness\" is one-sided and is measured as being within a factor of c ( ) which approaches 1 very quickly. Theorem 2. Let F be a formula with 2s solutions. Let > 0 and s = s - . For any solution of F , the probability ps ( ) with which XORSample' with parameters q = 1/2 and s outputs satisfies\n\n\nps ( ) > c ( ) 2-s ,\n\n\nwhere c ( ) =\n\n1 - 2- /3 . (1 + 2- )(1 + 2- /3 )\n\nFurther, XORSample' succeeds with probability larger than c ( ). Proof sketch. See the full version for a detailed proof. We begin by setting up a framework for analyzing the number of surviving solutions after s X O Rs Qs drawn from X(n,1/2 ) are added to F . Let Y be the indicator random variable which is 1 iff (Qs ) = 1, i.e., survives Qs . E [Y ] = 2-s and Var [Y ] E [Y ] = 2-s . Further, a straightforward generalization of Lemma 2 from a single X O R constraint D to s independent X O Rs Qs implies that the random variables Y are 3-wise independent. The variable mc (see Algorithm 2), which is the number of surviving solutions, equals Y . Consider the distribution of mc conditioned on the fact that survives. Using pairwise independence, the corresponding conditional expectation can be shows to satisfy: = E [mc | (Q s ) = 1] =\n\n\f\n1 + (2s - 1)2-s . More interesting, using 3-wise independence, the corresponding conditional variation can also be bounded: Var [mc | (Qs ) = 1] < E [mc | (Qs ) = 1].\n\n\nSince s = s - , 2 < < 1 + 2 . We show that mc conditioned on (Qs ) = 1 indeed lies very close to . Let 0 be a parameter whose value we will fix later. By Chebychev's inequality, | 22 Var [mc | (Q ) = 1] 22 2 2 s Pr mc - | | (Qs ) = 1 < = (E [mc | (Qs ) = 1])2 E [mc | (Qs ) = 1] 2 Therefore, conditioned on (Qs ) = 1, with probability more than 1 - 22 / , mc lies between (1 - 2- ) and (1 + 2- ) . Recall that ps ( ) is the probability that XORSample' outputs . ps ( ) = Pr [ (Qs ) = 1] 2-s Pr m\ni=1\n\n Pr [mc = i | (Qs ) = 1] i\n\nn\n\n1 1 2-s 1 - 22 / (1 + 2- )\n\nc (1 + 2- ) | (Qs ) = 1\n\n(1 + 2- )\n\nSimplifying this expression and optimizing it by setting = /3 gives the desired bound on p s ( ). Lastly, the success probability of XORSample' is ps ( ) > c ( ). Remark 1. Theorems 1 and 2 show that both XORSample and XORSample' can be used to sample arbitrarily close to the uniform distribution when q = 1/2 . For example, as the number of X O Rs used in XORSample is increased, increases, the deviation c( ) from the truly uniform sampling probability p approaches 0 exponentially fast, and we get progressively smaller error bands around p . However, for any fixed , these algorithms, somewhat counter-intuitively, do not always sample truly uniformly (see the full version). As a result, we expect to see a fluctuation around p , which, as we proved above, will be exponentially small in .\n\n4\n\nEmpirical validation\n\nTo validate our X O R-sampling technique, we consider two kinds of formulas: a random 3-SAT instance generated near the SAT phase transition [18] and a structured instance derived from a logistics planning domain (data and code available from the authors). We used a complete model counter, Relsat [12], to find all solutions of our problem instances. Our random instance with 75 variables has a total of 48 satisfying assignments, and our logistics formula with 352 variables has 512 satisfying assignments. (We used formulas with a relatively small number of assignments in order to evaluate the quality of our sampling. Note that we need to draw many samples for each assignment.) We used XORSample with MiniSat [14] as the underlying SAT solver to generate samples from the set of solutions of each formula. Each sample took a fraction of a second to generate on a 4GHz processor. For comparison, we also ran the best alternative method for sampling from SAT problems, SampleSAT [19, 2], allowing it roughly the same cumulative runtime as XORSample. Figure 1 depicts our results. In the left panel, we consider the random SAT instance, generating 200,000 samples total. In pure uniform sampling, in expectation we have 200, 000/48 4, 167 samples for each solution. This level is indicated with the solid horizontal line. We see that the samples produced by XORSample all lie in a narrow band centered around this line. Contrast this with the results for SampleSAT: SampleSAT does sample quite uniformly from solutions that lie near each other in Hamming distance but different solution clusters are sampled with different frequencies. This SAT instance has two solution clusters: the first 32 solutions are sampled around 2, 900 times each, i.e., not frequently enough, whereas the remaining 16 solutions are sampled too frequently, around 6,700 times each. (Although SampleSAT greatly improves on other sampling strategies for SAT, the split into disjoint sampling bands appears inherent in the approach.) The Kullback-Leibler (KL) divergence between the XORSample data and the uniform distribution is 0.002. For SampleSAT the KL-divergence from uniform is 0.085. It is clear that the XORSample approach leads to much more uniform sampling. The right panel in Figure 1 gives the results for our structured logistics planning instance. (To improve the readability of the figure, we plot the sample frequency only for every fifth assignment.) In this case, the difference between XORSample and SampleSAT is even more dramatic. SampleSAT in fact only found 256 of the 512 solutions in a total of 100,000 samples. We also see that one of these solutions is sampled nearly 60,000 times, whereas many other solutions are sampled less than\n\n\f\nAbsolute Frequency (log scale)\n\nAbsolute Frequency (log scale)\n\n10000\n\nXORsample SampleSat uniform\n\n100000\n\nXORSample SampleSat uniform\n\n10000\n\n1000\n\n100\n\n10\n\n1000\n\n1 0 10 20\n\nSolution #\n\n30\n\n40\n\n50\n\n0\n\n100\n\n200\n\nSolution #\n\n300\n\n400\n\n500\n\nFigure 1: Results of XORSample and SampleSAT on a random 3-SAT instance, the left panel, and a logistics planning problem, the right panel. (See color figures in PDF.) five times. The KL divergence from uniform is 4.16. (Technically the KL divergence is infinite, but we assigned a count of one to the non-sampled solutions.) The expected number of samples for each assignment is 100, 000/512 195. The figure also shows that the sample counts from XORSample all lie around this value; their KL divergence from uniform is 0.013. These experiments show that XORSample is a promising practical technique (with theoretical guarantees) for obtaining near-uniform samples from intricate combinatorial spaces. References\n[1] M. Richardson and P. Domingos. Markov logic networks. Machine Learning, 62(1-2):107136, 2006. [2] H. Poon and P. Domingos. Sound and efficient inference with probabilistic and deterministic dependencies. In 21th AAAI, pages 458463, Boston, MA, July 2006. [3] N. Madras. Lectures on Monte Carlo methods. In Field Institute Monographs, vol. 16. Amer. Math. Soc., 2002. [4] N. Metropolis, A. Rosenbluth, M. Rosenbluth, A. Teller, and E. Teller. Equations of state calculations by fast computing machines. J. Chem. Phy., 21:10871092, 1953. [5] S. Kirkpatrick, D. Gelatt Jr., and M. Vecchi. Optimization by simuleated annealing. Science, 220(4598): 671680, 1983. [6] D. Roth. On the hardness of approximate reasoning. J. AI, 82(1-2):273302, 1996. [7] M. L. Littman, S. M. Majercik, and T. Pitassi. Stochastic Boolean satisfiability. J. Auto. Reas., 27(3): 251296, 2001. [8] J. D. Park. MAP complexity results and approximation methods. In 18th UAI, pages 388396, Edmonton, Canada, August 2002. [9] A. Darwiche. The quest for efficient probabilistic inference, July 2005. Invited Talk, IJCAI-05. [10] T. Sang, P. Beame, and H. A. Kautz. Performing Bayesian inference by weighted model counting. In 20th AAAI, pages 475482, Pittsburgh, PA, July 2005. [11] F. Bacchus, S. Dalmao, and T. Pitassi. Algorithms and complexity results for #SAT and Bayesian inference. In 44nd FOCS, pages 340351, Cambridge, MA, October 2003. [12] R. J. Bayardo Jr. and R. C. Schrag. Using CSP look-back techniques to solve real-world SAT instances. In 14th AAAI, pages 203208, Providence, RI, July 1997. [13] L. Zhang, C. F. Madigan, M. H. Moskewicz, and S. Malik. Efficient conflict driven learning in a Boolean satisfiability solver. In ICCAD, pages 279285, San Jose, CA, November 2001. [14] N. Een and N. Sorensson. MiniSat: A SAT solver with conflict-clause minimization. In 8th SAT, St. Andrews, U.K., June 2005. Poster. [15] C. P. Gomes, A. Sabharwal, and B. Selman. Model counting: A new strategy for obtaining good bounds. In 21th AAAI, pages 5461, Boston, MA, July 2006. [16] L. G. Valiant and V. V. Vazirani. NP is as easy as detecting unique solutions. Theoretical Comput. Sci., 47(3):8593, 1986. [17] J. M. Crawford, M. J. Kearns, and R. E. Schapire. The minimal disagreement parity problem as a hard satisfiability problem. Technical report, AT&T Bell Labs., 1994. [18] D. Achlioptas, A. Naor, and Y. Peres. Rigorous location of phase transitions in hard optimization problems. Nature, 435:759764, 2005. [19] W. Wei, J. Erenrich, and B. Selman. Towards efficient sampling: Exploiting random walk strategies. In 19th AAAI, pages 670676, San Jose, CA, July 2004.\n\n\f\n", "award": [], "sourceid": 3013, "authors": [{"given_name": "Carla", "family_name": "Gomes", "institution": null}, {"given_name": "Ashish", "family_name": "Sabharwal", "institution": null}, {"given_name": "Bart", "family_name": "Selman", "institution": null}]}