• No results found

We give the denitions of MDD and introduce MDD constraints [CY10] in this subsection.

Multi-valued decision diagram. A multi-valued decision diagram (MDD) [SKMB90] is a true-terminal denoted by tt, or a false-terminal denoted by ff, or a directed

acyclic graph (DAG) G rooted at a non-terminal node, denoted by root(G), of the form G = mdd(x, {a1/G1, . . . , ad/Gd})where G1, . . . , Gdare also MDDs, a1, . . . , ad

are distinct integers, and ai/Gi is a branch of root(G). An MDD is reduced i

there is no isomorphic sub-MDDs (i.e., with the same branches) of G.

The semantics of an MDD G, denoted by Φ(G), can be dened as below:

Φ(G) ≡      T rue if G = tt F alse if G = ff Wd k=1(xi = ak∧ Φ(Gk)) if G = mdd(x, {a1/G1. . . ad/Gd}) (2.1) With the semantics, we dene the MDD constraint.

MDD constraint [CY10]. Let G be an MDD and X be a sequence of variables with nite domains. A MDD(X , G) constraint states that Φ(G) must be T rue for any sequence of values taken by the variables of X . This means that the values taken by the variables must adhere to one path from the root node to the true-terminal in the MDD.

A binary decision diagram (BDD) [Bry86] is an MDD in which every non- terminal node has at most two branches, 0/G0 and 1/G1, where G0 and G1 are

BDDs. A BDD constraint is an MDD constraint dened on BDD. Figure 2.4(d) gives an example of MDD constraint, which is a compact representation for the equivalent table constraint in Figure 2.4(a).

We remark that in the context of constraint programming, MDD is not only used to represent an independent constraint, but also to encode a constraint store. A series of research works can be found in [AHHT07, HHOT08, HVHH10].

To illustrate that there are many possible equivalent representations, we give the following example.

Example 2.3. Figure 2.4 gives examples for the table constraint, the CFG con- straint, the regular constraint, and the MDD constraint. The four 4-ary con- straints are all dened on variables (x1, x2, x3, x4) with D(xi) = {0, 1, 2} for

i ∈ {1, . . . , 4}. Although the constraints have dierent representations, they are in fact equivalent with the same semantics or relations c(x1, x2, x3, x4) ≡ [x1 =

0 ∧V4 i=2xi = {0, 1}] ∨ [ V4 i=1xi = 2]. x1 x2 x3 x4 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 2 2 2 2

(a) table constraint

A CFG in Chomsky normal form: S → C A | B B A → A A | 0 | 1 B → B B | 2 C → 0 (b) CFG constraint 0 start 2 2 2 2 0,1 q0 q1 q2 q3 q4 (c) DFA constraint 0 0 1 0 1 1 0 2 2 2 2 x1 tt x2 x2 x3 x3 x4 x4 (d) MDD constraint

Chapter 3

GAC Algorithms for Regular

Constraints

Global constraints based on formal languages can be used to express arbitrary constraints including other global constraints. The most well known is perhaps

the regular constraint [Pes04] which can also express other global constraints, e.g.

contiguity [Mah02],among [BC94], lex[CGLR96], precedence[LL04], stretch [Pes01],

etc. Theregularconstraint (originally) takes a deterministic nite automata (DFA) as the constraint denition but a non-deterministic nite automata (NFA) is also possible. On the other hand, the table constraint denes an arbitrary constraint explicitly as a set of solutions. Two ecient generalised arc consistency (GAC) algorithms for non-binary table constraints aremddc[CY10] and STR2 [Lec11]. In

mddc, the constraint is specied as a multi-valued decision diagram (MDD) while STR2 works with the explicit table.

We see then that there can be many input representations dening the same set of solutions (tuples) to a constraint, though these representations may be regarded as dierent constraint forms with equivalent semantics. Moreover, it is well known that transforming an NFA to a DFA can lead to an exponentially larger automata. The MDDs corresponding to an NFA can also be large. Thus, there are dierent constraint representation choices with dierent space requirements for the associated GAC algorithms. Experiments in [Lec11] also show that the representation size can determine solver runtime, mddc is faster than STR2 when the MDD representation is more compact and vice versa.

In this chapter, we investigate the space-time tradeos of the NFA, DFA and MDD representations of the same equivalent constraint. Figure 3.1 gives a graph- ical representation of equivalent NFA, DFA, and MDD constraints. We extend

(a) (b) (c)

Figure 3.1: (a) an NFA and (b) an equivalent DFA (non-minimized). Each (dou- ble) circle with label i represents a (nal) state qi. There is a directed edge from

i to j i qj ∈ δ(qi, a), where the edge is solid if a = 1 and dotted if a = 0. (c) an

equivalent MDD for a 4-ary regular constraint represented by the NFA in (a) or the DFA in (b).

DFA or an MDD. An algorithm which converts a constraint in NFA or DFA form directly to an MDD is also given.

We experiment with hard CSPs whose size dierences in their NFA, DFA and MDD representations are large. We show two space-time tradeos of nfac

algorithm for regular constraints dened on these representations. First, the NFA representation is more ecient for the nfacalgorithm once the corresponding DFA or MDD becomes big enough. If memory itself is an issue, e.g. the CSP has many large constraints, it may be worthwhile to use NFA even when the DFA or MDD is smaller. Second, when the size of the DFA or MDD is large enough, once the total time including construction and initialization times are taken into account, the NFA can be much faster then DFA or MDD. We also compare nfac with regularc.

3.1 Overview of the GAC Algorithms for the Reg-

ular and MDD constraints

In this section, we introduce two GAC algorithms, one for theregularconstraint and one for the MDD constraint. To dierentiate the propagation algorithms from the

name of the constraints, we call the two existing GAC algorithms regularc [Pes04] and mddc [CY10] respectively. Similarly, in the following section, we name the proposed GAC algorithm for the NFA constraint, nfac. The regularc and mddc

algorithms enforce GAC in dierent ways: regularc is ne-grained [LBH03] (incre- mental) that enforces GAC on the variable-value pairs, which results in a propaga- tion queue composed of variable-value pairs; whilemddcis coarse-grained [LBH03] (non-incremental) that enforces GAC on the constraints, which results in a prop- agation queue composed of constraints. An analog is that regularc is ne-grained like AC-4 [MH86], while mddc is coarse-grained like AC-3 [Mac77a].

Related documents