PBCounter: weighted model counting on pseudo-boolean formulas

Yong LAI, Zhenghang XU, Minghao YIN

Front. Comput. Sci. ›› 2025, Vol. 19 ›› Issue (3) : 193402.

PDF(3907 KB)
Front. Comput. Sci. All Journals
PDF(3907 KB)
Front. Comput. Sci. ›› 2025, Vol. 19 ›› Issue (3) : 193402. DOI: 10.1007/s11704-024-3631-1
Theoretical Computer Science
RESEARCH ARTICLE

PBCounter: weighted model counting on pseudo-boolean formulas

Author information +
History +

Abstract

In Weighted Model Counting (WMC), we assign weights to literals and compute the sum of the weights of the models of a given propositional formula where the weight of an assignment is the product of the weights of its literals. The current WMC solvers work on Conjunctive Normal Form (CNF) formulas. However, CNF is not a natural representation for human-being in many applications. Motivated by the stronger expressive power of Pseudo-Boolean (PB) formulas than CNF, we propose to perform WMC on PB formulas. Based on a recent dynamic programming algorithm framework called ADDMC for WMC, we implement a weighted PB counting tool PBCounter. We compare PBCounter with the state-of-the-art weighted model counters SharpSAT-TD, ExactMC, D4, and ADDMC, where the latter tools work on CNF with encoding methods that convert PB constraints into a CNF formula. The experiments on three domains of benchmarks show that PBCounter is superior to the model counters on CNF formulas.

Graphical abstract

Keywords

weighted model counting / pseudo-boolean constraint / algebraic decision diagrams / preprocessing techniques

Cite this article

Download citation ▾
Yong LAI, Zhenghang XU, Minghao YIN. PBCounter: weighted model counting on pseudo-boolean formulas. Front. Comput. Sci., 2025, 19(3): 193402 https://doi.org/10.1007/s11704-024-3631-1

1 Introduction

Model counting is a fundamental problem in computer science with a wide variety of applications in practice, ranging from neural network verification [1], network reliability [2], computational biology [3], and the like. Given a propositional formula φ, the model counting problem is to compute the number of satisfying assignments of φ. Weighted Model Counting (WMC) is a generalization of model counting. In WMC, we assign weights to literals and compute the sum of the weights of the models of φ where the weight of an assignment is the product of the weights of its literals. The WMC solvers can serve as efficient tools for probabilistic inference [4-6], and many applications benefit significantly from WMC-based probabilistic inference, including probabilistic planning [7], probabilistic databases [8], and probabilistic programming [9].
The major approaches to the design of scalable (exact) model counters are mainly divided into three types: (1) search-based, (2) compilation-based, and (3) variable elimination-based methods [10]. The search-based techniques predominately focus on the combination of component caching with Conflict Driven clause learning including Cachet [11], sharpSAT [12], and Ganank [13]. The compilation-based techniques rely on the paradigm of knowledge compilation. Target languages of interest include d-DNNF and CCDD, with two counters based on them, D4 and ExactMC [10,14]. Recently variable elimination-based techniques have been proposed, ADDMC uses the early project to eliminate variables represented by Algebraic Decision Diagrams [15]. NestHDB is a scalable hybrid tool that combines search-based and variable elimination-based counting methods [16]. There are also many approximate model counters, such as STS [17], ApproxMC [18], and PartialKC [19].
The current WMC solvers work on Conjunctive Normal Form (CNF) formulas. However, CNF is not a natural representation of human-beings in many applications. A Pseudo-Boolean (PB) constraint is of the form i=1nailib, where the ai and b are integers, literal li is a Boolean variable xi or its negation, and the relation operator ⊳∈{<,,=,,>}. PB constraints are a natural generalization of clauses in CNF; e.g., a clause l1l2lm is equivalent to the PB constraint i=1mli1. Compared with clauses, it is easier to use PB constraints to describe the arithmetic properties of a problem. Moreover, PB constraints are strictly more succinct than a CNF formula according to the criteria used in the knowledge compilation map [20]. Thus, PB constraints have been widely used to efficiently represent many problems ranging from wireless sensor network [21] and logic synthesis [22] to Minimum-Width Confidence Bands [23].
Currently, a general approach to solving the problems modeled in PB constraints is to encode them into a CNF formula with the same satisfiability or model count and then employ a SAT solver or model counter to solve the resulting CNF formula. The clear benefit of this approach is due to the high-performance of the modern SAT solvers and model counters. However, the encoding from a PB formula to CNF introduces many auxiliary variables, and thus increases the size of the problem and even sometimes damages the structure or semantics of the original constraints. For these reasons, developing tools that work directly on PB formulas makes sense.
For the satisfiability of PB constraints, there exist many complete tools that directly work on PB formulas, such as PBS [24], PUEBLO [25], and RoundingSat [26]. These tools are more efficient on PB constraints since they use cutting planes proof system to analyze conflicts, which was shown exponentially more powerful than the resolution-based proof system in normal SAT solving. There exist some incomplete tools for PB Optimization such as NuPBO [27] and DeepOpt-PBO [28] as well. Turning to model counting or WMC, there are no tools that directly work on PB formulas so far. In this study, we propose to perform WMC on PB formulas. Based on a recent dynamic programming algorithm framework called ADDMC for WMC on CNF formulas, we implement a weighted PB counting tool PBCounter. Our experiments have demonstrated that PBCounter was able to solve the greatest number of instances and was the fastest on most of them.
Model counting on PB constraints can also be viewed as a counting problem for 0-1 integer linear programming, which is a simplified version of integer linear programming (ILP) that restricts the variables to take values of 0 or 1. Counting integer solutions of ILP has important applications such as simple temporal planning [29] and probabilistic program analysis [30]. In practice, however, it is often difficult to count the solutions of an ILP problem with a great dimension [31]. We compare PBCounter with the ILP counter IntCount [32], and the experimental results show that PBCounter has a significant advantage.
The rest of the paper is organized as follows: We present notations and preliminaries in Section 2. Our algorithm of PBCounter is presented in Section 3. In Section 4, we present two preprocessing techniques on PB Constraints. Next, we present a detailed empirical evaluation in Section 5. Finally, we conclude in Section 6.

2 Preliminaries

In this section, we introduce the background knowledge about Weighted Model Counting (WMC), Pseudo-Boolean (PB) constraints, and Algebraic Decision Diagram (ADD), the primary data structure we used in our tool PBCounter.

2.1 Weighted model counting

Given a set of Boolean variables {x1,x2,,xn}, a literal is either a variable xi or its negation xi¯. The negation of a literal l, written l¯, denotes x¯ if l is x, and x if l is x¯. A clause is a disjunction of literals. A conjunctive normal form (CNF) formula F=c1c2cm is a conjunction of clauses.
Definition 1 (Weighted model counting). Given a CNF formula ψ over variables set X, ψ can be represented as a Boolean function ψ:2X{0,1}. Let W:2XR be an arbitrary function representing the weight of assignments. The weighted model count of ψ w.r.t. W is W(ψ)= τ2Xψ(τ)W(τ).
The function W:2XR is called the weight function. The weight of an assignment is the product of the weight of its literals. Next, we define two operations that are useful for WMC solving.
Definition 2 (Product). Let X and Y be sets of variables. The product of functions f:2XR and g:2YR is the function fg:2XYR defined for all τ2XY by (fg)(τ):= f(τX)g(τY).
In Definition 2, τX is the projection of τ over variable set X. Operation product is commutative and associative. If we use Boolean function φ:2X{0,1} and ψ:2Y{0,1} to represent two CNF formulas, the product φψ is the Boolean function corresponding to the conjunction φψ.
Definition 3 (Projection). Let X be a set of variables and xX. The projection of f:2XR w.r.t. x is the function Σxf:2X{x}R defined for all τ2X{x} by (Σxf)(τ):= f(τ{x})+f(τ{x¯}).
Note that projection is commutative, i.e., that ΣxΣyf=ΣyΣxf for all variables x,yX and functions f:2XR. Given a set X={x1,x2,,xn}, we define ΣXf=Σx1Σx2Σxnf and Σf=f.
The equation in Definition 1 can be expressed in an alternative form as W(ψ)=(ΣX(ψW))(), whose computation relies on the operations of product and projection. Dudek et al. showed that a special type of projection, called early projection, can accelerate WMC solving [15].
Theorem 1 (Early projection). Let X and Y be sets of variables. Given f:2XR and g:2YR, if xXY, then Σx(fg)=(Σxf)g.
The early projection has critical applications in many fields, such as database-query optimization [33], satisfiability solving [34]. and weighted model counting [15].

2.2 Pseudo-Boolean constraints

A Pseudo-Boolean (PB) constraint is of the form i=1nailib, where the ai and b are integers, literal li is a Boolean variable xi or its negation xi¯, i.e., li¯=1li, and the relation operator ⊳∈{<,,=,,>}. The right side of the constraint b is often called the degree of the constraint. PB constraints are more expressive than clauses. Actually, each clause is a special PB constraint in which degree b and all coefficients ai are 1, and is .
A PB formula φ is a conjunction of PB constraints. φ can be represented as a Boolean function φ:2X{0,1}. A complete truth assignment is a mapping that assigns to each variable in the set X either 0 or 1. In PB, a constraint is satisfied when the equality holds. Therefore we can regard the PB formulas as a mapping from truth assignment to satisfiability. We use γ:2Xγ{0,1} to represent a constraint γφ, where XγX is the set of variables appearing in γ.
There are many efficient methods for encoding PB constraints into CNF so that we can directly use the tools on CNF to solve the reasoning problems on PB. Eén et al. describe and evaluate three different techniques, translating by BDDs, Adder Network, and Sorting Network [35]. There are many studies that have made transformations for a special type of PB constraints, e.g., at-most-one constraints and PBMod-constraints [36,37].

2.3 Algebraic decision diagrams

Algebraic Decision Diagram (ADD) is a compact representation of a function as a directed acyclic graph [38]. It is an extension of the Binary Decision Diagram (BDD) that represents functions mapping each state to a finite set of values, e.g., integers representing costs.
We consider an ADD A over a set of Boolean variables X and an arbitrary set S. A is a rooted directed acyclic graph where each node of A is an element in either X or S. Every terminal node of A is labeled with an element of S, and every non-terminal node of A is labeled with an element of X and has two out-going edges labeled 0 and 1 (0-edge and 1-edge for short). For the directed path from the root to the terminal node in A, the element represented by the non-terminal node on the path will appear no more than once.

3 WMC on PB constraints

In this section, we introduce the algorithmic framework for weighted model counting on PB constraints. We first define the WMC task on PB as follows:
Definition 4 (Model counting on PB constraints). Let φ be a PB formula over variables set X, and let W:2XR be an arbitrary function. The weighted model count on φ w.r.t. W is defined as W(φ)=τ2Xφ(τ)W(τ).
Obviously, the product operation can be used to represent the entire formula by constraints, i.e., φ=γφγ. Then the equation in Definition 4 can be rewritten as W(φ)=(ΣX(φW))(). Just like ADDMC, our WMC algorithm uses ADDs to perform products and projections. To facilitate the transformation from PB constraints to ADDs, we normalize the PB constraints. It is widely recognized that the PB constraint can be normalized using only one operator, such as . In this context, a constraint i=1naili=b is split into two constraints i=1nailib and i=1nai(li¯1)b. However, when computing WMC, we need to perform product between constraints, and therefore the split incurs an additional cost. To address this issue, we relax the standard normalized PB constraint to admit = in addition to .
Definition 5 (Relaxed normalized PB constraint). Given a PB constraint i=1nailib, it is relaxed normalized iff each coefficient ai is non-negative integer and operator is or =.
We can transform each PB constraint into a relaxed normalized PB constraint as follows. First, we transform into except for =. That is, we multiply both sides of the inequality by 1 to transform the operators < (resp. ) into > (resp. ), and then we can replace >b by b+1. Second, we can replace al by al¯a to ensure every coefficient is a non-negative integer. Finally, if a relaxed normalized PB constraint has a negative degree, it cannot be satisfied, and therefore, the weighted model count is zero. Hereafter, we assume each PB constraint is relaxed normalized unless otherwise stated.

3.1 Dynamic programming framework

The focus of dynamic programming is to decompose complex problems into small sub-problems to solve and combine the solutions to get the answer. We extend the algorithmic framework of ADDMC [15] to solve the WMC on PB. Our algorithm is presented in Algorithm 1, and we will discuss our preprocessing techniques in Section 4 (line 1).
The input is called diagram variable order and is used to build ordered ADDs to support tractable products and projections. It determines the order of variable occurrence along the path from the root to the terminal node in ADDs and greatly influences the size of the diagram.
Another input ρ is injection XZ+, where X=Vars(φ) represents all variables appearing in formula φ. ρ is used to partition PB constraints into several disjoint parts {Γi}i=1m, called clusters. According to these clusters, we get the partition {Xi}i=1m of the variable set X. Variables already placed in Xi will not be placed in Γi+1,Γi+2,,Γm. This property allows us to early project the variables in Xi (line 11), because they will not appear later.

Full size|PPT slide

We use κi for each cluster to represent the set of ADDs in the cluster Γi. We product ADDs in κi (line 10), do project, and insert the result ADD Ai into another cluster (line 14).
Heuristics are essential parts of Algorithm 1. We implement all the heuristics used in ADDMC for PB constraints and choose MCS (maximum cardinality search [39]) and LexP (lexicographic search for perfect orders [40]) as the diagram variable order () and cluster variable order (ρ), respectively, and BM-Tree (Bouquet’s Method with tree data structure [15]) as the cluster heuristic for the function constraintRank and chooseCluster. This combination performed best in the experiment by ADDMC.

3.2 Construct ADDs for PB constraints

We show how PBCounter constructs ADDs to represent PB constraints (line 6 in Algorithm 1). We use two different construction methods, described in Algorithms 2–3, for the PB constraints with operators = and , respectively.

Full size|PPT slide

In Algorithm 2, we provide a recursive function for constructing ADD for constraint i=1naili=b. It divides the current constraint into two subconstraints (lines 7−8) and solves them recursively, then constructs the ADD of the current constraint (lines 9−10). Ite(xj,At,Af), known as If-Then-Else, is an operation of ADDs, which returns an ADD rooted at xj, 1-edge linked At and 0-edge linked Af. We use storeEqADD to store constructed sub-constraints with the same parameter k (line 11), avoiding duplicate constructions. If the same ADD has been constructed before, we can return it directly (lines 5−6).
For each PB constraint with positive literals and , Abío et al. proposed a linear algorithm for converting it into a reduced ordered BDD [41]. We modify this algorithm to make it be able to deal with negative literals and output ADDs, which is an extension of BDDs. For a PB constraint i=1nailib, we can partition the interval (,) into multiple sub-intervals such that when b belongs to the same sub-interval, their corresponding ADDs are the same. We use Example 1 to explain this point further.
Example 1 The constraint 2x1+3x2b with the order x1x2 can correspond to five possible ADDs when b has different values from five intervals, as shown in Fig.1. If b(,0], every possible assignment over {x1,x2} satisfies the constraint, and we obtain a single ADD with only one terminal node labeled with 1. Similarly, 2x1+3x24 and 2x1+3x25 will be both satisfied when x1=x2=true.
Fig.1 The five possible ADDs of 2x1+3x2b over x1x2

Full size|PPT slide

The modified algorithm is presented in Algorithm 3. Consider a PB constraint i=1nailib with an order x1x2xn. When we construct an ADD A for sub-constraint i=jnailik, we store this ADD and the corresponding interval [α,β]. When we compute a new sub-constraint i=jnailik with k[α,β], we can return the stored ADD and interval (lines 5–6). Otherwise, we need to recursively construct ADDs for sub-constraints (lines 7–8). With the outputs of recursive calls, we can compute the resulting ADD and the corresponding interval (lines 9–11).

Full size|PPT slide

Note that Algorithm 3 returns a tuple of an interval [α,β] and ADD A. That means every k[α,β] has same ADD A for sub-constraint γ:i=jnailik. In line 5 of Algorithm 1, we need to ignore intervals and only keep ADDs in κi.

4 Preprocessing techniques for WMC on PB

Efficient preprocessing techniques are an essential part of model counting solvers. Solvers like ExactMC and SharpSAT-TD have built-in preprocessors [10,42], and some preprocessors designed explicitly for Model Counting, such as pmc and B+E [43,44], have also demonstrated the significance of preprocessing. However, there are no dedicated pre-processing techniques for WMC on PB currently. We first applied two preprocessing techniques to pseudo-Boolean formulas as our built-in preprocessing methods.
The first technique is based on the backbone. The backbone of a formula φ is the set of all literals which are implied by φ when φ is satisfiable (variables that have the same value in all solutions) and is the empty set otherwise [43]. Algorithm 4 simplifies the PB formula φ by identifying backbone variables and propagating unit literals on these backbone variables. In our implementation, we use RoundingSAT [26] to solve a PB formula and return a solution that satisfies the formula (lines 2, 4). If the formula is unsatisfiable, an empty set is returned. Similar to CNF, when a literal is determined to be true, the unit propagation on PB removes the literal and its negation from all other constraints. It simultaneously eliminates the term (al or al¯) from both sides of the inequality. While the constraint is determined to be satisfiable, it can be deleted; if it is determined to be unsatisfiable, return .

Full size|PPT slide

Since PBCounter requires the construction and operations of ADDs for each constraint, we propose the second preprocessing technique deleteConstraint. It simplifies the formula by removing constraints γ:[φγ]γ representing in Algorithm 5. To verify [φγ]γ, which is equivalent to [φγ]γ¯, we transform γ into its corresponding CNF formula, denoted as c1c2cm. Then, we can proceed to validate [φγ](c1¯c2¯cm¯). Using the algorithm presented in Section 3, we can construct a ADD A for constraint γ (line 4). Each non-terminal node in A is labeled with a variable from X, and edges from each node represent literals (1-edge corresponds to positive literal, 0-edge corresponds to negative literal). That means all c1¯,c2¯,,cm¯ are unsatisfiable assignments for γ, and correspond to the path from the root node to a terminal node labeled with 0 in A (line 5).
Example 2 The PB formula φ includes three constraints, γ1:3x1+4x24, γ2:3x1+x3+x44, and γ3:3x2+x3+ x44. According to Fig.1, the ADD of γ1 has two paths, x1¯ and x1x2¯, to terminal node 0. Therefore, we get c1¯=x1¯ and c2¯=x1x2¯. Since [γ2γ3]c1¯ and [γ2γ3]c2¯, we can delete γ1 from φ.
To avoid the exponential explosion of ADD size, we do not attempt to delete constraints that involve more than 20 literals (line 2). We use unitPropagation to propagate all literals in unsatisfiable assignment ci¯ (line 8). If every ci satisfies [φγ]ci¯, γ is removed.

Full size|PPT slide

To achieve a more efficient implementation of Algorithm 5, we traverse all paths in A from the root to terminal nodes using a depth-first search. Based on the edges traversed along the path, we perform unit propagation on the literals it represented. When we reach the terminal node labeled 0 without encountering any conflicts, it implies there exists a ci¯ such that [φγ]ci¯. Therefore, the corresponding clause γ can not be removed (line 10). We can directly backtrack when a conflict occurs on non-terminal nodes.

5 Experimental results

In this section, we conducted experiments to evaluate the performance of our solver PBCounter. We implemented PBCounter in C++. All experiments were run on a computer with Intel(R) Xeon(R) W-2133 CPU @ 3.60 GHz and 64 GB RAM.

5.1 Experiment settings

As PBCounter is the first lazy WMC solver on PB constraints, we compare it with eager WMC solvers, an ILP counter, and a PB enumerator. We implemented two WMC encoding methods in C++ and combined them with four WMC counters on CNF. In other words, we have eight competitors for solving the WMC problem based on CNF, and two other approaches based on PB constraints. We ran each combination and PBCounter on each benchmark using a single core, 16 GB of memory, and 1800 seconds of the time limit.
Competitive solvers The four WMC solvers on CNF formulas include SharpSAT-TD, ExactMC, D4, and ADDMC. SharpSAT -TD is the winner of the Model Counting Competition 2021−2023 in the weighted track. It is based on solver SharpSAT and combines the technology of tree decomposition [12,42]. ExactMC is based on CCDD (a generalization of Decision-DNNF), which can capture literal equivalences [10]. After compiling the instance into CCDD, ExactMC can compute model counts in linear time. D4 is a Decision-DNNF compiler that can calculate model counts by knowledge compilation [14]. ADDMC is the winner of the Model Counting Competition 2020 in the weighted track. It is a dynamic programming algorithm using ADD as the main data structure [15]. We use the decision diagram package Sylvan to manage ADDs in ADDMC and our solver PBCounter. Sylvan can interface with the GNU Multiple Precision library to support ADDs with higher-precision numbers [45].
The two encoding methods we used are Warners [46] and ArcCons [47], which are proved counting safe [48]. We implemented the weighted encoders based on these two methods by keeping the original literals’ weights and setting the auxiliary literals’ weights to 1. This ensures that the weighted model counts are equal. We use VBS0 to denote the virtual best solver based on the CNF formulas and VBS1 to denote the virtual best solver after adding PBCounter to VBS0.
We also compared two other approaches. One is to run the PB solver RoundingSAT [26] to enumerate PB solutions and compute weighted model counts. The enumeration is achieved by continually adding the negation of the resulting satisfying assignments (called blocking clauses) to the formula to enumerate until the given formula is falsified. The other one uses ILP counter IntCount [32], which introduces column and row elimination techniques to decompose integer counting problems for linear constraints into independent sub-problems. Since IntCount cannot solve weighted instances, IntCount runs on an unweighted version of the benchmark.
Benchmarks Our benchmarks consist of three parts. 1) We select instances from PB Competition 06, excluding clause-style instances since they can be solved directly with the WMC solver, resulting in 287 instances. 2) We select the benchmarks of Exact Cover used by Junttila and Kaski, consisting of 539 instances from 7 different problem families [49]. 3) According to the generator proposed by Kovásznai, we randomly generated 600 instances of Wireless Sensor Network (WSN) problem for six different combinations of three types of sensor and target nodes (5-2, 6-2, 7-3), and two constraint sets (all constraints on and evasive & moving off) [21]. One hundred instances were generated for each configuration.
For these instances, we randomly assigned weights W(x)(0,1) and 1W(x) to each x and x¯, respectively. For SharpSAT-TD, ExactMC, and D4, random weights have no effect on their performance. For ADDMC and PBCounter, random weights may increase the number of terminal nodes in ADDs and therefore may increase the times of operating ADDs.

5.2 Evaluation

Experiment on preprocessing techniques Firstly, we compared the impact of the preprocessing techniques mentioned in Section 4 on PBCounter. We used “NoPre” to represent PBCounter without any preprocessing techniques, and “OnlyBb” to represent PBCounter with only the backbone technique (Algorithm 4). Tab.1 presents the results of the experiment for various benchmarks. We emphasize that the number of solved benchmarks only counts satisfiable instances. Unsatisfiable instances can be judged by pre-calling the PB or SAT solver and have no significance for model counting
Tab.1 Results of different preprocessing techniques
Benchmark(#) NoPre OnlyBb PBCounter
PB06 (287) 28 37 39
ExactCover (539) 192 193 194
WSN (600) 387 425 483
Total (1426) 607 655 716
The results show that the preprocessing techniques of Algorithms 4 and 5 exhibit positive impacts across three different benchmarks. After incorporating preprocessing techniques into PBCounter, the algorithm was able to solve an additional 109 instances in total. Additionally, using only backbone technique allows PBCounter to solve an additional 48 instances. Notably, the most significant enhancement was observed in the WSN benchmark.
Comparing with WMC Solvers on CNF The performances of PBCounter and other counting combinations are summarized in Tab.2 and Fig.2. PBCounter is the fastest solver in 327 instances and can uniquely solve 110 instances. PBCounter_NoPre turns off preprocessing techniques and solves more instances than CNF-based WMC solvers; it uses the shortest time in 62 instances and uniquely solves 19 instances.
Tab.2 The number of instances solved by solvers
Solvers Instances solved
Unique Fastest Total
VBS1(with PBCounter) 750
VBS0(without PBCounter) 557
PBCounter 110 327 716
PBCounter_NoPre 19 62 607
SharpSAT-TD + Warners 3 11 531
SharpSAT-TD + ArcCons 0 2 520
ExactMC + Warners 0 3 511
ExactMC + ArcCons 0 327 499
D4 + Warners 0 0 445
D4 + ArcCons 1 18 480
ADDMC + Warners 0 0 155
ADDMC + ArcCons 0 0 266
Fig.2 A cactus plot of the numbers of benchmarks solved by ten weighted model counters and two virtual best solvers (VBS1, with PBCounter, and VBS0, without PBCounter)

Full size|PPT slide

Two virtual best solvers: VBS1 shows the shortest solving time among all counters for each benchmark, while VBS0 shows the shortest time among eight WMC combinations (excluding PBCounter). Except for PBCounter, SharpSAT-TD solves the most number of instances, while ExactMC has shorter solving times on more instances.
For the instances PBCounter uniquely solved, we observed that they often have long constraints. Encoding long constraints into CNF introduces more auxiliary variables and increases the difficulty of solving. Additionally, if only a few variables appear in multiple long constraints, PBCounter can reduce the size of ADDs by early projection before product computations.
Comparing with different approaches We use “RSBlock” to denote our implementation of the enumeration solver based on RoundingSAT [26]. IntCount is an ILP counter developed by Ge et al. [32] based on Barvinok [50]. Tab.3 shows the number of benchmarks solved by PBCounter, RSBlock, and IntCount.
Tab.3 Results of different approaches
Benchmark (#) PBCounter RSBlock IntCount
PB06 (287) 39 16 5
ExactCover (539) 194 178 8
WSN (600) 483 0 23
Total (1426) 716 194 36
RSBlock performs well when the number of solutions is small, especially in the ExactCover benchmark. In fact, with only one solution, the enumeration algorithm only needs to call the PB solver twice. In the WSN benchmark, the time and space consumption of RSBlock enumerated solutions become unsolvable due to the large satisfiable solution space. The ILP solver IntCount performs poorly in the three PB benchmarks, even if they are unweighted. We find that IntCount is more difficult to solve when the number of variables in instances is large and cannot be decomposed.

6 Conclusion and future work

In this work, we implemented the first lazy weighted model counter PBCounter on PB constraints with two preprocessing techniques. Like ADDMC, PBCounter is based on variable elimination and uses dynamic programming techniques. Our experiments show that PBCounter performed better than the eager state-of-the-art WMC tools; that is, encoding PB constraints into CNF formulas, and then employing ADDMC, SharpSAT-TD, ExactMC, or D4.
The studies [43,51,52] in model counting on CNF formulas show that the usage of pre-processing is critical for the performance of model counters. Our experimental results show that the proposed two preprocessing techniques are very effective in improving the performance of PBCounter, which is consistent with the previous studies. However, on the one hand, the implementation of the two pre-processing techniques is still relatively basic and can be improved further; on the other hand, we can still design more preprocessing techniques. For example, there is a lot of exciting work that can transform PB constraints and CNF formulas into each other with the counting-safe property. Therefore, we can first transform PB constraints into a CNF formula, then pre-process the CNF formula, and finally transform the pre-processed CNF formula into PB constraints. One future direction of this study is to develop a more effective pre-processor for the WMC task on PB constraints.

Yong Lai is an associate professor at the College of Computer Science and Technology, Jilin University, China. He received his PhD degree from Jilin University, China. His research interests include knowledge representation and reasoning, neural-symbolic computation, tractable machine learning, and probabilistic graphical model

Zhenghang Xu received a BS degree in Computer Science and Information Technology, Northeast Normal University, China in 2020. Currently, he is pursuing a Master’s degree at the College of Computer Science and Technology, Jilin University, China. His research interests include model counting and algorithm design

Minghao Yin is a professor at the School of Computer Science and Information Technology, Northeast Normal University, China. He received his PhD degree in Computer Software and Theory from Jilin University, China. His research interests include heuristic search, data mining, and combinatorial optimization

References

[1]
Baluta T, Shen S, Shinde S, Meel K S, Saxena P. Quantitative verification of neural networks and its security applications. In: Proceedings of 2019 ACM SIGSAC Conference on Computer and Communications Security. 2019, 1249−1264
[2]
Duenas-Osorio L, Meel K S, Paredes R, Vardi M Y. Counting-based reliability estimation for power-transmission grids. In: Proceedings of the AAAI Conference on Artificial Intelligence. 2017, 4488−4494
[3]
Palash Sashittal, and Mohammed El-Kebir SharpTNl: counting and sampling parsimonious transmission networks under a weak bottleneck. RECOMB Comparative Genomics(RECOMB-CG), Montpellier, France, October 1−4, 2019
[4]
Roth D. On the hardness of approximate reasoning. Artificial Intelligence, 1996, 82(1−2): 273−302
[5]
Sang T, Beame P, Kautz H. Performing Bayesian inference by weighted model counting. In: Proceedings of the 20th National Conference on Artificial Intelligence. 2005, 475−481
[6]
Chavira M, Darwiche A. On probabilistic inference by weighted model counting. Artificial Intelligence, 2008, 172(6−7): 772−799
[7]
Domshlak C, Hoffmann J . Probabilistic planning via heuristic forward search and weighted model counting. Journal of Artificial Intelligence Research, 2007, 30: 565–620
[8]
Van Den Broeck G, Suciu D. Query processing on probabilistic data: a survey. Foundations and Trends® in Databases, 2017, 7(3−4): 197−341
[9]
Fierens D, Van Den Broeck G, Renkens J, Shterionov D, Gutmann B, Thon I, Janssens G, Raedt L D . Inference and learning in probabilistic logic programs using weighted Boolean formulas. Theory and Practice of Logic Programming, 2015, 15( 3): 358–401
[10]
Lai Y, Meel K S, Yap R H C. The power of literal equivalence in model counting. In: Proceedings of the AAAI Conference on Artificial Intelligence. 2021, 3851−3859
[11]
Sang T, Bacchus F, Beame P, Kautz H, Pitassi T. Combining component caching and clause learning for effective model counting. In: Proceedings of the 7th International Conference on Theory and Applications of Satisfiability Testing. 2004, 1−9
[12]
Thurley M. sharpSAT - counting models with advanced component caching and implicit BCP. In: Proceedings of the 9th International Conference Theory and Applications of Satisfiability Testing. 2006, 424−429
[13]
Sharma S, Roy S, Soos M, Meel K S. GANAK: a scalable probabilistic exact model counter. In: Proceedings of the 28th International Joint Conference on Artificial Intelligence. 2019, 1169−1176
[14]
Lagniez J M, Marquis P. An improved decision-DNNF compiler. In: Proceedings of the 26th International Joint Conference on Artificial Intelligence. 2017, 667−673
[15]
Dudek J, Phan V, Vardi M. ADDMC: weighted model counting with algebraic decision diagrams. In: Proceedings of the AAAI Conference on Artificial Intelligence. 2020, 1468−1476
[16]
Hecher M, Thier P, Woltran S. Taming high treewidth with abstraction, nested dynamic programming, and database technology. In: Proceedings of the 23rd International Conference on Theory and Applications of Satisfiability Testing. 2020, 343−360
[17]
Ermon S, Gomes C, Selman B. Uniform solution sampling using a constraint solver as an oracle. In: Proceedings of the 28th Conference on Uncertainty in Artificial Intelligence. 2012, 255−264
[18]
Chakraborty S, Meel K S, Vardi M Y. A scalable approximate model counter. In: Proceedings of the 19th International Conference on Principles and Practice of Constraint Programing. 2013, 200−216
[19]
Lai Y, Meel K S, Yap R H C. Fast converging anytime model counting. In: Proceedings of the AAAI Conference on Artificial Intelligence. 2023, 4025−4034
[20]
Le Berre D, Marquis P, Mengel S, Wallon R. Pseudo-Boolean constraints from a knowledge representation perspective. In: Proceedings of the 27th International Joint Conference on Artificial Intelligence. 2018, 1891−1897
[21]
Kovásznai G, Erdélyi B, Biró C. Investigations of graph properties in terms of wireless sensor network optimization. In: Proceedings of 2018 IEEE International Conference on Future IoT Technologies (Future IoT). 2018, 1−8
[22]
Aloul F A, Ramani A, Markov I L, Sakallah K A. Generic ILP versus specialized 0-1 ILP: an update. In: Proceedings of the IEEE/ACM International Conference on Computer Aided Design. 2002, 450−457
[23]
Lei Z, Cai S, Luo C, Hoos H. Efficient local search for pseudo Boolean optimization. In: Proceedings of the 24th International Conference on Theory and Applications of Satisfiability Testing. 2021, 332−348
[24]
Aloul F A, Ramani A, Markov I L, Sakallah K A. PBS: a backtrack-search pseudo-Boolean solver and optimizer. In: Proceedings of the 5th International Symposium on Theory and Applications of Satisfiability Testing. 2000, 346−353
[25]
Sheini H M, Sakallah K A. Pueblo: a hybrid pseudo-Boolean SAT solver. Journal on Satisfiability, Boolean Modeling and Computation, 2006, 2(1−4): 165−189
[26]
Elffers J, Nordström J. Divide and conquer: towards faster pseudo-Boolean solving. In: Proceedings of the 27th International Joint Conference on Artificial Intelligence. 2018, 1291−1299
[27]
Chu Y, Cai S, Luo C, Lei Z, Peng C. Towards more efficient local search for pseudo-Boolean optimization. In: Proceedings of the 29th International Conference on Principles and Practice of Constraint Programming. 2023, 12
[28]
Zhou W, Zhao Y, Wang Y, Cai S, Wang S, Wang X, Yin M. Improving local search for pseudo Boolean optimization by fragile scoring function and deep optimization. In: Proceedings of the 29th International Conference on Principles and Practice of Constraint Programming. 2023, 41
[29]
Huang A, Lloyd L, Omar M, Boerkoel J. New perspectives on flexibility in simple temporal planning. In: Proceedings of the International Conference on Automated Planning and Scheduling. 2018, 123−131
[30]
Luckow K, Păsăreanu C S, Dwyer M B, Filieri A, Visser W. Exact and approximate probabilistic symbolic execution for nondeterministic programs. In: Proceedings of the 29th ACM/IEEE International Conference on Automated Software Engineering. 2014, 575−586
[31]
Ge C, Ma F, Ma X, Zhang F, Huang P, Zhang J. Approximating integer solution counting via space quantification for linear constraints. In: Proceedings of the 28th International Joint Conference on Artificial Intelligence. 2019, 1697−1703
[32]
Ge C, Biere A. Decomposition strategies to count integer solutions over linear constraints. In: Proceedings of the 30th International Joint Conference on Artificial Intelligence. 2021, 1389−1395
[33]
Kolaitis P G, Vardi M Y . Conjunctive-query containment and constraint satisfaction. Journal of Computer and System Sciences, 2000, 61( 2): 302–332
[34]
Pan G, Vardi M Y. Symbolic techniques in satisfiability solving. Journal of Automated Reasoning, 2005, 35(1−3): 25−50
[35]
Eén N, Sörensson N. Translating pseudo-Boolean constraints into SAT. Journal on Satisfiability, Boolean Modeling and Computation, 2006, 2(1−4): 1−26
[36]
Aavani A, Mitchell D G, Ternovska E. New encoding for translating pseudo-Boolean constraints into SAT. In: Proceedings of the 10th Symposium on Abstraction, Reformulation, and Approximation. 2013
[37]
Bofill M, Coll J, Nightingale P, Suy J, Ulrich-Oltean F, Villaret M . SAT encodings for pseudo-Boolean constraints together with at-most-one constraints. Artificial Intelligence, 2022, 302: 103604
[38]
Bahar R I, Frohm E A, Gaona C M, Hachtel G D, Macii E, Pardo A, Somenzi F. Algebric decision diagrams and their applications. Formal Methods in System Design, 1997, 10(2−3): 171−206
[39]
Tarjan R E, Yannakakis M . Simple linear-time algorithms to test chordality of graphs, test acyclicity of hypergraphs, and selectively reduce acyclic hypergraphs. SIAM Journal on Computing, 1984, 13( 3): 566–579
[40]
Koster A M C A, Bodlaender H L, Van Hoesel S P M . Treewidth: computational experiments. Electronic Notes in Discrete Mathematics, 2001, 8: 54–57
[41]
Abío I, Nieuwenhuis R, Oliveras A, Rodríguez-Carbonell E, Mayer-Eichberger V . A new look at BDDs for pseudo-Boolean constraints. Journal of Artificial Intelligence Research, 2012, 45( 1): 443–480
[42]
Korhonen T, Järvisalo M. Integrating tree decompositions into decision heuristics of propositional model counters (short paper). In: Proceedings of the 27th International Conference on Principles and Practice of Constraint Programming. 2021, 8
[43]
Lagniez J M, Marquis P. Preprocessing for propositional model counting. In: Proceedings of the 28th AAAI Conference on Artificial Intelligence. 2014, 2688−2694
[44]
Lagniez J M, Lonca E, Marquis P . Definability for model counting. Artificial Intelligence, 2020, 281: 103229
[45]
Van Dijk T, Van De Pol J . Sylvan: multi-core framework for decision diagrams. International Journal on Software Tools for Technology Transfer, 2017, 19( 6): 675–696
[46]
Warners J P . A linear-time transformation of linear inequalities into conjunctive normal form. Information Processing Letters, 1998, 68( 2): 63–69
[47]
Bailleux O, Boufkhad Y, Roussel O. A translation of pseudo-Boolean constraints to SAT. Journal on Satisfiability, Boolean Modeling and Computation, 2006, 2(1−4): 191−200
[48]
Morgado A, Matos P J, Manquinho V, Marques-Silva J. Counting models in integer domains. In: Proceedings of the 9th International Conference on Theory and Applications of Satisfiability Testing. 2006, 410−423
[49]
Junttila T, Kaski P. Exact cover via satisfiability: an empirical study. In: Proceedings of the 16th International Conference on Principles and Practice of Constraint Programming. 2010, 297−304
[50]
Verdoolaege S, Seghir R, Beyls K, Loechner V, Bruynooghe M . Counting integer points in parametric polytopes using Barvinok’s rational functions. Algorithmica, 2007, 48( 1): 37–66
[51]
Lagniez J M, Lonca E, Marquis P. Improving model counting by leveraging definability. In: Proceedings of the 25th International Joint Conference on Artificial Intelligence. 2016, 751−757
[52]
Soos M, Meel K S. Arjun: an efficient independent support computation technique and its applications to counting and sampling. In: Proceedings of the 41st IEEE/ACM International Conference on Computer Aided Design. 2022, 1−9

Acknowledgements

This work was supported by NSFC (Grant Nos. 61976050, 61972384), the Jilin Province Science and Technology Department project (Nos. 20240101378JC, 20240602005RC, YDZJ202201ZYTS415), Jilin Education Department Project (No.JJKH20231319KJ). Thanks to the editorial board and reviewers for their valuable comments.

Competing interests

The authors declare that they have no competing interests or financial conflicts to disclose.

RIGHTS & PERMISSIONS

2025 Higher Education Press
AI Summary AI Mindmap
PDF(3907 KB)

Supplementary files

FCS-23631-OF-YL_suppl_1 (309 KB)

467

Accesses

0

Citations

7

Altmetric

Detail

Sections
Recommended

/