Institute for Software Integrated SystemsVanderbilt University
A MetaA Meta--model based Model model based Model Transformation Tool: GReAT and Transformation Tool: GReAT and
Code Generator: the GReAT CompilerCode Generator: the GReAT Compiler
Attila Vizhanyo
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 2/17
OverviewOverview
! MIC Recap! Model-to-model transformations as a GRT problem! Universal Data Model (UDM)! Graph Rewriting and Transformation (GReAT)! Code Generator (CG)
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 3/17
MIC: DomainMIC: Domain--Specific MDASpecific MDA
Tool Integration
Metamodeling
Analysis
Execution
Metamodels
Domainmodels
Translation
Synthesis & Generation
Model-ModelTransformations
Domain-specific modeling
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 4/17
Design challenges of the generic Design challenges of the generic model transformation tool model transformation tool
! Precise specification on categories of models! Categories= Domains (= Metamodels in MIC)
! The input & output models typically conform to different metamodels! Support heterogeneous domains! Cross references between domains (temporary
domain)! Automated generation of executable model
transformer code from the specification! Acceptable runtime performance! Simple semantics, usability
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 5/17
Graph TransformationsGraph Transformations
! Represent models with graphs! Graph grammars and transformations
! Over 30 years of research -- Node & Hyper edge replacement --Algebraic approaches -- Programmed graph replacement systems. Systems: PROGRES, AGG
! Graph transformations can be used to generate domain-specific model transformers
! Traditional transformation approaches cannot be applied directly
Output Graph
A
B
C
D
E
Text File
2 4
3 6
51
Input Graph
4
3 6
51
Input Graph
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 6/17
The UDM FrameworkThe UDM Framework
GME UML
GME/UML Interpreter
UDM.exe XML (Meta) <Uml.dtd>
.cpp .h .dtd
User Program
UDM Generated code
API Meta-objects
XML data file
Validates
UdmCopy
XML MEM MGA
GME
Backends
Binary file
CORBA
Network
Generic API OCL Eval
Metamodeling of data:
UML class diagrams
API Code Generator:Builds C++ “handle”classes
Backends:Generic object implementation
Reflection:Meta-objects
Analyze graph domains for type safetyProgrammatic manipulation of graphs
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 7/17
Metamodel of SourceMetamodel of Target
DS-PI ModelDS-PI Model
Source Models
DS-PS ModelDS-PS Model
Target Model
Model Transformation Specification
Input Output
Describes Describes
Refers to
Refers to
Transformation Modeling
Transformation Execution
Transformation
Mod
el A
PI
MetaMeta
Virtual Machine
Mod
el A
PI
Graph Rewriting & Transformation Graph Rewriting & Transformation ((GReATGReAT) Overview) Overview
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 8/17
The The GReATGReAT LanguageLanguage
! Pattern specification! Patterns with cardinality
! Graph transformation and rewrite! Create New Objects! Delete Objects! Modify Attributes
! High-level control flow! Hierarchy! Sequencing! Recursion! Branching
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 9/17
Pattern specification language & Pattern specification language & Pattern matchingPattern matching
! Time complexity is exponential in the number of pattern vertices and edges
! Optimization: start with at least one known vertex “pivoted pattern matching”
Pattern graph Host graph
T:T1
T:T2
T:T3
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 10/17
Graph transformation languageGraph transformation language
Find and deleteCreate New
Find
! Production (Rule)! Basic transformation entity! UML notation! Ports:
“Reusingpreviouslymatchedobjects”
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 11/17
Control Flow LanguageControl Flow Language
! Sequencing of rules necessary for efficiency! Explicit control flow! Simple semantics! Allows reasoning about
transformation
! Control Constructs! Sequencing! Branching! Hierarchical nesting! Recursion
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 12/17
GReATGReAT Tools:Tools:Transformation EngineTransformation Engine
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 13/17
GReATGReAT Tools:Tools:Code Generator (1/2)Code Generator (1/2)
! Transformation and the metamodels make up the invariant part of the transformation system
TransformationExecutable
Paradigm specific UDM API
Paradigm specific UDM API
10x-100xPERFORMANCE
GAIN
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 14/17
GReATGReAT Tools:Tools:Code Generator (2/2)Code Generator (2/2)
! Each rule is compiled into a C++ class! Ports are implemented with function argument list! Efficient pattern matching with “identity checks”! Quasi C++ syntax tree used to build the code
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 15/17
GReAT in ActionGReAT in Action
Matlab Simulink/ Stateflow to Hybrid Automata
Simulink Stateflow to C code
Hierarchical Concurrent State Machine (HCSM) to Finite State Machine (FSM)
KHORUS to GUDML
Hierarchical Data Flow (HDF) to Flat Data Flow (FDF)
Problem
~2.5K~2570/50Sandeep Neema
~5K~60154/43Aditya Agrawal
~500~821/5Aditya Agrawal
~500~819/10Abdullah Sowayan
~200~311/3Feng Shi
LOCMan hours
Primitive Rules #/ Compound Rules #
Hand codeGReAT
Developer
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 16/17
ConclusionConclusion
! In Domain Specific MDA there are many models & implementations:
Model Transformations are essential!! GReAT for model transformations
! A metamodel based transformation language using graph rewriting and transformations that support multiple graphs (that may belong to different domains) with an efficient implementation is suitable for the specification of model transformers.
! CG generates efficient code! Increase productivity
! Decrease the development time of model transformers
OMG MIC Workshop Oct 12-15, 2004 – Arlington, VA 17/17
Closing RemarksClosing Remarks
Key PublicationsAgrawal A., Karsai G., Ledeczi A.: An End-to-End Domain-Driven Software Development Framework, 18th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), Domain-Driven Development Track, Anaheim, CA, October, 2003.
Karsai G., Agrawal A., Shi F., Sprinkle J.: On the Use of Graph Transformations for the Formal Specification of Model Interpreters, Journal of Universal Computer Science, Special issue on Formal Specification of CBS, 2003.
Agrawal A., Karsai G., Shi F.: Graph Transformations on Domain-Specific Models, Technical report, ISIS, Vanderbilt University, Nashville, TN, 2003.
Vizhanyo A., Agrawal A., Shi F.: Towards Generation of High-performance Transformations, Generative Programming and Component Engineering, Vancouver, Canada, October 24, 2004.
GReAT and UDM Download URL:http://www.isis.vanderbilt.edu/projects/mobies/downloads.asp