Preprocessing Algorithms for non-binary

0 downloads 0 Views 199KB Size Report
temporal constraints of the form. , where are variables (time points) .... variables (time points). i x. Step1. We transform this n-ary constraint to the form: ∑. −. = ≤.
Preprocessing Algorithms for non-binary Disjunctive Constraint Satisfaction Miguel A. Salido1, Adriana Giret1, Federico Barber1 1

Dpto. Sistemas Informáticos y Computación Universidad Politécnica de Valencia, Camino de Vera s/n 46071 Valencia, Spain {msalido, agiret, fbarber}@dsic.upv.es

Abstract. Some constraint languages are more powerful than others because they allow us to express a larger collection of problems. More generally, the finite constraint satisfaction problem (CSP) with arbitrary constraints (nonbinary), is known to be NP-complete [9], whereas many families of restricted constraints have been identified like tractable subproblems [1][7]. We propose two preprocessing algorithms in order to study the consistency check (the consistency algorithm) when a new non-binary constraint is inserted into the system and to reduce the variable domains (the reduction algorithm) that participate in these non-binary disjunctive temporal constraints. Following, we can apply some of the techniques to solve this CSP. Thus, we can manage more complex and expressive constraints that many real problems must deal with.

1

Introduction

Nowadays many researchers are working on non-binary constraints [2],[3] and are mainly influenced by the growing number of real-life applications. Modelling a problem with non-binary constraints has several advantages: it facilitates the expression of the problem, it enables more powerful constraint propagation as more global information is available, etc. Many real problems require more complex temporal constraints that the system must manage efficiently. These problems are also frequently dynamic problems whose constraints can be dynamically inserted or deleted. In this paper, we extend the framework of simple temporal problems studied originally by Dechter, Meiri and Pearl [4] to consider non-binary disjunctive n

temporal constraints of the form ∑ pi xi ≤ b , where xi are variables (time points) i =1

ranging over disjunctive intervals and n ≥ 2 . The consistency of these problem types may be solved by means of techniques based on constraint satisfaction problems (CSPs) and techniques based on closure processes. These two techniques have a similar graphic representation, (a directed graph), but they have different goals.

In Proceedings of ES2001, the Twenty-first SGES International Conference on Knowledge Based Systems and Applied Artificial Intelligence. Published in book: Research And Development In Intelligent Systems XVIII. (Ed. Springer Verlag). (Cambridge) 2001.

ƒ

ƒ

CSP has been widely studied in the Artificial Intelligence community for many years. It has been recognised that CSPs have practical significance because many problems arising in scheduling, in operational research and other real problems, can be represented as CSPs. The main goal of a CSP is to find one or several solutions in a previously consistent system. We can also solve these problems by means of the closure processes. The main aim of closure techniques is to guarantee the consistency of the existing constraints, which may be included and/or excluded by means of a dynamic behaviour. There exist several levels of consistency depending on the solution exigency, from the lowest levels (path consistency [10]) to the most demanding ones (global consistency [5]).

Both techniques may have a common graphic representation by means of a disjunctive temporal constraint network, where nodes represent temporal points and arcs represent binary disjunctive temporal constraints between two temporal points. Arc and node consistency work well for pruning the domains in networks of this kind. However, they do not work well if the problem contains primitive constraints that involve more than two variables (non-binary) since such primitive constraints are ignored when performing consistency checks. In order to improve this deficiency, we propose two algorithms: the consistency algorithm performs a consistency check when a new non-binary temporal constraint is dynamically inserted into the system and the reduction algorithm may reduce the variable domains that participate in this non-binary temporal constraint. In Fig. 1, we can see the application order of the algorithms. In proposition 1 we prove the new domain consistency with the existing domains, so the closure graph maintains consistency. We will focus this paper on dynamic constraint satisfaction problems and make the following contributions: • In order to manage these non-binary constraints we present an algorithm called the consistency algorithm that studies whether the new inserted non-binary constraint is consistent with the existing binary ones. • If the new non-binary constraint is consistent with the existing binary ones, a new and simple algorithm, the reduction algorithm, might be applied to reduce the variable domains that participate in this non-binary constraint in order to make the CSP solving process more efficient. In section 3, we specify these two algorithms in order to apply them to nondisjunctive domain problems. Following, in section 4 we extend these two algorithms to disjunctive domain problems. Finally in future works, we will consider non-linear constraints that permit us to represent other types of more complex frameworks. Both algorithms can be applied to problems with these types of constraints.

Fig. 1. Application Ordering of Algorithms.

2

Preliminaries

Briefly, a constraint satisfaction problem (CSP) consists of a set of variables X = {x1 , K , x n } where each variable xi ∈ X has got a finite set Di of possible values (its domain) and a finite collection of constraints C = {c1 , K , c p } restricting the values that the variables can simultaneously take. Each constraint ci is a pair ( si , Ri ) , where s i is a list of variables of length mi , called the constraint scope, and Ri is an m i -ary relation, called the constraint relation.

The tuples of the constraint relation Ri indicate the allowed combinations of simultaneous values for the variables in the corresponding scope s i . The length of the tuples will be called the arity of the constraint. Non-binary CSPs are CSPs that contain constraints with arity greater than 2. In particular, we will classify the constraints by means of the arity. We denote Ri as ( ≤ ) to make the notation easier: • Unary constraint: specify the allowed values for a variable, a ≤ xi ≤ b : a, b ∈ Z . • Binary constraint: specify the allowed combinations of values for a pair of variables. We can classify binary constraints into two types:

a) •

Standard binary constraint: a ≤ xi − x j ≤ b : a, b ∈ Z .

b) Non-standard binary constraint: is a 2-ary constraint. n-ary constraint: specifies the allowed combinations of values for n variables: n

a ≤ ∑ p i x i ≤ b : a , b, p i ∈ Z . i =1

We denote x 0 as “The beginning of the world” where x0 = 0 . Thus, all unary constraints can be expressed by means of a standard binary constraint adding x 0 . For instance: a ≤ xi ≤ b ⇒ a ≤ xi − x0 ≤ b . We consider non-standard binary constraints as n-ary constraints. Therefore, we only have two different types of constraints: standard binary constraints and n-ary constraints (from now on “non-binary constraints”). A solution to a CSP is an assignment of a value from its domain to every variable in such a way that every constraint is satisfied. Our objective may be: • to get only one solution, with no preference as to which one; • to get all solutions; • to get an optimal, or at least, a good solution by means of an objective function defined in terms of some variables [6]. Solutions to CSPs are found by searching systematically through the possible assignments of values to variables, usually guided by heuristics. The consistency and reduction reductions study the consistency and reduce the variable domains in order to reduce these search processes and make these heuristics more efficient.

3

Specification of the Algorithms

Both the consistency and reduction algorithms are presented in this section. We will represent our problem by means of a Temporal Network (TCSP). This network is represented by a directed constraint graph, where nodes represent time points (variables), and arcs represent disjunctive temporal constraints between two temporal points. Thus, both algorithms will be applied to non-binary constraints: n

a ≤ ∑ pi xi ≤ b , where x i are temporal points, pi is the coefficient of x i variable. i =1

We introduce the time point x 0 ( x 0 = 0 ) in order to represent all unary constraint by means of a standard binary constraint a ≤ x i − x 0 ≤ b . In Fig.2 the new arcs joining all temporal points with x 0 are represented.

X1

X3

X2

X4

X0

[0,4]

[0,4] Fig. 2. An example adding the null variable x 0

Definition 1[4] Let I i and I j be two temporal intervals. The composition of I i and I j , denoted by I i ⊗ I j , admits only values r for which there exist t ∈ I i and s ∈ I j , such that

t + s = r , (i.e) if I i =[a,b] and I j =[c,d], then I i ⊗ I j =[a+c, b+d]. Definition 2[4] Let I i and I j be two temporal intervals. The intersection of I i and I j , denoted by I i ⊕ I j , admits only values that are allowed by both of them.

Definition 3 Let p i be the coefficient of the variable x i . We denote sig ( p i ) like the sign of p i . 3.1 The Consistency Algorithm The main goal of our consistency algorithm is to determine whether a non-binary constraint is consistent with the existing binary ones. Therefore, we start from a consistent system. When a new non-binary constraint is asserted into the system, the algorithm checks its consistency with the existing standard binary constraints. If the new constraint is consistent, then we will apply the reduction algorithm only in the case that the constraint intersects its variable domains. If the non-binary constraint n

has only one inequality in the upper bound ( ∑ p i xi ≤ b as usual) and this constraint i =1

is consistent with the existing ones, then, the consistency algorithm assigns (a) to the n

n

n

i =1

i =1

i =1

lower bound ( a ≤ ∑ p i xi ≤ b ). Analogously a ≤ ∑ pi xi ⇒ a ≤ ∑ pi xi ≤ b . In Fig 3. the consistency algorithm is represented.

n

Let a ≤ ∑ p i x i ≤ b be a n-ary constraint, where a, b, pi ∈ Z : i = 1..n , and xi are i =1

variables (time points). Step1. We transform this n-ary constraint to the form: n

pi

n

a ≤ ∑ ∑ sig ( pi )xi ≤ b : p 0 = − ∑ pi . i = 0 j =1

i =1

Step2. We make two disjunct sets, where each set is composed by the same sign variables. Step3. We make all possible combinations among elements of both sets. Step4. For each generated combination among variables, we make the multi-binary constraint (composition of standard binary constraints) with the same relation and same independent term. Step5. For each standard binary constraint, we assign its original temporal domains. Step6 We intersect all the resulting intervals corresponding to all the possible combinations obtaining the minimal domain ([d1,d2]) where the n-ary constraint could be consistent. Step7. We intersect the interval ([d1,d2]) with the original n-ary interval [a,b]. We can distinguish several different situations (see Fig 4a): 1.- If [d 1 , d 2 ] ⊕ [a, b] = φ , then the n-ary constraint is not consistent. (stop). 2.- If [d 1 , d 2 ] ⊕ [a, b] ≠ φ , then the n-ary constraint is consistent with the binary ones. We can also study: 2.1 If [d 1 , d 2 ] ⊕ [a, b ] = [d 1 , d 2 ] then, the n-ary constraint is consistent. We will not apply the reduction algorithm because we are not going to reduce the variable domains. We do not label these variables and we delete this constraint because it is redundant. (stop). 2.2 If [d 1 , d 2 ] ⊕ [a, b] ⊂ [d 1 , d 2 ] then we must apply the reduction algorithm in order to reduce the variable domains.

Fig.3.The Consistency Algorithm.

Example Let´s take a simple example in R2 where we can see the behaviour of the consistency algorithm. We represent all the constraints graphically. We study a non-binary constraint that will be consistent with the binary ones. Let the following initial binary constraints be: 2 ≤ x1 − x0 ≤ 6 → x1 ∈ [2,6][ ] 0 ≤ x 2 − x0 ≤ 4 → x 2 ∈ [0,4][ ] − 6 ≤ x 2 − x1 ≤ 2

Let´s see if the non-binary constraint c1 : 2 x1 − x 2 ≤ 2 is consistent with the existing ones. Fig. 4b. represents the variable domains and the binary constraints.

Step1. 2 x1 − x 2 ≤ 2 ⇒ x1 + x1 − x 2 − x0 ≤ 2 Step2. Positive variables set: { x1 , x1 }, negative variables set: { x 2 , x 0 } Step3. Possible combinations. Only one possible combination: {( x1 , x 2 ) ∧ ( x1 , x0 )} Step4. x1 + x1 − x 2 − x0 ≤ 2 ⇒ ( x1 − x 2 ) + ( x1 − x0 ) ≤ 2 Step5. We assign its corresponding intervals: [-2, 6] ⊗ [2, 6] = [0, 12] Step6.. We have only one possible combination: [d1,d2] = [0, 12] Step7. [a, b] = [-∞, 2], so [0, 12] ⊕ [-∞, 2] = [0, 2] ≠ φ . Therefore, the non-binary constraint c1 is consistent with the standard binary ones, and also [0, 12] ⊕ [-∞, 2] = [0, 2]⊂[0, 12], so we must apply the reduction algorithm in order to reduce the variable domains. We can also observe that the lower bound of the non-binary constraint is zero: 0 ≤ 2 x1 − x 2 ≤ 2 . (see Fig. 4c).

Fig. 4. a) Different situations in step7. b) Example graphic. c) Graphic with the non-binary one

Graphically, we can observe that the variable domain generates a quadratic polyhedron by means of Cartesian Product of the domains. The non-binary constraint is consistent because it intersects the quadratic polyhedron of possible solutions. Also, it can be observed that the variable domains can be reduced significantly because the minimal quadratic polyhedron that includes the new valid region is included strictly in the original polyhedron. This will be seen in the reduction algorithm 3.2 The Reduction Algorithm The reduction algorithm is only applied when the section (2.2) of the consistency algorithm is reached. The reduction algorithm only affects some of the variables that participate in the non-binary constraint reducing the domain size. In Fig. 5 the pseudo-code of The reduction algorithm is presented.

n

Let the n-ary constraint be: ∑ pi xi ≤ b , where b, pi ∈ Z : i = 1..n i =1

For each variable x i that participates in the non-binary constraint do the following: Step1. Fix all the positive variables of the n-ary constraint to their lower bound and all the negative variables of the n-ary constraint to their upper bound, except xi , and substitute them in the n-ary constraint, obtaining a unary constraint: ± x i ≤ ⎣u i′ ⎦ = u i .We obtain a real number u i′ and round it down to the nearest integer u i . Step2. If sig ( xi ) is positive, we verify if the resulting unary constraint can be reduced in its

original upper bound. If sig ( xi ) is negative, we verify it in its lower bound. In the case that this unary constraint is not upper bounded (or lower) then this new bound is added to the unary constraint. Fig.5. The Reduction Algorithm.

Example Let´s continue with the previous example in order to study the reduction algorithm in the non-binary constraint: c1 : 2 x1 − x 2 ≤ 2 . We are going to study the x1 domain: Step1. We fix x 2 = 4 . Step2. 2 x1 − 4 ≤ 2 ⇒ x1 ≤ ⎣6 2⎦ = 3 . The x1 domain is reduced to x1 ∈ [2,3][c1 ] . We are going to study x 2 domain: Step1. We fix x1 = 2 . Step2. 4 − x 2 ≤ 2 ⇒ x 2 ≥ ⎣2⎦ = 2 . The x 2 domain is reduced to x 2 ∈ [2,4][c1 ] . Example Now let´s look at the same example in which the non-binary constraint is not consistent with the existing ones. Let the non-binary constraint be: 2 x 2 + x1 ≤ 0 . We can observe graphically (Fig. 6a) that the non-binary constraint is not consistent with the existing ones. By means of the consistency algorithm, it can be seen that this constraint is really not consistent. Step1. 2 x 2 + x1 ≤ 0 ⇒ x 2 + x 2 + x1 − x0 − x0 − x 0 ≤ 0 Step2. Positive variables set: { x 2 , x 2 , x1 }, negative variables set: { x0 , x0 , x0 } Step3. Only one possible combination: {(2,0) ∧ (2,0) ∧ (1,0)} Step4. x 2 + x 2 + x1 − x0 − x0 − x0 ≤ 0 ⇒ ( x 2 − x 0 ) + ( x 2 − x0 ) + ( x1 − x 0 ) ≤ 0 Step5. We assign its corresponding intervals: [0, 4] ⊗ [0, 4] ⊗ [2, 6] = [2, 14] Step7. [-∞, 0] ⊕ [2, 14] = φ , so the constraint 2 x 2 + x1 ≤ 0 is not consistent. Therefore, the problem with this non-binary constraint does not have a solution.

Fig. 6. a) No consistent constraint. b) Constraint in disjunctive domains.c) Closure graph. [a’,b’] is the new interval between x 0 and x 2 .[c,d] and [e,f] are the previous closure domains.

Proposition 1. Let G be a closure graph. We assume that a new non-binary constraint is inserted into the system and reduce the domain of any binary constraint. Then, the new domain is consistent with the previous closure graph. (See, fig.6c). Proof: We must prove [c, d ] ∩ ([a ' , b'] ⊗ [− f ,−e]) ≠ φ . We assume [c, d ] ∩ ([a ' , b'] ⊗ [− f ,−e]) = φ ⇒ d < a'− f ∨ b'−e < c . If d < a '− f ⇒ d < a '− f = a '+ d − b ⇒ d < a '+ d − b ⇒ b < a ' < b' ⇒ b < b' false. If b'−e < c ⇒ b'+ c − a < c ⇒ b' < a < a ' ⇒ b' < a ' false.

4

Application to disjunctive problems

A problem with disjunctions in its variable domains is a very complex problem because the difficulty increases exponentially with the number of disjunctions (l). A variable has a disjunctive domain if its possible values are enclosed in disjunctive intervals, for example x1 ∈ [2,6] ∪ [7,9] . However, we can apply both consistency and reduction reductions to non-disjunctive problems in an analogous way. We only need to modify step5 of the consistency algorithm. Instead of assigning only the original temporal domain, we generate all the alternative possible domains according to all possible combinations among the variable intervals. If at least one of the possible combinations is valid, then the original constraint is consistent. Otherwise, the original constraint is not consistent. We must take into account that the complexity increases exponentially because we have a nondisjunctive problem for each possible combination. In the reduction algorithm, we might initially reduce the variable domains by means of a new step called step0 which reduces the intervals that do not participate in the valid combinations. First, we observe the variable intervals that only participate in invalid combinations. In this case, these intervals can be directly eliminated. Afterwards, we will apply the following steps of the reduction algorithm. Let´s see an example to clarify this property.

We assume a problem with only two variables x1 , x 2 with two disjunctions (l = 2) in the variable domains. x1 ∈ [2,6] ∪ [7,9] ; x 2 ∈ [0,4] ∪ [6,10]

Thus the set of possible solutions is formed by disjunct polyhedrons. Let´s see the consistency of the non-binary constraint: x1 + 2 x 2 ≤ 6 (Fig. 6b.) in the last problem. The non-binary constraint is consistent with the existing ones and three of the four polyhedrons are inconsistent with the new constraint. So, we can eliminate these three polyhedrons. This implies deleting the intervals that do not participate in the valid polyhedron. Let´s see how the consistency reduction changes. Step4. ( x 2 − x0 ) + ( x 2 − x0 ) + ( x1 − x0 ) ≤ 6 Step5. [0, 4] [0, 4] [6, 10] [6, 10]

⊗ ⊗ ⊗ ⊗

[0, 4] ⊗ [2, 6] [0, 4] ⊗ [7, 9] [6, 10] ⊗ [2, 6] [6, 10] ⊗ [7, 9]

= [2, 14] = [7, 17] = [14, 26] = [19, 29]

valid invalid invalid invalid

We can observe that the intervals [6, 10] and [7, 9] only participate in invalid combinations, so these intervals are directly eliminated by the step0 of the reduction algorithm. Thus, applying the following steps over the new domains: x1 ∈ [2,6] ; x2 ∈ [0,4] , we will reduce these domains to: x1 ∈ [2,6] ; x 2 ∈ [0,2]

5

Computational Cost

The computational cost depends on the number of variables that participate in the non-binary temporal constraint. Generally, constraints of this type do not have more than four variables in an attempt to represent durations by means of temporal points [8]. So, Thus, it is very common for constraints such as d i + d j ≤ 4 (duration i plus duration j is less than 4) can be translated to ( xi1 − xi2 ) + ( x j1 − x j2 ) ≤ 4 and managed by the consistency and reduction reductions. Let´s see the computational cost of the algorithms where k is the number of variables that participate in the non-binary constraints and l is the mean number of disjunction: Computational cost in the consistency algorithm: • Non-disjunctive constraints: The computational cost in the worst case is (k 2)! . •

Disjunctive non-binary constraints: The computational cost in the worst case is l k (k 2)! . This computational cost is due to the number of possible combinations, however this number can be reduced because of many combinations are repeated. Computational cost in the reduction algorithm: • The computational cost is O(k) in disjunctive and non-disjunctive constraints.

6

Conclusion and Future Works

In this paper, we have proposed a new technique for the study of consistency and domain reduction in problems with non-binary constraints. The consistency algorithm makes a study of the consistency when a new non-binary constraint is inserted into the system. If the new non-binary constraint is consistent with the binary ones, its consistency must be checked with the previous non-binary constraints inserted into the system by means of linear programming techniques. The reduction algorithm takes place when the non-binary constraint is consistent with the previously existing ones. In this case, it makes a reduction of the variable domains that participate in this non-binary constraint. These algorithms are applied in a preprocessing step. Therefore, when the non-binary constraint is consistent with the existing ones, some of the techniques can be applied to solve these reduced problems. Furthermore, we can manage non-binary constraints and study the management of consistency in systems with disjunctive temporal constraints. As future work, the consistency algorithm could also be applied to non-linear problems where some variables can be pondered by a non-integer factor. Problems of this type may permit us to represent other types of situations like the following example: “John ( x1 ) takes two to five times longer to go to the university than Michael ( x 2 ) does”. This non-linear constraint will be represented by: x1 = [2,5]x 2 , where x1 and x 2 can be disjunctive intervals. The consistency of constraints of this kind could be partial because these constraints can only be consistent in a subinterval of the original one. In this case, we can obtain the subinterval in which this constraint is consistent.

References 1. Cooper, M.C., Cohen, D.A., Jeavons, P.G.: Characterizing tractable constraint. Artificial Intelligence 65 (1994) 347-361 2. Bessière, C., Meseguer, P., Freuder, E.C., Larrosa, J.: On forward checking for non-binary constraint satisfaction. In Proceeding CP’99, Alejandria VA, (1999) 3. Gent, I.,Stergiou, K., Walsh, T.: Descomposable constraints, Artificial Intelligence 123. (2000) 133-156 4. Dechter, R., Meiri, I., Pearl, J,: Temporal Constraint Network, Artificial Intelligence 49, (1991) 61-95 5. Dechter, R.: From Local to Global Consistency, Artificial Intelligence 55, (1992) 87-107 6. Eiben, A.E., Ruttkay, Zs.: Constraint satisfaction problems, Handbook of Evolutionary Computation, IOP Publishing Ltd. and Oxford University Press, (1997) C5.7:1-C5.7:8. 7. Jeavons, P. G., Cooper, M. C.: Tractable constraints on ordered domains. Artificial Intelligence 79, (1996) 327-339 8. Jonsson, P., Bäckström, C.: A Unifying Approach to Temporal Constraint Reasoning. Artificial Intelligence 102(1). (1998) 143-155 9. Mackworth, A. K.: Consistency in Network of Relations, Artificial Intelligence 8. (1977) 99-118 10. Montanari, U.: Networks of constraints: fundamental properties and applications to picture processing. Information Sciences 7. (1974) 95-132