
Automated Metamodel Instance Generation Satisfying Quantitative Constraints Wu Hao(吴昊) Supervisors: Dr. Rosemary Monahan and Dr. James F. Power Department of Computer Science National University of Ireland, Maynooth A thesis submitted for the degree of Doctor of Philosophy October, 2013 I would like to dedicate this thesis to every one who helped me during my PhD studies. Acknowledgements I consider this section as one of the most important parts of this thesis because without any one of you mentioned below this thesis would never have been possible. First and foremost, I would like to thank my supervisors Dr. Rose- mary Monahan and Dr. James F. Power for their guidance during the last four years. Their critical and strict attitude towards my work are the key factors for me to keep up till the very end of my PhD studies. So, a huge thank you to both of you. I would like to exponentially extend my gratitude to those of you who helped me during my sickness in 2011. They include: Jimmy Gor- man, Joe Timoney, Lu Bing Bing(卢斌斌), Deirdre Dunne, Ying Fang Li(应方立), Yang Wen Bai(杨文白), Brendan Ashe, Zhang Xin(张 欣), Chen Yu Ying(陈昱颖), Chen Shuang(陈霜), Stephen Brown and many of who visited me when I was in hospital. It was the darkest time in my PhD studies, and probably also in my life so far. Fortu- nately, with the encouragement and support from all of you, I was able to quickly step out the darkness and start to recover. Therefore, all of you really deserve my biggest thanks. I also would like to thank those who shared an apartment with me during my last year studies. They include: Chen Xiao Ming(陈晓 敏), Emma Jackson, Michael Roche, Holly Henning and Jamie Mac Phillips. Thanks for all the nice conversations during the dinner time in the living room, which really helped me get relaxed after my daily stressful work. Finally, I would like to give my deepest gratitude to my loving parents (袁美萍, 吴国弟). Your greatest support is the ultra power supply for finishing this thesis, and it is far beyond any physical distance and time difference. Abstract Metamodels are the core of the metamodeling approach and widely used in model driven architecture. The high abstraction level provided by metamodels makes the metamodeling approach popular among software modelers and language designers. However, the metamod- eling approach has one big drawback: it does not support instance generation. Instances are particularly important for software model- ers and language designers to test or verify their metamodels. Un- fortunately, automatically generating metamodel instances is a very challenging task. Furthermore, the generated instances should ideally cover a more generic or specific feature of a metamodel as required by modelers for different purposes. This thesis presents a solution that combines both graph represen- tation and Satisfiability Modulo Theories (SMT) to the problem of metamodel instance generation. The solution consists of two ap- proaches, the first approach presents a new foundation for generating metamodel instances by translating a metamodel to an SMT prob- lem via a bounded graph representation. The second approach in- vestigates generating meaningful metamodel instances by using two new techniques. The first technique generates instances that meet partition-based coverage criteria by using criteria formulas to further constrain the entire generation process. The second technique gener- ates instances that satisfy graph-property based criteria by introducing different scenarios. These two approaches have been prototyped into a new tool, named ASMIG, to demonstrate the feasibility of automatic metamodel instance generation. Simplicity is prerequisite for reliability. Edsger.W.Dijkstra, 1975 Contents Contents v List of Figures ix Nomenclature xiv 1 Introduction 1 1.1 ModelDrivenEngineering ...................... 1 1.2 ModelandMetamodel ........................ 2 1.3 MetaObjectFacility.......................... 4 1.4 MetamodelsandUMLClassDiagrams . 4 1.5 ObjectConstraintLanguage . 4 1.6 ProblemStatement .......................... 5 1.7 Motivation............................... 6 1.8 Challenges............................... 6 1.9 SummaryofContributions . .. 7 2 A Systematic Literature Review of Metamodel Instance Gener- ation Techniques 9 2.1 ReviewResearchMethods ...................... 9 2.2 DefiningTheResearchQuestions . 10 2.2.1 Searchterms ......................... 12 2.2.2 PaperSelectionStudy . .. 15 2.3 Discussion............................... 15 v 0.0 CONTENTS 2.3.1 RQ1. What are the research domains with techniques that are applicable to metamodel instance generation? . 15 2.3.1.1 Compiler Testing . 17 2.3.1.2 Model Transformation Testing . 17 2.3.1.3 GraphGrammars. .. 19 2.3.1.4 SAT/SMT based Approaches . 20 2.3.1.5 Constraint Programming . 20 2.3.1.6 XML & Miscellaneous Domains . 21 2.3.2 RQ2. Within those research domains, what theoretical frameworks and associated algorithms have actually been used for metamodel instance generation? . 21 2.3.2.1 Compiler Testing . 21 2.3.2.2 Model Transformation Testing . 22 2.3.2.3 GraphGrammars. .. 24 2.3.2.4 SAT/SMT Based Approaches . 25 2.3.2.5 Constraint Programming Approach (CP) . 28 2.3.2.6 XML......................... 29 2.3.2.7 Miscellaneous Domains . 29 2.3.3 RQ3. What criteria are applied for selecting metamodel instances? ........................... 31 2.3.4 RQ4. What tools exist to implement those algorithms to producemodelinstances? . 32 2.3.5 Discussion........................... 36 2.4 Summary ............................... 40 3 Background: Graphs, SAT and SMT 41 3.1 MetamodelsandGraphs ....................... 42 3.1.1 TypedGraphs......................... 43 3.1.2 Attributed Graphs and Attributed Type Graphs . 44 3.1.3 AttributedTypeGraphwithInheritance . 48 3.2 Boolean Satisfiability Problem . 51 3.3 Satisfiability Modulo Theories . 52 3.3.1 SMT-Libversion2 ...................... 53 vi 0.0 CONTENTS 3.3.1.1 Functions . 53 3.3.1.2 LogicContext.................... 53 3.3.1.3 Formulas . 53 3.3.1.4 Models . 53 3.3.1.5 Solving An Integer Equation . 54 3.4 AnSMT-basedSudokuSolver . 54 3.5 Summary ............................... 58 4 Generating Metamodel Instances Satisfying Structural and OCL Constraints 59 4.1 Bounded Attributed Type Graphs with Inheritance . 60 4.2 Translating an AGu toSMT2Formulas. 64 4.2.1 TranslatingtheNodesandEdges . 65 4.2.2 TranslatingGraphEdges. 66 4.2.2.1 Unidirectional Associations . 68 4.2.2.2 Bidirectional Association . 70 4.3 TranslatingOCLInvariantstoSMT2Formulas . 72 4.4 AGraphColouringExample. 74 4.5 Evaluation............................... 77 4.5.1 Implementation ........................ 77 4.5.2 Results............................. 80 4.5.3 Comparison .......................... 84 4.6 Summary ............................... 89 5 Generating Metamodel Instances Satisfying Partition-Based Cov- erage Criteria 90 5.1 Partition-based Coverage Criteria for Metamodels . 91 5.2 Using Partition Switches and Criterial Formulas for Partition-based InstanceGeneration ......................... 93 5.2.1 Class Attribute Partitioning . 94 5.2.1.1 An Example of Attribute-based Partitions . 95 5.2.2 Association-End Multiplicity Partitioning . 97 5.2.2.1 Partitioning Unidirectional Associations . 98 vii 0.0 CONTENTS 5.2.2.2 Partitioning Bidirectional Associations . 101 5.2.3 Better ControlofInstance Enumeration . 103 5.3 An Example of Achieving CA and AEM Coverage Criteria . 105 5.4 Evaluation............................... 107 5.4.1 Implementation ........................ 107 5.4.2 Results............................. 107 5.5 Summary ............................... 112 6 Generating Metamodel Instances Satisfying Graph-Based Crite- ria 113 6.1 DirectedAcyclicGraphs . 114 6.2 SharingandNon-SharingNodes . 116 6.3 QuantityofNodesandEdges . 120 6.4 Examples: Class Cohesion and McCabe Complexity . 122 6.4.1 Class Cohesion and Call Graphs . 122 6.4.2 McCabeComplexity . .. 127 6.5 Evaluation............................... 128 6.5.1 Implementation ........................ 128 6.5.2 Results............................. 129 6.6 Summary ............................... 133 7 Conclusion 134 7.1 Discussion............................... 135 7.2 Futurework.............................. 141 7.2.1 SharedSMT2Formulas . 141 7.2.2 UnsatCoreAnalysis . .. 141 7.2.3 ExtendingOCLSupport . 142 7.2.4 Special Graph-Properties Based Language . 142 Appendix A 144 Bibliography 151 viii List of Figures 1.1 An example of model and its metamodel. This is the four-level MOF architecture, and from the top down it describes a meta- metamodel (level 3), metamodel (level 2), model (level 1) and an object(level0). ............................ 3 1.2 A metamodel with an OCL invariant indicating a person’s age mustbeover18. ........................... 5 1.3 Two instances: Figure 1.3(a) is a valid instance for metamodel in Figure 1.2, Figure 1.3(b) is an invalid instance. 5 1.4 The approach and techniques presented in Chapter 4, 5 and 6 have been implemented as a new tool: A Small Metamodel In- stance Generator (ASMIG). Not only can ASMIG automatically generate metamodel instances satisfying structural and OCL con- straints (described in Chapter 4) but also with consideration for partition and graph based criteria (described in Chapters 5 and 6). The generated formulas from ASMIG conform to the SMT-Lib Version 2.0 (SMT2) standard, and input to the SMT2 solver (that acts as a black-box engine) for solving the formulas, and each suc- cessful assignment for formulas is converted back into an instance ofametamodel............................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages183 Page
-
File Size-