Compiling Constraint Networks into Multivalued Decomposable Decision Graphs
Proceedings of the Twenty-Fourth International Joint Conference on Artificial Intelligence. Main Track. Pages 332-337.
© 2015 International Joint Conferences on Artificial Intelligence
Abstract
We present and evaluate a top-down algorithm for compiling finite-domain constraint networks (CNs) into the language MDDG of multivalued decomposable decision graphs. Though it includes Decision-DNNF as a proper subset, MDDG offers the same key tractable queries and transformations as Decision-DNNF, which makes it useful for many applications. Intensive experiments showed that our compiler cn2mddg succeeds in compiling CNs which are out of the reach of standard approaches based on a translation of the input network to CNF, followed by a compilation to Decision-DNNF. Furthermore, the sizes of the resulting compiled representations turn out to be much smaller (sometimes by several orders of magnitude).
- [Amilhastre et al., 2002] J. Amilhastre, H. Fargier, and P. Marquis. Consistency restoration and explanations in dynamic CSPs application to configuration. Artificial In- telligence, 135(1-2):199-234, 2002.
- [Amilhastre et al., 2014] J. Amilhastre, H. Fargier, A. Niveau, and C. Pralet. Compiling CSPs: A com- plexity map of (non-deterministic) multivalued decision diagrams. International Journal on Artificial Intelligence Tools, 23(4), 2014.
- [Boussemart et al., 2004] F. Boussemart, F. Hemery, Ch. Lecoutre, and L. Saïs. Boosting systematic search by weighting constraints. In Proc. of ECAI'04, pages 146- 150, 2004.
- [Brandes, 2008] U. Brandes. On variants of shortest-path be- tweenness centrality and their generic computation. Social Networks, 30(2):136-145, 2008.
- [Cambazard et al., 2010] H. Cambazard, T. Hadzic, and B. O'Sullivan. Knowledge compilation for itemset min- ing. In Proc. of ECAI'10, pages 1109-1110, 2010.
- [Darwiche and Marquis, 2002] A. Darwiche and P. Marquis. A knowledge compilation map. Journal of Artificial Intel- ligence Research, 17:229-264, 2002.
- [Darwiche, 2004] A. Darwiche. New advances in compiling CNF into decomposable negation normal form. In Proc. of ECAI'04, pages 328-332, 2004.
- [de Kleer, 1989] J. de Kleer. A comparison of ATMS and CSP techniques. In Proc. of IJCAI'89, pages 290-296, 1989. IJCAI
- [Dechter and Pearl, 1989] R. Dechter and J. Pearl. Tree clustering for constraint networks. Artificial Intelligence, 38(3):353-366, 1989.
- [Fargier and Marquis, 2006] H. Fargier and P. Marquis. On the use of partially ordered decision graphs in knowledge compilation and quantified Boolean formulae. In Proc. of AAAI'06, pages 42-47, 2006.
- [Freuder and O'Sullivan, 2014] E. Freuder and B. O'Sullivan. Grand challenges for constraint pro- gramming. Constraints, 19:150-162, 2014.
- [Gent, 2002] I. P. Gent. Arc consistency in SAT. In Proc. of ECAI'02, pages 121-125, 2002.
- [Huang and Darwiche, 2007] J. Huang and A. Darwiche. The language of search. Journal of Artificial Intelligence Research, 29:191-219, 2007.
- [Iwama and Miyazaki, 1994] K. Iwama and S. Miyazaki. SAT-variable complexity of hard combinatorial problems. In Proc. of IFIP World Computer Congress'94, pages 253- 258, 1994.
- [Junker, 2006] U. Junker. Configuration. In F. Rossi, P. van Beek, and T. Walsh, editors, Handbook of Constraint Pro- gramming, chapter 24. Elsevier, 2006.
- [Mateescu et al., 2008] R. Mateescu, R. Dechter, and R. Marinescu. AND/OR multi-valued decision diagrams (AOMDDs) for graphical models. Journal of Artificial Intelligence Research, 33:465-519, 2008.
- [Muise et al., 2012] Ch.J. Muise, Sh.A. McIlraith, J.Ch. Beck, and E.I. Hsu. Dsharp: Fast d-DNNF compilation with sharpSAT. In Proc. of AI'12, pages 356-361, 2012.
- [Oztok and Darwiche, 2014] U. Oztok and A. Darwiche. On compiling CNF into decision-DNNF. In Proc. of CP'14, pages 42-57, 2014.
- [Rossi et al., 2006] F. Rossi, P. van Beek, and T. Walsh. Handbook of Constraint Programming. Foundations of Artificial Intelligence. Elsevier, 2006.
- [Roussel and Lecoutre, 2009] O. Roussel and Ch. Lecoutre. XML Representation of Constraint Networks: Format XCSP 2.1. Technical report, Computing Research Repos- itory (CoRR) abs/0902.2362, feb 2009.
- [Tamura et al., 2009] N. Tamura, A. Taga, S. Kitagawa, and M. Banbara. Compiling finite linear CSP into SAT. Con- straints, 14(2):254-272, 2009.
- [Tanjo et al., 2012] T. Tanjo, N. Tamura, and M. Banbara. Azucar: A SAT-based CSP solver using compact order en- coding -(tool presentation). In Proc. of SAT'12, pages 456-462, 2012.
- [Vempaty, 1992] N.R. Vempaty. Solving constraint satisfac- tion problems using finite state automata. In Proc. of AAAI'92, pages 453-458, 1992.
- [Walsh, 2000] T. Walsh. SAT v CSP. In Proc. of CP'00, pages 441-456, 2000.
References were extracted automatically from the PDF and may contain errors.
Full text extracted automatically from the PDF; figures, tables and equations may differ. The PDF is the version of record.
1 Introduction
Constraint Programming (CP) has long been recognized as a paradigm of choice for representing and solving combinatorial problems [Rossi et al., 2006]. Knowledge about the problem is represented in a compact and intuitive way, using a constraint network (CN), which involves a set of variables associated with their domain of values, and a collection of constraints specifying that some subsets of values cannot be used together. Despite its undoubtable success in IA, one of the key remaining challenges of CP is to provide performance guarantees for query answering, which often amounts to solving instances of NP-hard problems. As emphasized in [Freuder and O'Sullivan, 2014], this issue is critical in on-line applications, such as configuration softwares [Junker, 2006] and recommender systems [Cambazard et al., 2010], where queries supplied "on the fly" by users, are to be answered in real time.
The aim of this paper is to address this challenge using knowledge compilation [Darwiche and Marquis, 2002]. The overall idea is to convert a constraint language into a target compilation language that supports inference tasks (often classified as queries and transformations) in polynomial time. Thus, while many queries are intractable when the input is a CN, they become tractable from a compiled representation of it, enabling on-line performance guarantees when the compiled representation remains small enough.
Specifically, we present a top-down algorithm cn2mddg for compiling finite-domain CNs into multivalued decomposable decision graphs. The input of cn2mddg is a CN represented in the XCSP 2.1 format [Roussel and Lecoutre, 2009]. The output of our compilation algorithm is a representation of the solutions of the CN in the language MDDG of multivalued decomposable decision graphs. MDDG is precisely the extension to non-Boolean domains of the language DDG [Fargier and Marquis, 2006] also known as DecisionDNNF [Oztok and Darwiche, 2014]: it is based on decomposable ∧-nodes and (multivalued) decision nodes. Similarly to Decision-DNNF, the MDDG language offers a number of tractable queries, including (possibly weighted) solution finding and counting, solution enumeration (solutions can be enumerated with polynomial delay), and optimization w.r.t. a linear objective function. It also offers tractable transformations, especially the conditioning one (i.e., the instantiation of variables, and more generally, the addition of unary constraints).
cn2mddg benefits from a specific caching technique, a new variable ordering heuristic based on betweenness centrality and it detects universal constraints during the search in order to perform additional simplifications. We performed an intensive evaluation of cn2mddg on a number of benchmarks (173) from several data sets (15). Given the availability of Decision-DNNF compilers, a way to compile CNs is to follow a translate-then-compile schema: one first encodes the input network into a CNF formula, then one takes advantage of a compiler like c2d [Darwiche, 2004] or Dsharp [Muise et al., 2012] to turn the resulting formula into a Decision-DNNF representation. Based on the results reported from our experimentations, it turns out that whatever the encodings used, both the huge number of Boolean variables in the generated CNF formulae, and the structure loss inherent to the CNF format (compared to the constraint network one) make the translate-then-compile approaches impractical in many cases. Contrastingly, our compiler cn2mddg proved much more robust since it succeeded in compiling many CNs which are out of reach of the translate-then-compile approaches. Moreover, the sizes of the resulting compiled representations turn out to be much smaller (sometimes by several orders of magnitude).
The run-time code of our compiler, as well as the translators and the benchmarks used in our experiments, and additional empirical results, can be downloaded from www.cril. fr/KC/
2 Formal Preliminaries
A finite-domain constraint network (CN) is a triple N = (X , D, C) consisting of a set X = {X1, · · · ,Xn} of variables, a set D = {D1, · · · ,Dn} of domains, and a set C = {C1, · · · , Cm} of constraints. Each domain Di is a finite set containing the possible values of Xi. Each constraint Cj characterizes the combinations of values satisfying it. Formally, Cj = (Sj,Rj), where Sj = {Xj1 , · · · ,Xjk } is a subset of variables from X, called the scope of Cj, and Rj is a predicate over the Cartesian product Dj1 × · · · × Djk , called the relation of Cj. Rj can be represented extensionally by the list of its satisfying tuples (or dually, by the list of its forbidden tuples), or intensionally by an oracle, i.e., a mapping from Dj1 ×· · ·×Djk to {0, 1} which is supposed to be computable in time polynomial in its input size. The arity of a constraint is given by the size of its scope. Constraints of arity 2 are called binary and constraints of arity greater than 2 are called non-binary.
Example 1 Let N be the CN given by four variables X1, X2, X3, and X4, each of them being defined on the same domain {0, 1, 2}, and three constraints C1, C2, and C3, specified by the following mathematical statements:
- C1 = (X1 ̸=X2);
- C2 = (X2 = 0) ∨ (X2 = 1) ∨ (X2 = X3 + X4 + 1);
- C3 = (X3 >X4).
Given a subset S of variables from X, a (decision) state s over S is a mapping that associates with each variable Xi in S a subset s(Xi) of values in Di. In what follows, states are often noted as union of elementary assignments, i.e., sets of the form {〈Xi, xj〉}, where xj ∈ s(Xi). scope(s) denotes the set S of variables over which s is defined. A state s is partial if scope(s) is a proper subset of X; otherwise, s is called a full state. A variable Xi in scope(s) is instantiated if s(Xi) is a singleton set. The set of instantiated variables in s is noted single(s). As usual, a state s is called an instantiation when all its variables are instantiated, i.e., scope(s) = single(s).
For a state s and a set of variables T ⊆ scope(s), s[T ] denotes the restriction of s to T , i.e., s[T ] is the set {〈Xi, xj〉 ∈ s | Xi ∈ T}. An instantiation s satisfies a contraint Cj = (Sj , Rj) if Sj ⊆ scope(s) and Rj(xj1 , . . . , xjk ) = 1, where ∀l ∈ 1, . . . , k, 〈Xjl , xjl 〉 ∈ s[Sj]. A solution of a CN N = (X , D, C) is a full instantiation s satisfying all constraints Cj in C. For example, s = {〈X1, 1〉, 〈X2, 0〉, 〈X3, 1〉, 〈X4, 0〉} is a solution of the CN given at Example 1.
Given a CN N = (X , D, C) and a state s over a subset of X, the conditioning N | s of N by s is the CN (X ′ ,D′ , C ′ ) defined as follows: X ′ = X \single(s); with each domain Di in D, one associates the domain D′i ∈ D′ , where D′i = Di if Xi ̸∈ scope(s) and D′i = s(Di) otherwise; finally, with each constraint Cj = (Sj,Rj) in C, one associates the constraint C ′j = (S′j ,R′j ) in C ′ , where S′j = Sj \ single(s) and R′j is the restriction of Rj to S′j .
The primal graph of a CN N = (X,D, C) is the undirected graph G with vertex set X and edge set E, such that {Xp,Xq} ∈ E if and only if {Xp,Xq} is a subset of the scope Sj of some constraint Cj in C. For instance, the primal graph of the CN given at Example 1 is depicted on Figure 1.

3 The MDDG Language
Let us first consider the language MDG of multivalued decision graphs:
Definition 1 (MDG) Given a finite set X of finite-domain variables, the (read-once) MDG language over X is the set of all single-rooted directed acyclic graphs ∆, where leaf nodes are labelled by ⊤ (true) or ⊥ (false), and every internal node is either a ∧-node N = ∧(N1, . . . , Ni) or a decision node N associated with variable Xi ∈ X , i.e., a deterministic ∨-node N = ∨(N1, . . . , Nj) such that Di = {xi1 , . . . , xij } and the arc from N to Nk (k ∈ 1, . . . , j) is labelled by the elementary assignment {〈Xi, xik 〉}. The paths of ∆ must satisfy the read-once property: for every path from the root of ∆ to a ⊤ leaf node, and for any variable Xi ∈ X, no more than one arc can be labelled by an elementary assignment over Xi.
For every node N in an MDG representation ∆, Var(N) is defined inductively as follows:
- if N is a leaf node, then Var(N) = ∅;
- if N is a ∧-node N = ∧(N1, . . . ,Ni), then Var (N) = ⋃ik=1 Var (Ni);
- if N is a decision node N = ∨(N1, . . . ,Nj) associated with variable X, then Var(N) = {X} ∪ ⋃jk=1 Var (Nk).
Let s be a full instantiation over X and let ∆ be a MDG representation over X, rooted at node N. Let eval(N, s) be the MDG representation without any decision node, defined inductively by:
- if N is a leaf node, then eval(N, s) = N;
- if N is a ∧-node N = ∧(N1, . . . ,Ni), then eval (N, s) = ∧(eval (N1, s), . . . , eval (Ni, s));
- if N is a decision node N = ∨(N1, . . . ,Nj) associated with variable Xi, then eval (N, s) = eval (Nk, s), where 〈Xi, xik 〉 ∈ s.
s is a solution of ∆ if and only eval (N, s) evaluates to true.
The language MDDG we are interested in is the subset of MDG consisting of decomposable representations, those where the children of any ∧-node do not share any variable:
Definition 2 (MDDG) Given a finite set X of finite-domain variables, the MDDG language over X is the subset of MDG representations ∆, where each ∧-node N = ∧(N1, . . . , Ni) is decomposable, i.e., ∀k, l ∈ 1, . . . , i, if k ̸= l, then Var (Nk) ∩ Var (Nl) = ∅.
The MDDG representation reported on Figure 2 is equivalent to the CN given at Example 1, i.e., they have the same solution set. Nodes with a single child are shunted, and their labels (in the case of decision nodes) are gathered with those of their incoming arcs. The corresponding elementary assignments typically result from propagation (the ∨-nodes are not created in that case, we mention them in the definition of MDDG for the ease of exposure). The arcs leading to ⊥ are not depicted. The ⊤ leaf is duplicated for readability reasons.

Decision-DNNF [Oztok and Darwiche, 2014; Fargier and Marquis, 2006] corresponds to the proper subset of MDDG where each variable has a Boolean domain. Despite the increase of generality obtained by accepting non-Boolean domains, the key tractable queries and transformations (weighted solution counting, solution enumeration, optimization w.r.t. a linear objective function and conditioning) offered by Decision-DNNF are also offered by MDDG (the polynomial-time (or polynomial-delay) algorithms used to achieve those queries and transformations in the DecisionDNNF case can be extended in a trivial way to the MDDG case).
MDDG is also close to the MDD language considered in [Amilhastre et al., 2014], and to the AOMDD language considered in [Mateescu et al., 2008], but it does not coincide with any of them. Thus, MDD and MDDG are not comparable w.r.t. set-inclusion; on the one hand, MDD consists of nondeterministic structures (more than one outgoing arc of a decision node labelled by a variable Xi can be labelled by the same value from the domain Di of Xi), while the decision nodes in an MDDG representation are always deterministic ones; on the other hand, MDDG representations include ∧- nodes, while the internal nodes of any MDD representation are decision nodes. Similarly, AOMDD and MDDG are not comparable w.r.t. set-inclusion; on the one hand, AOMDD is suited to the compilation of graphical models (or weighted constraint networks), and as such, it enables the representation of functions the co-domain of which is not Boolean in essence (like utility or cost functions, probability distributions, etc.) while MDDG cannot do it; on the other hand, AOMDD representations are ordered structures (they respect a pseudo-tree induced by a preset elimination order over the variables - this is a crucial requirement for canonicity) while in MDDG there is no such a requirement (MDDG representations are not canonical ones).
4 A Top-Down MDDG Compiler
We developed a top-down compiler cn2mddg which takes as input a CN represented in the XCSP 2.1 format [Roussel and Lecoutre, 2009], and generates a MDDG representation equivalent to it, i.e., having the same solutions. All the basic features offered by the XCSP 2.1 format are taken into account; especially, the constraints can be represented in intension (as "predicates") or in extension (as "relations"); however, only three global constraints are supported by our compiler in its current turn; namely allDifferent, weightedSum (i.e., linear constraints), and element . 1
The architecture of our cn2mddg compiler is somehow "standard", i.e., close to the one of a top-down compiler suited to Boolean domains, like the c2d compiler (reasoning.cs.ucla.edu/c2d/), or the Dsharp compiler (www. haz.ca/research/dsharp/), both targeting the Decision-DNNF language. Especially, our compiler is search-based: it follows the trace of a search engine [Huang and Darwiche, 2007]. It covers similar techniques as those used in c2d and in Dsharp, including conflict analysis for guiding the search, constraint propagation for simplification purpose, component caching in order to avoid the duplication of identical subparts of the compiled representation, and a dynamic variable ordering heuristic (as in Dsharp which takes advantage of the vsads variable selection heuristic). 2 Both the caching technique and the variable ordering heuristic used in cn2mddg are specific to the nature of the input (a CN), which exhibits much more structure than "flat" CNF formulae. Furthermore, our algorithm exploits a specific method for handling universal constraints, enabling additional simplifications to be performed.
Universal constraints. Universal constraints are constraints which are necessarily satisfied whatever the values (in the current domains of the variables) given to the variables of their scopes. Thus, for the CN given at Example 1, contraint C2 when conditioned by any of the elementary assignments {〈X2, 0〉} or {〈X2, 1〉} becomes universal. At every step of the compilation (i.e., whatever the current decision state), universal constraints are detected. Every constraint Cj = (Sj,Rj) ∈ C for which there exists Xi ∈ Sj such that Di has been reduced by propagation after the last elementary assignment, is checked for universality. One looks for an instantiation s of the variables of the current scope of Cj to values in their current domains such that s violates Rj; Cj is valid iff one cannot find such an instantiation s. For efficiency reasons, s is searched in a lazy way: when found, s is stored and the next time Cj is checked for universality, s is considered in priority. Once detected, a universal constraint Cj is simply deleted from the current network; obviously, this simplifies the forthcoming treatments (no need to take those constraints into account), favors decomposability (due to the edge deletion it leads to on the primal graph of the CN), and impacts the variable ordering heuristic. Note that in DecisionDNNF compilers the handling of universal constraints simply amounts to ignoring every clause sharing a literal with the current partial interpretation.
1 These constraints can be encoded as "predicates" as well, but then one cannot take advantage of their dedicated propagator.
2 Contrastingly, in c2d the variable ordering is static.
Caching. Caching is a key technique of any compiler computing DAG-based representations. It aims at refraining from solving the same subproblem twice or more, and duplicating parts of the compiled representation. Indeed, due to the (conditional) interchangeability of values in many networks, it is often the case that two distinct decision states s1 and s2 considered successively during the search give rise to the same problem, i.e., N | s1 and N | s2 are equivalent. In such a case, instead of compiling both networks, it can prove much better to compile N | s1 only, then to store in a cache an entry corresponding to N | s1 associated with the root node N of its MDDG representation, and to detect that N | s2 is equivalent to N | s1 by looking at each step into the cache: in this case, instead of performing the computationally demanding compilation of N | s2, it is enough to create an arc pointing to N to do the job. Thus, for the CN N given at Example 1, the component about {X3,X4} obtained by dynamic decomposition is the same one for the states {〈X2, 0〉} and {〈X2, 1〉}, so there is no need to duplicate it.
However, testing the equivalence of two CNs under states is computationally hard and an exponential number of subproblems have to be considered in general. For these reasons, it is not possible to perform brute-force caching where all non-equivalent N | s networks encountered during the search would be considered (this would require unmanageable compilation times). Thus, N | s1 and N | s2 are detected as "equivalent" when they are identical.
A main issue to be addressed for an efficient caching in practice concerns the size of the entries; preferably, one must keep them as small as possible. In our cache, one first stores the current domains of the current variables, i.e., s restricted to its unassigned variables. Storing all the current constraints would be too space demanding. Fortunately, this is useless in general. Indeed, every constraint Cj = (Sj,Rj) such that Sj ∩ single(s) = ∅ does not need to be saved (provided that the initial constraint Cj is available). Furthermore, no constraint Cj = (Sj,Rj) which is binary in the input network needs to be saved, provided that the current network is arc consistent: if no variable from Sj = {Xi,Xk} has been instantiated, then the previous case is recovered; if both variables Xi,Xk from Sj have been instantiated, then either Cj is universal or Cj is inconsistent, and there is no need to store it whatever the case; finally if only one variable Xi from Sj has been instantiated (say, to value xi), then the projection on the remaining (uninstantiated) variable Xk of the restriction of Rj for which Xi = xi coincides with the restriction of s to {Xk} when the current network is arc consistent. 3 Similarly, there is no need to store the allDifferent constraints which can be viewed as conjunctions of binary constraints. The remaining constraints are saved in our cache: for those represented in intension, the variables instantiated in s are replaced by their values in the predicates, and a simplification step is performed in order to possibly reduce the representations; those represented in extension are stored explicitly; finally, for each weightedSum constraint, the variables instantiated in s are replaced by their values, the constraint is simplified and only the resulting constant term needs to be stored; each element constraint R, when binary, does not need to be stored; in the remaining case, one stores {〈Xi, xi〉 ∈ s | Xi ∈ Sj} into the cache.
3 This is reminiscent to the treatment of binary clauses in Dsharp, which do not need to be cached provided that unit propagation has been performed [Muise et al., 2012].
Variable ordering heuristic. Our variable ordering heuristic bc is based on the concept of betweenness centrality [Brandes, 2008]which has been used in many network applications. Given a node Xi in a graph (in our case, the primal graph of the current CN in which the nodes can be identified as with the variables labelling them), bc(Xi) is equal to the number of shortest paths from all nodes to all others that pass through Xi. Formally,
where Xi, Xj , Xk are nodes of the given network, σ(Xj , Xk) is the number of shortest paths from Xj to Xk, and σXi (Xj,Xk) are the number of those paths passing through Xi. Thus, for the CNN given at Example 1, X2 is the unique variable maximizing the value of bc. Clearly enough, assigning first the most central variables of the primal graph (X, E) of a CN is a way to promote the generation of disjoint connected components of similar sizes, allowing the decomposition of the network into independent networks (i.e., bearing on pairwise disjoint sets of variables) of close sizes, which can be compiled separately and gathered using a ∧-node in the resulting MDDG representation. Interestingly, computing the betweenness centralities of all nodes in (X, E) can be done in time O(n.p), where n = #(X) and p = #(E). In practice, the computation of bc(Xi) for each node Xi of the primal graph (X, E) of a CN is efficient enough so that we can achieve it dynamically, i.e., for each network encountered during the compilation.
The cn2mddg compiler. Algorithm 1 provides the pseudo-code for the compiler cn2mddg. The compilation of a given CN N is achieved by calling cn2mddg on it and on the decision state s = {〈Xi, xi〉 | Xi ∈ X, xi ∈ Di}. First of all (line 1), the arc consistency of N under s is established (the values of the variables occurring in s which are not supported in N are removed from the state). For efficiency reasons, arc consistency is ensured at start (i.e., at the first call) and then maintained dynamically each time a new elementary assignment is considered (at line 13). Then, N is conditioned by the resulting state (line 2). 4 At line 3, a CSP solver is used to determine whether the resulting N is consistent or not. We developed our own solver, based on chronological backtracking and using the (now standard) conflict-directed dom/wdeg heuristic for selecting variables [Boussemart et al., 2004]. Arc consistency is maintained at every choice step. Every constraint Cj of C is associated with a weight, which is incremented each time a conflict is detected. If N is inconsistent, then it is equivalent to the MDDG representation reduced to a leaf labelled by ⊥, as returned by the algorithm. Line 4 concerns the other base case, when all the variables of X have been considered; in this situation, N is equivalent to the MDDG representation ⊤, as returned by the algorithm. In the remaining case (line 5), one first determines whether the current network N has already been encountered or not during the search. One takes advantage of the cache function which associates networks with MDDG representations given by their root nodes. If N has already been found, then the algorithm simply returns the root node of its MDDG compilation. Otherwise, N is first simplified by removing from it the universal constraints it may contain (this is achieved by the removeUniversal function, at line 6). Then (line 7) the connected components of the resulting network are looked for. The function connectedComponents returns a partition CoCo of the current set of variables X corresponding to the connected components of the primal graph of N (a simple breadth-first search is performed to find them). Each element Co of CoCo is considered successively (line 9); Co is a set of variables which are independent from the other elements of CoCo and each network corresponding to N restricted to Co can be compiled separately, leading to a set of nodes N∧ which is initialized to the empty set at line 8. For each Co, the current decision state s can be restricted to the variables occurring in Co. A variable Xi from Co is picked up using the function selectVariable at line 10. Then the values xi from the current domain of Xi are successively considered (line 12); each of them corresponds to an elementary assignment {〈Xi, xi〉} and the current network conditioned by s restricted to the variables of Co but Xi, and enriched with 〈Xi, xi〉, is compiled recursively (line 13); the set N∨ of resulting nodes, initialized to the empty set at line 11 is updated at line 13. When all the values xi have been considered, a new decision node labelled by Xi is created at line 14, and added to the set N∧. When all the connected components of CoCo have been considered, the elements of N∧ are gathered conjunctively to form a ∧-node N at line 15 thanks to the function aNode. This node is added to the cache associated with the entry N (line 16) and finally returned (line 17) as the root node of the MDDG representation of N.
4 In the implementation, the conditioning N | s at line 2 is not performed explicitly (it is presented as such for the sake of clarity); only the list of uninstantiated variables and the current domains are updated at each step (the constraints themselves are never modified for efficiency reasons).
Algorithm 1 is guaranteed to terminate since at each recursive step at least one variable of the initial CN is instantiated. By construction, the resulting MDDG representation is equivalent to N | s.
5 Experiments
While compiling CNs has been an issue considered for years (see e.g., [Vempaty, 1992; Amilhastre et al., 2002]), we are not aware of any available compiler suited to CNs over non-Boolean domains and handling constraints which
Algorithm 1: cn2mddg
input : a constraint network N = (X,D, C) input : a decision state s over a subset of X output: the root node N of an MDDG representation 1 s ← ac(N, s) 2 N ←N | s 3 if unsat(N) then return leaf(⊥) 4 if #(X) = 0 then return leaf(⊤) 5 if cache(N) ̸= nil then return cache(N) 6 C ← removeUniversal(C) 7 CoCo ← connectedComponents(N) 8 N∧ ← ∅ 9 foreach Co ∈ CoCo do 10 Xi ← selectVariable(Co) 11 N∨ ← ∅ 12 foreach xi s.t. 〈Xi, xi〉 ∈ s do 13 N∨ ← N∨ ∪cn2mddg(N , s[Co \ {Xi}] ∪{〈Xi , xi〉}) 14 N∧ ←N∧ ∪ dNode(Xi,N∨) 15 N ← aNode(N∧) 16 cache(N) ←N 17 return N
are intensionally represented. Especially, the AOMDD compiler available at http://graphmod.ics.uci.edu/group/aomdd assumes that each constraint of the input CN is represented extensionally by the list of its satisfying tuples. Fortunately, many SAT-encodings of CNs have been pointed out so far (see among others [de Kleer, 1989; Iwama and Miyazaki, 1994; Walsh, 2000; Gent, 2002]), rendering feasible a comparison with Decision-DNNF compilations of CNF translations of such CNs.
Setup. We have considered 173 CNs from 15 data sets, downloaded from github.com/MiniZinc/minizincbenchmarks, www.cril.univ-artois.fr/∼lecoutre/benchmarks. html, and www.itu.dk/research/cla/externals/clib/. Those data sets correspond to several families of problems, including configuration problems, scheduling problems, frequency allocation problems. For some instances, the constraints are represented extensionally, by the list of satisfying tuples or by the list of forbidden tuples; for other instances, they are given in intension.
Our purpose was to compile each input CN into an MDDG representation using cn2mddg, and into Decision-DNNF representations, using first a translation of it into CNF, then the Decision-DNNF compiler Dsharp. Two CNF encodings have been considered in our experiments: the sparse encoding S of the domains together with a mixed clause encoding of the constraints (i.e., each constraint is encoded using the support encoding or the conflict encoding, in order to minimize the number of generated clauses), and the log encoding L of the domains together with a conflict encoding of the constraints. 5
5 Some of the available translators, like Sugar [Tamura et al., 2009] or Azucar [Tanjo et al., 2012] lead to encodings which do not preserve equivalence (they are oriented to solve the satisfaction problem), and cannot be used as such for our compilation purpose.
| CN | CNF - sparse mixed encoding | CNF - log conflict encoding | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Name | type | #X | #C | maxA | maxD | tw | time | size | #pv | #pcl | time | size | #pv | #pcl | time | size |
| rect-packing/rect-packingrpp09-true ghoulomb/ghoulomb3-4-5 | I | 2196 | 2353 | 10 | 36 | 19 | 1673.33 | 514754 | 37044 | 593518 | 375.66 | 16118647 | 4466 | 392657 | TO | - |
| I | 2033 | 2051 | 11 | 26 | 31 | 15.17 | 5162 | MO | MO | MO | MO | MO | MO | MO | MO | |
| driver/normalized-driverlogw-08c-sat-ext | E | 408 | 9321 | 2 | 11 | 92 | 15.63 | 2931 | 9528 | 62825 | 6.42 | 139306 | 1050 | 46081 | 32.78 | 499796 |
| scheduling/talent-concert | I | 325 | 352 | 46 | 316 | 52 | 1277.21 | 404437 | MO | MO | MO | MO | MO | MO | MO | MO |
| fapp/fapp19/normalized-fapp19-0350-6 | I | 350 | 3114 | 2 | 802 | 130 | 79.34 | 1694146 | 166130802 | 867243022 | - | MO | MO | MO | MO | MO |
| costaArray/CostasArray10 | I | 110 | 338 | 4 | 19 | 23 | 10.39 | 13440 | 149564 | 841930 | TO | - | 540 | 3606946 | TO | - |
| costaArray/CostasArray14 | I | 210 | 808 | 4 | 27 | 36 | TO | - | 988671 | 5568047 | TO | - | 1036 | 34687218 | - | MO |
| photo/photophoto2 | I | 89 | 133 | 21 | 11 | 21 | 499.93 | 9564220 | 685555 | 14326576 | TO | - | 204 | 10923133 | - | MO |
| rlfap/normalized-scen4 | I | 680 | 3967 | 2 | 44 | 30 | 3.47 | 52226 | 915553 | 4875002 | - | MO | 4060 | 3058032 | TO | - |
| radiation/radiation04 | I | 781 | 569 | 9 | 5180 | 33 | - | MO | MO | MO | MO | MO | MO | MO | MO | MO |
| renault/normalized-renault-mod-32-ext | E | 111 | 154 | 10 | 42 | 11 | 20.39 | 160238 | 222582 | 1755876 | TO | - | 286 | 138124077 | - | MO |
| renault/normalized-renault-mod-11-ext | E | 111 | 149 | 10 | 42 | 10 | 16.22 | 41919 | 223718 | 1762294 | 3538.01 | 2399273 | 286 | 138117804 | - | MO |
| still-life/still-life7x7 | I | 690 | 803 | 50 | 50 | 49 | 1819.87 | 738478 | MO | MO | MO | MO | MO | MO | MO | MO |
| configit/Aralia/edfpa15r | I | 198 | 110 | 13 | 2 | 28 | 175.49 | 2044261 | 396 | 24710 | - | MO | 396 | 24710 | - | MO |
| configit/Aralia/edfpa14q | I | 505 | 194 | 22 | 2 | 34 | TO | - | 1010 | 5793030 | TO | - | 1010 | 5793030 | TO | - |
| configit/Aralia/das9207 | I | 600 | 324 | 8 | 2 | 15 | 8.94 | 45853 | 1200 | 3894 | 642.68 | 22707412 | 1200 | 3894 | 97.86 | 9937506 |
For each instance, we computed the compilation time (in seconds) and the size of the compiled representation (number of arcs in the DAG). For translation-based approaches, we also computed the translation time and the size of the resulting CNF formula (number of variables and number of clauses). Our experiments have been conducted on a Quadcore Intel XEON X5550 with 32GB of memory. A time limit of 3600s for the CNF translation phase (resp. the off-line compilation phase) and a total amount of 8GB of memory for storing the resulting CNF formula (resp. the compiled representation) have been considered for each instance.
Some Results. Within the time and memory limits we set, cn2mddg succeeded in compiling 131 instances over 173; the computation aborted with a time-out (TO) for 32 instances, and with a memory-out (MO) for 10 instances. This heavily contrasts with Dsharp which succeeded in compiling only 83 instances when the S encoding was used, and 61 instances when the L encoding was used. More in details, the CNF translation using S (resp. L) led to a memory-out for 27 (resp. 35) instances over 173; over the 146 (resp. 138) remaining instances, the DNNF compilation using Dsharp aborted with a time-out for 24 (resp. 21) instances, and with a memory-out for 39 (resp. 56) instances.

Whatever the encoding used (S or L), the translate-thencompile approach appears as impractical in many cases. This can be explained both by the huge number of Boolean variables in the generated CNF formulae, and the structure loss inherent to the CNF format (compared to the CN one). Contrastingly, our compiler cn2mddg proved much more robust since it succeeded in compiling many CNs which are out of reach of the translate-then-compile approaches. Especially, each of the 83 instances which have been compiled with success using Dsharp (with the S encoding) have also proved compilable into MDDG using cn2mddg. The compilation times required to produce MDDG representations from the input network are often smaller than the compilation times required to produce DNNF representations from the CNF translation of the network. More importantly, the sizes of the resulting compiled representations turn out to be always smaller, sometimes by several orders of magnitude, when MDDG is targeted compared to the DNNF case. This is salient on Figure 3, where each dot represents one of the 83 instances for which Dsharp (with the S encoding) did not fail. The time needed to compute (resp. the size of) the resulting MDDG representation is given by its x-coordinate and the the time needed to compute (resp. the size of) the resulting DNNF representation from the CNF translation is given by its y-coordinate. 6 Every scale is a logarithmic one.
Table 1 presents a selection of the results. Each line corresponds to a constraint network N = (X,D, C) identified by the leftmost column. The next columns give respectively the "type" of CN (Extension or Intension), the number #X of variables, the number #C of constraints, the maximal arity maxA of the constraints, the maximal size maxD of the domains, a upper bound tw of the treewidth of its primal graph, 7 the time needed to get the MDDG representation using cn2mddg, and the size of it. For the two CNF encodings under consideration, one can find the number #pv of propositional variables in it, the number #pcl of clauses in it, the time needed to get the DNNF representation using Dsharp, and the size of it. The reported results illustrate the benefits offered by cn2mddg over the translate-then-compile approaches, about both the number of benchmarks for which the compilation succeeded, and the sizes of the compiled representations. They also show the feasibility of MDDG compilation of CNs corresponding to real applications, and of significant complexity (often out of reach of tree clustering compilations [Dechter and Pearl, 1989], given the sizes of their domains and the treewidth of their primal graphs).
6 Note that the time differences in favor of cn2mddg would be even larger if the time needed to translate the CN into CNF would have been taken into account.
7 Computed using QuickBB - see http://www.hlt.utdallas.edu/ ∼vgogate/quickbb.html - equipped with the random ordering heuristic and for an allocated time of 1800s.
We also performed a differential evaluation for assessing the impact of each technique used within cn2mddg. Let dom/wdeg+noU be the version of cn2mddg for which the dom/wdeg heuristic is used (instead of bc), and the handling of universal constraints is disabled. dom/wdeg+noU solved only 101 instances (over 173) within the time and memory limits. Besides, the number of instances (over 101) for which the size of the MDDG representation obtained by cn2mddg (resp. dom/wdeg+noU) is lower than p = 12 times the size of the MDDG representation obtained by dom/wdeg+noU (resp. cn2mddg) is 35 (resp. 6). The corresponding number for the proportion p = 1 10 (instead of 12 ) is 12 (resp. 0).
6 Conclusion
The contribution of the paper is a top-down algorithm cn2mddg for compiling finite-domain CNs into multivalued decomposable decision graphs. cn2mddg takes advantage of a specific caching technique, a new variable ordering heuristic based on betweenness centrality, and the handling of universal constraints. Intensive experiments showed that cn2mddg succeeds in compiling CNs which cannot be compiled into Decision-DNNF via a preliminary translation into CNF, and leads to compiled forms which are typically much smaller.
@inproceedings{ijcai2015p53,
title = {Compiling Constraint Networks into Multivalued Decomposable Decision Graphs},
author = {Koriche, Frédéric and Lagniez, Jean-Marie and Marquis, Pierre and Thomas, Samuel},
booktitle = {Proceedings of the Twenty-Fourth International Joint Conference on
Artificial Intelligence, {IJCAI-15}},
publisher = {International Joint Conferences on Artificial Intelligence},
editor = {Qiang Yang and Michael Wooldridge},
pages = {332--337},
year = {2015},
month = {7},
note = {Main Track},
url = {https://ijcai.org/proceedings/2015/53},
}
TY - CPAPER TI - Compiling Constraint Networks into Multivalued Decomposable Decision Graphs AU - Koriche, Frédéric AU - Lagniez, Jean-Marie AU - Marquis, Pierre AU - Thomas, Samuel T2 - Proceedings of the Twenty-Fourth International Joint Conference on Artificial Intelligence, IJCAI-15 PB - International Joint Conferences on Artificial Intelligence PY - 2015 SP - 332 EP - 337 UR - https://ijcai.org/proceedings/2015/53 ER -Copied
Machine-readable versions of this paper, for tools and AI agents: