1 / 40

Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans

Adaptive Graph Pattern Ma t ching 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. Talk o verview. Introduction & GT. Approach overview. PM techniques.

Télécharger la présentation

Adaptive Graph Pattern Ma t ching for Model Transformations using Model -sensitive Search Plans

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Adaptive Graph Pattern Matching for Model Transformations using Model-sensitive Search Plans Gergely Varrógervarro@cs.bme.huDániel Varró varro@mit.bme.hu Katalin Friedl friedl@cs.bme.hu

  2. Talk overview Introduction & GT Approach overview PM techniques Model-sensitive search plans Adaptive PM

  3. 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. p2:Package c3:Class eo3:EO r1:Ref s2:Schema c1:Class eo1:EO p1:Package c2:Class eo2:EO Metamodeling Association Class 1 Ref ModelElement 1 EO At most one UF UniqueKey Feature Namespace Attribute * * PKey Column CF Arbitrary Class Package Inheritance Multiplicity constraint Link Object Table Schema CWM Metamodel Instance model Slot

  5. Graph transformation rule eo1:EO eo1:EO c:Class c:Class p:Package p:Package r1:Ref rn:Ref r1:Ref r2:Ref eo2:EO t:Table s:Schema tn:Table s:Schema eo3:EO cf:CF uf:UF tpk:PKey tid:Column ClassRule LHS RHS Negative applicationcondition Left-HandSide Right-HandSide

  6. Pattern matching phase eo1:EO eo1:EO p:Package c:Class c:Class p:Package r1:Ref rn:Ref r1:Ref r2:Ref eo2:EO t:Table s:Schema tn:Table s:Schema eo3:EO cf:CF uf:UF tpk:PKey tid:Column ClassRule LHS RHS p2:Package c3:Class eo3:EO r1:Ref s2:Schema c1:Class eo1:EO p1:Package c2:Class eo2:EO

  7. Updating phase eo1:EO eo1:EO p:Package c:Class c:Class p:Package r1:Ref rn:Ref r1:Ref r2:Ref eo2:EO t:Table s:Schema tn:Table s:Schema eo3:EO cf:CF uf:UF tpk:PKey tid:Column ClassRule LHS RHS p2:Package c3:Class id2:Column eo3:EO r1:Ref r2:Ref eo6:EO uf:UF t2:Table pk2:PKey s2:Schema eo5:EO eo4:EO c1:Class eo1:EO p1:Package c2:Class eo2:EO

  8. Talk overview Introduction & GT Approach overview PM techniques Model-sensitive search plans Adaptive PM

  9. eo1:EO c:Class p:Package r1:Ref r2:Ref eo2:EO t:Table s:Schema eo3:EO cf:CF uf:UF tpk:PKey tid:Column RHS Practical consideration eo1:EO c:Class • Most critical step: pattern matching • Simplification: without NAC p:Package r1:Ref rn:Ref tn:Table s:Schema LHS ClassRule

  10. 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. Traditional approach I. multiplicity & type restrictions eo1:EO 1 Search plan c:Class • 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, ... p:Package c 2 r1:Ref p 3 frequently used & efficient solution s:Schema Rule Search sequence s LHS Design/Compile time order of traversal in the search plan

  12. Traditional approach II. eo1:EO 1 Search plan c:Class • Search space tree (SST) • Search space traversed according to a specific search plan • Contains all decisions made during pattern matching p:Package c 2 r1:Ref p 3 s:Schema Rule Search sequence s LHS Design/Compile time Execution time p2:Package c3:Class eo3:EO c r1:Ref Model p s2:Schema c1:Class s eo1:EO p1:Package c2:Class Search space tree eo2:EO

  13. Talk overview Introduction & GT Approach overview PM techniques Model-sensitive search plans Adaptive PM

  14. Model-sensitive search plans Search plan 1 Rule Search plan 2 Search plan 3 Typical model 1 Typical model 2 Typical model 3 Design/Compile time

  15. Adaptive PM approach Search plan 1 Rule Search plan 2 Search plan 3 Typical model 1 Typical model 2 Typical model 3 Design/Compile time Execution time Strategyselection Current model Search space tree

  16. Talk overview Introduction & GT Approach overview PM techniques Model-sensitive search plans Adaptive PM

  17. Statistical data based on rules collected from instance models Example: Inheritance Package p2:Package c3:Class eo3:EO r1:Ref Typical model 1 Schema s2:Schema c1:Class eo1:EO p1:Package c2:Class eo2:EO Instance model with statistics eo1:EO c:Class p:Package r1:Ref s:Schema Rule LHS 1 3 3 3 1

  18. Search graph eo1:EO • 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 c:Class s p c p:Package r1:Ref s:Schema Rule LHS Search graph Starting node

  19. Weighted search graph p2:Package c3:Class • Edge weight • average branching factor of a possible SST at the level, when the given edge is selected for navigation s p c eo3:EO r1:Ref Typical model 1 s2:Schema c1:Class #Ref(Package,Schema)/#Package = 1/3 = 0.33 #Ref(Package,Schema)/#Schema = 1/1 = 1 eo1:EO p1:Package c2:Class Search graph 1 eo2:EO 1 1 s p c 0.33 1 3 1 3

  20. Search tree 1 1 1 s p c 0.33 1 3 1 3 Search plan 1 1 1 s p c 2 3 0.33 1 3 1 3 1 Search plan Weighted search graph 1 1 1 s p c Algorithm 1 0.33 1 3 1 3 Algorithm 2

  21. Estimated number of traversed nodes in SST Properties of the minimal search plan SST optimal in size first-fail principle Search plan p2:Package c3:Class eo3:EO r1:Ref Typical model 1 s2:Schema c1:Class eo1:EO p1:Package c2:Class eo2:EO w(P) = 1 w(P) = 1 + 1*1 w(P) = 1 + 1*1 + 1*1*1 = 3 w(P) = Search plan 1 1 1 s p c 1 2 3 s 0.33 1 1 p 3 1 Estimated search space tree 1 3 c 1

  22. 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. Chu-Liu / Edmonds algorithm I. Weighted search graph 1 • Discard edges entering the starting node 1 1 s p c 0.33 1 3 1 3

  24. Chu-Liu / Edmonds algorithm II. Weighted search graph 1 • For each other node, select the incoming edge with the smallest weight. Let the selected n-1 edges be the set S. 1 1 s p c 0.33 1 3 1 3

  25. Chu-Liu / Edmonds algorithm III. Weighted search graph 1 • 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. 1 1 M = min(1,0.33) = 0.33 s p c 0.33 0.67 1 c(i,k) = c(i,j) – [c(x(j),j)-M] 2.67 3 1 1 3

  26. Chu-Liu / Edmonds algorithm IV. Weighted search graph 1 • For each pseudo-node, select the entering edge, which has the smallest weight. • Go to the previous step with the contracted graph. 1 1 s p c 0.33 0.67 1 2.67 1 3

  27. Chu-Liu / Edmonds algorithm V. Weighted search graph 1 • 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. 1 M = min(1,0.67) = 0.67 c 0.67 c(i,k) = c(i,j) – [c(x(j),j)-M] 1 1 2.67 2.67 2.67 3

  28. Chu-Liu / Edmonds algorithm VI. Weighted search graph 1 • For each pseudo-node, select the entering edge, which has the smallest weight. • Go to the previous step with the contracted graph. 1 c 0.67 1 2.67 2.67

  29. Chu-Liu / Edmonds algorithm VII. Weighted search graph 1 • No cycles • Restore the consistency of edges in contracted nodes. 1 c 0.67 1 2.67 3 2.67

  30. Chu-Liu / Edmonds algorithm VIII. Weighted search graph 1 Search tree 1 • Restore the consistency of edges in contracted nodes. 1 1 s p c 0.33 1 3 1 3

  31. Algorithm 2 Search tree 1 Search plan 1 • 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. Simple greedy algorithm 1 1 s p c 2 3 0.33 1 counter = 4, S = {0,s,p,c} counter = 1, S = {0} counter = 2, S = {0,s} counter = 3, S = {0,s,p} 3 1 3 1

  32. 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. p2:Package s2:Schema r2:Ref eo1:EO Typical model 2 c1:Class r1:Ref p1:Package s1:Schema Search plan 2 1 0.25 s p c 0.5 1 3 2 4 2 1 1 Model-sensitive search plan generation p2:Package c3:Class eo3:EO r1:Ref Typical model 1 s2:Schema c1:Class eo1:EO p1:Package c2:Class eo2:EO Search plan 1 1 1 s p c 2 3 0.33 1 Same as the search plan of the traditional approach 3 1 3 1

  34. Talk overview Introduction & GT Approach overview PM techniques Model-sensitive search plans Adaptive PM

  35. Adaptive PM implementation Strategy • 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 cost()match() StrategyFromModel1 StrategyFromModel2

  36. p2:Package c3:Class eo3:EO r1:Ref Typical model 1 s2:Schema c1:Class eo1:EO p1:Package c2:Class eo2:EO Runtime behaviour I. 1 1 1 1 s p c s p c 2 3 0.33 0.33 1 1 3 2 3 3 1 3 1 3 1 1 Search plan 1 Search plan 2 w(P1) = 3 w(P2) = 7 s c p p c s Search space tree Search space tree

  37. p2:Package s2:Schema r2:Ref eo1:EO Typical model 2 c1:Class r1:Ref p1:Package s1:Schema Runtime behaviour II. 1 0.25 1 0.25 s p c s p c 2 3 0.5 0.5 1 1 3 2 4 4 2 1 2 1 1 1 Search plan 1 Search plan 2 w(P1) = 4.5 w(P2) = 2.5 s c p p c s Search space tree Search space tree

  38. Runtime behaviour III. 0 1 0 1 s p c s p c 2 3 0 0 1 1 3 2 3 3 0 3 0 3 1 1 Immediate PM failure detection Search plan 1 Search plan 2 w(P1) = 0 w(P2) = 6 p2:Package c3:Class eo3:EO s c Model 3 p p c1:Class c s eo1:EO p1:Package c2:Class Search space tree Search space tree eo2:EO

  39. 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. 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?

More Related