Download presentation
Presentation is loading. Please wait.
Published byElaine Bryan Modified over 9 years ago
1
Budapest University of Technology and Economics Adaptive Graph Pattern Matching for Model Transformations using Model-sensitive Search Plans Gergely Varró gervarro@cs.bme.hu Dániel Varró varro@mit.bme.hu Katalin Friedl friedl@cs.bme.hu
2
2 Budapest University of Technology and Economics Talk overview Introduction & GT PM techniques Approach overview Model-sensitive search plans Adaptive PM
3
3 Budapest University of Technology and Economics Introduction Common problem to be solved by model transformation tools: –Efficient query and manipulation of complex graph-based patterns One possible solution: –Graph transformation
4
4 Budapest University of Technology and Economics Metamodeling Attribute CF Ref EO UF ** 1 ModelElement NamespaceFeature Column TableSchema ClassPackage UniqueKey PKey 1 ClassAssociation At most one Inheritance Instance model CWM Metamodel Slot r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO Arbitrary Object Multiplicity constraint Link
5
5 Budapest University of Technology and Economics Graph transformation rule s:Schema r1:Refrn:Ref tn:Table p:Package Left-Hand Side Right-Hand Side c:Class eo1:EO s:Schema r1:Refr2:Ref t:Table p:Package c:Class eo1:EO tpk:PKeytid:Column eo2:EO eo3:EO cf:CF uf:UF ClassRule Negative applicationc ondition LHSRHS
6
6 Budapest University of Technology and Economics Pattern matching phase LHSRHS s:Schema r1:Refrn:Ref tn:Table p:Packagec:Class eo1:EO s:Schema r1:Refr2:Ref t:Table p:Package c:Class eo1:EO tpk:PKeytid:Column eo2:EO eo3:EO cf:CF uf:UF ClassRule r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO
7
7 Budapest University of Technology and Economics Updating phase id2:Column t2:Table uf:UF LHSRHS s:Schema r1:Refrn:Ref tn:Table p:Packagec:Class eo1:EO s:Schema r1:Refr2:Ref t:Table p:Package c:Class eo1:EO tpk:PKeytid:Column eo2:EO eo3:EO cf:CF uf:UF ClassRule r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO pk2:PKey eo6:EO eo5:EO eo4:EO r2:Ref
8
8 Budapest University of Technology and Economics Talk overview Introduction & GT PM techniques Approach overview Model-sensitive search plans Adaptive PM
9
9 Budapest University of Technology and Economics Practical consideration Most critical step: pattern matching Simplification: without NAC s:Schema r1:Refrn:Ref tn:Table p:Package c:Class eo1:EO ClassRule LHS s:Schema r1:Refr2:Ref t:Table p:Package c:Class eo1:EO tpk:PKeytid:Column eo2:EO eo3:EO cf:CF uf:UF RHS
10
10 Budapest University of Technology and Economics Pattern matching techniques Style –Interpreted: AGG, VIATRA underlying PM engine –Compiled: Fujaba, GReAT, PROGRES directly executed as a C or Java code (no PM engine) Base algorithm –Constraint satisfaction: AGG, VIATRA variables + constraints –Local search: Fujaba, GReAT, PROGRES step-by-step extension of the matching
11
11 Budapest University of Technology and Economics Traditional approach I. Pattern matching strategy –defined in design/compile time –single search plan –based on multiplicity and type restrictions e.g. at-most-one multiplicity precedes arbirtrary multiplicity Fixed implementation –nested-loops –in Java, C,... s:Schema r1:Ref p:Package c:Class eo1:EO Rule LHS Design/Compile time c p s 1 2 3 Search plan Search sequence frequently used & efficient solution order of traversal in the search plan multiplicity & type restrictions
12
12 Budapest University of Technology and Economics Traditional approach II. s:Schema r1:Ref p:Package c:Class eo1:EO Rule LHS Design/Compile time Execution time Search space tree c p s 1 2 3 r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO c p s Model Search plan Search sequence Search space tree (SST) –Search space traversed according to a specific search plan –Contains all decisions made during pattern matching
13
13 Budapest University of Technology and Economics Talk overview Introduction & GT PM techniques Approach overview Model-sensitive search plans Adaptive PM
14
14 Budapest University of Technology and Economics Model-sensitive search plans Rule Design/Compile time Search plan 1 Search plan 2 Search plan 3 Typical model 1 Typical model 2 Typical model 3
15
15 Budapest University of Technology and Economics Adaptive PM approach Rule Design/Compile time Execution time Current model Search plan 1 Search plan 2 Search plan 3 Typical model 1 Typical model 2 Typical model 3 Strategy selection Search space tree
16
16 Budapest University of Technology and Economics Talk overview Introduction & GT PM techniques Approach overview Model-sensitive search plans Adaptive PM
17
17 Budapest University of Technology and Economics Instance model with statistics Statistical data –based on rules –collected from instance models Example: s:Schema r1:Ref p:Package c:Class eo1:EO Rule LHS r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO Typical model 1 # Schema Package Class EO(Package,Class) Ref(Package,Schema) 1 3 3 3 1 Schema Inheritance Package
18
18 Budapest University of Technology and Economics Search graph s:Schema r1:Ref p:Package c:Class eo1:EO Rule LHS cps Search graph Edge from the starting node to another node –Iteration over all objects in the model of the corresponding type Edge between non-starting nodes –When source pattern node is already matched –Navigation along the corresponding pattern edge towards the unmatched (target) pattern node Starting node
19
19 Budapest University of Technology and Economics Weighted search graph cps Search graph 1 cps 1 0.33 1 1 3 3 1 r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO Typical model 1 Schema 1 Package 3 Class 3 EO(Package,Class) 3 Ref(Package,Schema) 1 #Ref(Package,Schema)/#Package = 1/3 = 0.33#Ref(Package,Schema)/#Schema = 1/1 = 1 Edge weight –average branching factor of a possible SST at the level, when the given edge is selected for navigation
20
20 Budapest University of Technology and Economics Search plan Weighted search graph 1 cps 1 0.33 1 1 3 3 1 cps 1 1 1 3 3 1 Search tree 1 cps 1 0.331 1 3 3 1 23 1 Search plan 1 Algorithm 1 Algorithm 2
21
21 Budapest University of Technology and Economics Search plan cps 1 0.331 1 3 3 1 23 1 Search plan 1 Estimated search space tree s p c 1 1 1 r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO Typical model 1 w(P) =w(P) = 1w(P) = 1 + 1*1w(P) = 1 + 1*1 + 1*1*1 = 3 Estimated number of traversed nodes in SST Properties of the minimal search plan –SST optimal in size –first-fail principle
22
22 Budapest University of Technology and Economics Algorithm 1 Given: –Search graph Goal: –Low cost search tree Chu-Liu / Edmonds algorithm –Relatively simple greedy algorithm –Spanning tree in a weighted directed graph –Optimality guaranteed, if cost function is the sum of edge weights ! + Fast
23
23 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm I. Discard edges entering the starting node Weighted search graph 1 cps 1 0.33 1 1 3 3 1
24
24 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm II. For each other node, select the incoming edge with the smallest weight. Let the selected n-1 edges be the set S. Weighted search graph 1 cps 1 0.33 1 1 3 3 1
25
25 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm III. For each cycle formed, contract the nodes of the cycle into a pseudo-node k, and Modify the weight of each edge entering node j of the cycle from some node i outside the cycle. Weighted search graph 1 cps 1 0.33 1 1 3 3 1 M = min(1,0.33) = 0.33 c(i,k) = c(i,j) – [c(x(j),j)-M] 0.67 2.67 1
26
26 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm IV. For each pseudo-node, select the entering edge, which has the smallest weight. Go to the previous step with the contracted graph. Weighted search graph 1 cps 1 0.33 0.67 1 3 2.67 1 1
27
27 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm V. For each cycle formed, contract the nodes of the cycle into a pseudo-node k, and Modify the weight of each edge entering node j of the cycle from some node i outside the cycle. Weighted search graph 1 c 0.67 1 3 2.67 1 1 M = min(1,0.67) = 0.67 c(i,k) = c(i,j) – [c(x(j),j)-M]
28
28 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm VI. For each pseudo-node, select the entering edge, which has the smallest weight. Go to the previous step with the contracted graph. Weighted search graph 1 c 0.67 1 2.67 1
29
29 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm VII. No cycles Restore the consistency of edges in contracted nodes. Weighted search graph 1 c 0.67 1 3 2.671
30
30 Budapest University of Technology and Economics Chu-Liu / Edmonds algorithm VIII. Restore the consistency of edges in contracted nodes. Weighted search graph 1 cps 1 0.33 1 1 3 3 1 Search tree 1
31
31 Budapest University of Technology and Economics Algorithm 2 Set the label of the smallest tree edge leaving S to the value of the counter. Increment the counter, and add the target node of the selected edge to S. Repeat these steps until S contains all nodes of the graph. cps 1 0.33 1 1 3 3 1 Search tree 1 counter = 1, S = {0}counter = 2, S = {0,s}counter = 3, S = {0,s,p}counter = 4, S = {0,s,p,c} 32 1 Search plan 1 Simple greedy algorithm
32
32 Budapest University of Technology and Economics Additional notes NACs –general rule: checked after a matching found –simple checks (e.g. cardinality check) when shared node is processed during the traversal of LHS –NAC pattern ~ LHS pattern no problem Completion of partially matched patterns –several starting nodes in Algorithms 1 and 2 –search tree forest rooted at starting nodes –all other nodes are reachable on tree edges
33
33 Budapest University of Technology and Economics Model-sensitive search plan generation r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO Typical model 1 cps 1 0.331 1 3 3 1 1 32 cps 1 0.5 1 0.25 1 4 2 1 32 Search plan 2 Search plan 1 Same as the search plan of the traditional approach r2:Ref s2:Schema p1:Package p2:Package eo1:EO Typical model 2 s1:Schema r1:Ref c1:Class
34
34 Budapest University of Technology and Economics Talk overview Introduction & GT PM techniques Approach overview Model-sensitive search plans Adaptive PM
35
35 Budapest University of Technology and Economics Adaptive PM implementation cost() : –calculates the cost of the search plan based on the current instance model –invoked on every strategies before each pattern matching match() : –pattern matching implementation –invoked only on the strategy with the smallest cost Strategy Strategy FromModel1 Strategy FromModel2 cost() match()
36
36 Budapest University of Technology and Economics Runtime behaviour I. cps 1 0.331 1 3 3 1 1 32 cps 1 1 1 3 3 1 1 32 Search plan 2Search plan 1 Search space tree w(P1) = 3w(P2) = 7 r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO Typical model 1 s p c c p s
37
37 Budapest University of Technology and Economics Runtime behaviour II. cps 1 0.51 0.25 1 4 2 1 32 cps 1 0.5 1 0.25 1 4 2 1 32 Search plan 2Search plan 1 r2:Ref s2:Schema p1:Package p2:Package eo1:EO Typical model 2 s1:Schema r1:Ref c1:Class Search space tree s p c c p s w(P1) = 4.5w(P2) = 2.5
38
38 Budapest University of Technology and Economics Runtime behaviour III. cps 0 01 1 3 3 0 1 32 cps 0 0 1 1 3 3 0 1 32 Search plan 2Search plan 1 Search space tree w(P1) = 0w(P2) = 6 eo1:EO c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO Model 3 s p c c p s Immediate PM failure detection
39
39 Budapest University of Technology and Economics Pros and contras Resource related + time: smaller execution time during pattern matching –time: extra computation for cost calculation –storage: small amount of additional (statistical) data Application area related + when only one matching is needed + first-fail principle early detection of PM failure + manually created (or tool provided) search plans can be used –search plan generation algorithm: not necessarily optimal –estimated and executed SST may differ + estimated SST better for the worst case
40
40 Budapest University of Technology and Economics Future work Topics not discussed –Java implementation of search plans Todo list –Quantitative measurements for assessing the performance of the approach –Algorithm for finding an optimal search plan Thanks for your kind attention. Questions, comments, remarks?
41
41 Budapest University of Technology and Economics Search graph s:Schema r1:Ref p:Package c:Class eo1:EO Rule LHS cps 1 11 1 1 1 1 1 32 cps 1 11 1 1 1 1 cps 1 11 1 1 1 1
42
42 Budapest University of Technology and Economics Instance model r1:Ref eo1:EO s2:Schema c1:Class p1:Package p2:Package c2:Class eo2:EO c3:Class eo3:EO
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.