University of Toronto Department of Computer Science Lifting Transformations to Product Lines Rick Salay, Michalis Famelis, Julia Rubin, Alessio Di Sandro, Marsha Chechik
Product lines +Dry +Dry/Delay +Delay +Heat … Manage a large number of similar but different artifact variants (products) Washing Machine Co. 2Lifting Transformations to Product Lines
Product line structure +Dry +Dry/Delay +Delay +Heat … Product line (annotative) represented by Domain Model – combined parts from all products Feature Model – shows possible features and restrictions for products Washing Machine Co. Feature Model Wash Heat Dry Delay excludes Domain Model 3Lifting Transformations to Product Lines
Product line configuration – example 1 +Dry +Dry/Delay +Delay +Heat … +Heat product Feature configuration: {Wash, Heat} Washing Machine Co. Feature Model Wash Heat Dry Delay excludes +Heat 4Lifting Transformations to Product Lines
Product line configuration – example 2 +Dry +Dry/Delay +Delay +Heat … +Dry/Delay product Feature configuration: {Wash, Dry, Delay} Washing Machine Co. Feature Model Wash Heat Dry Delay excludes +Dry/Delay 5Lifting Transformations to Product Lines
Domain Model Model product line: washing machine state machine LockingWaiting Washing entry/TempCheck() Drying Unlocking [heatEnabled;delayEnabled] / HeaterOn() / HeaterOff(); wash.Start(); / QuickCool() [not heatEnabled;not delayEnabled]/ wash.Start(); Presence Conditions Feature Model Wash Heat Dry Delay excludes 6Lifting Transformations to Product Lines Heat Delay Heat Dry Heat Delay
Domain Model Feature Model Configuring a model (product) LockingWaiting Washing entry/TempCheck() Drying Unlocking [heatEnabled;delayEnabled] / HeaterOn() / HeaterOff(); wash.Start(); / QuickCool() [not heatEnabled;not delayEnabled]/ wash.Start(); Wash Heat Dry Delay excludes Heat Delay Heat Dry 7Lifting Transformations to Product Lines Heat Delay
+Dry/Delay Variant +Dry/Delay state machine LockingWaiting Washing Drying Unlocking [ delayEnabled] / wash.Start(); / QuickCool() 8Lifting Transformations to Product Lines [ not delayEnabled]/ wash.Start();
+Dry/Delay Variant +Dry/Delay state machine LockingWaiting Washing Drying Unlocking [delayEnabled] /wash.Start(); / QuickCool() 9Lifting Transformations to Product Lines [not delayEnabled]/ wash.Start();
Outline Product lines Transformations Why lift transformations to product lines? Sketch of lifting algorithm Evaluation Summary and next steps 10Lifting Transformations to Product Lines
Use to convert one artifact into another For refinement, generating implementations, refactoring, optimization, translation, etc. Automates mundane tasks and ensures quality Enables raising level of abstraction in software development Transformations in Model Driven Engineering (MDE) WideYellow 11Lifting Transformations to Product Lines
Key problem: Transformations written for models cannot be used directly with product lines of models Ideally we should lift them to product lines - b ut how? Model Our goal ? Model Model Product Line configure 12Lifting Transformations to Product Lines
+Dry Idea 1 – Avoid lifting transformation Wash Heat Dry Delay excludes WideYellow configure Problems: Must keep track of transformations to apply Can’t do analysis of transformation’s effect on product line 13Lifting Transformations to Product Lines
+Dry +Delay Idea 2: Configure all products and merge Wash Heat Dry Delay excludes Wash Heat Dry Delay excludes configure merge +Delay +Dry WideYellow Problems: Expensive: may be many products! Merge is non-trivial 14Lifting Transformations to Product Lines
WideYellow Manual Lift Idea 3: Manually lift by re-developing transformation Wash Heat Dry Delay excludes Wash Heat Dry Delay excludes Problems: Requires extensive effort Error-prone 15Lifting Transformations to Product Lines
Automated Lift Our contribution: Automate the lift Wash Heat Dry Delay excludes WideYellow Wash Heat Dry Delay excludes 16Lifting Transformations to Product Lines Benefits Low cost Eliminates manual effort Guarantees correctness
Outline Product lines Transformations Why lift transformations to product lines? Sketch of lifting algorithm Evaluation Summary and next steps 17Lifting Transformations to Product Lines
Example: State machine refactoring transformation NAC Applicability Condition: Apply the rule if the LHS matches and no NAC matches 18Lifting Transformations to Product Lines Negative Application Condition
Applying FoldEntry – example 1 FoldEntry NAC +Dry/Delay Variant LockingWaiting Washing /wash.Start(); Drying Unlocking [delayEnabled] / QuickCool() 19Lifting Transformations to Product Lines [not delayEnabled] / wash.Start(); Matching Site No NAC matches – applicability condition passes Apply rule
Applying FoldEntry – example 1 FoldEntry NAC +Dry/Delay Variant LockingWaiting Washing entry/ wash.Start(); Drying Unlocking [delayEnabled] / QuickCool() 20Lifting Transformations to Product Lines [not delayEnabled]
Applying FoldEntry – example 2 FoldEntry NAC +Heat Variant LockingWaiting Washing entry/TempCheck() Unlocking [heatEnabled]/ HeaterOn() / HeaterOff(); wash.Start(); / QuickCool() 21Lifting Transformations to Product Lines [not heatEnabled] / wash.Start(); NAC Matches – applicability condition fails Do not apply rule Matching Site
Domain Model Feature Model How to apply FoldEntry to a Product Line? LockingWaiting Washing entry/TempCheck() Drying Unlocking [heatEnabled;delayEnabled] / HeaterOn() / HeaterOff(); wash.Start(); / QuickCool() Wash Heat Dry Delay excludes Heat Delay Heat Dry 22Lifting Transformations to Product Lines Heat Delay [not heatEnabled;not delayEnabled]/ wash.Start();
Correctness Criteria Model Product Line Model Same set of valid configurations Model 23Lifting Transformations to Product Lines
Lifting algorithm sketch 1. Find matching sites in the domain model 2. Reinterpret rule applicability condition Rule must be applicable in at least one product requires SAT check 3. Reinterpret how to apply the rule Modify domain model and presence conditions so rule effect only occurs in applicable products 24Lifting Transformations to Product Lines
25 Domain Model LockingWaiting Washing entry/TempCheck() Drying Unlocking [heatEnabled;delayEnabled] / HeaterOn() / HeaterOff(); wash.Start(); / QuickCool() Feature Model Wash Heat Dry Delay excludes Heat +Dry/Delay Variant LockingWaiting Washing /wash.Start(); Drying Unlocki ng [delayEnabled] / QuickCool( ) / wash.Start(); +Dry/Delay Variant +Heat Variant Lockin g Waitin g Washing entry/TempCheck() Unlock ing [heatEnabled]/ HeaterOn() / HeaterOff(); wash.Start(); / QuickCool () / wash.Start(); +Heat Variant Heat Dry Heat Delay Heat Dry Heat Delay [not heatEnabled;not delayEnabled] /wash.Start(); 1) Matching Site 2) Lifted rule applicability condition passes Apply rule 2) Rule applicable in at least one product?
26Lifting Transformations to Product Lines Domain Model LockingWaiting Washing entry/TempCheck(); wash.Start(); Drying Unlocking [heatEnabled;delayEnabled] / HeaterOn() / HeaterOff(); wash.Start(); / QuickCool() Heat 3) Apply rule domain model and update presence conditions Delay Feature Model Wash Heat Dry Delay excludes +Dry/Delay Variant LockingWaiting Washing /wash.Start(); Drying Unlocki ng [delayEnabled] / QuickCool( ) / wash.Start(); +Dry/Delay Variant +Heat Variant Lockin g Waitin g Washing entry/TempCheck() Unlock ing [heatEnabled]/ HeaterOn() / HeaterOff(); wash.Start(); / QuickCool () / wash.Start(); +Heat Variant [not heatEnabled;not delayEnabled] /wash.Start();
Properties of lifting algorithm Correct Lifting satisfies the correctness condition Termination Lifting preserves rule set termination Confluence Lifting preserves rule set confluence up to product line equivalence 27Lifting Transformations to Product Lines
Effect of a lifted rule on a product line Domain model Lifting preserves domain model minimality Feature model: Lifting may not preserve feature model minimality Lifting may make some features superfluous Presence conditions 28Lifting Transformations to Product Lines
Outline Product lines Transformations Why lift transformations to product lines? Sketch of lifting algorithm Evaluation Summary and next steps 29Lifting Transformations to Product Lines
Prototype Implementation Modified the Henshin [Arendt et al.] graph transformation engine to Use the lifting semantics for rule execution Use Z3 [Microsoft] for SAT checks via MMTF [U of T] Henshin Graph Transformation Engine (modified) Eclipse Workbench Z3 SMT Solver Model Management Tool Framework(MMTF) 30Lifting Transformations to Product Lines
Application: Car Crash Management Product Line Benchmark used in modeling studies 15,360 products (class diagram variants) 444 elements, 118 presence conditions Applied to two transformations (AddGet) Class Diagram to Class Diagram adds getters to public data members (1 rule) (C2R) Class Diagram to Relational Database schema Translates a class diagram to equivalent schema (9 rules) 31Lifting Transformations to Product Lines Objective: Illustrate lifting on a more realistic scenario
Application: Car Crash Management Product Line Objective: Illustrate lifting on a more realistic scenario Benchmark used in modeling studies 15,360 class diagram variants Applied to two transformations (C2R) Class Diagram to Relational Database schema Translates a class diagram to equivalent schema (9 rules) (AddGet) Class Diagram to Class Diagram Refactoring that adds getters to public data members (1 rule) Results Class to RelationalTime/App (msec) Classical2.6 Lifted288.6 Slowdown128.5 AddGetTime/App (msec) Classical0.5 Lifted12.5 Slowdown27.7 Some slowdown but much better than applying to all 15,360 products! 32Lifting Transformations to Product Lines
Scalability Study (RQ) How does lifted rule execution time scale with: 1. Size of product line (# of features) 2. Size of transformation rule (# of elements) Method Varying product lines : use the S.P.L.O.T. feature model repository 359 real feature models from 9 to 290 features Varying rules: use 7 rules of varying sizes from the literature Problem: domain models/presence conditions hard to find! Solution: simulate using random rule matching Tuned various parameters using the Car Crash Product Line example Details available online 33Lifting Transformations to Product Lines
Results – time vs. features # of match elements 34Lifting Transformations to Product Lines Time seems to increase with rule size and then suddenly drops! Time increase close to linear with # of features
Results - # UNSAT vs. features 35Lifting Transformations to Product Lines # of match element s Reason: larger rules have more fast UNSAT results
Summary Product lines and transformations help manage software development But, using existing transformations with product lines is a challenge Possible solutions Always apply transformation after configuration extra maintenance, lose analysis capability Apply transformation to all products and merge expensive Manually redevelop transformation for product line high effort and error prone Our solution: automated lifting of transformation to product line lifting reinterprets transformation execution semantics 36Lifting Transformations to Product Lines
Summary Cont’d Lifting Transformations to Product Lines37 Preliminary evaluation shows a clear benefit Automation eliminates effort and potential for error Lifted transformations are slower but orders of magnitude faster than applying to all products Scales well with increasing feature model size
Next Steps More extensive evaluation Extending the approach To richer transformation languages with control flow pragmatic transformation languages (e.g., ATL) To richer product line languages E.g., Common Variability Language 38Lifting Transformations to Product Lines
Thank you Lifting Transformations to Product Lines39