Mitch Wand - PowerPoint PPT Presentation

About This Presentation
Title:

Mitch Wand

Description:

From o1 of class C1, follow edge e iff there is some object graph O and some o2, o3 s.t. ... be class(o2), c'' be class(o3) 10/23/09. Navigation in Object ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 42
Provided by: karllie
Category:
Tags: mitch | ozone | wand

less

Transcript and Presenter's Notes

Title: Mitch Wand


1
Navigation in Object Graphs
  • Mitch Wand
  • and
  • Karl Lieberherr

2
Searching for Reachable Objects
  • Task Given an object o1 of class c1 in an object
    graph, find all objects of type c2 that are
    reachable from o1.
  • Assumptions we know the class structure that
    describes the object graph, but we know nothing
    else about the object graph except the class of
    the current object.

3
Search using meta information
  • we could visit the entire object but that
  • would be wasteful or
  • might lead to wrong results

4
Classes and Objects Basic Notations
e
c2
c1
Class c1 has a part e of type c2
c2
c1
Class c1 inherits from class c2
c1
o1c1
Object o1 is of class c1
c1
o1c1
c2
Object o1 is of type c2 (i.e., its class is a
subclass of c2)
e
o2
o1
Object o1 has a part e which is object o2
5
Finding the first step for the search
C1
C2
ObjectGraph-object
o2
o1C1
o4
o3
Which arrows might lead to an object of type C2?
Traversal Strategy from C1 to C2
6
Relations between Classes
e
C2
C1
e(C1,C2)
C2
C1
C(C1,C2) (that is, e(C1,C2) for some e)
C2
C1
C1 lt C2
C1
o1C1
Class(o1) C1
C1
o1C1
C2
Object o1 is of type C2 Class(o1) lt C2
7
Relations between Objects
e
o2
o1
e(o1,o2)
o2
o1
O(o1,o2) (that is, e(o1,o2) for some e)
8
Operations on Relations
  • R.S (x,z) exists y s.t. R(x,y) and S(y,z)
  • R reflexive, transitive closure of R

9
Possible edges in the object graph
e
C1
C2
e(o1, o2) implies class(o1) (lt .e .gt )
class(o2) in the class graph

up, over, and down
O(o1, o2) implies class(o1) (lt .C .gt )
class(o2) in the class graph
e
o1
o2
10
Which edges to follow to C2?
C2
  • From o1 of class C1, follow edge e iff there is
    some object graph O and some o2, o3 s.t.
  • e(o1,o2),
  • O(o2,o3), and
  • class(o3) lt C2

C1
o1C1

o3
o2
e
The existential quantifier there is some object
graph represents our lack of knowledge about the
rest of the object graph
11
Example
from Basket to Orange
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
premature termination
f
a1Apple
f
b1Basket
b1Basket
v
object graph
v1Vegetable
object graph slice
12
Example
from Basket to Orange
mapping o1 b1 o2 a1 o3 a1 e f
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
f
a1Orange
b1Basket
object graph
v
object graph slice
v1Vegetable
13
Lack of Knowledge
  • Objects of a given class may be very different.
  • We want to go down edges without looking ahead!
  • We dont want to go down edges that are
    guaranteed to be unsuccessful (never reaching a
    target object).

14
Object graph conforms to class graph
  • The object graph O must follow the rules of the
    class graph the object graph cannot contain more
    information than the class graph allows.

For all edges e(o1,o2) in the object graph e(o1,
o2) implies class(o1) (lt .e .gt ) class(o2)
in the class graph
15
From dynamic to static characterization
  • From o1 of class c1, follow edge e iff there is
    some object graph O and some o2, o3 s.t.
  • e(o1,o2),
  • O(o2,o3), and
  • class(o3) lt c2
  • From o1 of class c1, follow edge e iff there are
    classes c, c s.t.
  • c1 lt.e.gt c
  • c (lt.C.gt) c and
  • c lt c2

Let c be class(o2), c be class(o3)
16
Example
static characterization
from Basket to Orange
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
premature termination
f
a1Apple
f
b1Basket
b1Basket
v
object graph
v1Vegetable
object graph slice
17
Example
static characterization
from Basket to Orange
mapping c1 Basket c Orange c Orange e f
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
f
a1Orange
b1Basket
object graph
v
object graph slice
v1Vegetable
18
Relational Formulation
from c1 to c2
From object o of class c1, to get to c2, follow
edges in the set POSS(c1,c2,o)e c1 lt.e.gt
(lt.C.gt) lt c2
Can easily compute these sets for every c1, c2
via transitive-closure algorithms. POSS
abbreviation for following these edges it is
still possible to reach a c2-object for some
c1-object rooted at o.
19
Generalizations
  • More complex strategies
  • from c1 through c2 to c3
  • Use waypoint navigation get to a c2 object,
    then search for a c3 object.
  • More complex strategy graphs also doable in this
    framework

20
Traversal algorithms
  • Rename POSS to FIRST.
  • Applications of FIRST for strategies of the form
    from c1 through c2 through to ck.

21
Definition of R-path
  • Let R (c1, ,ck) be a non-empty sequence of
    classes. Let p (o1, , oN) be a path in O. We
    say that p is an R-path iff there is a
    subsequence oj1, ,ojk of p such that for each
    i, oji has type ci and jkN, (that is the last
    element of the path must be a part of the
    subsequence).

22
Minimal R-paths
  • We say that an R-path is minimal iff it has no
    initial segment that is also an R-path.

23
Algorithm search(o,R)(visit all endpoints of
minimal R-paths)
  • Let (c1, ,cn) be the classes such that R (c1,
    ,cn).
  • 1. If o does not have type c1, then for each e in
    FIRST(class(o), c1) and each o such that
    e(o,o), do search(o, R).
  • 2. If o has type c1, and R(c1), then do
    visit(o).
  • 3. If o has type c1, and R(c1, c2, ,cn), then
    do search(o,(c2, ,cn)).

24
Cyclic and acyclic object graphs
  • If the object graph is acyclic, algorithm search
    will terminate, since every step either decreases
    the longest chain of links in the object graph or
    decreases the length of R.
  • If the object graph is cyclic, then we need to
    mark each searched object with the state R in
    which it was reached (to not visit it again in
    the same state).

25
Extra Slides
26
Example A
z
Strategy S -gt T
x
X1
Y1
Z1
y
X2
S
Y2
Z2
T
t
X3
Y3
Z3
x
y
z
t
x31X3
y31Y3
z31Z3
t1T
s1S
go down x iff S lt.x. gt(lt.C.gt)lt) T
27
Example A
z
Strategy S -gt T
x
X1
Y1
Z1
y
X2
S
Y2
Z2
T
t
X3
Y3
Z3
x
y
z
t
x31X3
y31Y3
z31Z3
t1T
s1S
lt,gt not used
go down x iff S lt.x. gt.(lt.C.gt).lt) T
28
Example A
z
Strategy S -gt T
x
X1
Y1
Z1
y
X2
S
Y2
Z2
T
t
X3
Y3
Z3
x
y
z
t
x31X3
y31Y3
z31Z3
t1T
s1S
lt,gt not used
go down x iff S lt.x. gt.(lt.C.gtlt.C.gtlt.Cgt).lt
) T
29
Example B
class dictionary
strategy
A x X r R. B b B D. R S. S
t T C C D. X B. T R. D .
A -gt T T -gt D
0..1
POSS(c1,c2,o)e c1 e.C c2
X
B
0..1
D
A
C
0..1
D
C
R
S
T
A
0..1
class graph
object graph r
R
S
30
Example B1
class dictionary
strategy
A x X r R. B b B D. R S. S
t T C C D. X B. T R. D .
A -gt T T -gt D
POSS(A,T,a1) 1 edge POSS(R,T,r1) 1
edge POSS(S,T,s1) 0 edges
0..1
X
B
0..1
D
A
C
0..1
D
C
R
S
T
a1A
0..1
class graph
object graph r
r1R
s1S
POSS(c1,c2,o)e c1 e.C c2
31
Example B1
class dictionary
strategy
A x X r R. B b B D. R S. S
t T C C D. X B. T R. D .
A -gt T T -gt D
POSS(A,T,a1) 1 edge POSS(R,T,r1) 1
edge POSS(S,T,s1) 0 edges
0..1
X
B
0..1
D
A
C
0..1
object graph slice
D
C
R
S
T
a1A
0..1
class graph
object graph r
r1R
s1S
POSS(c1,c2,o)e c1 e.C c2
32
Example B2
strategy
POSS(A,T,a1) 1 edge POSS(R,T,r1) 1
edge POSS(S,T,s1) 1 edge POSS(T,D,t1) 1
edge POSS(R,D,r2) 1 edge
A -gt T T -gt D
object graph slice
a1A
0..1
D
r1R
X
B
0..1
c1C
s1S
D
A
C
s2S
t1T
0..1
object graph r t
r2R
R
S
T
0..1
c2C
class graph
d2D
POSS(c1,c2,o)e c1 e.C c2
33
Example C
Only node paths shown for space reasons
strategy SG A -gt B B -gt C
Object graph
Strategy s
t
A
A
B
C
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
OG A X R X C OG A X B X C SG A
B C
c2C
BOpt
c
c3C
C
34
Example C1
Only node paths shown for space reasons
strategy SG A -gt S S -gt C
Object graph
early termination
Strategy s
t
A
A
S
C
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
OG A X R X OG A X B X SG A
B CG A X Bopt B X
c2C
BOpt
c
c3C
C
35
Example D
S from BusRoute through Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
NGasPowered
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
DieselPowered
36
Example D1
OG BR BL DP PL P OG BR BL B PL P S BR
B P
Only node paths shown for space reasons
BusList
Route1BusRoute
buses
busStops
BusStopList
Bus15DieselPowered
passengers
CentralSquareBusStop
waiting
PersonList
PersonList
JoanPerson
PaulPerson
SeemaPerson
EricPerson
S from BusRoute through Bus to Person
37
Example D2
OG BR BL OG BR BL S BR
Only node paths shown for space reasons
early termination
BusList
Route1BusRoute
buses
busStops
BusStopList
Bus15DieselPowered
passengers
CentralSquareBusStop
waiting
PersonList
PersonList
JoanPerson
PaulPerson
SeemaPerson
EricPerson
S from BusRoute via NGasPowered to Person
38
Relational Formulation
from c1 bypassing x1,x2, ,xn to c2
From object o of class c1, to get to c2, follow
edges in the set POSS(c1,c2,o)e c1 lt.e.gt
(lt.C.gt) lt c2
POSS abbreviation for following these edges it
is still possible to reach a c2-object for some
c1-object rooted at o.
Delete x1,x2, ,xn and all edges incident with
these nodes from the class graph (assumed to be
different from c1, c2).
39
Example D
S from BusRoute bybassing Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
NGasPowered
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
DieselPowered
40
Example D
S from BusRoute bybassing Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
NGasPowered
BusList
waiting
PersonList
Person
0..
DieselPowered
41
Conclusions
  • Programming language elements are mathematical
    objects having precise mathematical definitions.
  • Exercise in applying an abstract algorithm to
    concrete inputs. Mapping abstract situations to
    concrete situations.
  • Separation of concerns is also useful for
    defining programming language elements
  • separate subgraph selected from
  • how the subgraph is traversed (depth-first etc.)
  • In earlier works meaning of a traversal strategy
    for an object graph
  • was a traversal history
  • now it is a subgraph of the object graph. A
    traversal history can be defined ...
Write a Comment
User Comments (0)
About PowerShow.com