Skip to main content
Log in

Clone detection in MATLAB Stateflow models

  • Published:
Software Quality Journal Aims and scope Submit manuscript

Abstract

MATLAB Simulink is one of the leading tools for model-based software development in the automotive industry. One extension to Simulink is Stateflow, which allows the user to embed Statecharts as components in a Simulink model. These state machines contain nested states, an action language that describes events, guards, conditions, actions, and complex transitions. As Stateflow has become increasingly important in Simulink models for the automotive sector, we extend previous work on clone detection of Simulink models to Stateflow components. While Stateflow models are stored in the same file as the Simulink models that host them, the representations differ. Our approach incorporates a pretransformation that converts the Stateflow models into a form that allows us to use the SIMONE model clone detector to identify candidates and cluster them into classes. In addition, we push the results of the Stateflow clone detection back into the Simulink models, improving the accuracy of the clones found in the host Simulink models. We validated our approach on the MATLAB Simulink/Stateflow demo set. Our approach showed promising results on the identification of Stateflow clones in isolation, as well as integrated components of the Simulink models that are hosting them.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Listing 1
Listing 2
Listing 3
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Listing 4
Listing 5
Listing 6

Similar content being viewed by others

Notes

  1. www.mathworks.com/products/simulink.

  2. www.mathworks.com/products/stateflow.

  3. www.necsis.ca.

  4. www.mathworks.com/products/matlab.

  5. They come with MATLAB installation located at the MATLAB installation directory.

  6. http://www.conqat.org.

References

  • Al-Batran, B., Schätz, B., & Hummel, B. (2011). Semantic clone detection for model-based development of embedded systems. In Proceedings of the 14th International conference on model driven engineering languages and systems, (pp 258–272), MODELS’11. Berlin, Heidelberg: Springer. http://dl.acm.org/citation.cfm?id=2050655.2050681.

  • Alalfi, M., Cordy, J., Dean, T., Stephan, M., & Stevenson, A. (2012a). Models are code too: Near-miss clone detection for Simulink models. In ICSM (pp 295–304).

  • Alalfi, M., Cordy, J., Dean, T., Stephan, M., & Stevenson, A. (2012b). Near-miss model clone detection for Simulink models. In IWSC (pp. 78–79).

  • Antony, E., Alalfi, M., & Cordy, J. (2013). An approach to clone detection in behavioural models. In Reverse engineering (WCRE), 2013 20th working conference on (pp. 472–476). doi:10.1109/WCRE.2013.6671325.

  • Chen, J., Dean, T.R., & Alalfi, M.H. (2014). Clone detection in matlab stateflow models. In Proceedings of the 8th international workshop on software clones, Elec. Comm. EASST (vol. 63, p. 13).

  • Cordy, J. R. (2006). The TXL source transformation language. Science of Computer Programming, 61(3), 190–210.

    Article  MathSciNet  MATH  Google Scholar 

  • Cordy, J.R. (2013). Submodel pattern extraction for simulink models. In Proceedings of the 17th International Software Product Line Conference, ACM, New York, NY, USA, SPLC ’13 (pp. 7–10). doi:10.1145/2491627.2492153.

  • Cordy, J.R., & Roy, C.K. (2011). The NiCad clone detector. In Proceedings of the 2011 IEEE 19th international conference on program comprehension, IEEE Computer Society, Washington, DC, USA, ICPC ’11 (pp. 219–220). doi:10.1109/ICPC.2011.26.

  • Deissenboeck, F., Pizka, M., & Seifert, T. (2005). Tool support for continuous quality assessment. In Software technology and engineering practice, 2005. 13th IEEE International Workshop on (pp. 127–136). doi:10.1109/STEP.2005.31.

  • Deissenboeck, F., Hummel, B., Jürgens, E., Schätz, B., Wagner, S., Girard, J.F., & Teuchert, S. (2008). Clone detection in automotive model-based development. In Proceedings of the 30th international conference on software engineering, ACM, New York, NY, USA, ICSE ’08 (pp. 603–612). doi:10.1145/1368088.1368172.

  • Deissenboeck, F.,Hummel, B., Juergens, E., Pfaehler, M., & Schaetz, B. (2010). Model clone detection in practice. In: IWSC (pp. 57–64).

  • Dominguez, A.L.J. (2012). mdl2smv: A tool for translating automotive feature models in matlab’s stateflow to smv. https://cs.uwaterloo.ca/~aljuarez/mdl2smv.html, Accessed November 6, 2014.

  • Harel, D. (1987). Statecharts: A visual formalism for complex systems. Science of Computer Programming, 8(3), 231–274.

    Article  MathSciNet  MATH  Google Scholar 

  • Hirschberg, D. S. (1977). Algorithms for the longest common subsequence problem. Journal of the ACM, 24(4), 664–675. doi:10.1145/322033.322044.

    Article  MathSciNet  MATH  Google Scholar 

  • Hummel, B., Juergens, E., & Steidl, D. (2011). Index-based model clone detection. In Proceedings of the 5th International Workshop on Software Clones, ACM, New York, NY, USA, IWSC ’11 (pp. 21–27). doi:10.1145/1985404.1985409.

  • Juergens, E., Deissenboeck, F., & Hummel, B. (2009). Clonedetective—A workbench for clone detection research. In Proceedings of the 31st international conference on software engineering, IEEE computer society, Washington, DC, USA, ICSE ’09 (pp. 603–606). doi:10.1109/ICSE.2009.5070566.

  • Koschke, R. (2006). Survey of research on software clones. In Dagstuhl Seminars.

  • Liu, H., Ma, Z., Zhang, L., & Shao, W. (2006). Detecting duplications in sequence diagrams based on suffix trees. In Software engineering conference, 2006. APSEC 2006. 13th Asia Pacific (pp. 269–276). doi:10.1109/APSEC.2006.32.

  • Martin, D., & Cordy, J. R. (2010). Towards web services tagging by similarity detection. In M. Chignell, J. Cordy, J. Ng, & Y. Yesha (Eds.), The smart internet, lecture notes in computer science (Vol. 6400, pp. 216–233). Berlin Heidelberg: Springer.

  • Martin, D., & Cordy, J.R. (2011). Analyzing web service similarity using contextual clones. In Proceedings of the 5th international workshop on software clones, ACM, New York, NY, USA, IWSC ’11 (pp. 41–46). doi:10.1145/1985404.1985412.

  • Pham, N., Nguyen, H., Nguyen, T., Al-Kofahi, J., & Nguyen, T. (2009). Complete and accurate clone detection in graph-based models. In Software Engineering, 2009. ICSE 2009. IEEE 31st International Conference on (pp. 276–286). doi:10.1109/ICSE.2009.5070528.

  • Roy, C.K., & Cordy, J.R. (2007). A survey on software clone detection research. In: School of Computing TR 2007-541, Queen’s University 115.

  • Roy, C. K., Cordy, J. R., & Koschke, R. (2009). Comparison and evaluation of code clone detection techniques and tools: A qualitative approach. Science of Computer Programming, 74(7), 470–495.

    Article  MathSciNet  MATH  Google Scholar 

  • Grant, S., Martin, J. C. D., & Skillicorn, D. (2011). Contextualized semantic analysis of web services. In WSE, 2011, 33–42.

    Google Scholar 

  • Stephan, M., Alafi, M., Stevenson, A., & Cordy, J. (2012). Towards qualitative comparison of simulink model clone detection approaches. In IWSC (pp. 84–85).

  • Stevenson, A., & Cordy, J. R. (2012). Grammatical inference in software engineering: An overview of the state of the art. In Hedin (Ed.), Pre-proceedings of the fifth international conference on software language engineering (SLE 2012), Fakultät Informatik, Technische Universität (pp. 206–225).

  • Störrle, H. (2009). VMQL: A generic visual model query language. In Visual languages and human-centric computing, 2009. VL/HCC 2009. IEEE Symposium on (pp. 199–206). doi:10.1109/VLHCC.2009.5295261.

  • Störrle, H. (2013). Towards clone detection in uml domain models. Software and Systems Modeling, 12(2), 307–329.

    Article  Google Scholar 

  • The MathWorks Inc (2014). Stateflow hierarchy of objects. http://www.mathworks.com/help/stateflow/ug/stateflow-hierarchy-of-objects.html. Accessed March, 2014.

Download references

Acknowledgments

We would like to acknowledge funding from Network for the Engineering of Complex Software-Intensive Systems for Automotive Systems (NECSIS), the Ontario Research Fund (ORF), and the National Sciences and Engineering Research Council of Canada (NSERC).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Thomas R. Dean.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Chen, J., Dean, T.R. & Alalfi, M.H. Clone detection in MATLAB Stateflow models. Software Qual J 24, 917–946 (2016). https://doi.org/10.1007/s11219-015-9296-0

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11219-015-9296-0

Keywords

Navigation