Handbook of Constraints Programming——Chapter3 Constraint Propagation-Background

来源:F.Rossi, P.Van Beek, T. Walsh. Handbook of Constraints Programming. Elsevier, 2006.

 

Constraint reasoning involves various types of techniques to tackle the inherent intractability of the problem of satisfying a set of constraints. Constraint propagation is one of those types of techniques. Constraint propagation is central to the process of solving a constraint problem, and we could hardly think of constraint reasoning without it.

Constraint propagation is a very general concept that appears under different names depending on both periods and authors. Among these names, we can find constraint relaxation, filtering algorithms, narrowing algorithms, constraint inference, simplification algorithms, label inference, local consistency enforcing, rules iteration, chaotic iteration.

Constraint propagation embeds any reasoning which consists in explicitly forbidding values or combinations of values for some variables of a problem because a given subset of its constraints cannot be satisfied otherwise. For instance, in a crossword-puzzle, when you discard the words NORWAY and SWEDEN from the set of European countries that can fit a 6-digit slot because the second letter must be a ’R’, you propagate a constraint. In a problem containing two variables x1 and x2 taking integer values in 1..10,and a constraint specifying that |x1 − x2| > 5, by propagating this constraint we can forbid values 5 and 6 for both x1 and x2. Explicating these ’nogoods’ is a way to reduce the space of combinations that will be explored by a search mechanism.

The concept of constraint propagation can be found in other fields under different kinds and names. (See for instance the propagation of clauses by ’unit propagation’ in propositional calculus [40].) Nevertheless, it is in constraint reasoning that this concept shows its most accomplished form. There is no other field in which the concept of constraint propagation appears in such a variety of forms, and in which its characteristics have been so deeply analyzed.

In the last 30 years, the scientific community has put a lot of effort in formalizing and characterizing this ubiquitous concept of constraint propagation and in proposing algorithms for propagating constraints. This formalization can be presented along two main lines: local consistencies and rules iteration. Local consistencies define properties that the constraint problem must satisfy after constraint propagation. This way, the operational behavior is left completely open, the only requirement being to achieve the given property on the output. The rules iteration approach, on the contrary, defines properties on the process of propagation itself, that is, properties on the kind/order of operations of reduction applied to the problem.

This chapter does not include data-flow constraints [76], even if this line of research has been the focus of quite a lot of work in interactive applications and if some of these papers speak about ‘propagation’ on these constraints [27]. They are indeed quite far from the techniques appearing in constraint programming.

The rest of this chapter is organized as follows. Section 3.1 contains basic definitions and notations used throughout the chapter. Section 3.2 formalizes all constraint propagation approaches within a unifying framework. Sections 3.3–3.8 contain the main existing types of constraint propagation. Each of these sections presents the basics on the type of propagation addressed and goes briefly into sharper or more recent advances on the subject.

 

3.1 Background

The notations used in this chapter have been chosen to support all notions presented. I tried to remain on the borderline between ‘heavy abstruse notations’ and ‘ambiguous definitions’, hoping I never fall too much on one side or the other of the edge.

A constraint satisfaction problem (CSP) involves finding solutions to a constraint network, that is, assignments of values to its variables that satisfy all its constraints. Constraints specify combinations of values that given subsets of variables are allowed to take. In this chapter, we are only concerned with constraint satisfaction problems where variables take their value in a finite domain. Without loss of generality, I assume these domains are mapped on the set Z of integers, and so, I consider only integer variables, that is, variables with a domain being a finite subset of Z.

Definition 3.1 (Constraint). A constraint c is a relation defined on a sequence of variables X(c)=(xi1 ,...,xi|X(c)|), called the scheme of c. c is the subset of |X(c)| that contains the combinations of values (or tuples) τ ∈ Z|X(c)| that satisfy c. |X(c)| is called the arity of c. Testing whether a tuple τ satisfies a constraint c is called a constraint check.

A constraint can be specified extensionally by the list of its satisfying tuples, or intensionally by a formula that is the characteristic function of the constraint. Definition 3.1 allows constraints with an infinite number of satisfying tuples. I sometimes write c(x1,...,xk) for a constraint c with scheme X(c)=(x1,...,xk). Constraints of arity 2 are called binary and constraints of arity greater than 2 are called non-binary. Global constraints are classes of constraints defined by a formula of arbitrary arity (see Section 3.8.2).

Example 3.2. The constraint alldifferent(x1, x2, x3)≡(vi ≠ vj∧vi ≠ vk∧vj ≠vk) allows the infinite set of 3-tuples in Z3 such that all values are different. The constraint c(x1,x2,x3)= {(2, 2, 3), (2, 3, 2), (2, 3, 3), (3, 2, 2), (3, 2, 3), (3, 3, 2)} allows the finite set of 3-tuples containing both values 2 and 3 and only them.

Definition 3.3 (Constraint network). A constraint network (or network) is composed of:

• a finite sequence of integer variables X =(x1,...,xn),

• a domain for X, that is, a set D = D(x1) × ... × D(xn), where D(xi) ⊂Z is the finite set of values, given in extension 1, that variable xi can take, and

• a set of constraints C = {c1,...,ce}, where variables in X(cj ) are in X.

Given a network N, I sometimes use XN, DN and CN to denote its sequence of variables, its domain and its set of constraints. Given a variable xi and its domain D(xi), minD(xi) denotes the smallest value in D(xi) and maxD(xi) its greatest one. (Remember that we consider integer variables.)

In the whole chapter, I consider constraints involving at least two variables. This is not a restriction because domains of variables are semantically equivalent to unary constraints. They are separately specified in the definition of constraint network because the domains are given extensionally whereas a constraint c can be defined by any Boolean function on |X(c)| (in extension or not). I also consider that no variable is repeated in the scheme of a constraint. This restriction could be relaxed in most cases, but it simplifies the notations. The vocabulary of graphs is often used to describe networks. A network can indeed be associated with a (hyper) graph where variables are nodes and where schemes of constraints are (hyper) edges.

According to Definitions 3.1 and 3.3, the variables XN of a network N and the scheme X(c) of a constraint c ∈ CN are sequences of variables, not sets. This is required because the order of the values matters for tuples in DN or in c. Nevertheless, it simplifies a lot the notations to consider sequences as sets when no confusion is possible. For instance, given two constraints c and c’, X(c) ⊆ X(c’) means that constraint c involves only variables that are in the scheme of c’ , whatever their ordering in the scheme. Given a tuple τ on a sequence Y of variables, and given a sequence W ⊆ Y , τ [W] denotes the restriction of τ to the variables in W, ordered according to W.Given xi ∈ Y, τ [xi] denotes the value of xi in τ .If X(c)= X(c’), c ⊆ c’ means that for all τ ∈ c the reordering of τ according to X(c’) satisfies c’ .

Example 3.4. Let (1, 1, 2, 4, 5) be a tuple on Y =(x1,x2,x3,x4,x5) and W =(x3,x2,x4). τ [x3] is the value 2 and τ [W] is the tuple (2, 1, 4). Given c(x1,x2,x3) defined by x1 + x2 = x3 and c’ (x2,x1,x3) defined by x2 + x1 ≤ x3,we have c ⊆ c’ .

We also need the concepts of projection, intersection, union and join. Given a constraint c and a sequence Y ⊆ X(c), πY (c) denotes the projection of c on Y, that is, the relation with scheme Y that contains the tuples that can be extended to a tuple on X(c) satisfying c. Given two constraints c1 and c2 sharing the same scheme X(c1)= X(c2), c1 ∩c2 (resp. c1 ∪ c2) denotes the intersection (resp. the union)of c1 and c2, that is, the relation with scheme X(c1) that contains the tuples τ satisfying both c1 and c2 (resp. satisfying c1 or c2). Given a set of constraints {c1,...,ck}, ⋈j=1k cj (or ⋈ {c1,...,ck}) denotes the join of c1,...,ck, that is, the relation with scheme ∪j=1k X(cj ) that contains the tuples τ such that τ [X(cj)] ∈ cj for all j, 1 ≤ j ≤ k.

Backtracking algorithms are based on the principle of assigning values to variables until all variables are instantiated.

Definition 3.5 (Instantiation). Given a network N =(X, D, C),

• An instantiation I on Y =(x1,...,xk) ⊆ X is an assignment of values v1,...vk to the variables x1,...,xk, that is, I is a tuple on Y . I can be denoted by ((x1,v1),..., (xk,vk)) where (xi,vi) denotes the value vi for xi.

• An instantiation I on Y is valid if for all xi ∈ Y, I[xi] ∈ D(xi).

• An instantiation I on Y is locally consistent iff it is valid and for all c ∈ C with X(c) ⊆ Y , I[X(c)] satisfies c. If I is not locally consistent, it is locally inconsistent.

• A solution to a network N is an instantiation I on X which is locally consistent. The set of solutions of N is denoted by sol(N).

• An instantiation I on Y is globally consistent (or consistent) if it can be extended to a solution (i.e., there exists s ∈ sol(N) with I = s[Y ]).

Example 3.6. Let N =(X, D, C) be a network with X =(x1,x2,x3,x4), D(xi)={1, 2, 3, 4, 5} for all i ∈[1..4] and C = {c1(x1,x2,x3),c2(x1,x2,x3),c3(x2,x4)} with c1(x1,x2,x3)= alldifferent(x1,x2,x3), c2(x1,x2,x3) ≡ (x1 ≤ x2 ≤ x3), and c3(x2,x4) ≡ (x4 ≥ 2 · x2). We thus have π{x1,x2}(c1) ≡ (x1 ≠ x2) and c1 ∩ c2 ≡ (x1 <x2 <x3). I1 =((x1, 1), (x2, 2), (x4, 7)) is a non valid instantiation on Y =(x1,x2,x4) because 7 ∉ D(x4). I2 =((x1, 1), (x2, 1), (x4, 3)) is a locally consistent instantiation on Y because c3 is the only constraint with scheme included in Y anditissatisfiedby I2[X(c3)].However, I2 is not globally consistent because it does not extend to a solution of N. sol(N)= {(1, 2, 3, 4), (1, 2, 3, 5)}.

There are many works in the constraint reasoning community that put some restrictions on the definition of a constraint network. These restrictions can have some consequences on the notions handled. I define the main restrictions appearing in the literature and that I will use later.

Definition 3.7 (Normalized and binary networks).

• Anetwork N is normalized iff two different constraints in CN do not involve exactly the same variables.

• Anetwork N is binary iff for all ci ∈ CN, |X(ci)| =2.

When a network is both binary and normalized, a constraint c(xi,xj ) ∈ C is often denoted by cij. To simplify even further the notations, cji denotes its transposition, i.e., the constraint c(xj ,xi)= {(vj ,vi) | (vi,vj ) ∈ cij}, and since there cannot be ambiguity with another constraint, I act as if cji was in C as well.

Given two normalized networks N =(X,D,C) and N’=(X,D’,C’), N ⊔N N’ denotes the network N’’=(X,D’’,C’’) with D’’= D ∪ D’ and C’’= {c’’|∃c ∈C, ∃c’∈ C’,X(c)= X(c’) and c’’= c ∪ c’}.

The constraint reasoning community often used constraints with a finite number of tuples, and even more, constraints that only allow valid tuples, that is, combinations of values from the domains of the variables involved. I call these constraints ‘embedded’.

Definition 3.8 (Embedded network). Given a network N and a constraint c ∈ CN, the embedding of c in DN is the constraint clip_image002 with scheme X(c) such that clip_image002[1] = c ∩ πX(c)(DN). A network N is embedded iff for all c ∈ CN,c =clip_image002[2].

In complexity analysis, we sometimes need to refer to the size of a network. The size of a network N is equal to clip_image004+clip_image006+clip_image008,where
||c|| is equal to |X(c)|·|c| if c is given in extension, or equal to the size of its encoding if c is defined by a Boolean function.

你可能感兴趣的:(programming)