Download presentation
Presentation is loading. Please wait.
1
N-Way Model Merging CSC2125 Project
Julia Rubin December 19, 2012
2
Model merging is used to:
Reconcile complimentary views of different stakeholders
3
Model merging is used to:
Reconcile complimentary views of different stakeholders Unite changes made in distinct branches of an SCM system
4
Model merging is used to:
Reconcile complimentary views of different stakeholders Unite changes made in distinct branches of an SCM system Combine distinct program variants into a single-copy product line representation
5
Consists of three steps:
Compare – a heuristic that calculates the similarity degree for input elements Compare x M1 y z M2 ? ?
6
Consists of three steps:
Compare – a heuristic that calculates the similarity degree for input elements Match – a heuristic that decides which elements are similar, based on the results of compare Match x M1 y z M2
7
Consists of three steps:
Compare – a heuristic that calculates the similarity degree for input elements Match – a heuristic that decides which elements are similar, based on the results of compare Merge – an algorithm that combines matched elements in a prescribed way Union-merge, agreement-based, annotative, … Merge M1+M2 xy z
8
Merging is extensively studied
UML class diagram UML state machines Matlab/Simulink models Verilog … Existing works focus on two input models!
9
What if we want to compose n inputs?
10
Do it in a pair-wise manner, one by one!
What if we want to compose n inputs? Do it in a pair-wise manner, one by one!
11
Example 0.66 M2 M1 M3 Square Square position:point position:point
center:point Square Square position:point width:int Square center:point width:int Circle position:point radius:int M3
12
Example 0.66 M2 M1 position:point center:point Square Square position:point width:int Elements of a pair share one attribute and have one proprietary attribute each Square center:point width:int Circle position:point radius:int M3
13
Example 0.66 M2 M1 0.66 0.66 0.66 0.66 M3 Square Square position:point
center:point Square Square position:point width:int 0.66 0.66 0.66 0.66 Square center:point width:int Circle position:point radius:int M3
14
Pair-wise similar (no matter how we define compare)
Example 0.66 M2 M1 position:point center:point Square Square position:point width:int Pair-wise similar (no matter how we define compare) 0.66 0.66 0.66 0.66 Square center:point width:int Circle position:point radius:int M3
15
Example 0.66 M2 M1 0.66 0.66 0.66 0.66 M3 Square Square position:point
center:point Square Square position:point width:int 0.66 0.66 0.66 0.66 Square center:point width:int Circle position:point radius:int M3
16
Example: the first merge
M1+M3 M2 Square [M3] center:point width:int Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point width:int
17
Example: the first merge
M1+M3 M2 Square [M3] center:point width:int Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point width:int 0.62 0.66
18
Example: the first merge
M1+M3 M2 Square [M3] center:point width:int Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point width:int 0.62 0.66
19
Example: the second merge
M1+ M2 + M3 Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point [M2] center:point [M3] width:int [M2,M3]
20
Example: the second merge
M1+ M2 + M3 Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point [M2] center:point [M3] width:int [M2,M3] Circle position:point radius:int Square center:point width:int M3 M2 M1
21
Example: the second merge
M1+ M2 + M3 Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point [M2] center:point [M3] width:int [M2,M3] Circle position:point radius:int Square center:point width:int M3 M2 M1 “Outlier”
22
Example: the second merge
M1+ M2 + M3 Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point [M2] center:point [M3] width:int [M2,M3] position:point center:point Square Square position:point width:int M1 M2 Square center:point width:int Circle position:point radius:int M3
23
Example: the second merge
M1+ M2 + M3 Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point [M2] center:point [M3] width:int [M2,M3] Circle [M3] position:point radius:int Square position:point [M1,M2] center:point [M1,M3] width:int [M2,M3] position:point center:point Square Square position:point width:int M1 M2 Square center:point width:int Circle position:point radius:int M3
24
Example: the second merge
M1+ M2 + M3 Circle [M3] position:point radius:int Square position:point [M1,M2] center:point [M1,M3] width:int [M2,M3] Taking the global view is better Square/Circle position:point [M1, M3] center:point [M1] radius:int [M3] Square position:point [M2] center:point [M3] width:int [M2,M3]
25
Maybe some “smart” heuristic on the order of merging models?
position:point center:point Square Square position:point width:int M1 M2 Square center:point width:int Circle position:point radius:int M3
26
Maybe some “smart” heuristic on the order of merging models?
Selecting M1 and M1 first would eliminate the problem position:point center:point Square Square position:point width:int M1 M2 Square center:point width:int Circle position:point radius:int M3
27
Maybe some “smart” heuristic on the order of merging models?
Selecting M1 and M1 first would eliminate the problem position:point center:point Square Square position:point width:int Does not work in the general case M1 M2 Square center:point width:int Circle position:point radius:int M3
28
Earlier Example – an Abstract Form
Circle position:point radius:int Square center:point width:int B C A D M3
29
Earlier Example M1 M2 A B A C M3 B C A D
30
Example 2 M2 M1 M3 A C J K I M E F A B I J E H F G B C A D I K E G
case2compare.pdf B C A D I K E G M3 30
31
Example 2 M2 M1 M3 A C J K I M E F A B I J E H F G B C A D I K E G
case2compare.pdf B C A D I K E G M3 31
32
Example 2 M2 M1 M3 A C J K I M E F A B I J E H F G B C A D I K E G
case2compare.pdf B C A D I K E G M3 32
33
Example 2 M2 M1 M3 A C J K I M E F A B I J E H F G B C A D I K E G
case2compare.pdf B C A D I K E G M3 33
34
Example 2 M2 M1 M3 A C J K I M E F A B I J E H F G B C A D I K E G
case2compare.pdf B C A D I K E G M3 34
35
Models are pair-wise similar
Example 2 A C J K I M E F M2 M1 A B I J Models are pair-wise similar E H F G case2compare.pdf Without seeing the “global picture”, it is impossible to know which match is the best B C A D I K E G M3 35
36
Example 2 M2 M1 M3 A C J K I M E F A B I J E H F G B C A D I K E G
case2compare.pdf B C A D I K E G M3 36
37
Do it in a pair-wise manner, one by one!
What if we want to compose n inputs? Do it in a pair-wise manner, one by one! Look at n models simultaneously – n-way merge!
38
Outline Why model merging? Why n-way merge?
Formal definition of n-way merge (using Alloy) Data representation The compare operator The match operator The merge operator Issues with the implementation Next steps
39
1. Data Representation In general: In this work:
a model is a typed graph In this work: all elements are of the same type e.g., UML classes relevant information about elements is represented by properties A-Z e.g., UML class attributes and methods
41
Each element of the tuple comes from some InputModel
2. The Compare Operator Each element of the tuple comes from some InputModel
42
There are no two elements from the same model
2. The Compare Operator There are no two elements from the same model
43
union is a set of all properties of all tuple elements
2. The Compare Operator union is a set of all properties of all tuple elements
44
2. The Compare Operator Weight is
Alloy does not support floating point numbers. Thus, we limit the precision to one decimal digit and do not normalize by the number of models
45
Example M2 M1 M3 Square Square position:point position:point
center:point Square Square position:point width:int Square center:point width:int Circle position:point radius:int M3
46
Example (2+2+2) /3=2 M2 M1 M3 position center width Square Square
position:point center:point Square Square position:point width:int Square center:point width:int Circle position:point radius:int M3
47
Example (2+2) /3=1.33 M2 M1 M3 position center width Square Square
position:point center:point Square Square position:point width:int Square center:point width:int Circle position:point radius:int M3
48
position center radius
Example (2+2) /3=1.33 position center radius M2 M1 position:point center:point Square Square position:point width:int Square center:point width:int Circle position:point radius:int M3
49
position center width radius
Example (2+2+2) /4=1.5 position center width radius M2 M1 position:point center:point Square Square position:point width:int Square center:point width:int Circle position:point radius:int M3
50
Disjoint: no element appears in two tuples
3. The Match Operator Disjoint: no element appears in two tuples
51
3. The Match Operator Maximal: not possible to add additional tuples without violating the disjoint constraint
52
Weight: an average weight of the tuples
3. The Match Operator Weight: an average weight of the tuples
53
3. The Match Operator Pick the solution with the maximal weight. If there are multiple, pick the one that has the smallest number of tuples
54
Example
55
3. The Merge Operator Each input element is either part of a tuple or in the result by itself
56
There is an element in the result for each tuple
3. The Merge Operator There is an element in the result for each tuple
57
There are no additional elements in the result
3. The Merge Operator There are no additional elements in the result
58
Example
59
In Summary Compare: computes weight for each tuple of elements
Match: picks a maximal disjoint set of tuples with the largest average weight Merge: unifies matched tuples and copy the remaining elements as is
60
Outline Why model merging? Why n-way merge?
Formal definition of n-way merge (using Alloy) Data representation The compare operator The match operator The merge operator Issues with the implementation Next steps
61
Exponential number of maximal disjoint sets
In Summary Compare: computes weight for each tuple of elements Match: picks a maximal disjoint set of tuples with the largest average weight Merge: unifies matched tuples and copy the remaining elements as is Exponential number of tuples: (m1+1)*(m2+1)*..*(mn+1) - (m1+m2+..+mn+1) Exponential number of maximal disjoint sets
62
Any implementation that is based on - enumerating the tuples and - considering all possible solution will not scale
63
Open Issues and Next Steps
Devise an efficient n-way merge algorithm Either exact or approximate Q: What are the properties of compare / match that can be used for optimization? If implementing an approximation: Theoretically show its approximation factor Compare to the pair-wise approach Pair-wise is at least by 11/15 worse than optimal, so we should do better than that
64
Open Issues and Next Steps
Devise an efficient n-way merge algorithm Either exact or approximate Q: What are the properties of compare / match that can be used for optimization? If implementing an approximation: Theoretically show its approximation factor Compare to the pair-wise approach Empirically compare n-way and pairwise approaches On a number of large scale examples Q: How to obtain real-life examples of a reasonable size (vs. randomly generated)
65
Summary Redefined model merging for the case of n input models: n-way model merging Showed on two examples that n-way merging produces better results than a pair-wise approach Provided a formal definition and a naïve implementation of n-way merging using the Alloy Analyzer Discussed open issues and next steps
66
Thank You!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.