Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans
-
Upload
thor-anderson -
Category
Documents
-
view
19 -
download
1
description
Transcript of Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans
![Page 1: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/1.jpg)
Budapest University of Technology and Economics
Adaptive Graph Pattern Matching for Model Transformations using
Model-sensitive Search Plans
Gergely Varró [email protected]ániel Varró [email protected]
Katalin Friedl [email protected]
![Page 2: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/2.jpg)
2Budapest University of Technology and Economics
Talk overview
Introduction & GT
PM techniques
Approach overview
Model-sensitive search plans
Adaptive PM
![Page 3: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/3.jpg)
3Budapest 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
![Page 4: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/4.jpg)
4Budapest University of Technology and Economics
Metamodeling
Attribute
CF
Ref
EO
UF**
1ModelElement
NamespaceFeature
Column
Table Schema
Class Package
UniqueKey
PKey
1ClassAssociation
At most one
Inheritance
Instance model
CWM Metamodel
Slot
r1:Ref
eo1:EO
s2:Schema
c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
Arbitrary
ObjectMultiplicity constraint
Link
![Page 5: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/5.jpg)
5Budapest University of Technology and Economics
Graph transformation rule
s:Schema
r1:Ref rn:Ref
tn:Table
p:Package
Left-HandSide
Right-HandSide
c:Classeo1:EO
s:Schema
r1:Ref r2:Ref
t:Table
p:Package c:Classeo1:EO
tpk:PKey tid:Column
eo2:EO
eo3:EO cf:CF
uf:UFClassRule
Negative applicationc
ondition
LHS RHS
![Page 6: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/6.jpg)
6Budapest University of Technology and Economics
Pattern matching phase
LHS RHS
s:Schema
r1:Ref rn:Ref
tn:Table
p:Package c:Classeo1:EO
s:Schema
r1:Ref r2:Ref
t:Table
p:Package c:Classeo1:EO
tpk:PKey tid:Column
eo2:EO
eo3:EO cf:CF
uf:UFClassRule
r1:Ref
eo1:EO
s2:Schema
c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
![Page 7: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/7.jpg)
7Budapest University of Technology and Economics
Updating phase
id2:Column
t2:Table
uf:UF
LHS RHS
s:Schema
r1:Ref rn:Ref
tn:Table
p:Package c:Classeo1:EO
s:Schema
r1:Ref r2:Ref
t:Table
p:Package c:Classeo1:EO
tpk:PKey tid:Column
eo2:EO
eo3:EO cf:CF
uf:UFClassRule
r1:Ref
eo1:EO
s2:Schema
c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
pk2:PKey
eo6:EO
eo5:EOeo4:EO
r2:Ref
![Page 8: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/8.jpg)
8Budapest University of Technology and Economics
Talk overview
Introduction & GT
PM techniques
Approach overview
Model-sensitive search plans
Adaptive PM
![Page 9: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/9.jpg)
9Budapest University of Technology and Economics
Practical consideration
• Most critical step: pattern matching
• Simplification: without NAC
s:Schema
r1:Ref rn:Ref
tn:Table
p:Package c:Classeo1:EO
ClassRuleLHS
s:Schema
r1:Ref r2:Ref
t:Table
p:Package c:Classeo1:EO
tpk:PKey tid:Column
eo2:EO
eo3:EOcf:CF
uf:UF
RHS
![Page 10: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/10.jpg)
10Budapest 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
![Page 11: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/11.jpg)
11Budapest 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:Classeo1:EO
RuleLHS
Design/Compile time
c
p
s
1
2
3
Search plan
Search sequencefrequently used & efficient solution
order of traversal in the search plan
multiplicity & type restrictions
![Page 12: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/12.jpg)
12Budapest University of Technology and Economics
Traditional approach II.
s:Schema
r1:Ref
p:Package c:Classeo1:EO
RuleLHS
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:Classeo2:EO
c3:Classeo3: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
![Page 13: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/13.jpg)
13Budapest University of Technology and Economics
Talk overview
Introduction & GT
PM techniques
Approach overview
Model-sensitive search plans
Adaptive PM
![Page 14: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/14.jpg)
14Budapest University of Technology and Economics
Model-sensitive search plans
Rule
Design/Compile time
Search plan 1
Search plan 2
Search plan 3Typical model 1
Typical model 2
Typical model 3
![Page 15: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/15.jpg)
15Budapest University of Technology and Economics
Adaptive PM approach
Rule
Design/Compile time
Execution time
Current model
Search plan 1
Search plan 2
Search plan 3Typical model 1
Typical model 2
Typical model 3
Strategyselection
Search space tree
![Page 16: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/16.jpg)
16Budapest University of Technology and Economics
Talk overview
Introduction & GT
PM techniques
Approach overview
Model-sensitive search plans
Adaptive PM
![Page 17: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/17.jpg)
17Budapest 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:Classeo1:EO
RuleLHS
r1:Ref
eo1:EO
s2:Schema
c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
Typical model 1
#
Schema
Package
Class
EO(Package,Class)
Ref(Package,Schema)
1
3
3
3
1
Schema
InheritancePackage
![Page 18: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/18.jpg)
18Budapest University of Technology and Economics
Search graph
s:Schema
r1:Ref
p:Package c:Classeo1:EO
RuleLHS
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
![Page 19: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/19.jpg)
19Budapest University of Technology and Economics
Weighted search graph
cps
Search graph 1
cps 1
0.33 1
1
33
1
r1:Ref
eo1:EO
s2:Schema
c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
Typical model 1
Schema 1Package 3Class 3EO(Package,Class) 3Ref(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
![Page 20: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/20.jpg)
20Budapest University of Technology and Economics
Search planWeighted search graph 1
cps 1
0.33 1
1
33
1
cps 1
0.33 1
1
33
1
Search tree 1
cps 1
0.33 1
1
33
1
2 3
1
Search plan 1
Algorithm 1
Algorithm 2
![Page 21: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/21.jpg)
21Budapest University of Technology and Economics
Search plan
cps 1
0.33 1
1
33
1
2 3
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:Classeo2:EO
c3:Classeo3: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
![Page 22: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/22.jpg)
22Budapest 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
![Page 23: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/23.jpg)
23Budapest 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
33
1
![Page 24: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/24.jpg)
24Budapest 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
33
1
![Page 25: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/25.jpg)
25Budapest 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
33
1
M = min(1,0.33) = 0.33
c(i,k) = c(i,j) – [c(x(j),j)-M]0.67
2.671
![Page 26: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/26.jpg)
26Budapest 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
32.67
11
![Page 27: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/27.jpg)
27Budapest 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
32.672.671
2.671
M = min(1,0.67) = 0.67
c(i,k) = c(i,j) – [c(x(j),j)-M]
![Page 28: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/28.jpg)
28Budapest 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.672.671
![Page 29: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/29.jpg)
29Budapest 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
32.671
2.67
![Page 30: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/30.jpg)
30Budapest 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
33
1
Search tree 1
![Page 31: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/31.jpg)
31Budapest 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
33
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
![Page 32: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/32.jpg)
32Budapest 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
![Page 33: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/33.jpg)
33Budapest University of Technology and Economics
Model-sensitive search plan generation
r1:Ref
eo1:EO
s2:Schema
c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
Typical model 1
cps 1
0.33 1
1
33
11
32 cps 1
0.5 1
0.25
14
21
3 2
Search plan 2Search plan 1
Same as the search plan of the traditional
approach
r2:Refs2:Schema
p1:Package
p2:Package
eo1:EOTypical model 2
s1:Schemar1:Ref
c1:Class
![Page 34: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/34.jpg)
34Budapest University of Technology and Economics
Talk overview
Introduction & GT
PM techniques
Approach overview
Model-sensitive search plans
Adaptive PM
![Page 35: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/35.jpg)
35Budapest 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
StrategyFromModel1
StrategyFromModel2
cost()match()
![Page 36: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/36.jpg)
36Budapest University of Technology and Economics
Runtime behaviour I.cps 1
0.33 1
1
33
11
32 cps 1
0.33 1
1
33
11
3 2
Search plan 2Search plan 1
Search space tree Search space tree
w(P1) = 3 w(P2) = 7
r1:Ref
eo1:EO
s2:Schema
c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
Typical model 1s
p
c
c
p
s
![Page 37: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/37.jpg)
37Budapest University of Technology and Economics
Runtime behaviour II.cps 1
0.5 1
0.25
14
21
32 cps 1
0.5 1
0.25
14
21
3 2
Search plan 2Search plan 1
r2:Refs2:Schema
p1:Package
p2:Package
eo1:EOTypical model 2
s1:Schemar1:Ref
c1:Class
Search space tree
s
p
c
Search space tree
c
p
s
w(P1) = 4.5 w(P2) = 2.5
![Page 38: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/38.jpg)
38Budapest University of Technology and Economics
Runtime behaviour III.cps 0
0 1
1
33
01
32 cps 0
0 1
1
33
01
3 2
Search plan 2Search plan 1
Search space tree Search space tree
w(P1) = 0 w(P2) = 6
eo1:EO c1:Class
p1:Package
p2:Package
c2:Classeo2:EO
c3:Classeo3:EO
Model 3s
p
c
c
p
s
Immediate PM failure detection
![Page 39: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/39.jpg)
39Budapest 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
![Page 40: Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans](https://reader030.fdocuments.us/reader030/viewer/2022013011/568131eb550346895d984cb2/html5/thumbnails/40.jpg)
40Budapest 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?