submodel pattern extraction for simulink models
play

Submodel Pattern Extraction for Simulink Models James R. Cordy - PowerPoint PPT Presentation

Submodel Pattern Extraction for Simulink Models James R. Cordy Queens University NECSIS Automotive Partnership Canada MPE near-miss clones near-miss clone detection Simone analysis of GM models pattern extraction pattern evolution


  1. Submodel Pattern Extraction for Simulink Models James R. Cordy Queen’s University NECSIS Automotive Partnership Canada

  2. MPE near-miss clones near-miss clone detection Simone analysis of GM models pattern extraction pattern evolution

  3. MPE near-miss clones near-miss clone detection Simone analysis of GM models pattern extraction pattern evolution

  4. Model Pattern Engineering discover, catalogue and formalize submodel patterns emergent domain-specific, client-specific

  5. discovery analysis, identification methodology, techniques classification characterization, formalization notation, tooling, catalogues application deployment, analysis organization, documentation, use cases

  6. why? reuse in model development standards/consistency analysis/enforcement failure/change propagation in model maintenance verification/test optimization deployment variation/optimization model product lines

  7. MPE near-miss clones near-miss clone detection Simone analysis of GM models pattern extraction pattern evolution

  8. code clones copy-paste programming efficient, widely used problematic

  9. bool ConfNextToken (char **p) { // skip white space while (1) switch (**p) { case '\t' : // ignore case ' ' : (*p)++; break; case '\0' : return FALSE; default : return TRUE; }; code clones } type 1 - exact bool ConfNextToken (char **p) { // skip white space while (1) switch (**p) { case '\t' : // ignore case ' ' : (*p)++; break; case '\0' : return FALSE; default : return TRUE; }; } [Roy, Cordy, Koschke SCP 2009]

  10. bool ConfNextToken (char **p) { // skip white space while (1) switch (**p) { case '\t' : // ignore case ' ' : (*p)++; break; case '\0' : return FALSE; default : return TRUE; }; code clones } type 1 - exact bool ConfNextToken (char **p) { while (1) switch (**p) { case '\t': case ' ': // just skip (*p)++; break; case '\0': // eof return FALSE; default: // something we want return TRUE; }; } [Roy, Cordy, Koschke SCP 2009]

  11. bool ConfNextToken (char **p) { // skip white space while (1) switch (**p) { case '\t' : // ignore case ' ' : (*p)++; break; case '\0' : return FALSE; default : return TRUE; }; code clones } type 2 - renamed bool NextToken (char **bp) { while (1) // not really switch (**bp) { case '\t': case ' ': // next (*bp)++; break; case '\0': return 0; default: return 1; }; } [Roy, Cordy, Koschke SCP 2009]

  12. bool ConfNextToken (char **p) { // skip white space while (1) switch (**p) { case '\t' : // ignore case ' ' : (*p)++; break; case '\0' : return FALSE; default : return TRUE; }; code clones } bool NextToken (char **bp) type 3 - near miss { while (1) // not really switch (**bp) { case '\t': (*bp)++ case ' ': break; case '\0': return 0; default: return 1; } } [Roy, Cordy, Koschke SCP 2009]

  13. 1 2/3*R*muk 1 Fn Tfmaxk Torque Conversion mus/muk 2 Tfmaxs Ratio of static model clones to kinetic type 1 - exact 1 2/3*R*muk 1 Fn Tfmaxk Torque Conversion mus/muk 2 Tfmaxs Ratio of static to kinetic [Alalfi, Cordy, Dean, Stephan, Stevenson ICSM 2012] [Störrle SSM 2013]

  14. model clones type 2 - renamed [Alalfi, Cordy, Dean, Stephan, Stevenson ICSM 2012] [Störrle SSM 2013]

  15. model clones type 3 - near miss [Alalfi, Cordy, Dean, Stephan, Stevenson ICSM 2012] [Störrle SSM 2013]

  16. MPE near-miss clones near-miss clone detection Simone analysis of GM models pattern extraction pattern evolution

  17. ConQAT graph-based model clone detection [Deissenboeck et al. IWSC 2010]

  18. graph flattening ignores hierarchical structure problems with near-miss

  19. graph flattening ignores hierarchical structure problems with near-miss

  20. code-based near-miss works well NiCad, iClones, others mature, accurate, efficient handles unexpected differences threshold-based, tunable scalable

  21. Renaming, Parsing & Potential Clone Filtering, 4 4 3 3 Extraction Normalization 2 2 1 1 Original Code Base Pretty-printed Normalized Potential Clones Potential Clones 1. Parse / Extract 2. Rename / Filter / Normalize Choose Next (Repeat) Potential Clone as Exemplar 5.pc 12.pc 23.pc Pairwise Cluster 17.pc 15.pc 67.pc 4 18.pc 21.pc . . . 22.pc 3 Comparison 78.pc 63.pc 37.pc . . . Comparable 39.pc 2 . . . 97.pc 44.pc 1 . . . with Exemplar Size PCs . . . Comparable Size Normalized Clone Potential Clone Cluster Potential Clones Classes NiCad 3. Clone Analysis parse - extract - normalize - diff threshold [Roy, Cordy ICPC 2008]

  22. crazy idea: can we use near-miss text code methods on graphical models? “Models are source code too” Mark Harman, keynote at SCAM 2010 [Harman SCAM 2010]

  23. MPE near-miss clones near-miss clone detection Simone analysis of GM models pattern extraction pattern evolution

  24. Simone Simulink near-miss clone detection experiment adapt NiCad near-miss code clone detector to graphical models validate vs. ConQAT for types 1 & 2 hand validate type 3 (near-miss) [Alalfi, Cordy,Dean, Stephan, Stevenson ICSM 2012]

  25. Simulink hybrid hardware/software models widespread in industry - automotive, aerospace, embedded systems mature and interesting at GM

  26. Simulink hierarchical models [Alalfi, Cordy,Dean, Stephan, Stevenson ICSM 2012]

  27. Challenge #1 ... � System { � Name "onoff" � Location [168, 385, 668, 686] � code methods Open on � ModelBrowserVisibility off � ModelBrowserWidth 200 � require text ScreenColor "automatic" � PaperOrientationi "landscape" � PaperPositionMode "auto" � PaperType "usletter" � NiCad requires PaperUnits "inches" � ZoomFactor "100" � AutoZoom on � a parser ReportName "simulink-default.rpt" � Block { � BlockType DiscretePulseGenerator � Name "Discrete Pulse\nGenerator" � Solution: Position [45, 25, 75, 55] � Amplitude "1" � Period "2" � grammar inference PulseWidth "1" � PhaseDelay "0" � SampleTime "1" � } � on Simulink’s Block { � BlockType Product � Name "Product" � internal form Ports [2, 1, 0, 0, 0] � Position [145, 67, 175, 98] � Inputs "2" � SaturateOnIntegerOverflow on � } � ... � } � ... �

  28. Challenge #2 ... � System { � Name "onoff" � Location [168, 385, 668, 686] � what granularity? Open on � ModelBrowserVisibility off � ModelBrowserWidth 200 � ScreenColor "automatic" � NiCad requires PaperOrientationi "landscape" � PaperPositionMode "auto" � PaperType "usletter" � candidates for PaperUnits "inches" � ZoomFactor "100" � AutoZoom on � ReportName "simulink-default.rpt" � comparison Block { � BlockType DiscretePulseGenerator � Name "Discrete Pulse\nGenerator" � Position [45, 25, 75, 55] � Simulink: Amplitude "1" � Period "2" � PulseWidth "1" � model (too big) PhaseDelay "0" � SampleTime "1" � block (too small) } � Block { � BlockType Product � system (just right!) Name "Product" � Ports [2, 1, 0, 0, 0] � Position [145, 67, 175, 98] � Inputs "2" � SaturateOnIntegerOverflow on � } � ... � } � ... �

  29. neutral neutral 1 validated_neutral 1 validated_neutral neutral neutral action action 2 2 up up up up checked_action validated_up 1 checked_action validated_up 1 [reset] reset neutral_up_down [reset] reset neutral_up_down From2 From2 check_up check_up action action 3 3 down down down down checked_action validated_down checked_action validated_down [reset] reset [reset] reset From1 From1 check_down check_down mutually_exclusive mutually_exclusive 4 [reset] 4 [reset] reset Goto1 reset Goto1 even with raw text, find some subsystem clones � � � � � � � � but: 90% irrelevant Simulink internal “formatting” systems some identical systems only 70% same entirely missed exact copies displayed differently

Recommend


More recommend