520 likes | 723 Views
Temporal Constraint Networks Chapter 12. Chao Chen CSCE 990-06 Advanced Constraint Processing. Outline. Gentle reminder… Introduction Qualitative Temporal Networks Interval Algebra Point Algebra Quantitative Temporal Networks Simple Temporal Problem General TCSP
E N D
Temporal Constraint NetworksChapter 12 Chao Chen CSCE 990-06 Advanced Constraint Processing 1
Outline • Gentle reminder… • Introduction • Qualitative Temporal Networks • Interval Algebra • Point Algebra • Quantitative Temporal Networks • Simple Temporal Problem • General TCSP • Path consistency in quantitative networks • Network-based algorithms • Translations between representations 2
Main CSP Properties • Node consistency • Arc consistency • Path consistency • Minimality • Decomposability (i.e., global consistency) • Consistency 3
Minimality • Domain is minimal iff every value in the domain can be extended to a solution • Constraint is minimal iff every tuple in the constraint can be extended to a solution • A network is minimal iff • its domains are minimal and • constraints are minimal • Given two values for two variables, if they are consistent, then they appear in at least one solution • Tightest possible binary constraints yield the minimal network 4
Decomposability • A network is decomposable if every consistent assignment of values to a set of variables S can be extended to a solution 5
Minimality vs Decomposability • Minimality: any consistent combination of 2 variables is extendable to a solution • Decomposability: any consistent combination of k (kn) variables is extendable to a solution. PC Minimal Decomposable 6
Temporal Reasoning: Introduction • Many areas in AI: • planning, scheduling, qualitative reasoning, plan recognition, … • Reasoning about time • Represent time, mathematical and numerical • Reason time, inference • Model a problem about time and constraints on time • View as a CSP • Apply constraint processing framework & techniques 7
Vocabulary • Temporal Objects: • Points, beginning and ending of some events: BC/AD • Intervals, time period during which events occur or propositions hold: during class, am, pm • Constraints: Qualitative & Quantitative • Qualitative: Relation between time point and interval • Extensional, atomic relations • Interval algebra: before, during, starts, etc. • Point algebra: <, =, > • Quantitative: duration of an event in a numerical fashion • Intensional relations • Constraints of bounded differences • Domain: continuous intervals in R represent time 8
Interval Algebra: Relations (a.k.a. Allen Interval Algebra, after James Allen [1983]) Relation Symbol Inverse Examples X before Y b bi X equal Y = = X meets Y m mi X overlaps Y o oi X during Y d di X starts Y s si X finishes Y f fi x y x y x y x y x y x y x y 9
Qualitative TN: Interval Algebra • Two intervals I, J represent two events • 13 basic relations r = { b, m, o, s, d, f, bi, mi, oi, si, di, fi, = } • I { r1, r2, …, rk } J(I r1 J) (I r2 J) … (I rk J) disjunctive clauses • Not interested in explicit relations over domains of variables • Enumerated atomic relations between variables 10
Interval Algebra Constraint Network • Definition 12.1.2, page 338 • Variables: temporal intervals I and J • Domain: set of ordered pairs of real numbers • Constraints are 13 relations • A solution is an assignment of a pair of numbers to each variable such that no constraint is violated 11
Interval Algebra: Example Story: John was not in the room when I touched the switch to turn on the light but John was in the room later when the light was on. CSP modeling: Variables: Switch – the time of touching the switch Light – the light was on Room – the time that John was in the room Constraints: Switch overlaps or meets Light: S {o, m} L Switch is before, meets, is met by or after Room: S {b, m, mi, bi} R Light overlaps, starts or is during Room:L {o, s, d} R 12
Light Light {o, s, d} {o, s} {o, m} {o, m} Switch Switch Room Room {b, m, mi, a} {b, m} Minimal Network Constraint Tightening A unique network equivalent to original network All constraints are subsets of original constraints Provides a more explicit representation Useful in answering many types of queries 13
IA: Path Consistency • Intersection • Composition (a table like 12.5 page 342) • QPC-1 (page 342) • Tighten every pair of constraints using • Until minimal network or inconsistency detected 14
IA: Path Consistency • Composition table (page 12.5) • QPC-1, in some cases, guaranteed to generate minimal network (exact) • But, minimal network is not guaranteed • Global consistent • Backtrack free • Solution: combine, at each node, • backtracking scheme with • path-consistency look-ahead engine 15
Light {o, m} {o, s, d} {o, m} Switch Light Switch Room {o, s, d} {b, m, mi, a} {b, m} Room Backtracking scheme with path-consistency look-ahead engine • Dual graph representation • Use constraints as variables • Use common variables as edges Path-consistency look-ahead A minimal network Backtracking 16
Point Algebra [Vilain & Kautz 1986] • Each variable represents a time point • Domain are real numbers • Constraint express relative positions of 2 points • Three basic relations: P<Q, P=Q, P>Q • Constraints are PA elements {<, >, =} • Cheaper than IA: • reasoning tasks are polynomial O(n3) 17
Point Algebra: Example • Story: Fred put the paper down and drank the last of his coffee • IA: Paper { s, d, f, = } Coffee • PA: Paper=[x, y], Coffee=[z, t] Constraints: x<y, z<t, x<t, x>=z, y<=t, y>z paper paper paper paper Coffee Coffee Coffee Coffee 18
PA: Path Consistency • Algorithm is basically the same as IA • Composition table (Table 12.2 page 343) • ? means universal constraint • Path-consistent minimal decomposable (globally consistent) • Convex PA (CPA) network • Only have {<, <=, =, >=, >} • Exclude 19
PA: Consistency Inference • Theorem 12.1.10 • Path-consistency decides the consistency in O(n3) • Consistency and solution generation of PA networks can be accomplished in O(n2) • Minimal network of a PA consistent network can be obtained using 4-consistency in O(n4) • Minimal network of CPA networks can be obtained by path-consistency in O(n3) 20
Limitations of Point Algebra • In some cases, PA can NOT fully express the constraints IA: Paper {b, a} Coffee y<z and t<x cannot exist simultaneously paper coffee x y z t coffee paper z t x y Time increasing 21
PA versus IA • Determining consistency of statement in IA is NP-hard. • Polynomial-time algorithm (Allen’s) sound but not complete • PA constraint propagation is sound and complete. • Time: O(n3) and space: O(n2) 22
PA versus IA • PA trades off expressiveness with tractability • PA is a restricted form of IA • PA can be used to identify classes of easy case of IA • Solution: Transform IA to PA • solve it as PA and • translate back to IA, cost= O(n2) 23
Quantitative Temporal Networkssection 2 • Explicitly deal with number instead of relation • Express the duration of time • starting point x1 • end point x2 • duration=x2-x1 • John travel by car from home to work takes him 30 to 40 minutes or he travel by bus takes him at least 60 minutes 30 x2-x1 40 or 60 x2-x1 24
[30,40] x1 x2 [10,20] x0 [10,20] x3 x4 [20,30] [60,70] Example of a Quantitative Net • Simple Temporal Problem: Example 12.2.1 (page 346) x0 =7:00am , x1 John left home between 7:10 to 7:20, x2 John arrive work in 30 to 40 minutes x3 Fred left home 10 to 20 minutes before x2, x4 Fred arrive work between 8:00 to 8:10 Fred travel from home to work in 20 to 30 minutes 25
Simple Temporal Problem (STP) • A special class of temporal problems • can be processed in polynomial time • Each edge eij: ij is labeled by a single interval [aij, bij] • Constraint (aij xj-xi bij ) expressed by (xj-xi bi ) ( xi-xj -aij ) (xj-xi 20) ( xi-xj -10) j i [10, 20] 26
x1 20 x0 -10 Simple Temporal Problem • We transform the problem to compute all pairs shortest paths of the distance graph. • Each constraint is represented by two edges, one + and one - • Constraint graph directed cyclic graph 27
40 x2 x1 -30 20 20 -10 x0 x3 -10 50 x4 -40 -60 Distance Graph of the STP 70 • Run F-W all pair shortest path, is a special case of PC • If any pair of nodes has a negative cycle inconsistency • If consistent after F-W minimal & decomposable • Once d-graph formed, assembling a solution by checking against the previous assignment. • Total time: F-W O(n3) + Assembling O(n2) = O(n3). 28
[30,40] [60,oo] x1 x2 [10,20] x0 [10,20] x3 x4 [20,30] [40,50] [60,70] Temporal Constraint Graph 29
Temporal CSP Definition 12.2.2 • A set of variables with continuous domain • Each variable represents a time point • Each constraint is represented by a set of intervals { [1, 12], [23, 45], …, [100, 104] } • Unary constraint: a1 xi b1… • Binary constraint: a1 xj-xi b1 … • A tuple x=a1, …, an is a solution if x1=a1, x2=a2,…, xn=an do not violate any constraints 30
[30,40] [60,oo] x1 x2 [10,20] x0 [10,20] x3 x4 [20,30] [40,50] [60,70] Temporal Constraint Graph • We are interested in • is it consistent? (consistency problem) • what are the possible time at which Xicould occur? • (minimal domain problem) • 3) what are all possible relationship between Xi and Xj? • (minimal constraint problem) 31
Inference on TCSP • T={ I1,…, Il}, S={J1,…, Jm} • Union: (this is set union) • T S = { I1,…, Il , J1,…, Jm } • Intersection: (this is set intersection) • T S = { zT and z S} • Composition: (this is the cross product ) 32
The General TCS Problem • Multiple intervals in the label of an edge • A solution is • one interval per edge • for every edge • such that the network is consistent • NP-complete, solved with search 33
(Bad solution) to the TCSP • Select one interval per edge • Decompose general TCSP into a set of separate STPs (TCSP all STPs) • Solve each STP separately • takes advantage of STP’s polynomial time complexity, • Every solution in STP will be a solution for general TCSP • Minimal TCSP all Minimal STPs [Theorem 12.2.11] 34
Solving General TCSP • Minimal network of a TCSP = Uall possible STPs {minimal network of each possible labeling} • Complexity of solving general TCSP by generating all labelings and solving them independently is O(n3ke), • k is maximum number of labels and • e is the number of edges 35
Better Alternative: Meta-CSP Meta-CSP = CSP of a CSP Model the TCSP as a CSP and solve it with BT • Variables: edges of the constraint network • Domain: the intervals in the label of a given edge • Constraint: one global constraint, consistent STP • A solution: • one interval per edge • such that the current network is a consistent STP 36
C1={ i11, i12} x1 C2= { i21, i22, i23 } STP x2 C3={ i31, i32} x3 C4={i41, i42} x4 C5={i51} An Example of Meta-CSP i21=[30,40] i22=[60,70] i23=[25, 75] x2 x1 i11=[10,20] i12=[35, 60] x0 i31=[10,23] i32=[24, 29] x3 x4 i41=[20,30] i42=[40,50] i51=[60,70] Original CSP Meta-CSP 37
Search on Meta-CSP • Root node is the start node (dummy node) • First level corresponds to (a STP with) an edge e1 (variable) • Each node at this level corresponds to e1 labeled with each of its intervals i1, • The next level corresponds to (an STP with) two edges e1 and e2 • At a given level i, we have an STP with i edges.. 38
i21 i11 i21 C22 C32 C21 C22 C32 i31 i32 i31 i32 i41 i42 i51 i51 Search on Meta-CSP Dummy node C1 C2 C3 C4 C5 Ci 39
Summary: TCSP with search • Running a BT search on a meta-CSP in which the variables are edges of the temporal network and domains are possible intervals • Assign intervals to edges as long as no negative cycle of current STP (F-W) • If partial assignment cannot be extended, backtrack • Otherwise, add one more edge… 40
Warning: Temporal Inference • On STP: we tighten the unique interval • Composition: interval addition [a,b]+[c,d]=[a+c, b+d] • Intersection: Interval intersection [a,b][c,d]=[max(a,c), min(b,d)] • On TCSP: we eliminate one or more intervals from the label, which is a set of intervals • Composition: cross product (the main factor for exponential growth of inference process) • Intersection: set definition 41
i1=[1,3] i2= [6, 17] i3=[5, 30] i3’=[7, 20] Examples on STP • STP: Each edge has only one label Tighten Constraint Operation in NPC i1,, i2,i3 are the original constraints, we are tightening i3, let i3’ be the tightened constraint. i3’ = i3(i1 i2) I = i1 i2 = [1+6, 3+17]=[7,20] i3’= i3 I ={max(5, 7), min (30, 20)} = [7, 20] i3’ is the newly tightened the constraint 42
i11=[1,2] i12=[11,12] i13=[21,22] i21= [0, 1] i22=[16,17] i23=[23,24] i3={ [1, 3], [12, 15], [23, 27] } i3’={ [1,3], [17,19], [24, 26], [11, 13], [27, 29], [34, 36] [21, 23], [37, 39], [44, 46] } { [1, 3], [12, 15], [23, 27] } = { [1, 3], [12, 13], [24, 26], [23, 23], [27, 27] } Examples on TCSP • TCSP: Each edge has multiple labels 43
PC on Quantitative Network • A temporal constraint Tij is path consistentiff Tij Tij(Tik Tik) for all k i and j. • A temporal network is path-consistent iff all its constraints are path-consistent. • Problem: • Continuous domain termination??? • Box-consistency! Work on endpoints only • Integral TCSP: values are discrete, will terminate • Non integral TCSP, if extreme points are rational number, will terminate. 44
Propagation on STP vs TCSP • STP: • i3 = [5, 30] • i3’= [7, 20] • domain is tightened • TCSP: • i3 = { [1, 3], [12, 15], [23, 27] } • i3’ = { [1, 3], [12, 13], [24, 26], [23, 23], [27, 27] } • domain is fractioned, source of combinatorial growth • PC (a la Dechter) is source of combinatorial explosion approximation algoriths • PC (a la Xu Lin, PL2) is poly-time & avoids this drawback 45
PC on Quantitative Network • Range of {[1, 5], [7, 9], [10, 18]} is {[1, 18]} • Range of the network is the maximum range over all constraints. • NPC-1(mirror PC-1): O(n3R3) • NPC-3 (mirror PC-3): O(n3R) • PC not guarantee minimal network or decomposable. • Directional Path Consistency (a weaker version) is more effective(alg. on pp. 357, Fig. 12.15) 46
Fragmentation and Remedies • Composition operation cause exponential growth. (Figure 12.16, page 358) • Upper Lower Tightening (ULT) • Form STP by impose upper and lower bound on all subintervals • Tighten this STP’constaints using F-W • The resulting consistent STP intersects with original TCSP. • Iterate the above steps until no change or inconsistency detected. 47
ULT verse NPC • ULT O(n3ek+e2k2) • NPC O(n3R) • Compare with NPC, ULT is guaranteed to converge in O(ek) iterations, even if interval boundary are not rational • ULT is better than NPC 48
Network-Based Algorithm • Can TCSP exploit topology of its graph and use network-base algorithm? • For Temporal CSP • Due to structure of TCSP (binary network), we can utilize induced-width = 1 or 2 or tree-decomposition algorithms • General tree-decomposition does not seem natural (enforce constraints of large scope) • Cycle-set cannot be beneficial to TCSP • Xu Lin exploits articulation points & triangulation in a new algorithm 49
Translation between Representations PA and IA to TCSP • PA to TCSP (example 12.19 page 361) • PA network is a special case of TCSP lacking metric information • IA cannot always be translated in to binary TCSP 50