800 likes | 1.01k Vues
Constraint Databases and Temporal Reasoning. Peter Revesz. University of Nebraska-Lincoln. Constraint Database. A generalization of relational database A set of constraint tables/relations Each constraint table consists of a set of constraint tuples
E N D
Constraint Databases and Temporal Reasoning Peter Revesz University of Nebraska-Lincoln
Constraint Database • A generalization of relational database • A set of constraint tables/relations • Each constraint table consists of a set of constraint tuples • Each constraint tuple is a conjunction of allowed types of constraints over a set of variables and parameters
Example Constraint Databases • Linear Constraint Databases (any conjunction of linear constraints over the attribute variables) • Parametric Rectangles • Periodic Parametric Rectangles • Parametric 2-Spaghetti • Geometric Transformations • etc
Parametric Rectangles (P□) Scheme: (X, Y, T) Variables: x, y, t Constraints: x >= a1 t + b1 x <= a2 t + b2 y >= c1t + d1 y <= c2 t + d2 from ≤ t ≤ to
Periodic Parametric Rectangle A PP□ is a parametric rectangle that repeats its motion every period (p) until t = end (e) • A PP□ is equivalent to a P□ when p = -1 • [from,to]p,end • Exa: [80,82]10,111 means union of [80,82], [90,92], [100,102], [110,111]
Exa: Periodic Parametric Rectangle t’ = t mod 5
Parametric 2-Spaghetti • Constraint Level: • Scheme 1: (Ax, Ay, Bx, By, Cx, Cy, From, To) • Parameter: t • Scheme 2: (X, Y, T) • Variables: x, y, t • Conjunction of constraints over x, y, t that define a changing triangle ABC • Logical Level: • Variables: x, y, t • Tuples (x,y,t) such that (x,y) is in ABC at time t
Expressive Power PP□ P∆
Geometric Transformations [Chomicki & Revesz Time’99] • A triple (V, I, f) • V is d dimensional representative spatial object • I is time domain • f is V x t V’, parametric geometric transformation function that maps the V at any time t in I to some V’ d dimensional spatial object.
Exa: Geometric Transformation • Whale(V, I, f) where • V = [20, 30] x [20, 30] • I = [0, 20] • x -t f(x, y, t) = + y 0 Any (x,y) at time t is mapped to (x-t, y). The whale moves west with 1 unit speed.
Raster Parametric Rectangle • given the initial and final snapshots at time ti and tf • first, rectangulate the smaller snapshot: • next, rectangulate the bigger snapshot, ensuring that both have the same number of rows of rectangles
Queries use the logical level Constraint level is for storage. Since logical level is the same*** as for relational databases, relational queries are possible. ***except the logical level can beinfinite set of points for constraint database
Constraint Query Languages • Relational algebra • SQL Max op in LCDB linear programming • Datalog • Spatial operators: Area, Buffer, etc. • Spatio-temporal operators: Animation (visualization by video) Block (find movement when …) Collide (find movement bouncing …) Deflect (find movement in gravitational field…) etc.
A Query for Parametric Rectangles • Region(X, Y, T, temperature) • Clouds(X, Y, T, humidity) • Where and when will it snow? Relational algebra: PROJECT x,y,t (SELECT(temperature < 32) Region) PROJECT x,y,t (SELECT(humidity > 80) Clouds)
SQL: SELECT x, y, t FROM Region WHERE temperature < 32 INTERSECT SELECT x, y, t FROM Clouds WHERE humidity > 80 Datalog: Snow (x, y, t) : - Region(x, y, t, temperature), Clouds(x, y, t, humidity), temperature < 32, humidity > 80
A Query for Parametric 2-Spaghetti • Region(Ax, Ay, Bx, By, Cx, Cy, F, T,temperature) • Clouds(Ax, Ay, Bx, By, Cx, Cy, F, T, humidity) • Where and when will it snow? Same as before
Query Language Issues • High-level, user-friendly • Expressiveness • Termination • Closed-Form • Complexity Data complexity: fixed queries (as in a library/menu) and variable size input relations
Theorem: Parametric Rectangles are Closed under Relational Algebra Queries Proof: Intersection R1 = ( [t+6, t+20], [5, 15], [0, 10] ) R2 = ( [2t, 3t+10], [0, 10], [0, 10] ) 0 t < 5 5 t < 6 6 t 10
Theorem: Relational algebra can be evaluated in PTIME data complexity forParametric Rectangle Databases. Similar theorems for other combinations of constraint databases and query languages.
Spatial Operators • Area Operator • computes the area of a relation R at a time ti • denoted by area (R, ti)
Animation • Look at the examples.
Other Spatiotemporal Operators • Block Operator • computes the change in a relation R2, as a result of being “blocked” by R1, until the time tk • denoted by block (R1, R2, tk) • if we view a parametric rectangle as a set of moving points, it can be defined as the set of moving points in R2 that did not intersect with R1 before tk
Other Spatiotemporal Operators • Block Operator (contd.) • the second figure shows the result of difference operation and the third shows the result of block operation at t = 15
Other Spatio-temporal Operators • Block Operator (contd.) • evaluation • instantiate R1, R2 at tk • successive partitioning • maximum depth
Other Spatio-temporal Operators • Collide Operator • computes the result of a collision between two (moving) parametric rectangles (which do not grow or shrink) • denoted by collide (r1, r2) • assume that the collision is elastic • view the parametric rectangles as spherical bodies, with given fixed masses
Other Spatio-temporal Operators • Collide Operator (contd.) • determine line joining centers (LC) at time of collision • resolve velocities along LC
Other Spatio-temporal Operators • Collide Operator (contd.) • initial velocity (Vi) • LC velocity before collision (ViLC) • LC velocity after solving “head-on” collision (VfLC) • final velocity (Vf) = vector sum of [VfLC - ViLC, Vi] • PReSTO System Simulation
PReSTO System • PReSTO System • Parametric Rectangles as SpatioTemporal Objects • Visual C++ implementation • GUI Queries • operator icons provided on the interface Other systems: CCUBE, DEDALE, MLPQ, etc.
Uses of Constraint Databases • Decision Support Systems example: fire control • Approximate Reasoning example: approximation of Time Series (t1,y1), (t2,y2), …., (tn,yn) • Timed Automata Verification • Animation
Forest Fire Control Problem • Problem Description • a fire starts in some portion of a forest • fire-fighters have several options to control the fire spread • option which minimizes damage must be chosen
Forest Fire Control Problem • Problem Description (contd.) • assume that we can predict the fire spread from environmental conditions • two possible strategies of dropping foam could be:
Forest Fire Control Problem • Problem Solution (contd.) • after applying the block and area operators in PReSTO, we get the following results: Strategy Burnt Area 16056 None 1 12426 2 7315
Piecewise Linear Approximation Temperature Temperature PLA =3 Constraint Database Relational Database
Querying Piecewise Linear Approximations • For the relation Temperature(Temp, t), find the temperatures at time 1.5 : select Temp from Temperature where t = 1.5; • For the relation Temperature(Temp, t), find the lowest temperature: select min(Temp) from Temperature;
TOURIST Timed Automata d >= 100 ? e := e + 198 d := d - 100 y >= 30,000 ? e := e + 198 y := y - 30000
Timed Automata Datalog • T(d, e’, y’) :- T(d, e, y), y >= 30000, y’ = y – 30000, e’ = e+198.
Value-by-Area Cartogram A value-by-area cartogram is a map in which each display area is proportional to some geographically distributed “value”. Contiguous cartograms Noncontiguous cartograms
Some Disadvantages of Current Animation Algorithms • Current cartogram animation algorithms run very slowly. • Current cartogram animation algorithms require pre-computing and saving the snapshots. This greatly limits the number of snapshots that can be displayed in animation.
Cartogram Animation Two snapshots of value-by-area cartogram animation for U.S. population in 1970 and 1990.
Volume Animation Two snapshots of daily mean temperature in U.S. during a winter day and a summer day.
Constraint-Based Animation Methods Avoid pre-computation Support animation with large number of snapshots Run fast
Methods for Animation • Parallel Method • Serial Method • Hybrid Method