Coping With Disjunctions in Temporal Constraint Satisfaction Problems 3 Eddie Schwalb, Rina Dechter Department of Information and Computer Science University of California at Irvine, CA 977 eschwalb@ics.uci.edu, dechter@ics.uci.edu Abstract Path-consistency algorithms, which are polynomial for discrete problems, are exponential when applied to problems involving quantitative temporal information. The source of complexity stems from specifying relationships between pairs of time points as disjunction of intervals. We propose a polynomial algorithm, called, that approximates path-consistency in Temporal Constraint Satisfaction Problems (TCSPs). We compare empirically to path-consistency and directional path-consistency algorithms. When used as a preprocessing to backtracking, is shown to be times more eective then either or PC.. Introduction Problems involving temporal constraints arise in various areas of computer science such as scheduling, circuit and program verication, parallel computation and common sense reasoning. Several formalisms for expressing and reasoning with temporal knowledge have been proposed, most notably Allen's interval algebra (Allen 83), Vilain and Kautz's point algebra (Vilain 86, Vanbeek 9), and Dean & Mcdermott's Time Map Management (TMM) (Dean & McDermott 87). Recently, a framework called Temporal Constraint Problem (TCSP) was proposed (Dechter Meiri & Pearl 9), in which network-based methods (Dechter & Pearl 88, Dechter 9) were extended to include continuous variables. In this framework, variables represent time points and quantitative temporal information is represented by a set of unary and binary constraints over the variables. This model was further extended in (Meiri 9) to include qualitative information. The advantage of this framework is that it facilitates the following tasks: () nding all feasible times a given event can occur, () nding all possible relationships between two given events, (3) nding one or more scenarios consistent with the information provided, and () representing the data in a minimal network form that can pro- 3 This work was partially supported by NSF grant IRI- 957636, by Air Force Oce of Scientic Research, AFOSR 936, and by erox grant. vide answers to a variety of additional queries. It is well known that all these tasks are NP-hard. The source of complexity stems from specifying relationships between pairs of time points as disjunctions of intervals. Even enforcing path-consistency, which is polynomial in discrete problems, becomes worst-case exponential in the number of intervals in each constraint. On the other hand, simple temporal problems having only one interval per constraint are tractable and can be solved by path-consistency. Consequently, we propose to exploit the eciency of processing simple temporal problems for approximating path consistency. This leads to a polynomial algorithm, called. We compare empirically with path-consistency (PC) and directional path-consistency (). Our results show that while is always a very ecient algorithm, it is most accurate (relative to full pathconsistency enforced by PC) for problems having a small number ofintervals and high connectivity. When used as a preprocessing procedure before backtracking, is times more eective then or PC. The paper is organized as follows. Section presents the TCSP model. Section 3 presents algorithm ; Section presents the empirical evaluation and the conclusion is presented in Section 5.. The TCSP Model A TCSP involves a set of variables, ;...; n,having continuous domains, each representing a time point. Each constraint T is represented by a set of intervals T (I ;...;I n )=f[a ;b ];...; [a n ;b n ]g. For a unary constraint T i over i, the set of intervals restricts the domain such that (a i b ) [...[ (a n i b n ). For a binary constraint T ij over i ; j, the set of intervals restricts the permissible values for the distance j i ; namely it represents the disjunction (a j i b l ) [...[ (a n j i b n ). All intervals are pairwise disjoint. A binary TCSP can be represented byadirected con-
straint graph, where nodes represent variables and an edge i! j indicates that a constraint T ij is specied. Every edge is labeled by the interval set (Figure ). A special time point is introduced to represent the \beginning of the world". Because all times are relative to,thus we may treat each unary constraint T i as a binary constraint T i (having the same interval representation). For simplicity,wechoose =. [,3] [,7] [8,] [,] [3,5] T = f[; ]; [3; ]g T 3 = f[; 3]; [; 7]; [8; ]g T = f[; ]; [6; 7]g T 3 = f[; ]; [6; 9]; [3; 5]g T 3 = f[; 5]g 3 T ( ) [ (3 ) T 3 ( 3 3) [ ( 3 7) [ (8 3 ) T ( ) [ (6 7) T 3 ( 3 ) [ (6 3 9) [ (3 3 5) T 3 ( 3 5) Figure : A graphical representation of a TCSP where =; =:5; =:5; 3 = 8 is a solution. A tuple =(x ;...;x n ) is called a solution if the assignment = x ;...; n = x n satises all the constraints. The network is consistent i at least one solution exists. Avalue v is a feasible value of i if there exists a solution in which i = v. The minimal domain of a variable is the set of all feasible values of that variable. The minimal constraint is the tightest constraint that describes the same set of solutions. The minimal network is such that its domains and constraints are minimal. Denition : Let T = fi ;...;I l g and S = fj ;...;j m g be two sets of intervals which can correspond to either unary or binary constraints.. The intersection of T and S, denoted by T 8 S, admits only values that are allowed by both of them.. The composition of T and S, denoted by T S, admits only values r for which there exists t T and s S such that r = t + s. T S T S T S - 3 5 6 7 8 9 T = f[:5; :5]; [:75; :5]g S = f[:5; :5]; [3:77; :5]g T 8 S = f[:5; :5]; [3:75; :5]g T S = f[:5; :5]; [:5; 5:5]; [6:5; 8:5]g Figure : A pictorial example of the 8 and operations. The operation may result in intervals that are not pairwise disjoint. Therefore, additional processing may be required to compute the disjoint interval set. Denition : The path-induced constraint onvari- ables i ; j is R path ij = 8 8k (T ik T kj ). A constraint T ij is path-consistent i T ij R path ij and pathredundant i T ij R path ij. A network is path-consistent i all its constraints are path-consistent. A general TCSP can be converted into an equivalent path-consistent network by applying the relaxation operation T ij T ij 8 T ik T kj, using algorithm PC (Figure 3). Some problems may benet from a weaker version, called, which can be enforced more eciently. Algorithm PC. Q f(i; k; j)j(i <j)and(k 6= i; j)g. while Q 6= fg do 3. select and delete a path (i; k; j) from Q. if T ij 6= T ik T kj then 5. T ij T ij 8 (T ik T kj) 6. if T ij = fg then exit (inconsistency) 7. Q Q [ RELATED-PATHS((i; k; j)) 8. end-if 9. end-while Algorithm. for k n downtoby-do. for 8i; j < k such that (i; k); (k; j) E do 3. if T ij 6= T ik T kj then. E E [ (i; j) 5. T ij T ij 8 (T ik T kj) 6. if T ij = fg then exit (inconsistency) 7. end-if 8. end-for 9. end-for Figure 3: Algorithms PC and (Dechter Meiri &Pearl 9). 3. Upper-Lower Tightening () The relaxation operation T ij T ij 8T ik T kj increases the number ofintervals and may result in exponential blow-up. As a result, the complexity of PC and is exponential in the number ofintervals, but can be bounded by O(n 3 R 3 ) and O(n 3 R ), respectively, where n is the number of variables and R is the range of the constraints. When running PC on random instances, we encountered problems for which path-consistency required minutes on toy-sized problems with variables, range of [,6], and with 5 input intervals in each constraint. Evidently, PC is computationally expensive (also observed by (Poesio 9)). A special class of TCSPs that allow ecient processing is the Simple Temporal Problem (STP) (Dechter Meiri & Pearl 9). In this class, a constraint has a single interval. An STP can be associated with a directed edge-weighted graph, G d, called a distance graph, having the same vertices as the constraint graph G; each edge i! j is labeled by aweight w ij representing the constraint j i w ij (Figure ). An STP is consistent i the corresponding d-graph G d has no negative cycles and the minimal network of the STP
N N () N () N (3) [,3] [,7] [8,] [,] [3,5] [,] [,5] [3,6] [,9] [,9] N () N () N (3) [3,6] [,] [,9] [,9] N () N () N (3) [,6] Figure 5: A sample run of. We start with N (Figure ) and compute N () ; N () ; N (). Thereafter, we perform a second iteration in which we compute N () ; N () ; N () and nally, in the third iteration, there is no change. The rst iteration removes two intervals, while the second iteration removes one. corresponds to the minimal distances of G d.for a processing example, see gure. Alternatively, the minimal network of an STP can be computed by PC in O(n 3 ) steps. [,] [,5] Distance Graph G d - 5 5 Floyd - Warshall Minimal Distance Algorithm 7-3 6-3 - Figure : Processing an STP. The minimal network is in Figure 5, network N () Motivated by these results, we propose an ecient algorithm that approximates path-consistency. The idea is to use the extreme points of all intervals associated with a single constraint as one big interval, yielding an STP, and then to perform path-consistency on that STP. This process will not increasing the number of intervals. Denition 3 : Let T ij = [I ;...;I m ] be the constraint over variables i ; j and let L ij ; U ij be the lowest and highest value of T ij, respectively. We de- ne N ;N ;N as follows (see Figure 5): 5 7 Algorithm Upper-Lower Tightening (). input: N. N N 3. repeat. N N 5. compute N ; N ; N. 6. until 8ij (L ij = L ij) and (Uij 7. if 9ij (U ij <L or 9ij (Uij <L ij ) = U ij) ij ) output: \Inconsistent." otherwise output: N Figure 6: The algorithm. N is an STP derived from N by relaxing its constraints to T ij =[L ij; U ij ]. N is the minimal network of N. N is derived from N and N by intersecting T ij = T ij 8 T ij. Algorithm is presented in Figure 6. We can show that computes a network equivalent toits input network. Lemma : Let N be the input to and R be its output. The networks N and R are equivalent. Regarding the eectiveness of, we can show that Lemma : Every iteration of (excluding the last) removes at least one interval.
This can be used to show that Theorem : Algorithm terminates in O(n 3 ek+ e k ) steps where n is the number of variables, e is the number of edges, and k is the maximal number of intervals in each constraint. In contrast to PC, is guaranteed to converge in O(ek) iterations even if the interval boundaries are not rational numbers. For a sample execution see Figure 5. Algorithm can also be used to identify pathredundancies. Denition : A constraint T ij is redundant-prone i, after applying, T ij is redundant inn. Lemma 3: T ij is path-redundant in N if T ij T ij and T ij = 8 8k(T ik T kj ). Corollary : A single interval constraint T ij is redundant-prone i T ij = 8 8k(T ik T kj ). Consequently, after applying to a TCSP,we can test the condition in Corollary and eliminate some redundant constraints. A brute-force algorithm for solving a TCSP decomposes it into separate STPs by selecting a single interval from each constraint (Dechter Meiri & Pearl 9). Each STP is then solved separately and the solutions are combined. Alternatively, a naive backtracking algorithm will successively assign an interval to a constraint, as long as the resulting STP is consistent. Once inconsistency is detected, the algorithm backtracks. Algorithm can be used as a preprocessing stage to reduce the number of intervals in each constraint and to identify some path-redundant constraints. Since every iteration of removes at least one interval, the search space is pruned. More importantly, if causes redundant constraints to be removed, the search space may be pruned exponentially in the number of constraints removed. Note however that the number of constraints in the initial network is e while following the application of, or PC, the constraint graph becomes complete thus the number of constraints is O(n ).. Empirical Evaluation We conducted two sets of experiments. One comparing the eciency and accuracy of and relative to PC, and the other comparing their eectiveness as a preprocessing to backtracking. Our experiments were conducted on randomly generated sets of instances. Our random problem generator uses ve parameters: () n, the number of variables, () k, the number of intervals in each constraint, (3) We call this process \labeling the TCSP". Time in Seconds Fraction of inconsistency detection Efficiency of,, PC, PC- ( reps) on variables, tightness.95, Pc=.... 6 Number of Intervals Approximation Quality relative to PC on variables, tightness.95, Pc=...9.8.7.6 6 Number of Intervals 8 8 PC PC- Figure 8: The execution time and quality of the approximation obtained by and to PC. Each point represents runs on networks with variables,.95 tightness, connectivity P C = : and range [; 6]. R = [Inf,Sup], the range of the constraints, () T I, the tightness of the constraints, namely, the fraction of values allowed relative to the interval [Inf,Sup], and (5) P C, the probability that a constraint T ij exists. Intuitively, problems with dense graphs and loose constraints with many intervals should be more dicult. To evaluate the quality of the approximation achieved by and relative to PC, we counted the number of cases in which and detected inconsistency given that PC detected one. From Figure 8, we conclude that when the number of intervals is small, is faster than but produces weaker approximations. When the number of intervals is large, is much slower but is more accurate. In addition, we observe that when the number of intervals is very large, computes a very good approximation to PC, and runs about times faster. In Figure 9 we report the relative quality of and for a small (3) and for a large () number of intervals, as a function of connectivity. As the connectivity increases, the approximation quality of both
Fraction of inconsistency detection Fraction of inconsistency detection Approximation Quality relative to PC on variables, 3 intervals, tightness.95..8.6...8....6.8. Connectivity parameter Pc Approximation Quality relative to PC on variables, intervals, tightness.95..8.6...6.8....6.8 Connectivity parameter Pc Figure 9: Quality of the approximation vs connectivity on problems with variables, tightness.95 and range [; 6]. We measured on problems of 3 intervals (top) where each point represents runs, and on intervals (bottom) where each point represents runs. and increases. Note again that is more accurate for a small number of intervals while dominates for large number of intervals. We measured the number of iterations performed by, PC, and PC- (Figure ). We observe that for our benchmarks, performed iteration (excluding the termination iteration) in most of the cases, while PC- and PC performed more ( performs only one iteration). In the second set of experiments we tested the power of, and PC as preprocessing to backtracking. Without preprocessing, the problems could not be solved using the naive backtracking. Our preliminary tests ran on problem instances with variables and 3 intervals and none terminated before STP checks. We therefore continued with testing backtracking following preprocessing by, and PC. A brute force path-consistency algorithm (Dechter Meiri & Pearl).. Number of iterations Number of Iterations Iteration count of, PC, PC- 8 6 8 6 8 6.8 3 Number of intervals Iteration count for, PC, PC-....6 5.8 Connectivity Parameter Pc. PC PC- PC PC- Figure : The number of iterations, PC and PC- performed (excluding the termination iteration) on problems with variables, intervals, P C = :, and tightness.95. Each point represents runs. Testing the consistency of a labeling requires solving the corresponding STP. An inconsistent STP represents a dead-end. Therefore, we counted the number of inconsistent STPs tested before a single consistent one was found and the overall time required (including preprocessing). The results are presented in Figure on a logarithmic scale. We observe that was able to remove intervals eectively and appears to be the most eective as a preprocessing procedure. For additional experiments with path-consistency for qualitative temporal networks see (Ladkin & Reinefeld 9). Summary and conclusion In this paper we presented a polynomial approximation algorithm to path-consistency for temporal constraint problems, called. Its complexityiso(n 3 ek+e k ), in contrast to path-consistency which is exponential in k, where n is the number of variables, e is the number of constraints and k is the maximal numberofintervals per constraint. We also argued that can be used to eectively identify some path-redundancies. Weevaluated the performance of and em-
Time in Seconds Number of STPs tested Backtracking efficiency using,, PC as preprocessing stage PC.....6.8 Connectivity Parameter Pc Backtracking Efficiency using,, PC as preprocessing stage....6 Connectivity Parameter Pc.8 PC Figure : Backtracking performance following preprocessing by, PC and PC- respectively, on problems with variables, 3 intervals, and tightness.95. Each point represents runs. The time includes preprocessing. pirically by comparing their run-time and quality of output relative to PC. The results show that while is always very ecient, it is most accurate (i.e. it generates output closer to PC) for problems having a small number of intervals and high connectivity. Specically, we saw that:. The complexity of both PC and grows exponentially in the number of intervals, while the complexity of remains almost constant.. When the number of intervals is small, is faster but produces weaker approximations relative to. When the number of intervals is large, is much slower but more accurate. 3. For a large number of intervals, computes a very good approximation to PC, and runs about times faster.. When used as a preprocessing procedure before backtracking, is shown to be times more eective then either or PC. Finally, our experimental evaluation is by no means complete. We intend to conduct additional experiments with wider range of parameters and larger problems. 6 References Allen, J.F. 983. Maintaining knowledge about temporal intervals. CACM 6():83-83. Dechter, R.; Meiri, I.; Pearl, J. 99. Temporal Constraint Networks. Articial Intelligence 9:6-95. Dechter, R.; 99. \Constraint Networks", Encyclopedia of Articial Intelligence, (nd ed.) (Wiley, New York, 99) 7685. Dechter, R.; Pearl, J. 988. Network-based heuristics for constraint satisfaction problems. Articial Intelligence 3:-38. Dechter, R. 99. Enhancement schemes for constraint processing: Backjumping, learning and cutset decomposition. Articial Intelligence :73-3. Dechter, R.; Dechter, A. 987. Removing redundancies in constraint networks. In Proc. of AAAI-87, 5-9. Dean, T.M.; McDermott, D. V. 987. Temporal data base management. Articial Intelligence 3:-55. Freuder, E.C. 985. A sucient condition of backtrack free search. JACM 3():5-5. Ladkin, P. B.; Reinefeld, A. 99. Eective solution of qualitative interval constraint problems. Articial Intelligence 57:5-. Meiri, I. 99. Combining qualitative and quantitative constraints in temporal reasoning. In Proc. of AAAI-9, 667. Meiri, I.; Dechter, R.; Pearl, J. 99. Tree decomposition with application to constraint processing. In Proc. of AAAI-9, 6. Kautz, H.; Ladkin, P. 99. Intergating metric and qualitative temporal reasoning", In Proc. of AAAI-9, 6. Koubarakis, M. 99. Dense time and temporal constraints with 6=. In Proc. KR-9, -35. Poesio, M.; Brachman, R. J. 99. Metric constraints for maintaining appointments: Dates and repeated activities. In Proc. AAAI-9, 5359. Van Beek, P. 99. Reasoning about qualitative temporal information. Articial Intelligence 58:97-36. Vilain, M.; Kautz, H. 986. Constraint propagation algorithms for temporal information. In Proc AAAI-86, 377-38.