Estimating the Volume of the Solution Space of SMT(LIA) Constraints by a Flat Histogram Method

: The satisﬁability modulo theories (SMT) problem is to decide the satisﬁability of a logical formula with respect to a given background theory. This work studies the counting version of SMT with respect to linear integer arithmetic (LIA), termed SMT(LIA). Speciﬁcally, the purpose of this paper is to count the number of solutions (volume) of a SMT(LIA) formula, which has many important applications and is computationally hard. To solve the counting problem, an approximate method that employs a recent Markov Chain Monte Carlo (MCMC) sampling strategy called “ﬂat histogram” is proposed. Furthermore, two reﬁnement strategies are proposed for the sampling process and result in two algorithms, MCMC-Flat 1/2 and MCMC-Flat 1/t , respectively. In MCMC-Flat 1/t , a pseudo sampling strategy is introduced to evaluate the ﬂatness of histograms. Experimental results show that our MCMC-Flat 1/t method can achieve good accuracy on both structured and random instances, and our MCMC-Flat 1/2 is scalable for instances of convex bodies with up to 7 variables.


Introduction
Satisfiability Modulo Theories (SMT) considers the satisfiability of a formula specified in a fragment of the first order logic with some kind of background theory [1]. One of those important theories is linear integer arithmetic (LIA). An atom in a SMT(LIA) formula is an inequation of LIA. A valuation on variables of the formula that evaluates the formula to true, is called a model (a.k.a. a solution).
Counting the number of models of a SMT(LIA) formula, #SMT(LIA), is theoretically hard. In the simple case, if all the LIA constraints are joined only by conjunctions, #SMT(LIA) reduces to the problem of computing the volume of convex bodies [2] which is shown to be #P-Complete [3]. However, the #SMT(LIA) problem considered in this paper supports formulas with arbitrary Boolean structures.
#SMT(LIA) has valuable applications in various areas, including approximate reasoning [4], program analysis [5] and verification [6,7]. Let us first consider an approximate reasoning problem. Suppose there is a knowledge base specified by a SMT(LIA) formula φ, and a formula ϕ is given. If neither ϕ nor ¬ϕ is a logical consequence of φ, then it is reasonable to assume that the more models of φ support ϕ the more likely ϕ is true. Another important application of #SMT(LIA) is in the static analysis techniques of programs. One such technique is to check the program's properties by processing individual paths in the program's flow graph [8,9]. However, not all paths in the graph correspond to program executions. A path is called feasible if there are some values of the variables that can drive the program to be executed along that path. Otherwise, the path is called infeasible. There

Backgrounds
In this section, we first describe the #SMT(LIA) problem and its application in hot/cold path analysis, and then introduce the flat histogram method.

SMT(LIA) Formulas and Their Solution Spaces
Definition 1. A linear integer arithmetic (LIA) constraint is an expression of the form a 1 x 1 + a 2 x 2 + . . . + a n x n ∞ a 0 , where {x 1 , x 2 , . . . , x n } are numeric variables that take integer values, {a 1 , a 2 , . . . , a n } are constant coefficients (reals or integers), and the operator ∞ ∈ {≥, >, =, =, <, ≤}. A LIA constraint is also called an SMT(LIA) atom.   For example, the SMT(LIA) formula φ in Example 1 has a propositional skeleton PS(φ): b 1 ∧ (b 2 ∨ b 3 ), which contains two clauses: b 1 , and b 2 ∨ b 3 . To avoid confusion, we call x i numeric variables, and call b i Boolean variables. Definition 4. The solution (model) of a SMT(LIA) formula φ is a valuation on numeric variables in φ that evaluates φ to true. And the volume of φ is the number of its solutions, denoted by Vol(φ). The problem of computing the volume of a SMT(LIA) formula is denoted as #SMT(LIA).

Hot/Cold Path Analysis
To show the practical importance of #SMT(LIA), we introduce a program analysis problem that can be translated into a #SMT(LIA) problem. In Figure 1, there is a path executing i = 5, and the other executing i = 6. We are interested in which path is the hot path. To solve this problem, we consider two SMT(LIA) formulas.

•
The condition of the second path is the logical complement of the first condition.

Hot/Cold Path Analysis
To show the practical importance of #SMT(LIA), we introduce a program analysis problem that can be translated into a #SMT(LIA) problem. In Figure 1, there is a path executing i = 5, and the other executing i = 6. We are interested in which path is the hot path. To solve this problem, we consider two SMT(LIA) formulas.

•
The condition of the second path is the logical complement of the first condition.

Volumes of Convex Bodies and SMT(LIA) Formulas
In this subsection, we explain the differences between the volume computation problem of a convex body and that of a SMT(LIA) formula. A convex body is defined by a conjunction of several LIA constraints. For example, the area with mosaics in Figure 2a is a convex body, and it is defined by: Note that the boundaries of x1 and x2 ([−128, 127]) are indicated by a square with broken lines, and the volume of the body is the number of value pairs for x1 and x2 that satisfy all the LIA constraints.

Volumes of Convex Bodies and SMT(LIA) Formulas
In this subsection, we explain the differences between the volume computation problem of a convex body and that of a SMT(LIA) formula. A convex body is defined by a conjunction of several LIA constraints. For example, the area with mosaics in Figure 2a is a convex body, and it is defined by: Note that the boundaries of x 1 and x 2 ([−128, 127]) are indicated by a square with broken lines, and the volume of the body is the number of value pairs for x 1 and x 2 that satisfy all the LIA constraints.

Hot/Cold Path Analysis
To show the practical importance of #SMT(LIA), we introduce a program analysis problem that can be translated into a #SMT(LIA) problem. In Figure 1, there is a path executing i = 5, and the other executing i = 6. We are interested in which path is the hot path. To solve this problem, we consider two SMT(LIA) formulas.

•
The condition of the second path is the logical complement of the first condition.

Volumes of Convex Bodies and SMT(LIA) Formulas
In this subsection, we explain the differences between the volume computation problem of a convex body and that of a SMT(LIA) formula. A convex body is defined by a conjunction of several LIA constraints. For example, the area with mosaics in Figure 2a is a convex body, and it is defined by: Note that the boundaries of x1 and x2 ([−128, 127]) are indicated by a square with broken lines, and the volume of the body is the number of value pairs for x1 and x2 that satisfy all the LIA constraints.  In contrast, a SMT(LIA) formula may imply multiple convex bodies, depending on the underlying logical structure. For example, with the same boundaries for x 1 and x 2 , a formula implies two convex bodies as shown in Figure 2b. In general, a SMT(LIA) formula may imply m convex bodies, and the maximal value of m is: 2 m − 1 where m is the number of Boolean variables involved. However, the idea to break a SMT(LIA) formula into a set of convex bodies and then take the sum of the corresponding volumes is not feasible. One reason is that this idea possibly results in an exponential number of convex bodies, and the other reason is there may exist overlaps among the convex bodies [8].

Markov Chain Monte Carlo and the Flat Histogram Method
Markov Chain Monte Carlo (MCMC) is a sampling method that has been widely used for statistical physics. Sampling from a state (configuration) space S is the process of generating samples from a probability distribution π defined over S. The aim is to estimate the distribution or to compute the states having a maximum (minimum) probability. A MCMC algorithm samples the space in a way that the transition probability from the current state σ to the next state σ , p σ→σ , depends only on σ, but not on any previously sampled states. If π(σ) > 0 for any σ ∈ S, and p σ→σ satisfies the detailed balance property, then the sampling process will reach a stationary distribution. In statistical physics, the flat histogram method [14] was firstly used to estimate the density of states (DOS) of a state space S w.r.t. an energy function, The DOS of a given energy level E is, To estimate n(·), the flat histogram method visits a state σ in the energy level g(σ) with a probability p(σ) that is inversely proportional to n(g(σ)). As a result, a flat visit histogram to each energy level is generated. Specifically, the method defines a random walk process with the following transition probability where g(σ) = E and g(σ ) = E . The process satisfies the detailed balance equation when P(σ) is proportional to 1/n(E). This strategy guides the process to visit states at every energy level equally often.

Related Works
A pioneer work of applying the flat histogram method in model counting is for Boolean formulas [22]. The authors built the connection between the model counting problem of SAT and the DOS computation problem. Their method was shown to outperform the standard Metropolis sampling. In this work, we extend the flat histogram to the field of SMT for solving #SMT(LIA).
A recent work on #SMT(LIA) developed a multiphase Monte-Carlo method that exploits a novel technique for estimating the volume of convex polytopes [9]. Specifically, that work designed a set of strategies to reduce the number of samplings. On top of their methods, a tool called VolCE that uses LattE [23] was developed (we refer to it as VolCE+LattE) for #SMT(LIA). Experiments in [9] show that VolCE+LattE is superior to a word-level hash-mapping method SMTApproxMC [19] on instances which have more than 4,000,000 solutions.
Hash-mapping-based approximate methods for model counting of SMT formulas have been paid much attention in recent years. The bit-level hash-mapping-based methods ApproxMC [20] and its improved version ApproxMC2 [21] used XOR-based bit-level hash functions to obtain a randomized subset of the solution space by calling a satisfiability solver. However, the approaches have the danger of introducing too many discrete variables when dealing with linear real constraints [9]. On the other hand, meanings of variables are lost in a bit-level encoding, as argued in [9,19]. To advance the techniques of estimating by hash-mapping and to overcome the weakness of bit-level encoding, a word-level hash-mapping method was proposed in [19], where an approximate model counter for linear integer constraints called SMTApproxMC was developed. A great advantage of SMTApproxMC is the ability to exploits the continuously advanced reasoning power of word-level SMT solvers. However, SMTApproxMC is reported to have difficulty in scaling to instances having a large number of solutions [9].
Monte-Carlo based model counting (or volume computation) has a wealth of studies. Nonetheless, few implementations are available for SMT. One recently implemented direct Monte-Carlo method for SMT with linear real constraints was reported in [24]. They showed, by experiments on a set of convex bodies involving increasing number of variables, their direct Monte Carlo method fails on all instances with seven or more variables. In contrast, our experiments (in Section 5: More Results on Convex Bodies) on a subset of their benchmarks will show that one of our techniques can work on many instances with seven or more variables.
We briefly summarize the characteristics of our techniques and the related as follows.
• Our techniques vs. VolCE+LattE [9]: Both techniques are suited for #SMT(LIA). VolCE+LattE is an exact method whereas our methods are approximate. In our experiments, VolCE+LattE fails to scale on many convex body instances (obtained from [24]) that are with more than six variables, whereas one of our techniques succeed in reporting solutions for the test set. Note that both techniques require low memories. In our test, their required memory on all instances is less than 1 GB. So, a failure of VolCE+LattE is due to time out. • Our techniques vs. SMTApproxMC [19] and ApproxMC2 [21]: The three are approximate techniques. SMTApproxMC and ApproxMC2 provide a guarantee that if given a tolerance ε >0 and a confidence 1-δ ∈ (0, 1), its output lies in the interval [(1 + ε) −1 R F , (1 + ε) R F ] with probability greater than δ, where R F is the real count of a formula. Our techniques do not provide such a guarantee. However, experiments will show that our techniques lead to a relative error smaller than 20% in most of the tests. In addition, our methods are capable of working on tested instances with 4,000,000 and more solutions, whereas SMTApproxMC cannot. ApproxMC2 has similar scalability issue as well (see Section 5: More Results on Convex Bodies). • Our techniques vs. the direct Monte Carlo method [23]: Both techniques are not complicated applications of the Monte Carlo sampling method. The direct Monte Carlo method is reported to fail in sampling from the solution area of convex body instances with seven or more variables, whereas one of our techniques succeeds in obtaining a lot of samplings from the solution areas for many instances extracted from the same test set.

The Proposed Flat Histogram Method
To estimate the volume of an SMT(LIA) formula, we propose a flat histogram method that consists of three components.

•
A specialized energy function g over the valuations of the SMT(LIA) formula, which satisfies that for any valuation γ, g(γ) = 0 if γ is a solution and g(γ) > 0 otherwise.
• A MCMC algorithm based on the flat histogram method to estimate the density of states with respect to g. • Histogram reweighting strategies and flatness evaluating methods.
After the sampling process, the DOS for energy zero, n(0), is outputted as the volume of the SMT(LIA) formula.

The Energy Function
For SMT(LIA) formulas, we define an energy function based on their propositional skeletons. Given the propositional skeleton of a formula φ: PS(φ), and the set of clauses of PS(φ): C(φ), we define the energy of a valuation σ as It can be seen that g maps valuations of numeric variables to integers in [0, |C(φ)|] , which facilitates program implementation. We can use a one-dimensional array with size |C(φ)| + 1, and thus the ith entry is used to record the density of valuations with energy i.

The Sampling Algorithm
In this subsection, we propose a MCMC method to solve the #SMT(LIA) problem based on the flat histogram method. In the proposed method, we make each random move follow the probability specified in Equation (1). Therefore, our method avoids using Metropolis sampling, and visits states at every energy level equally often. However, the density function n(·) in Equation (1) is not known a priori. To handle this, we use a changing current estimate n (·) to approximate n(·). Initially, n (E) is set to 1 for every energy level E. With the initial values of n (·), our algorithm samples the space with increasing the visit histogram H(g(σ)) by 1 and update n (g(σ)) with a modification factor F, every time a valuation σ is visited. Specifically, the estimate of DOS is updated by The sampling process repeats until the visit histogram H(·) is sufficiently flat. If F does not reach its designated value, a new sampling process is started with resetting H(·) and starts with a refinement of F. The role of F will be explained next. An outline of the MCMC-Flat algorithm is shown in Algorithm 1. It returns the estimate n (0).
As is seen at the end of Algorithm 1, the information in n (·) reflects the relative density of each energy level. To obtain the real density of each level, we normalize n (·) w.r.t. the volume of the sampling area. For a SMT(LIA) formula φ defined on K numeric variables and each has the same range [lb, ub] (lb is the lower bound and ub is the upper bound), the volume of the sampling area is (ub − lb) K . Therefore, the volume of φ is obtained by

Updating Strategy for the Modification Factor
In Algorithm 1, the modification factor F is used to reweight the density of states. The outer loop updates F at each iteration with the function Update(F). Two strategies of updating F were studied. Belardinelli et al. [25] showed that the 1/t strategy can lead to a smaller error than the 1/2 strategy. We also verified this behavior on a small set of test problems. So, we focus on studying the performance of MCMC-Flat 1/t on the #SMT(LIA) problem. One of our important findings is that the flatness condition for H(·) is difficult to reach for some test problems. Next, we will examine the notion of flatness of a visit histogram and introduce a new rule to evaluate flatness.

Evaluating the Flatness of Visit Histogram
One method to evaluate the flatness of the visit histogram H is based on its minimum value min and maximum value max [14]. Specifically, H is considered to be flat if max − min < δ × max, where δ is a pre-set constant parameter. Obviously, the more flat H is (i.e., with smaller δ) the more uniformly Algorithm 1 visits each energy level. However, with smaller δ we need more sampling steps. Furthermore, literature [26] pointed out that the flatness is not a good indicator for convergence.
Among other works, Belardinelli and Pereyra [25] introduced a condition to evaluate the visits of each energy level: every energy level must be visited one time. We tested MCMC-Flat 1/t with this condition on one of our random problems and found that MCMC-Flat 1/t does not converge. In particular, with this condition the relative error of MCMC-Flat 1/t stays at −1.0 (see Figure 3a).
One of the underlying reasons, as we conjecture, is that the number of states of a particular energy level is very large for SMT(LIA) formulas with many variables (a.k.a. high dimensions). So, MCMC-Flat 1/t needs many trails to visit every energy level and to fulfil the condition for the visit histogram. To overcome the shortcomings, we introduce a new rule to analyze the visit histogram (as shown in Algorithm 2). Algorithm 2 marks one unvisited energy level as visited and then returns, each time it is called (i.e., do a pseudo sampling), while it does not stop the current sampling process. This behavior will force the sampling process do another sweep on energy levels. Note that a sweep will require more Monte Carlo trials. In the worst case, Algorithm 2 will force the sampling process to make N sweeps, where N is the number of energy levels. The amount of sweeps shall be enough to visit each energy level. We call Algorithm 1 with this method MCMC-Flat 1/t-pv . The behaviour of MCMC-Flat 1/t-pv is shown in Figure 3b. It can be seen that MCMC-Flat 1/t-pv converges (with a decreasing relative error) when the modification factor F is decreasing. Note that in our method, F initially takes 1.0, and is reduced in the following iterations. What we expect is that the smaller F is, the more accurate our method's estimate of n(0) is.

Algorithm 2. Pseudo Visit (PV) of Histogram Input: A visit histogram H Output: A Boolean value indicates if every energy is visited
return false end if end for return true

Experimental Evaluation
This section consists of two parts. In the first part, we show the accuracy and efficiency of the proposed algorithms on structured and random SMT(LIA) instances. In the second part, we compare our techniques with VolCE+LattE [9], SMTApproxMC [19] and ApproxMC2 [21], on hard convex bodies (where every linear integer constraint is joined by conjunction) instances extracted from the benchmark suit of [24].
In the first part, every structured instance is defined in a two-dimensional space (i.e., involving two numeric variables) containing a single square of varying volumes. The random instances contain different numbers of variables, LIA constraints, and clauses. The Exact Method presented in [18] is used as a reference. Properties of random instances are shown in Table 1.

Experimental Evaluation
This section consists of two parts. In the first part, we show the accuracy and efficiency of the proposed algorithms on structured and random SMT(LIA) instances. In the second part, we compare our techniques with VolCE+LattE [9], SMTApproxMC [19] and ApproxMC2 [21], on hard convex bodies (where every linear integer constraint is joined by conjunction) instances extracted from the benchmark suit of [24].
In the first part, every structured instance is defined in a two-dimensional space (i.e., involving two numeric variables) containing a single square of varying volumes. The random instances contain different numbers of variables, LIA constraints, and clauses. The Exact Method presented in [18] is used as a reference. Properties of random instances are shown in Table 1. All the experiments were run on a Linux system with a CPU running at 2.53 GHz, 60 min time limit and 2 GB memory limit. The programs were restricted to run on one core of the CPU by using the Linux command taskset. MCMC-Flat 1/2 and MCMC-Flat 1/t-pv were run 10 times on each problem; their results were averaged on successful runs. In the following results, Vol. is short for volume, SR is short for success ratio, and RE is short for relative error. Let d be an estimation of a target value d, we define the relative error d to d as RE(d, d ) = (d −d)/d. We use MO to indicate the memory out of the Exact Method and use "\" to indicate 'time out'.
With structural instances, we want to see that whether the accuracies of MCMC-Flat methods improve with increasing size of volumes. The detailed results are shown in Table 2. On instance s1, the relative errors of MCMC-Flat 1/2 and MCMC-Flat 1/t-pv are 302.69% and 297.97%, respectively. The errors of the two algorithms decrease consistently when the volumes of the target convex bodies increase. In addition, on the structured instance s6 which is with the maximal volume 4096, both of our algorithms reach small relative errors within 10% (9.33% and 5.65% for MCMC-Flat 1/2 and MCMC-Flat 1/t-pv , respectively). We can also see that MCMC-Flat 1/t−pv leads to smaller relative errors, compared with MCMC-Flat 1/2 , on instances s5, s6 and s7, though the running times of the former are more than the latter. Finally, we note that the Exact Method is the fastest among these three algorithms, with nearly neglectable running times. However, this advantage of the Exact Method will be lost on complex SMT(LIA) formulas contained in our random instances. With random instances, the ability of MCMC-Flat methods on hard instances is verified (see Table 3). Table 3 shows that MCMC-Flat 1/t-pv reaches good accuracy very fast, in contrast with the running time of MCMC-Flat 1/2 . For example, MCMC-Flat 1/2 takes more than 2000 s on instances ran2, ran5, and ran9, whereas MCMC-Flat 1/t-pv takes at most 205.18 s for ran9. Note that the relative errors of MCMC-Flat 1/2 and MCMC-Flat 1/t-pv on ran2, ran5, and ran9 are close. It can also be seen that the volume estimations of MCMC-Flat 1/t-pv on instances ran2, ran4, ran7, and ran10 are close to those of MCMC-Flat 1/2 . On all the random instances tested, the running times of MCMC-Flat 1/t-pv varies from about ten seconds to a few hundreds of seconds, whereas those of MCMC-Flat 1/2 varies from 7.59 to 3266.07 s. Therefore, MCMC-Flat 1/t-pv is more scalable than MCMC-Flat 1/2 . Next, let us look at the results of the Exact Method. The Exact Method runs out of memory on ran2, ran4, ran7, ran10 and ran11, which is of dimension 15,10,8,8, and 9 respectively (please refer to Table 1). Seeing that the Exact Method succeeds on other instances with less than 8 dimensions, we can conclude that the Exact Method does not scale well. Overall, we see that MCMC-Flat 1/t-pv has a good scalability and outperforms MCMC-Flat 1/2 and the Exact Method. Another note is that both MCMC-Flat 1/2 and MCMC-Flat 1/t-pv return greater than zero estimates on all the random instances, especially on those with 8 or more dimensions. The results indicate the ability of our MCMC-Flat algorithms in finding at least one solution. In contrast, the direct Monte Carlo method implemented in [24] failed to find any solution for instances with dimensions greater than 7, which results in a relative error of 100% (please refer to Figure 10b in [24]). We argue that this good ability of our MCMC-Flat algorithms is due to both the transition probability in Equation (2) and a mapping from the valuation space (with possibly exponentially number of states) of a SMT(LIA) formula to our defined energy space that is linear in the number of clauses.

More Results on Convex Bodies
In the second part of experiments, we focus on a restricted form of STM(LIA), the convex body. Specifically, using the volume computation problem of convex bodies, we compare our MCMC-flat methods with some state-of-the-art model counters. Instances of convex bodies were obtained from the benchmarks (http://code.google.com/p/rvc/) used in [24]. All the problems are extracted from the sub-folder named "Exp3_1". A problem with name m-n-i involves m variables, and n + 1 constraints where i is the index of a variant. Each variable has a value bound [−15, 15]. Every constraint is an inequality, and coefficients of variables are rational numbers represented by fractions. For example, the first inequality of the problem "7-5-1" is: −1/2·x 1 − 2/5·x 2 − 7/5·x 3 + 7/10·x 4 + 3/8·x 5 ≤ −3/5.
A brief summary on properties of the selected instances are presented in Table 4. "#Variable", "#Constraint", and "Space", in Table 4, stand for the number of variables, the number of LIA constraints, and the number of valuations in the space, respectively. The "Volume/Space" column is the proportion of the number of models to the size of the space, where "NA" represents an unknown property. Intuitively, a problem with lower Volume/Space is more constrained. We take an exact model counter Volce+LattE [9] and two approximate model counters SMTApproxMC [19] and ApproxMC2 [21] for comparison. Note that all the three are state-of-the-art model counters. To run them, the benchmark problems were converted to their corresponding formats. The problem format in [24] is similar to that of our methods' accepts. However, the format is quite different from the formats of Volce+LattE, SMTApproxMC, and ApproxMC2. Volce+LattE accepts an input format called the "Enhanced DIMACS CNF Format", whereas SMTApproxMC accepts SMT-LIB2 format of Bit Vector theory. In our implementation, we first translate the instances from [24] into the "Enhanced DIMACS CNF Format" of Volce+LattE. Specifically, denominators of coefficients in a LIA constraint are all multiplied by their least common multiple. For example, the translation result of (7) is, In this way, every coefficient in an LIA constraint is a number, instead of a fraction. In addition, every value bound for a variable is translated into a corresponding inequality. Moreover, due to that each problem instance representing a convex body, our converter states that all constraints must be satisfied. For SMTApproxMC, equations in the form of (8) are translated into sentences in the Fixed Size Bit Vector theory of SMT-LIB2, where the size of a bit vector is 32.
To run ApproxMC2 [21], the benchmark problems were bit-blasted by using an embedded function of the SMT solver Yices (http://yices.csl.sri.com/). Specifically, for the problems described in the SMT-LIB2 Bit Vector theory (which is suited for SMTApproxMC), the SMT-LIB2 keywords are replaced by Yices' corresponding ones, for example: "bvsle" in SMT-LIB2 is replaced with "bv-sle" in the Yices language. Furthermore, at the end of the problem, an "export-to-dimacs" command is set. The resulted problem file was then bit-blasted by Yices (with command-line option "-logic = QF_BV").
This part of the test was carried out on a 64-bit Linux platform with a 2.6 GHz CPU, 4 GB memory limit. The time limit of each test is 12 h. Volce+LattE was executed once, since it is an exact method. MCMC-Flat 1/2 was given 5 runs on each instance and the averaged results are reported. A "\" indicates failure due to time out. SMTApproxMC was run with the default configuration (50 iterations, tolerance ε = 0.8 and δ = 0.2, for an instance). Note that these settings for ε and δ are the same as those used by the authors of SMTApproxMC, which make the value v returned by SMTApproxMC satisfy Note that RF is the real volume. ApproxMC2 was run with its default configuration as well (with the same ε and δ). So, return values of ApproxMC2 satisfy (9) as well.
Results regarding Volce+LattE and MCMC-Flat 1/2 are shown in Table 5. We can observe that Volce+LattE fails on many instances with 6 and 7 variables, among which it only succeeds on 6-5-1, 6-5-2, and 6-5-4 with dozens of minutes. In contrast, our MCMC-Flat 1/2 method works on all the instances. On the other hand, MCMC-Flat 1/2 reports a result of 1.74 × 10 8 on the problem 6-5-1 with a relative error 6.21%. In summary, on the 13 instances on which Volce+LattE succeeds, MCMC-Flat 1/2 gives 3 results with RE beyond 20% (52.07% for 5-10-2, 48.17% for 5-20-5, and −25.17% for 6-5-4), and gives the other 10 results with RE in [−20%, 20%]. Therefore, results in Table 5 show that MCMC-Flat 1/2 is more scalable than Volce+LattE. Table 6 are results of MCMC-Flat 1/2 , SMTApproxMC and ApproxMC2; the results of MCMC-Flat 1/2 are the same as those in Table 5. In Table 6, a brief summary of the results is presented at the bottom: "#Solved" is the number of solved instances of an algorithm, "#BestRE" is the number of instances on which an algorithm obtained the best relative error, and "#AvgTime" is the averaged solving time over instances that are solved by all the three algorithms. We make several observations from the results in Table 6, as follows.
• In terms of scalability, our MCMC-Flat 1/2 method is superior to SMTApproxMC and ApproxMC2.
In [9], the word-level hash-mapping-based method SMTApproxMC was shown to handle instances with less than 3.98 × 10 6 models (around 4,000,000) and failed on others. On our test platform, SMTApproxMC got a result of 1.04 × 10 7 on instance 6-5-5. However, SMTApproxMC can return a value 15 out of 22 instances, whereas MCMC-Flat 1/2 returns values on all the 22 instances. Notably, MCMC-Flat 1/2 reports a result of 1.74 × 10 8 on the problem 6-5-1 with a low relative error 6.21%. From the results, the scalability of SMTApproxMC is better than ApproxMC2, as the former solved 15 instances whereas the latter solved 11 instances. Therefore, MCMC-Flat 1/2 is the best, with respect to scalability.

•
In terms of accuracy, MCMC-Flat 1/2 is better than SMTApproxMC and ApproxMC2. Among 13 instances for which the exact volume is known by Volce+LattE (see Table 5), MCMC-Flat 1/2 returns best results on 8 instances, and ApproxMC2 does the best on the other 5 instances, in terms of relative error. The accuracy of SMTApproxMC is not competitive to either MCMC-Flat 1/2 or ApproxMC2. The variance in relative errors of ApproxMC2 is better than that of MCMC-Flat 1/2 , as we can observe from Table 6 that on instances where ApproxMC2 returns none-zero results the relative error of ApproxMC2 is better than that of MCMC-Flat 1/2 . On the other hand, ApproxMC2 seems to have big difficulty in working on instances having volume greater than 1.0 × 10 6 , as it takes relatively long time on instances 5-10-1, 6-10-1, and 7-10-1.

•
In terms of efficiency, MCMC-Flat 1/2 is significantly better than SMTApproxMC and ApproxMC2.
• Regarding the ability of obtaining samples from the solution area for large size instances, MCMC-Flat 1/2 is superior to the direct Mont Carlo method in [24]. Note that, all the test instances are took from [24], and the direct Mont Carlo method in [24] is reported to give results of RE of 100% on all instances with 7 variables (We failed to run that method due to that its call on Matlab 2010b leads to segment faults). That is, the direct Mont Carlo method failed to sample any solution when the problem size is large. In contrast, MCMC-Flat 1/2 is able to reach the solution area on all the tested instances with 7 variables.
A final note for this part of experiments is that MCMC-Flat 1/t-pv is not good at these instances. Actually, we also run several tests for MCMC-Flat 1/t-pv on instances with 5 variables. However, its success rate is very low. The underlying reason is to be explored in our future work.

Conclusions
We have proposed a flat histogram strategy-based Markov Chain Monte Carlo (MCMC) method for computing the volume of possibly intersected polytopes in a space. Specifically, we have introduced three implementations of the MCMC method, which have different performance in terms of efficiency and accuracy. To analyze the performance of our methods, extensive experiments against two exact and two approximate model counters were carried out on different types of test problems. From our tests on SMT(LIA) instances, MCMC-Flat 1/t-pv is showed to be able to reach good accuracy. From our test on convex bodies (where LIA constraints are joined by conjunctions), MCMC-Flat 1/2 is competitive with the state-of-the-art and shows a better scalability.
Our future work is to investigate theoretical properties of MCMC-Flat 1/2 to obtain a guarantee on the quality of the returned values and to improve MCMC-Flat 1/t for the model-counting problem of convex bodies.