ABSTRACT INTELLIGENT SIMULINK MODELING ASSISTANCE VIA MODEL CLONES and MACHINE LEARNING by Bhisma Adhikari Source Code Auto-Comp
Total Page:16
File Type:pdf, Size:1020Kb
ABSTRACT INTELLIGENT SIMULINK MODELING ASSISTANCE VIA MODEL CLONES AND MACHINE LEARNING by Bhisma Adhikari Source code auto-completion has been pursued extensively by the research community, and has benefited software engineering to a great extent. In contrast, analogous research in Model Driven Engineering (MDE), that is, model auto-completion has not been explored as extensively. As a result, there does not exist sufficient MDE tooling that allows for automatic completion of models. This thesis aims to fill that gap by developing a prototype modeling assistant for Simulink using Simone as the underlying model clone detector and machine learning algorithms. The modeling assistant provides two types of suggestions: (1) Simulink block-level suggestions, and (2) Simulink (sub)system-level suggestions, to help modelers auto-complete or extend their Simulink models. It uses machine learning algorithms to produce block-level suggestions and model clone detection to produce (sub)system-level suggestions. Simulink and Simone are chosen over other tools due to their greater maturity and wider adoption. Although this prototype modeling assistant is developed specifically for Simulink, the results and knowledge gained from this research are extendable to any modeling environment for which a text-based model clone detector is available. INTELLIGENT SIMULINK MODELING ASSISTANCE VIA MODEL CLONES AND MACHINE LEARNING A Thesis Submitted to the Faculty of Miami University in partial fulfillment of the requirements for the degree of Master of Science by Bhisma Adhikari Miami University Oxford, Ohio 2021 Advisor: Dr. Matthew Stephan Reader: Dr. Eric J. Rapos Reader: Dr. Christopher Vendome ©2021 Bhisma Adhikari This Thesis titled INTELLIGENT SIMULINK MODELING ASSISTANCE VIA MODEL CLONES AND MACHINE LEARNING by Bhisma Adhikari has been approved for publication by The College of Engineering and Computing and The Department of Computer Science & Software Engineering Dr. Matthew Stephan Dr. Eric J. Rapos Dr. Christopher Vendome Table of Contents List of Tables vi List of Figures vii Acknowledgements viii Statement of Originality ix 1 Introduction1 1.1 Motivation . .1 1.2 Contributions . .2 1.3 Overview . .3 2 Background & Related Work4 2.1 Model-Driven Engineering . .4 2.1.1 MDE Tools . .5 2.1.2 Simulink . .5 2.1.3 Simulink App . .7 2.1.4 App Designer . .8 2.2 Software Clones . 11 2.2.1 Code Clones . 11 2.2.2 Code Clone Types . 11 2.2.3 Model Clones . 13 2.2.4 Model Clone Types . 13 2.2.5 Drawbacks of Software Clones . 15 2.2.6 Advantages of Software Clones . 16 2.2.7 Simone . 16 2.3 Static Software Analysis . 17 2.3.1 Software Clone Detection . 17 2.3.2 Source Code Suggestion . 18 2.3.3 Model Suggestion . 19 2.4 Machine Learning . 20 2.4.1 Recommender Systems . 20 2.4.2 Association Rule Mining . 20 iii 2.4.3 Ensemble Learning . 20 2.5 Related Work . 21 2.5.1 Source Code Assistance/Completion . 21 2.5.2 Model Assistance/Completion . 22 2.5.3 Reference Framework for Intelligent Modeling Assistance (RFIMA) . 22 3 Overview 24 3.1 SimIMA Components . 24 3.2 SimIMA Architecture . 25 3.3 SimIMA User Interface . 26 4 SimGestion: Simulink Block-Level Suggestions 29 4.1 Block Prediction Models . 29 4.1.1 ARM Model . 29 4.1.2 Freq Model . 31 4.1.3 Ensemble Model . 36 4.2 Performance Optimization of Block-Prediction Models . 37 4.3 User Interface . 38 4.3.1 SimGestion Suggestion Panel . 38 4.3.2 SimGestion Configuration Wizard . 39 4.4 Running Example: ExampleSUD . 41 5 SimXample: Simulink Complete Model Examples 43 5.1 Phase 1: Clone Detection . 44 5.1.1 Phase 1 Implementation . 44 5.2 Phase 2: Subsystem Recommendation . 46 5.2.1 Phase 2 Implementation . 46 5.3 Phase 3: Candidate Selection . 48 5.3.1 Phase 3 Implementation . 48 5.4 Phase 4: Application to User Model . 48 5.4.1 Phase 4 Implementation . 48 5.5 Running Example Continued: ExampleSUD . 53 6 Evaluation 54 6.1 Data . 54 6.2 SimGestion Evaluation . 55 6.2.1 Data Preparation . 55 6.2.2 Determining Block Prediction Model Parameters . 56 6.2.3 Evaluation of Ensemble Block Suggestions . 56 6.2.4 Results . 57 6.2.5 Discussion . 58 6.3 SimXample Evaluation . 59 iv 6.3.1 Data Preparation . 59 6.3.2 Evaluation of Visualization of Inferred Suggestions . 59 6.3.3 Evaluation of the Replacement . 60 6.3.4 Results . 61 6.3.5 Discussion . 62 6.4 Qualitative Evaluation via IMA Evaluation Grid . 63 7 Conclusion 65 7.1 Threats to Validity . 65 7.1.1 External Threats . 65 7.1.2 Internal Threats . 66 7.2 Future Work . 66 7.3 Summary . 67 A Source Code 68 A.1 Class Definitions . 68 A.2 Function Definitions . 105 References 220 v List of Tables 4.1 Example ARM Matrix . 30 6.1 SimGestion Suggestion Accuracy . 58 6.2 Evaluation Tests for the 5 Insertion Cases . 61 6.3 Inferred Suggestion Accuracy . 62 6.4 Summary of Qualitative Assessment . 64 vi List of Figures 2.1 A simulink model that adds two integers and outputs the result . .6 2.2 A Simulink app that computes and plots the mortgage based on different input values. This app (Mortgage.mlapp) is included with the official distribution of MATLAB software. .7 2.3 The design view of the Simulink app shown in Figure 2.2. This app (Mortgage.mlapp) is included with the official distribution of MATLAB software. .9 2.4 The code view of the Simulink app shown in Figure 2.2............... 10 2.5 An example of Type I (exact) model clones in Simulink . 14 2.6 An example of Type II (renamed) model clones in Simulink . 14 2.7 An example of Type III (near-miss) model clones in Simulink . 15 2.8 An example of Type IV (semantic) model clones in Simulink . 15 2.9 Model suggestion as envisioned in SimIMA . 19 3.1 SimIMA Architecture Overview . 25 3.2 SimIMA UI: Querying SimIMA using customized tools menu . 27 3.3 SimIMA UI: Querying SimIMA using customized context menu . 28 4.1 SimGestion suggestion panel . 39 4.2 SimIMA Block-Level Suggestion Configuration Wizard . 40 4.3 Initial composition of ExampleSUD . 41 4.4 Initial Suggestions for First Insertion into ExampleSUD . 42 4.5 Interim view of ExampleSUD after four applications of SimGestion . 42 4.6 Interim view of ExampleSUD after sseven applications of SimGestion . 42 5.1 SimXample Process Overview . 44 5.2 SimXample user interface . 45 5.3 Decision Process for Inserting SFS into SUD . 51 5.4 Engineer-guided replacement notification – prompt to proceed with replacement . 52 5.5 Engineer-guided replacement notification – prompt to adjust connections manually 52 5.6 ExampleSUD after inserting the suggestion from SimXample . 53 6.1 Accuracy of Suggestion Based on Number of Suggestions Shown . 57 vii Acknowledgements I am very thankful to my thesis advisor, Dr. Matthew Stephan of the Department of Computer Science and Software.