A Generalized Arc-Consistency Algorithm for a Class of Counting Constraints: Revised Edition that Incorporates One Correction

10/21/2011 ∙ by Thierry Petit, et al. ∙ 0

This paper introduces the SEQ BIN meta-constraint with a polytime algorithm achieving general- ized arc-consistency according to some properties. SEQ BIN can be used for encoding counting con- straints such as CHANGE, SMOOTH or INCREAS- ING NVALUE. For some of these constraints and some of their variants GAC can be enforced with a time and space complexity linear in the sum of domain sizes, which improves or equals the best known results of the literature.



There are no comments yet.


page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Many constraints are such that a counting variable is equal to the number of times a given property is satisfied in a sequence of variables. To represent some of these constraints in a generic way, we introduce the seq_bin meta-constraint, where is an integer variable, is a sequence of integer variables and and are two binary constraints.

Based on the notion -stretch, a generalization of stretch [Pesant2001] where the equality constraint is made explicit and is replaced by , seq_bin holds if and only if two conditions are both satisfied: (1)  is equal to the number of -stretches in the sequence , and (2)  holds on any pair of consecutive variables in .

Among the constraints that can be expressed thanks to seq_bin, many were introduced for solving real-world problems, e.g., Change [Cosytec1997] (time tabling problems), Smooth [Beldiceanu et al.2010a] (time tabling and scheduling), or Increasing_Nvalue [Beldiceanu et al.2010b] (symmetry breaking for resource allocation problems).

The main contribution of this paper is a generic polytime filtering algorithm for seq_bin, which achieves generalized arc-consistency (GAC) according to some conditions on and . This algorithm can be seen as a generalization of the Increasing_Nvalue filtering algorithm [Beldiceanu et al.2010b]. Given the size of , the maximum domain size, and the sum of domain sizes, we characterize properties on and which lead to a time and space complexity in . These properties are satisfied when seq_bin represents  Increasing_Nvalue, and several variants of Change (provided its parameter is a monotonic binary constraint, e.g., ’’, ’’, ’’, ’’). For these constraints, our technique improves or equals the best known results.

Section 2 provides the definitions used in this paper. Section 3 defines seq_bin and shows how to express well-known constraints with seq_bin. Section 4 provides a necessary and sufficient condition for achieving GAC. Section 5 details the corresponding GAC filtering algorithm. Finally, Section 6 discusses about related works and Section 7 concludes.

2 Background

A Constraint Network is defined by a sequence of variables , a sequence of domains , where each is the finite set of values that variable can take, and a set of constraints that specifies the allowed combinations of values for given subsets of variables. (resp. ) is the minimum (resp. maximum) value of . A sequence of variables , (resp. or ), is a subsequence (resp. a strict subsequence) of and is denoted by (resp. ). denotes an assignment of values to variables in . Given , is the value of in . is valid if and only if , . An instantiation is a valid assignment of . Given , is the value of in . Given the sequence and , two integers such that , is the projection of on . A constraint specifies the allowed combinations of values for . We also use the simple notation . defines a subset of the cartesian product of the domains . If is a pair of variables, then is binary. We denote by a pair of values that satisfies a binary constraint . is the opposite of , that is, defines the relation = . A feasible instantiation of is an instantiation which is in . We say that satisfies , or that is a support on . Otherwise, violates . If is a binary constraint on and then the set of supports such that can be considered as a set of values (a subset of . A solution of a constraint network is an instantiation of all the variables satisfying all the constraints.

Value , , is (generalized) arc-consistent (GAC) with respect to  if and only if belongs to a support of . A domain , , is GAC with respect to  if and only if , is GAC with respect to . is GAC if and only if , is GAC with respect to . A constraint network is GAC if and only if it is closed for GAC [Bessière2006]: all values in that are not GAC with respect to a constraint in have been removed.

3 The Seq_bin Meta-Constraint

We first generalize the notion of stretches [Pesant2001] to characterize a sequence of consecutive variables where the same binary constraint is satisfied.

Definition 1 (-stretch).

Let be an instantiation of the variable sequence and C a binary constraint. The C-sequence constraint holds if and only if:

  • Either ,

  • or and   holds.

A -stretch of is a subsequence such that the two following conditions are both satisfied:

  1. The C-sequence holds,

  2. such that the C-sequence does not hold.

The intuition behind Definition 1 is to consider the maximum length subsequences where the binary constraint is satisfied between consecutive variables. Thanks to this generalized definition of stretches we can now introduce seq_bin.

Definition 2.

The meta-constraint seq_bin is defined by a variable , a sequence of variables and two binary constraints and . Given an instantiation , seq_bin is satisfied if and only if for any , holds, and is equal to the number of -stretches in .

The constraint Change was introduced in the context of timetabling problems [Cosytec1997], in order to put an upper limit on the number of changes of job types during a given period. The relation between classical stretches and Change was initially stressed in [Hellsten2004, page 64]. Change is defined on a variable , a sequence of variables , and a binary constraint . It is satisfied if and only if is equal to the number of times the constraint holds on consecutive variables of . Without hindering propagation (the constraint network is Berge-acyclic), Change can be reformulated as seq_bintrue, where true is the universal constraint.

Smooth is a variant of Change, where is defined by , . It is useful to limit the number of drastic variations on a cumulative profile [Beldiceanu et al.2010a, De Clercq2010].

As a last example, consider the Increasing_Nvalue constraint, which is a specialized version of NValue [Pachet and Roy1999]. It was introduced for breaking variable symmetry in the context of resource allocation problems [Beldiceanu et al.2010b]. Increasing_Nvalue is defined on a variable and on a sequence of variables . Given an instantiation, Increasing_Nvalue is satisfied if and only if is equal to the number of distinct values assigned to variables in , and for any , . We reformulate Increasing_Nvalue as seq_bin.

4 Consistency of Seq_bin

We first present how to compute, for any value in a given domain of a variable , the minimum and maximum number of -stretches within the suffix of starting at (resp. the prefix of ending at ) satisfying a chain of binary constraints of type . Then, we introduce several properties useful to obtain a feasibility condition for seq_bin, and a necessary and sufficient condition for filtering which leads to the GAC filtering algorithm presented in Section 5.

4.1 Computing of the Number of -stretches

According to Definition 2, we have to ensure that the chain of constraints are satisfied along the sequence of variables . An instantiation is said -coherent if and only if either or for any , we have . A value is said to be -coherent with respect to if and only if it can be part of at least one -coherent instantiation. Then, given an integer , if is -coherent with respect to then there exists such that .

Consequently, within a given domain , values that are not -coherent can be removed since they cannot be part of any solution of seq_bin. Our aim is now to compute for each -coherent value in the domain of any variable the minimum and maximum number of -stretches on .

Notation 1.

(resp. ) is the minimum (resp. maximum) number of -stretches within the sequence of variables under the hypothesis that . (resp. ) is the minimum (resp. maximum) number of -stretches within the sequence under the hypothesis that . Given , (resp. ) denotes the minimum (resp. maximum) value of (resp. ).

Lemma 1.

Given seq_bin with , assume the domains in contain only -coherent values. Given and ,

  • If : .

  • Else:


By induction. From Definition 1, for any , we have (i.e., a -stretch of length ). Consider now with , and a value . Consider the set of instantiations that are -coherent, and that minimize the number of -stretches in . We denote this minimum number of -stretches by . At least one -coherent instantiation exists since all values in the domains of are -coherent. For each such instantiation, let us denote by the value associated with . Either there exists such an instantiation with -stretches with the conjunction satisfied by . Then, since the first -stretch of is extended when augmenting with value for . Or all instantiations with -stretches are such that is violated by : satisfies . By construction, any instantiation with has a number of -stretches strictly greater than . Consequently, given with -stretches, the number of -stretches obtained by augmenting this instantiation with value for is exactly . ∎

Lemma 2.

Given seq_bin with , assume the domains in contain only -coherent values. Given and :

  • If : .

  • Else:

Given a sequence of variables such that their domains contain only -coherent values, for any in the sequence and any , computing (resp. ) is symmetrical to (resp. ). We substitute by (resp. by ), by , and by for any .

4.2 Properties on the Number of -stretches

This section provides the properties linking the values in a domain with the minimum and maximum number of -stretches in . We consider only -coherent values, which may be part of a feasible instantiation of seq_bin. Next property is a direct consequence of Lemmas 1 and 2.

Property 1.

For any -coherent value in , with respect to , .

Property 2.

Consider seq_bin, a variable (), and two -coherent values . If or if there exists a -coherent such that and , then .


Obviously, if . If , by Property 1 the property holds. Otherwise, assume there exist two values and such that for which and , and (hypothesis ). By Lemma 2, . By Lemma 1, . From hypothesis , this entails , which leads to , which is, by Property 1, not possible. ∎

Property 3.

Consider seq_bin, a variable (), and two -coherent values . If either or there exists -coherent such that and then, for any , either or .


Obviously, if or . If is not empty, then the property holds. Assume and are disjoint. W.l.o.g., assume . By Property 2, , thus . Either or (there is no hole in the range formed by the union of these intervals). ∎

4.3 Properties on Binary Constraints

Property 3 is central for providing a GAC filtering algorithm based on the count, for each -coherent value in a domain, of the minimum and maximum number of -stretches in complete instantiations. Given seq_bin, we focus on binary constraints which guarantee that Property 3 holds.

Definition 3.

[Van Hentenryck et al.1992]  A binary constraint is monotonic if and only if there exists a total ordering of values in domains such that: for any value and any value , holds implies holds for all valid tuple such that and .

Binary constraints , , and are monotonic, as well as the universal constraint true.

Property 4.

Consider seq_bin such that all non -coherent values have been removed from domains of variables in .  is monotonic if and only if for any variable , , for any values , there exists such that and .


() From Definition 3 and since we consider only -coherent values, each value has at least one support on . Moreover, from Definition 3, or . The property holds. () Suppose that the second proposition is true (hypothesis H) and  is not monotonic. From Definition 3, if is not monotonic then and in the domain of a variable such that, by considering the constraint on the pair of variables (), neither nor . Thus, there exists a support such that is not a support on , and a support such that is not a support on . We can have , which leads to a contradiction with H. The property holds. ∎

4.4 Feasibility

From Property 4, this section provides an equivalence relation between the existence of a solution for seq_bin and the current variable domains of and . Without loss of generality, in this section we consider that all non -coherent values have been removed from domains of variables in . First, Definition 2 entails the following necessary condition for feasibility.

Proposition 1.

Given seq_bin, if or then seq_bin fails.

can be restricted to , but may have holes or may be strictly included in . We have the following proposition.

Proposition 2.

Consider seq_bin such that is monotonic, with . For any integer in there exists in such that .


Let a value such that . Let a value such that . By Property 4, either or such that and . Thus, from Property 3, , either or . ∎

By Proposition 2, any value for in is generalized arc-consistent provided a property is satisfied on the instance of seq_bin we consider: given a variable , for any value in and for all , there exists a solution of  seq_bin with exactly -stretches.

Definition 4.

The constraint seq_bin is counting-continuous if and only if for any instantiation with -stretches, for any variable , changing the value of in leads to a number of -stretches equal either to , or to , or to .

Property 5.

Consider seq_bin such that is monotonic, with , a variable and . If seq_bin is counting-continuous then there exists for any integer an instantiation with exactly -stretches.


By recurrence, we assume that the property is true for all instantiations of such that (the property is obviously true if ). At step , we assume that there exists such that there is no instantiation with -stretches, while seq_bin is counting-continuous (hypothesis). We prove that this assumption leads to a contradiction. By Lemmas 1 and 2, there exists an instantiation with -streches and , and there exists an instantiation with -stretches and . Thus, by hypothesis, and . We have . By Property 3 and since the property is assumed true for all instantiations of , there exists at least one pair of values , in such that , satisfies and violates (this is the only possible configuration leading to the hypothesis). In this case seq_bin is not counting-continuous: Given an instantiation with and , changing by for increases the number of -stretches by . ∎

Proposition 3.

Given an instance of seq_bin which is counting-continuous and such that is monotonic, seq_bin has a solution if and only if .


() Assume seq_bin has a solution. Let be such a solution. By Lemmas 1 and 2, the number of -stretches belongs to . () Let (not empty). From Proposition 2, for any value in , such that . Since  seq_bin is counting-continuous, there exists an instantiation of with -stretches. By Definition 2 and since Lemmas 1 and 2 consider only -coherent values, there is a solution of seq_bin with -stretches. ∎

4.5 Necessary and Sufficient Filtering Condition

Given seq_bin, Proposition 3 can be used to filter the variable from variables in . Propositions 1 and 2 ensure that every remaining value in is involved in at least one solution satisfying seq_bin. We consider now the filtering of variables in .

Proposition 4.

Given an instance of seq_bin which is counting-continuous and such that is monotonic, let be a value in , . The two following propositions are equivalent:

  1. is -coherent and is GAC with respect to seq_bin


If is not -coherent then, by Definition 2, is not GAC. Otherwise, (resp. ) is the exact minimum number of -stretches among -coherent instantiations (resp. ) such that . Thus, by Lemma 1 (and its symmetrical for prefixes), the exact minimum number of -stretches among -coherent instantiations such that is . Let such that all domains in are equal to domains in except which is reduced to . We call the sequence of variables associated with domains in . By construction . By a symmetrical reasoning, . By Proposition 3, the proposition holds. ∎

The “ ” in expressions and prevents us from counting twice a -stretch at an extremity of the two sequences and .

5 GAC Filtering Algorithm

Based on the necessary and sufficient filtering condition of Proposition 4, this section provides an implementation of the GAC filtering algorithm for a counting-continuous instance of seq_bin with a monotonic constraint .

If true then the total ordering entailing monotonicity of is not the natural order of integers. In this case, if is not known, it is necessary to compute such an ordering with respect to all values in , once before the first propagation of seq_bin. Consider that the two variables of can take any value in : Due to the inclusion of sets of supports of values (see Definition 3), the order remains the same when the domains of the variables constrained by do not contain all values in .

To compute , the following procedure can be used: Count the number of supports of each value, in time (recall is the maximum domain size of a variable in ), and sort values according to the number of supports, in time.

Then, given the sequence of variables , the algorithm is decomposed into four phases:

  1. Remove all non -coherent values in the domains of .

  2. For all values in the domains of , compute the minimum and maximum number of -stretches of prefixes and suffixes.

  3. Adjust the minimum and maximum value of with respect to the minimum and maximum number of -stretches of .

  4. Using the result phase ➁ and Proposition 4, prune the remaining -coherent values.

With respect to phase ➀, recall that is monotonic: According to , for any pair of variables , in such that , , has a set of supports on included in the supports of on . By removing from non supports of on in , all non -coherent values of with respect to are removed. By repeating such a process in the two directions (starting from the pair and from the pair )), all non -coherent values can be removed from domains in time complexity.

To achieve phase ➁ we use Lemmas 1 and  2 and their symmetrical formulations for prefixes. Without loss of generality, we focus on the minimum number of -stretches of a value in the domain of a variable , , thanks to Lemma 1. Assume that for all , has been computed. If there is no particular property on , the supports of on and the subset of non-supports of on which satisfy have to be scanned, in order to determine for each set a value minimizing and a value minimizing . This process takes for each value, leading to for the whole domain. Since all the variables need to be scanned and for all the values in domains the quantities are stored, phase ➁ takes in time, and in space.

Phases ➂ and ➃ take time each since all the domains have to be scanned. By Proposition 4, all the non-GAC values have been removed after this last phase.

If true, is known. The worst-case time and space results come from Phase ➁. The bottleneck stems from the fact that, when a domain is scanned, the minimum and maximum number of