Presentation is loading. Please wait.

Presentation is loading. Please wait.

Gergely Varró, Frederik Deckwerth, Martin Wieber, Andy Schürr 26. April.

Similar presentations


Presentation on theme: "Gergely Varró, Frederik Deckwerth, Martin Wieber, Andy Schürr 26. April."— Presentation transcript:

1 Gergely Varró, Frederik Deckwerth, Martin Wieber, Andy Schürr 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 1 An Algorithm for Generating Model-Sensitive Search Plans for EMF Models

2 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 2 Railway Systems and Safety Requirements Developed in the MOGENTES project [www.mogentes.eu] ro:Route d:defines sp:SwPossw1:Switch o1:observes Model se1:Sensor s1:sensors sw2:Switch o2:observes se2:Sensor i:inPosition s2:sensors [2] [1] Route defines SwPosSwitch observes Sensor sensors inPosition Metamodel {ordered} sw1sw2 sp ro se1se2 Ordered reference navigable in one direction Acknowledgements to Benedek Izsó, István Ráth and Dániel Varró (TU Budapest) for the example.

3 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 3 Ensuring Safety Requirements at Runtime by Pattern Matching Which sensors, switches and positions must be checked for a route? ro:Route d:defines sp:SwPossw1:Switch o1:observes Model se1:Sensor s1:sensors sw2:Switch o2:observes se2:Sensor i:inPosition s2:sensors RO:Route defines SWP:SwPosSW:Switch observes SE:Sensor sensors inPosition Pattern IDX:Integer [2] [1] Route defines SwPosSwitch observes Sensor sensors inPosition Metamodel {ordered} sensors(RO,IDX,SE) observes(SE,SW) inPosition(SW,SWP) defines(RO,SWP) Constraints RO,IDX,SE,SW,SWP Variables Non-binary constraint Pattern matching sw1sw2 sp ro se1se2

4 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 4 Motivation Pattern matcher application scenarios On-the-fly consistency validation Ensuring safety requirements at runtime Application condition checks in rule-based model transformation tools Transformation rules with several elements on the source side Bidirectional model synchronization … Pattern matcher requirements in an industrial context Efficiency Scalability Standard compliance Goal Improve the runtime performance of pattern matching Run the pattern matcher on top of EMF models

5 Search plan: a sequence of operations 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 5 Search Plan Driven Pattern Matching I. ro:Route d:defines sp:SwPossw1:Switch o1:observes Model se1:Sensor s1:sensors sw2:Switch o2:observes se2:Sensor i:inPosition s2:sensors RO:Route defines SWP:SwPosSW:Switch observes SE:Sensor sensors inPosition Pattern IDX:Integer roRO IDX SE SW SWP B F F F F roRO IDX SE SW spSWP B F F F B roRO IDX SE sw1SW spSWP B F F B B roRO 1IDX se1SE sw1SW spSWP B B B B B BB B F F F F [2] [1] Adornment: binding information for all variablesOperation: navigation along a defines edge from a Route to a SwPos Operation adornment: binding precondition RO and SWP must be bound and free, respectively Free variable SWP gets bound by the operation BFFFF sensors(RO,IDX,SE) BFFBFFBBBFFFBBBBBBBF defines(RO,SWP)inPosition(SW,SWP) FB observes(SE,SW) (Initial) partial match Variable RO is Bound (mapped) to ro.Variables IDX, SE, SW and SWP are Free (unmapped). Pattern matcher performs 4 steps (i.e., traverses 4 matches)

6 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 6 Search Plan Driven Pattern Matching II. ro:Route d:defines sp:SwPossw1:Switch o1:observes Model se1:Sensor s1:sensors sw2:Switch o2:observes se2:Sensor i:inPosition s2:sensors RO:Route defines SWP:SwPosSW:Switch observes SE:Sensor sensors inPosition Pattern IDX:Integer roRO IDX SE SW SWP B F F F F roRO 1IDX se1SE SW spSWP B B B F B roRO 1IDX se1SE sw1SW spSWP B B B B B roRO 2IDX se2SE SW spSWP B B B F B roRO 2IDX se2SE sw2SW spSWP B B B B B roRO IDX SE SW spSWP B F F F B [2] [1] BFFFF sensors(RO,IDX,SE) BFFBFFBBBFFFBBBBBB observes(SE,SW) BFBBBFB BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF Pattern matcher performs 6 steps with the second search plan. Backtracking The number of pattern matching steps is influenced by the used search plan. Perform search plan optimization (before pattern matching) to reduce the number of steps (during pattern matching)

7 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 7 Search Plan Optimization Space Each path (from BFFFF to BBBBB ) represents a search plan Which is the best one? Quantitative characterization needed Weights for operations Costs for partial search plans (i.e., path prefixes) Goal: weights and costs characterize the pattern matching traversal process Algorithm needed (search plan generation algorithm) Goal: find the best search plan (w.r.t. the cost) BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) observes(SE,SW) BF

8 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 8 Search Plan Generation Approaches Domain-specific (DS) approaches Operation weights and search plan costs From the metamodel: type and multiplicity information Independent from the model Always the same search plan for all models Model-sensitive (MS) approaches Operation weights and search plan costs From model statistics: number of objects/links of a certain type Different search plans for different models BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) observes(SE,SW) BF

9 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 9 Model-Sensitive Search Plan Generation Approaches [1] Giese, Hildebrandt, Seibel: Improved Flexibility and Scalability by Interpreting Story Diagrams [2] Geiß, Batz, Grund, Hack, Szalkowski: GrGen: A Fast SPO-Based Graph Rewriting Tool [3] Varró, Varró, Friedl: Adaptive Graph Pattern Matching for Model Transformations Using Model-Sensitive Search Plans Binary Cost function Supported constraints Model representation Search plan generation algorithm GrGen [2] VIATRA [3] Fujaba [1] Simple (product)OwnGraph BinarySimple (sum)OwnGraph Current approach BinaryN/AEMF Built-in greedy Arbitrary Complex (pluggable) EMF (pluggable) Dynamic programming

10 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 10 Dynamic Programming Based Search Plan Generation Algorithm Dynamic programming Table is filled out iteratively Columns: number of free variables in the initial adornment (+1) BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) observes(SE,SW) BF FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) BFFFF has 4 free variables

11 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 11 Algorithmic Problems I. Exponential number of adornments (2 5 ) Store only a limited number of adornments in each column Limit User-defined parameter of the algorithm (e.g., k=2 in our example) Trade-off between efficiency and optimality Number of rows defined by k BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) observes(SE,SW) BF FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP)

12 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 12 Algorithmic Problems II. Unnecessary recalculations in case of shared path suffixes Store only the best of those path prefixes that end at the same adornment Adornment check required when inserting into the table BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) observes(SE,SW) BF BFFFB

13 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 13 Algorithmic Problems III. Best search plan Sorted columns in increasing order according to the search plan costs Search plan cost comparison required when inserting into the table BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) observes(SE,SW) BF FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP)

14 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 14 Algorithmic Problems IV. Adornments without outgoing edges Reachability analysis required when inserting into the table Not discussed now BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) observes(SE,SW) BF FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP)

15 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 15 Algorithm Data Structures BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) observes(SE,SW) BF B***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 BFFFF 10 Adornment Applicable operations Operation weights (sorted in an increasing order) Search plan cost Search plan (no operations applied yet) State

16 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 16 Algorithm Initialization BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) observes(SE,SW) BF B***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 BFFFF Initial state goes to the top-left field

17 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 17 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 BFFFF defines(RO,SWP) BFB***F 1 1 BFFFB Iterative process On the columns in decreasing order On the rows in increasing order On the applicable operations in weight increasing order Each iteration creates a new state BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) observes(SE,SW) BF

18 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 18 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BFFFF BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 1 BFFFB 1 inPosition(SW,SWP) FB***FB 1 The new state has 3 free variables BFFFF observes(SE,SW) sensors(RO,IDX,SE) BFF FB BBBFF BFFBBBFFFBBBBBB BBBBF inPosition(SW,SWP) BF defines(RO,SWP) inPosition(SW,SWP) FB BBBFB BFBBB sensors(RO,IDX,SE) BFF BF defines(RO,SWP)inPosition(SW,SWP) FB sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) observes(SE,SW) BF

19 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 19 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 BFFFF 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 1 BFFFB 10 inPosition(SW,SWP) FB***FB 1 sensors(RO,IDX,SE) BFFBFF** 2 2 BBBFF 2 BFB***F 1defines(RO,SWP) observes(SE,SW) BF**BF* 1 BFFFF BBBFF BFFBBBFFFBBF defines(RO,SWP) sensors(RO,IDX,SE) BFF observes(SE,SW) BF defines(RO,SWP) sensors(RO,IDX,SE) BFF inPosition(SW,SWP) FB 2

20 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 20 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BFFFF 10 3 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 1 BFFFB 1 inPosition(SW,SWP) FB***FB 1 2 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BBBFF 2 observes(SE,SW) BF**BF* 1 1

21 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 21 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 1 BFFFB 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BBBFF 2 observes(SE,SW) BF**BF* 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BFFBB 1 observes(SE,SW) FB**FB* 1 inPosition(SW,SWP) FB***FB 1 21 Same adornment? No Better search plan? No

22 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 22 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BBBFF 2 observes(SE,SW) BF**BF* 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BFFBB 1 observes(SE,SW) FB**FB* 1 inPosition(SW,SWP) FB***FB 1 3 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 1 BFFFB 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 3 BBBFB 2 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) FB***FB 1 10

23 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 23 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BBBFF 2 observes(SE,SW) BF**BF* 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BFFBB 1 observes(SE,SW) FB**FB* 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 3 BBBFB 2 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BBBFB 2 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BBBBF 2 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) BF***BF 1/2 0 Same adornment? Yes Better search plan? No

24 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 24 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BBBFF 2 observes(SE,SW) BF**BF* 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BFFBB 1 observes(SE,SW) FB**FB* 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 3 BBBFB 2 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BBBBF 2 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) BF***BF 1/2 BFB***F 1defines(RO,SWP) 3 BFBBB 1 observes(SE,SW) FB**FB* 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BBBBB 2 observes(SE,SW) BB**BB* inPosition(SW,SWP) FB***FB 1 No valid continuation

25 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 25 Algorithm BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BBBFF 2 observes(SE,SW) BF**BF* 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 2 BFFBB 1 observes(SE,SW) FB**FB* 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 3 BBBFB 2 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BBBBF 2 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) BF***BF 1/2 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 4 BBBBB 2 observes(SE,SW) BB**BB* inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 5 BBBBB 2 inPosition(SW,SWP) FB***FB 1 BFB***F 1 sensors(RO,IDX,SE) defines(RO,SWP) BFFBFF** 2 5 BBBBB 2 observes(SE,SW) BF**BF* 1 sensors(RO,IDX,SE) BFFBFF** 2 5 BBBBF 1 observes(SE,SW) BF**BF* 1 inPosition(SW,SWP) BF***BF 1/2 sensors(RO,IDX,SE) BFFBFF** 2 6 BBBBF 2 observes(SE,SW) BF**BF* 1 BFB***F 1defines(RO,SWP) Same adornment? Better search plan? No Yes

26 April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 26 Algorithm BF sensors(RO,IDX,SE) defines(RO,SWP) BFF observes(SE,SW) BB inPosition(SW,SWP) FB B***F 1 BFF** 2 4 BBBBB 2 **BB* ***FB 1 Algorithm returns the search plan in T[0][1]

27 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 27 Measurement Results I. Eager strategy (k=1) suffices in practical cases? Larger k can be better even for small patterns

28 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 28 Measurement Results II. Search plan cost function makes sense Good correlation between search plan cost and pattern matching steps

29 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 29 Measurement Results III. Model-sensitive (MS) search plans outperform domain-specific (DS) ones On all test models By nearly 400 steps in average When the pattern has many edges with arbitrary multiplicity

30 26. April 2014 | Real-Time Systems Lab | Prof. Dr. Andy Schürr | Dr. Gergely Varró | 30 Summary Pattern matcher Improve runtime performance: reduced number of PM steps Fully implemented Flexible and embeddable into different tools Model-sensitive search plans Operation weights from the model First such solution for EMF Search plan generation algorithm General n-ary operations Complex cost functions (not only addition/multiplication) Parameterization: trade-off between efficiency and optimality Usable without the pattern matcher Complex attribute manipulation in bidirectional transformation


Download ppt "Gergely Varró, Frederik Deckwerth, Martin Wieber, Andy Schürr 26. April."

Similar presentations


Ads by Google