SlideShare uma empresa Scribd logo
1 de 80
Baixar para ler offline
MULTI-LEVEL MODELLING
FOR MODEL-DRIVEN
ENGINEERING
MULTI’2021
Juan de Lara
with contributions from
E. Guerra and J. Sánchez Cuadrado
miso research group
Universidad Autónoma de Madrid (Spain)
@miso_uam
http://miso.es
WHAT IS THE TALK ABOUT?
2
Model-Driven Engineering
• Models are core assets of development
• Frequently built using DSLs, based on domain meta-models
• Transformed (in-place, out-place), refined into code, etc
• Mainstream modelling approach is two-level (meta-models/models)
Meta-model1
model1
«conforms to»
model2
Meta-model2
«conforms to»
model-to-model
in-place
code-gen
code
OCL
invariants
OCL
invariants
WHAT IS THE TALK ABOUT?
3
Multi-level modelling
• More than two meta-levels at a time
• Meta-levels can influence other levels beyond the immediate one
• Simplifies modelling in some scenarios
ProductType@2
VAT@1: double
price: double
Book: ProductType
VAT=18.0
price=10.0
mobyDick: Book
two-level multi-level
Can we use Multi-
Level modelling for
Model-driven
Engineeering?
4
YES, BUT WE NEED...
5
Suitable scenarios for M(LM)DE
Multi-level:
• Constraints
• Transformations
• Code generators
• DSLs
Supporting tools
AGENDA
6
Basic concepts of (potency-based) multi-level modelling
• Motivation and real world applicability
• Clabjects, potency, levels, OCA
• Examples
Tool Support: MetaDepth
• Case study: game development
Multi-level model management
• Constraints, transformations, code generation
• Multi-level DSLs
Advanced concepts
MOTIVATION
Sometimes, one needs to explicitly model meta-modelling
facilities, like:
• Instantiation (modelling both types and objects)
• Declaration and instantiation of attributes and references
• Inheritance
For example:
• Product types and instances [e-commerce applications]
• Task types and instances [process modelling languages]
• Component types and instances [architectural languages]
• Player types and instances [gaming applications]
• …
7
EXAMPLE
8
Model product types (books, CDs) and their instances, to be
added on demand. Product types have a VAT, while
instances have a price.
Explicit modelling of types and instances
• Types can be added dynamically
• Features of types are fixed and known a priori
Common modelling pattern, also known as: Type object
[Martin et. al 97], item descriptor [Coad 1992], metaobject
[Kiczales and Rivieres 1991]
TWO-LEVEL SOLUTIONS
9
ProductType
Book
vat: double {readonly}
price: double
vat : double =4.0
GoF: Book
price = 35
Static types
Requirements
not satisfied
ProductType
vat: double
Product
price: double
type
1
Book: ProductType
vat = 4.0
:type
GoF: Product
price = 35
Explicit types
Complex
meta-model
Book
type facet
GoF: Book
price = 35
Product
price: double
ProductType
vat: double
instance facet
Book:ProductType
vat=4.0
Promotion transformation
Requires a transformation
Hides information
MULTI-LEVEL SOLUTION
10
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
Instantiation semantics is fixed
Elements with instance and type
facets at the same time
Simplicity (less objects)
ProductTypes can be extended
with additional features,
dynamically
wait!
But does this
scenario occur often
in practice?
11
MULTI-LEVEL
PATTERNS
12
Patterns signalling that a multi-level solution could be
beneficial
Emulate a meta-modelling facility within a meta-model:
• Type-object: typing and instantiation
• Dynamic features: feature definition and instantiation
• Dynamic auxiliary domain concepts: class definition and
instantiation
• Relation configurator: Reference cardinality and its semantics
• Element classification: Inheritance
In multi-level these facilities are native at every meta-level
J. de Lara, E. Guerra, J. Sánchez Cuadrado: When and How to Use Multilevel Modelling.
ACM Trans. Softw. Eng. Methodol. 24(2): 12:1-12:46 (2014)
PRACTICAL APPLICABILITY
How often do these patterns occur?
Analysis of >400 meta-models from:
• ATL meta-model zoo (305 meta-models) [8.5% occur.]
• OMG specifications (116 specs) [35%~38% occur.]
• ReMoDD (15 meta-models) [20% occur.]
• Articles in journals/conferences
84 meta-models with 459 occurrences (avg 5.5)
• Most common pattern is the type-object
• Most used solution is explicit types (~70%)
13
WHERE?
14
19
17
13
4
4
3
3
3
2 3
Enterprise/Process Modelling
Software Architecture
Systems/Software Modelling
Manufacturing
Reverse Engineering
Data modelling
Requirements
Bibliographic
Traceability
Metrics
#META-MODELS
153
85
48
46
19
14
10 9 8
4
#PATTERN
OCCURRENCES
WHERE?
Software architecture,
components and
services
• Component types and
instances, port types and
instances
• Mostly explicit types
solution
15
Example: CloudML
EXPLICIT TYPES TO MULTI-LEVEL
16
• CloudML (6 T-O, 1 DF)
• 14 classes
• Multi-level solution
• 6 classes
Multi-level modelling
the basics
17
CLABJECT =
CLASS + OBJECT
Elements have a combined type and instance facet
Book
• Instance of ProductType
• Can provide a value for vat
• Type for GoF
• Can declare new features
• (We’ll see how, using the OCA)
ProductType has type facet only
GoF has instance facet only
18
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
C. Atkinson and T. Kühne. 2001. The essence of multilevel metamodeling. UML’01 (LNCS), Vol.
2185. Springer, 19–33.
POTENCY
Used to characterize instances beyond the
next meta-level
Models, clabjects and their features have a
potency
• Natural number (or zero)
• Decreased at each lower meta-level
• Indicates at how many meta-levels the
element can be instantiated
We use the “@potency” notation
By default elements take the potency of their
containers
19
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
C. Atkinson and T. Kühne. 2001. The essence of multilevel metamodeling. UML’01 (LNCS), Vol.
2185. Springer, 19–33.
LEVEL
Refers to the potency of the model
A model with level L can hold elements with potency  L
20
ProductType
Book:
ProductType
GoF: Book
price: double
price = 35
@2
@1
@0
TaxKind@1
value: double
tax@1
0..1
SuperReduced:
TaxKind
value = 6.0
Reduced:
TaxKind
value = 10.0
:tax
General:
TaxKind
value = 21.0
ORTHOGONAL
CLASSIFICATION (OCA)
21
Linguistic
meta-model
(meta-modelling
facilitites)
…
Meta-meta-model
(meta-modelling facilitites)
Meta-model
Model
MM
M
MM
M
M’
«instance of» (onto)
«instance of» (onto)
«instance
of»
(ling)
«instance
of»
(ling)
«instance
of»
(ling)
«instance of»
«instance of»
• Dual typing (ontological, linguistic)
• Make meta-modelling facilities
available at every meta-level
• Types and meta-modelling
facilities only at the meta-model
level
Multi-level Two-Level (eg., EMF)
C. Atkinson, T. Kühne. 2002. Rearchitecting the UML infrastructure. ACM Trans. Model. Comput.
Simul. 12, 4 (2002), 290–321.
22
ORTHOGONAL
CLASSIFICATION (OCA)
Clabject
*
supers
Instance
Type
potency: int
vat@1: double
price: double
ProductType
vat = 4.0
Book:
ProductType
@1
price = 35
GoF: Book
@0
type
*
*
@2
ont
instanceOf
Linguistic meta-model
(very simplified)
*
Feature
«ling.
instanceOf»
ont
instanceOf
Model
*
0..1
23
LINGUISTIC VIEW
Clabject
*
supers
Instance
Type
potency: int
type
*
*
Linguistic meta-model
(very simplified)
*
Feature
«ling.
instanceOf»
Model
*
L2: Model
vat: Feature
potency=2
ProductType: Clabject
potency=2
potency=1
price: Feature
potency=2
L1: Model
potency=1
:type
Book: Clabject
potency=1
price1: Feature
potency=1
vat: Feature
potency=0
:type
:type
L0: Model
potency=0
GoF: Clabject
potency=0
price0: Feature
potency=0
:type
:type
:type :type
0..1
de Lara, Guerra. 2010. Deep meta-modelling with
metaDepth. In TOOLS’10 (LNCS), Vol. 6141.
Springer, 1–20.
24
LINGUISTIC
EXTENSIONS
Elements with no ontological type
• Ontological typing is optional
• Linguistic typing is mandatory
New clabjects or features
Not everything can be anticipated
at the top-most level
Author
Book:
ProductType
GoF: Book
vat@1: double
price: double
price = 35
numPages = 395
@2
@1
@0
vat=4.0
numPages : int
ProductType
name: String
books
*
eg: Author
name=“Gamma”
:books
eg: Author
name=“Johnson”
:books
Examples
25
DOMAIN SPECIFIC PROCESS
MODELLING
26
TaskKind Resource
Kind
Performer
Kind
Artefact
Kind
GatewayKind
Seq Join Fork
ins outs
*
src
tar perfBy
*
*
*
*
name@1: String
initial:Boolean=false
final:Boolean=false
timeStamp:Date
duration:double
DSPM@2
DOMAIN SPECIFIC PROCESS
MODELLING
27
DSPM@2
Attend :TaskKind
name=“attend classes”
Study :TaskKind
name=“study”
Preparation:TaskKind
name=“preparation”
P2P:Seq
Exam :TaskKind
name=“do exam”
S2E:Seq
Subject
name: String
level: int
subs
1
on
1
src
tar
src tar
TaskKind Resource
Kind
Performer
Kind
Artefact
Kind
GatewayKind
Seq Join Fork
ins outs
*
src
tar perfBy
*
*
*
*
name@1: String
initial:Boolean=false
final:Boolean=false
timeStamp:Date
duration:double
Edu-PML@1
de Lara, Guerra, Sánchez Cuadrado. Model-driven engineering with domain-specific meta-
modelling languages. Software and System Modeling 14(1): 429-459 (2015)
28
DSPM@2
Attend :TaskKind
name=“attend classes”
Study :TaskKind
name=“study”
Preparation:TaskKind
name=“preparation”
P2P:Seq
Exam :TaskKind
name=“do exam”
S2E:Seq
Subject
name: String
level: int
subs
1
on
1
src
tar
src tar
TaskKind Resource
Kind
Performer
Kind
Artefact
Kind
GatewayKind
Seq Join Fork
ins outs
*
src
tar perfBy
*
*
*
*
name@1: String
initial:Boolean=false
final:Boolean=false
timeStamp:Date
duration:double
Maths: Subject
name: “Maths”
level: 1
: Attend : Study : Exam
:P2P :S2E
initial=true
timeStamp=1/07/12
duration=2
timeStamp=08/07/12
duration=2
final=true
timeStamp=10/07/12
duration=1
Edu-PML@1
Proc@0
DOMAIN SPECIFIC PROCESS
MODELLING
29
TaskKind Resource
Kind
Performer
Kind
Artefact
Kind
GatewayKind
Seq Join Fork
ins outs
*
src
tar perfBy
*
*
*
*
name@1: String
initial:Boolean=false
final:Boolean=false
timeStamp:Date
duration:double
DSPM@2
DOMAIN SPECIFIC PROCESS
MODELLING
30
DSPM@2
TaskKind Resource
Kind
Performer
Kind
Artefact
Kind
GatewayKind
Seq Join Fork
ins outs
*
src
tar perfBy
*
*
*
*
name@1: String
initial:Boolean=false
final:Boolean=false
timeStamp:Date
duration:double
Soft-PML@1
Coding: TaskKind tests: next
1..*
Testing: TaskKind
name=“testing”
SoftwareEngineer:
PerformerKind
actor: perfBy
@1
SETask: TaskKind
*
Programmer:
PerformerKind
Tester:
PerformerKind
skills: String[*]
name=“se-task”
ADVANTAGES
The top level can be customized for the process domain
• Family of DSLs for process modelling
Transformations can be defined over the top level and reused
across the whole family
• Code generators
• Model-to-model transformations
• In-place transformations
• Queries
31
COLLABORATIVE WEB
APPLICATIONS
32
COLLABORATIVE WEB
APPLICATIONS
33
de Lara, Guerra, Cobos, Moreno-Llorena: Extending Deep Meta-Modelling for
Practical Model-Driven Engineering. Comput. J. 57(1): 36-58 (2014)
ARCADE/ADVENTURE GAMES
34
Sabre Wulf Pacman
Atic atac Gauntlet
Commando
35
TileKind ElementKind
CharacterKind
EvilKind HeroKind
TreasureKind
initLives@1: int = 3
lives: int = 3
score: int = 0
next
*
elements
*
ArcadeGame@2
MLM FOR ARCADE GAMES
Cell: TileKind
nextCell: next
*
coin: elements
0..1
Castle: TileKind
Coin: TreasureKind
value: int = 10
Pacman: HeroKind
Ghost: EvilKind
pacman: elements
0..1
ghosts: elements
*
Pacman@1
36
RuntimePacman@0
MLM FOR ARCADE GAMES
c0: Cell
c1: Cell
c2: Cell
c3: Castle
c4: Cell
:nextCell
:nextCell :nextCell
:nextCell
:nextCell
:nextCell
:nextCell
:nextCell
:nextCell
:nextCell
co1: Coin
co2: Coin
co3: Coin
value=20
co4: Coin
co0: Coin
g: Ghost
p: Pacman
AGENDA
37
Basic concepts of (potency-based) multi-level modelling
• Motivation
• Clabjects, potency, levels, OCA
• Examples
Tool Support: MetaDepth
• Case study: game development
Multi-level model management
• Constraints, transformations, code generation
• Multi-level DSLs
Advanced concepts
TOOLS!
38
...
(and more!)
Jácome-Guerrero, de Lara: TOTEM: Reconciling multi-level modelling with standard
two-level modelling. Comput. Stand. Interfaces 69: 103390 (2020)
Textual multi-level modelling tool with a REPL
• Started in 2009
• Deep characterization based on clabjects/potency
• Orthogonal Classification Architecture
• http://metaDepth.org
Integrated with the Epsilon Languages for model management
• Constraints in EOL/EVL
• Derived attributes in EOL
• In-place transformations in EOL
• Model-to-model transformations in ETL
• Code generation in EGL
39
de Lara, Guerra: Deep Meta-modelling with MetaDepth. TOOLS (48) 2010: 1-20
METADEPTH
40
Model Ecommerce@2 {
Node ProductType {
vat@1 : double=10;
price : double=7.5;
}
}
Ecommerce BookStore{
ProductType Book { vat = 4.0; }
}
BookStore WHSmith {
Book GoF { price = 35; }
}
ProductType
Book:
ProductType
GoF: Book
vat@1: double=10
price: double=7.5
vat=4.0
price = 35
@2
@1
@0
SAMPLE SESSION
> load “ProductSimple”
:: loading ../metadepth.samples/ProductSimple.mdepth
(6 clabjects created in 0.22 s).
> dump
:: dumping all
… (shows the models in memory)
> compile PlantUML
Executing...
:: compiling all models to PlantUML format,
generated file ./Ecommerce.txt
41
(generated png
by PlantUML)
LINGUISTIC META-MODEL
42
DERIVED FIELDS
Model Store@2 {
Node ProductType{
vat@1 : double = 7.5;
price : double = 10;
/finalPrice@2: double = $self.vat*self.price/100 +self.price$;
}
}
43
Computation expressions for derived fields using the Epsilon
Object Language (EOL)
Derived fields with primitive type, or references
RUNNING EXAMPLE (1)
44
Model ArcadeGame@2 {
Node TileKind {
next : TileKind[*];
elements : ElementKind[*];
}
abstract Node ElementKind{}
abstract Node CharacterKind : ElementKind { }
Node HeroKind : CharacterKind {
initLives@1 : int = 3;
lives : int = 3;
score : int = 0;
}
Node EvilKind : CharacterKind {}
Node TreasureKind : ElementKind {}
}
RUNNING EXAMPLE (2)
45
ArcadeGame PacMan {
TileKind Cell {
nextCell : Cell[*] {next};
coin : Coin[0..1] {elements};
pacman : Pacman[0..1] {elements};
ghosts : Ghost[*] {elements};
}
TileKind Castle : Cell {}
TreasureKind Coin {
value : int=10;
}
HeroKind Pacman {
initLives = 3;
}
EvilKind Ghost {}
}
TileKind
Element
Kind
elements
*
Cell:
TileKind
Coin:
Element
Kind
coin:
elements
0..1
@2
Pacman:
Element
Kind
0..1
pacman:
elements
...
RUNNING EXAMPLE (3)
46
PacMan RuntimePacman {
Cell c0 { nextCell = [c1, c4]; coin = co0; pacman = p; }
Cell c1 { nextCell = [c2, c0]; coin = co1; }
Cell c2 { nextCell = [c3, c1]; coin = co2; }
Castle c3{ nextCell = [c4, c2]; coin = co3; ghosts = g; }
Cell c4 { nextCell = [c0, c3]; coin = co4;}
Pacman p {}
Ghost g {}
Coin co0 {}
Coin co1 {}
Coin co2 {}
Coin co3 { value = 20; }
Coin co4 {}
}
AGENDA
47
Basic concepts of (potency-based) multi-level modelling
• Motivation
• Clabjects, potency, levels, OCA
• Examples
Tool Support: MetaDepth
• Case study: game development
Multi-level model management
• Constraints, transformations, code generation
• Multi-level DSLs
Advanced concepts
CONSTRAINTS
MetaDepth uses the Epsilon Object Language (EOL) to
express constraints
• Also for operations and expressions for derived fields
EOL is a variant of OCL
• Permits side effects (assignments, object creation)
• Has imperative constructs (e.g., loops)
The basis of other Epsilon languages
• ETL for model-to-model transformation
• EGL for code generation
48
DEEP CONSTRAINT
LANGUAGE
Level at which the constraint is defined vs level at which we want to
evaluate it
• Constraints have “potency”
49
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
posPrice@2:
self.price>0
defined
evaluated
DEEP CONSTRAINT
LANGUAGE
Level at which the constraint is defined vs level at which we want to
evaluate it
• Constraints have “potency”
50
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 0
@2
@1
@0
posPrice@2:
self.price>0
defined
evaluated
51
TRANSITIVE TYPING
We might not know type names at intermediate levels
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
lotsOfProducts@2:
ProductType.allInstances()->
size()>10
defined
CD:
ProductType
vat=10.0
Disintegration:
CD
price = 20
evaluated
TYPE.allInstances() returns all
direct and indirect instances of
TYPE at the current level
LEVEL NAVIGATION
Make (upwards) meta-level navigation implicit
• At level 0:
> GoF.vat.println();
> 4.0
Fields with instance facet in clabjects can be
accessed in instance clabjects.
52
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
LINGUISTIC META-
MODEL
Transparent access to the linguistic meta-model in constraint
expressions
53
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
lotsOfProducts@2:
self.type.allInstances()->
size()>10
defined
evaluated
Node
*
supers
Instance
Type
potency: int
type
*
*
Linguistic meta-model
(simplified)
*
Feature
«ling.
instanceOf»
^ prefix can be used to
prevent name collisions:
self.^type…
LINGUISTIC META-
MODEL
Transparent access to the linguistic meta-model in constraint
expressions
54
ProductType
Book:
ProductType
GoF: Book
vat@1: double
price: double
vat=4.0
price = 35
@2
@1
@0
lotsOfProducts@2:
self.type.allInstances()->
size()>10
defined
evaluated Node
*
supers
Instance
Type
potency: int
type
*
*
Linguistic meta-model
(simplified)
*
Feature
«ling.
instanceOf»
lotsOfProducts2@2:
ProductType.allInstances()->
size()>10
vs.
evaluated
lotsOfNodes@2:
Node.allInstances()-> size()>10
vs.
RUNNING EXAMPLE
We’ll add a few constraints to ensure that:
• There are no isolated tiles at level 0
• Treasures, Heroes and Evils are connected to one tile at level 0
• There is at least one hero at level 0
• There are no less evils than heroes at level 0
• There can be no Pacman in the castle
A derived attribute to calculate the number of (direct) reachable
tiles at level 0.
55
56
Model ArcadeGame@2 {
Node TileKind {
next : TileKind[*];
elements : ElementKind[*];
/numReachable : int = $self.next.size()$;
noIsolated : $self.numReachable>0 or
TileKind.all.exists( t | t.next.includes(self))$
}
abstract Node ElementKind{
connected : $TileKind.all.one( t | t.elements.includes(self))$
}
abstract Node CharacterKind : ElementKind { }
Node HeroKind : CharacterKind {
initLives@1 : int = 3;
lives : int = 3;
score : int = 0;
}
Node EvilKind : CharacterKind {}
Node TreasureKind : ElementKind {}
someHero@2 : $HeroKind.all.size()>=1$
moreEvils@2 : $EvilKind.all.size() >= HeroKind.all.size()$
}
RUNNING EXAMPLE
(LEVEL 2)
no isolated tiles at level 0
treasures, heores and evils are connected to exactly one tile
(global constraints) at least one hero, more evils than heroes
57
ArcadeGame PacMan {
TileKind Cell {
nextCell : Cell[*] {next};
coin : Coin[0..1] {elements};
pacman : Pacman[0..1] {elements};
ghosts : Ghost[*] {elements};
}
TileKind Castle : Cell {
noPacmans : $not self.pacman.isDefined()$
}
TreasureKind Coin {
value : int=10;
}
HeroKind Pacman {
initLives = 3;
}
EvilKind Ghost {
}
}
Conflicts and consistency of (ML) constraints
can be analyzed:
Guerra, de Lara: Automated analysis of integrity
constraints in multi-level models. Data Knowl.
Eng. 107: 1-23 (2017)
RUNNING EXAMPLE
(LEVEL 1)
no Pacman in the Castle
MULTI-LEVEL MODEL
MANAGEMENT
58
DSMM
model
DSML
model
Model
operation
DSMM
model
DSML
model
Model
operation
DSMM
model
DSML
model
Model
operation
DSMM
model
DSML
model
Model
operation
operation’
Node
Clabject
defined on applicable to redefines
Legend
Deep operations Refinement Generic
IN-PLACE MODEL
TRANSFORMATION
59
Infrastructure for a family of DSLs
• Operations can be attached to meta-classes
• Operations with potency
Design similar to an object oriented framework
• Common operations
• Operations expected to be overriden at next meta-level
For the running example:
• A game engine for the DSL (autonomous play)
• Core of the engine will be common (basic movement rules, game over
and winning condition)
• Some operations can be overriden at level 1 (ie., particular to Pacman)
60
ElementKind
EvilKind HeroKind
ArcadeGame@2
ARCADE GAME SIMULATOR
Pacman: HeroKind
Ghost: EvilKind
Pacman@1
main()
checkDamaged(h: HeroKind) : Boolean
isDamaged(): Boolean
TileKind
elements
hasEvils(): Boolean
removeHero(h: HeroKind)
addHero(h: HeroKind)
*
getCurrentTile(): TileKind
...
Cell: TileKind
eatCoin(h: HeroKind)
removeHero(h: HeroKind)
addHero(h: HeroKind)
0..1
pacman: elements
0..1
ghosts: elements
...
return
TileKind.all.select( t |
t.elements.includes(self)).
first();
return getCurrentTile().hasEvils();
return elements.exists( e |
e.isKindOf(EvilKind));
self.pacman:=null;
self.pacman:= h;
self.eatCoin(h);
OTHER APPROACHES
Multecore (https://ict.hvl.no/multecore/)
• A tool for MLM within Eclipse
• Graphical modelling
• Formal theory based on graph
transformation [WMR20]
• By translation into rewriting logic (MAUDE)
61
Wolter, Macías, Rutle: Multilevel Typed Graph Transformations. ICGT 2020, 163-182
MODEL-TO-MODEL
TRANSFORMATION
Many scenarios:
• Deep transformations (eg. defined at @2, applied at @0)
• Co-transformations (eg. defined at @2, applied at @1 and @0)
• Refining transformations (overriding rules at @1)
• Reflective & linguistic transformations (generic, using linguistic
types)
• Multi-level target (eg. creating models at @1 and @0)
For the running example:
• A (deep) transformation into Petri nets
• Reusable for any concrete adventure game
62
de Lara, Guerra, Sánchez Cuadrado. Model-driven engineering with domain-specific meta-modelling
languages. SoSyM 14(1): 429-459 (2015)
MODEL-TO-MODEL
TRANSFORMATION
63
@metamodel(name=ArcadeGame,file=Arcade.mdepth,domain=source)
@metamodel(name=PetriNet,file=PetriNet.mdepth,domain=target)
rule CharacterToToken
transform h : SLevel0!CharacterKind
to p : Target!Token {
p.^name := h.^type+'_'+h.^name;
}
rule TileToPlace
transform t : SLevel0!TileKind
to p : Target!Place {
p.name := t.type.name+'_'+t.^name;
p.^name := t.type.name+'_'+t.^name;
p.tokens ::= t.elements;// implicit call to equivalents()
for ( n in t.next) {
var tr := new Target!Transition;
tr.name := t.^name+' to '+n.^name;
tr.^name := t.^name+'_to_'+n.^name;
p.outTr := tr;
n.equivalents().first().inTr := tr;
}
}
c1: Cell
h:
Pacman
c2: Cell
:nextCell
:pacman
Pacman_h
: Token
Cell_c1:
Place
Cell_c2:
Place
:tokens
: Transition
:outTr
:inTr
@0
ArcadeG
Pacman
Game
Petri nets
Net
@2
@1
@0
rules
@1
@0
MODEL-TO-MODEL
TRANSFORMATION
64
@metamodel(name=ArcadeGame,file=Arcade.mdepth,domain=source)
@metamodel(name=PetriNet,file=PetriNet.mdepth,domain=target)
rule CharacterToToken
transform h : SLevel0!CharacterKind
to p : Target!Token {
p.^name := h.^type+'_'+h.^name;
}
rule TileToPlace
transform t : SLevel0!TileKind
to p : Target!Place {
p.name := t.type.name+'_'+t.^name;
p.^name := t.type.name+'_'+t.^name;
p.tokens ::= t.elements;// implicit call to equivalents()
for ( n in t.next) {
var tr := new Target!Transition;
tr.name := t.^name+' to '+n.^name;
tr.^name := t.^name+'_to_'+n.^name;
p.outTr := tr;
n.equivalents().first().inTr := tr;
}
}
c1: Cell
h:
Pacman
c2: Cell
:nextCell
:pacman
OTHER APPROACHES
Melanee (http://www.melanee.org)
• A tool for MLM within Eclipse
• Graphical modelling (and more)
• Enhancement of the ATL
transformation language for
multi-level modelling [AGT15]
65
Atkinson, Gerbig, Tunjic. Enhancing classic transformation languages to support multi-
level modeling. Softw. Syst. Model. 14(2): 645-666 (2015)
…
CODE GENERATION
66
<!doctype html>
<html>
<head>
…
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet([
[% var counter : Integer := 0;
// Generic
for(t in Level0!Node.all) {
counter := counter+1;
%]
[%if (counter > 1) {%], [%}%]
{id: [%=counter%],
label: '[%=t.type%] [%=counter%]'}
[% t.~identif := counter; %]
[%}%]
]);
…
</html>
Visualization of the game
• vis.js (http://visjs.org)
Code generator
• Deep (reusable for the DSL)
• Generic (linguistic types)
ArcadeG
Pacman
Game
@2
@1
@0
code gen
def
apply
html+js
GENERATED CODE
67
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet([
{id: 1, label: 'Coin 1'}
, {id: 2, label: 'Coin 2'}
, {id: 3, label: 'Coin 3'}
, {id: 4, label: 'Coin 4'}
, {id: 5, label: 'Coin 5'}
, {id: 6, label: 'Pacman 6'}
, {id: 7, label: 'Ghost 7'}
, {id: 8, label: 'Castle 8'}
, {id: 9, label: 'Cell 9'}
, {id: 10, label: 'Cell 10'}
, {id: 11, label: 'Cell 11'}
, {id: 12, label: 'Cell 12'}
]);
AGENDA
68
Basic concepts of (potency-based) multi-level modelling
• Motivation
• Clabjects, potency, levels, OCA
• Examples
Tool Support: MetaDepth
• Case study: game development
Multi-level model management
• Constraints, transformations, code generation
• Multi-level DSLs
Advanced concepts
CUSTOMIZING THE TEXTUAL
SYNTAX
69
MetaDepth supports a uniform textual concrete syntax
accross meta-levels.
Define customized syntax
• Pen(8%) instead of
• Product Pen {VAT=8;}
Challenges imposed by a
multi-level setting.
DSMM model @2
DSML model @1
Model @0
Syntax
Templates @1
Syntax
Templates @2
Refining
Templates @1
defined on defines syntax for
TEXTUAL
CONCRETE
SYNTAX
70
Syntax for Ecommerce [".ecommerce_mm"] {
template@1 TEcommerce for Model Ecommerce:
“id ‘{’ &TProduct * ‘}’ ”
template@1 TProduct for Node Product:
“id ‘(’ #VAT ‘%’ ‘)’ ”
}
strict Model Ecommerce@2 {
strict Node Product {
VAT@1 : double;
price : double;
}
}
Syntax for Ecommerce [".ecommerce"] {
template@2 DeepProds for Model Ecommerce:
“typename id ‘{’ &DeepProd * ‘}’ ”
template@2 DeepProd for Node Product:
“typename id ‘(’ #price ‘€’ ‘)’ ”
}
Stationer {
Pen(8%)
}
Stationer WHSmith {
Pen parker(5.0€)
}
Meta-Level 2
Meta-Level 1
Meta-Level 0
REFINEMENT
TEMPLATES
71
template@1 TNail for Node Nail:
“id ‘(’ #price ‘€’ ‘,’ #caliber ‘,’ #length ‘)’ ”
strict Model Ecommerce@2 {
Node Product {
VAT@1 : double;
price : double;
}
}
Hardware {
Nail (8.0%){
caliber: double;
length: double;
bigger: $self.caliber>=0.1$
}
}
We can design a special syntax for specific
clabjects of potency 1
Hardware DoItBest {
n1(0.1€, 0.1, 10)
}
GRAPHICAL
CONCRETE SYNTAXES
Melanee
• Graphical
• Form-based
• Virtual Reality
72
Atkinson, Gerbig: Aspect-oriented Concrete Syntax Definition for Deep Modeling
Languages. MULTI@MoDELS 2015: 13-22
Gerbig: Deep, Seamless, Multi-format, Multi-notation Definition and Use of Domain-specific
Languages. University of Mannheim, Germany, Dr. Hut 2017
AGENDA
73
Basic concepts of (potency-based) multi-level modelling
• Motivation
• Clabjects, potency, levels, OCA
• Examples
Tool Support: MetaDepth
• Case study: game development
Multi-level model management
• Constraints, transformations, code generation
• Multi-level DSLs
Advanced concepts
MULTI-LEVEL
REFACTORINGS
74
Refactoring multi-level models. 2018. Juan de Lara, Esther Guerra. ACM
Transactions on Software Engineering and Methodology, Vol 27(4)
75
MULTI-LEVEL
REFACTORINGS
Refactoring multi-level models. 2018. Juan de Lara, Esther Guerra. ACM
Transactions on Software Engineering and Methodology, Vol 27(4)
MULTI-LEVEL MODEL
PRODUCT LINES
ML languages
with variability
Users can
configure the
76
de Lara, J., Guerra, E. Language Family Engineering with Product Lines of
Multi-level Models. Form Asp Comp (2021).
languages at different levels using a multi-level feature model
Open variability: instantiation
Closed variability: configuration
77
Language
Family
Designer
DSL-2 Designer DSL-1 Designer
instantiates
Language
family
MM
Model
ProcessLanguage
Gateways
object
simple initial enactment
Tasks
@0 @1 @2
variability
ProcessLanguage
enactment
Tasks
@0
variability
DSL-2 Users
Level 2
Level 1
creates
Level 0
DSL-1 Users
1
4b
Specialized
language
family MM
variability
2b
specializes
DSL-2
MM
variability
3b
Specialized
DSL-2
MM
variability
ProcessLanguage
enactment
Tasks
@1
5b
Model
variability
6b
specialize
specialize
2a
DSL-1
MM
variability
instantiates 3a
Fully
specialized
language
family MM
variability
Model
variability
instantiate 4a
instantiate
ProcessLanguage
initial enactment
Tasks
@1
@0
specializes
empty
empty
empty
empty
USING MULTI-LEVEL
MODEL PRODUCT LINES
CONCLUSIONS AND
SUMMARY
Multi-level modelling
• Simplifies modelling in some scenarios
• Relevant in practice (OMG specs, process modelling, architectural
languages)
Families of DSLs
• Common semantics and services
• Defined through MDE techniques
Tooling
• MetaDepth (but many others are available)
78
WHAT’S NEXT?
Use in real projects
• (Large) case study reports
• Is potency flexible enough in practice?
Bridges with two-level modelling
• EMF
• Automated rearchitecture from 2-level into multi-level
Bridges between multi-level modelling tools
• Interoperability with other tools
79
THANKS!
Juan.deLara@uam.es
80
http://www.miso.es
@miso_uam
https://metadepth.org/

Mais conteúdo relacionado

Semelhante a Multi21

MDE-experiments
MDE-experimentsMDE-experiments
MDE-experimentsmiso_uam
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2Julie Iskander
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsShanmuganathan C
 
Model-driven Development of Model Transformations
Model-driven Development of Model TransformationsModel-driven Development of Model Transformations
Model-driven Development of Model TransformationsPieter Van Gorp
 
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)Jordi Cabot
 
Model Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in ScalaModel Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in ScalaFilip Krikava
 
Model Execution: Past, Present and Future
Model Execution: Past, Present and FutureModel Execution: Past, Present and Future
Model Execution: Past, Present and FutureBenoit Combemale
 
Object Oriented Programming with COBOL
Object Oriented Programming with COBOLObject Oriented Programming with COBOL
Object Oriented Programming with COBOLMicro Focus
 
Math with .NET for you and Azure
Math with .NET for you and AzureMath with .NET for you and Azure
Math with .NET for you and AzureMarco Parenzan
 
Modelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdfModelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdfCarlos Paredes
 
Eclipse IoT - Day 0 of thingmonk 2016
Eclipse IoT - Day 0 of  thingmonk 2016Eclipse IoT - Day 0 of  thingmonk 2016
Eclipse IoT - Day 0 of thingmonk 2016Boris Adryan
 
Open travel 2-0_introduction_jan_2014_slideshare
Open travel 2-0_introduction_jan_2014_slideshareOpen travel 2-0_introduction_jan_2014_slideshare
Open travel 2-0_introduction_jan_2014_slideshareOpenTravel Alliance
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patternsJeremy Duvall
 
A peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserA peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserKoan-Sin Tan
 

Semelhante a Multi21 (20)

MDE-experiments
MDE-experimentsMDE-experiments
MDE-experiments
 
MLMPLs
MLMPLsMLMPLs
MLMPLs
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
Model-driven Development of Model Transformations
Model-driven Development of Model TransformationsModel-driven Development of Model Transformations
Model-driven Development of Model Transformations
 
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
 
Model Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in ScalaModel Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in Scala
 
Model Execution: Past, Present and Future
Model Execution: Past, Present and FutureModel Execution: Past, Present and Future
Model Execution: Past, Present and Future
 
Object Oriented Programming with COBOL
Object Oriented Programming with COBOLObject Oriented Programming with COBOL
Object Oriented Programming with COBOL
 
Math with .NET for you and Azure
Math with .NET for you and AzureMath with .NET for you and Azure
Math with .NET for you and Azure
 
Modelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdfModelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdf
 
C++ Basics
C++ BasicsC++ Basics
C++ Basics
 
Eclipse IoT - Day 0 of thingmonk 2016
Eclipse IoT - Day 0 of  thingmonk 2016Eclipse IoT - Day 0 of  thingmonk 2016
Eclipse IoT - Day 0 of thingmonk 2016
 
Open travel 2-0_introduction_jan_2014_slideshare
Open travel 2-0_introduction_jan_2014_slideshareOpen travel 2-0_introduction_jan_2014_slideshare
Open travel 2-0_introduction_jan_2014_slideshare
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patterns
 
A peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserA peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk User
 
Smalltalk.pptx
Smalltalk.pptxSmalltalk.pptx
Smalltalk.pptx
 
Miso
MisoMiso
Miso
 

Mais de miso_uam

Model-driven engineering for AR
Model-driven engineering for ARModel-driven engineering for AR
Model-driven engineering for ARmiso_uam
 
Capone.pdf
Capone.pdfCapone.pdf
Capone.pdfmiso_uam
 
MLE_keynote.pdf
MLE_keynote.pdfMLE_keynote.pdf
MLE_keynote.pdfmiso_uam
 
Scientific writing
Scientific writingScientific writing
Scientific writingmiso_uam
 
Facets_UCM
Facets_UCMFacets_UCM
Facets_UCMmiso_uam
 
Máster en Métodos Formales en Ingeniería Informática
Máster en Métodos Formales en Ingeniería InformáticaMáster en Métodos Formales en Ingeniería Informática
Máster en Métodos Formales en Ingeniería Informáticamiso_uam
 
Analysing-MMPLs
Analysing-MMPLsAnalysing-MMPLs
Analysing-MMPLsmiso_uam
 
Miso-McGill
Miso-McGillMiso-McGill
Miso-McGillmiso_uam
 
Model Transformation Reuse
Model Transformation ReuseModel Transformation Reuse
Model Transformation Reusemiso_uam
 
keynote modelsward 2017
keynote modelsward 2017keynote modelsward 2017
keynote modelsward 2017miso_uam
 
MODELSWARD 2017 Panel
MODELSWARD 2017 PanelMODELSWARD 2017 Panel
MODELSWARD 2017 Panelmiso_uam
 

Mais de miso_uam (20)

Model-driven engineering for AR
Model-driven engineering for ARModel-driven engineering for AR
Model-driven engineering for AR
 
Capone.pdf
Capone.pdfCapone.pdf
Capone.pdf
 
MLE_keynote.pdf
MLE_keynote.pdfMLE_keynote.pdf
MLE_keynote.pdf
 
Scientific writing
Scientific writingScientific writing
Scientific writing
 
Facets_UCM
Facets_UCMFacets_UCM
Facets_UCM
 
SLE_MIP08
SLE_MIP08SLE_MIP08
SLE_MIP08
 
mtATL
mtATLmtATL
mtATL
 
Máster en Métodos Formales en Ingeniería Informática
Máster en Métodos Formales en Ingeniería InformáticaMáster en Métodos Formales en Ingeniería Informática
Máster en Métodos Formales en Ingeniería Informática
 
Analysing-MMPLs
Analysing-MMPLsAnalysing-MMPLs
Analysing-MMPLs
 
Facets
FacetsFacets
Facets
 
kite
kitekite
kite
 
MTPLs
MTPLsMTPLs
MTPLs
 
Miso-McGill
Miso-McGillMiso-McGill
Miso-McGill
 
Model Transformation Reuse
Model Transformation ReuseModel Transformation Reuse
Model Transformation Reuse
 
DSLcomet
DSLcometDSLcomet
DSLcomet
 
SICOMORO
SICOMOROSICOMORO
SICOMORO
 
ReusingMT
ReusingMTReusingMT
ReusingMT
 
keynote modelsward 2017
keynote modelsward 2017keynote modelsward 2017
keynote modelsward 2017
 
MODELSWARD 2017 Panel
MODELSWARD 2017 PanelMODELSWARD 2017 Panel
MODELSWARD 2017 Panel
 
DSL-maps
DSL-mapsDSL-maps
DSL-maps
 

Último

AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdfkalichargn70th171
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesNeo4j
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersEmilyJiang23
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfmbmh111980
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignNeo4j
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfDeskTrack
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Gáspár Nagy
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionMohammed Fazuluddin
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...naitiksharma1124
 
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityAPVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityamy56318795
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfVictor Lopez
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfsteffenkarlsson2
 

Último (20)

AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java Developers
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and Prevention
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityAPVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 

Multi21

  • 1. MULTI-LEVEL MODELLING FOR MODEL-DRIVEN ENGINEERING MULTI’2021 Juan de Lara with contributions from E. Guerra and J. Sánchez Cuadrado miso research group Universidad Autónoma de Madrid (Spain) @miso_uam http://miso.es
  • 2. WHAT IS THE TALK ABOUT? 2 Model-Driven Engineering • Models are core assets of development • Frequently built using DSLs, based on domain meta-models • Transformed (in-place, out-place), refined into code, etc • Mainstream modelling approach is two-level (meta-models/models) Meta-model1 model1 «conforms to» model2 Meta-model2 «conforms to» model-to-model in-place code-gen code OCL invariants OCL invariants
  • 3. WHAT IS THE TALK ABOUT? 3 Multi-level modelling • More than two meta-levels at a time • Meta-levels can influence other levels beyond the immediate one • Simplifies modelling in some scenarios ProductType@2 VAT@1: double price: double Book: ProductType VAT=18.0 price=10.0 mobyDick: Book two-level multi-level
  • 4. Can we use Multi- Level modelling for Model-driven Engineeering? 4
  • 5. YES, BUT WE NEED... 5 Suitable scenarios for M(LM)DE Multi-level: • Constraints • Transformations • Code generators • DSLs Supporting tools
  • 6. AGENDA 6 Basic concepts of (potency-based) multi-level modelling • Motivation and real world applicability • Clabjects, potency, levels, OCA • Examples Tool Support: MetaDepth • Case study: game development Multi-level model management • Constraints, transformations, code generation • Multi-level DSLs Advanced concepts
  • 7. MOTIVATION Sometimes, one needs to explicitly model meta-modelling facilities, like: • Instantiation (modelling both types and objects) • Declaration and instantiation of attributes and references • Inheritance For example: • Product types and instances [e-commerce applications] • Task types and instances [process modelling languages] • Component types and instances [architectural languages] • Player types and instances [gaming applications] • … 7
  • 8. EXAMPLE 8 Model product types (books, CDs) and their instances, to be added on demand. Product types have a VAT, while instances have a price. Explicit modelling of types and instances • Types can be added dynamically • Features of types are fixed and known a priori Common modelling pattern, also known as: Type object [Martin et. al 97], item descriptor [Coad 1992], metaobject [Kiczales and Rivieres 1991]
  • 9. TWO-LEVEL SOLUTIONS 9 ProductType Book vat: double {readonly} price: double vat : double =4.0 GoF: Book price = 35 Static types Requirements not satisfied ProductType vat: double Product price: double type 1 Book: ProductType vat = 4.0 :type GoF: Product price = 35 Explicit types Complex meta-model Book type facet GoF: Book price = 35 Product price: double ProductType vat: double instance facet Book:ProductType vat=4.0 Promotion transformation Requires a transformation Hides information
  • 10. MULTI-LEVEL SOLUTION 10 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0 Instantiation semantics is fixed Elements with instance and type facets at the same time Simplicity (less objects) ProductTypes can be extended with additional features, dynamically
  • 11. wait! But does this scenario occur often in practice? 11
  • 12. MULTI-LEVEL PATTERNS 12 Patterns signalling that a multi-level solution could be beneficial Emulate a meta-modelling facility within a meta-model: • Type-object: typing and instantiation • Dynamic features: feature definition and instantiation • Dynamic auxiliary domain concepts: class definition and instantiation • Relation configurator: Reference cardinality and its semantics • Element classification: Inheritance In multi-level these facilities are native at every meta-level J. de Lara, E. Guerra, J. Sánchez Cuadrado: When and How to Use Multilevel Modelling. ACM Trans. Softw. Eng. Methodol. 24(2): 12:1-12:46 (2014)
  • 13. PRACTICAL APPLICABILITY How often do these patterns occur? Analysis of >400 meta-models from: • ATL meta-model zoo (305 meta-models) [8.5% occur.] • OMG specifications (116 specs) [35%~38% occur.] • ReMoDD (15 meta-models) [20% occur.] • Articles in journals/conferences 84 meta-models with 459 occurrences (avg 5.5) • Most common pattern is the type-object • Most used solution is explicit types (~70%) 13
  • 14. WHERE? 14 19 17 13 4 4 3 3 3 2 3 Enterprise/Process Modelling Software Architecture Systems/Software Modelling Manufacturing Reverse Engineering Data modelling Requirements Bibliographic Traceability Metrics #META-MODELS 153 85 48 46 19 14 10 9 8 4 #PATTERN OCCURRENCES
  • 15. WHERE? Software architecture, components and services • Component types and instances, port types and instances • Mostly explicit types solution 15 Example: CloudML
  • 16. EXPLICIT TYPES TO MULTI-LEVEL 16 • CloudML (6 T-O, 1 DF) • 14 classes • Multi-level solution • 6 classes
  • 18. CLABJECT = CLASS + OBJECT Elements have a combined type and instance facet Book • Instance of ProductType • Can provide a value for vat • Type for GoF • Can declare new features • (We’ll see how, using the OCA) ProductType has type facet only GoF has instance facet only 18 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0 C. Atkinson and T. Kühne. 2001. The essence of multilevel metamodeling. UML’01 (LNCS), Vol. 2185. Springer, 19–33.
  • 19. POTENCY Used to characterize instances beyond the next meta-level Models, clabjects and their features have a potency • Natural number (or zero) • Decreased at each lower meta-level • Indicates at how many meta-levels the element can be instantiated We use the “@potency” notation By default elements take the potency of their containers 19 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0 C. Atkinson and T. Kühne. 2001. The essence of multilevel metamodeling. UML’01 (LNCS), Vol. 2185. Springer, 19–33.
  • 20. LEVEL Refers to the potency of the model A model with level L can hold elements with potency  L 20 ProductType Book: ProductType GoF: Book price: double price = 35 @2 @1 @0 TaxKind@1 value: double tax@1 0..1 SuperReduced: TaxKind value = 6.0 Reduced: TaxKind value = 10.0 :tax General: TaxKind value = 21.0
  • 21. ORTHOGONAL CLASSIFICATION (OCA) 21 Linguistic meta-model (meta-modelling facilitites) … Meta-meta-model (meta-modelling facilitites) Meta-model Model MM M MM M M’ «instance of» (onto) «instance of» (onto) «instance of» (ling) «instance of» (ling) «instance of» (ling) «instance of» «instance of» • Dual typing (ontological, linguistic) • Make meta-modelling facilities available at every meta-level • Types and meta-modelling facilities only at the meta-model level Multi-level Two-Level (eg., EMF) C. Atkinson, T. Kühne. 2002. Rearchitecting the UML infrastructure. ACM Trans. Model. Comput. Simul. 12, 4 (2002), 290–321.
  • 22. 22 ORTHOGONAL CLASSIFICATION (OCA) Clabject * supers Instance Type potency: int vat@1: double price: double ProductType vat = 4.0 Book: ProductType @1 price = 35 GoF: Book @0 type * * @2 ont instanceOf Linguistic meta-model (very simplified) * Feature «ling. instanceOf» ont instanceOf Model * 0..1
  • 23. 23 LINGUISTIC VIEW Clabject * supers Instance Type potency: int type * * Linguistic meta-model (very simplified) * Feature «ling. instanceOf» Model * L2: Model vat: Feature potency=2 ProductType: Clabject potency=2 potency=1 price: Feature potency=2 L1: Model potency=1 :type Book: Clabject potency=1 price1: Feature potency=1 vat: Feature potency=0 :type :type L0: Model potency=0 GoF: Clabject potency=0 price0: Feature potency=0 :type :type :type :type 0..1
  • 24. de Lara, Guerra. 2010. Deep meta-modelling with metaDepth. In TOOLS’10 (LNCS), Vol. 6141. Springer, 1–20. 24 LINGUISTIC EXTENSIONS Elements with no ontological type • Ontological typing is optional • Linguistic typing is mandatory New clabjects or features Not everything can be anticipated at the top-most level Author Book: ProductType GoF: Book vat@1: double price: double price = 35 numPages = 395 @2 @1 @0 vat=4.0 numPages : int ProductType name: String books * eg: Author name=“Gamma” :books eg: Author name=“Johnson” :books
  • 26. DOMAIN SPECIFIC PROCESS MODELLING 26 TaskKind Resource Kind Performer Kind Artefact Kind GatewayKind Seq Join Fork ins outs * src tar perfBy * * * * name@1: String initial:Boolean=false final:Boolean=false timeStamp:Date duration:double DSPM@2
  • 27. DOMAIN SPECIFIC PROCESS MODELLING 27 DSPM@2 Attend :TaskKind name=“attend classes” Study :TaskKind name=“study” Preparation:TaskKind name=“preparation” P2P:Seq Exam :TaskKind name=“do exam” S2E:Seq Subject name: String level: int subs 1 on 1 src tar src tar TaskKind Resource Kind Performer Kind Artefact Kind GatewayKind Seq Join Fork ins outs * src tar perfBy * * * * name@1: String initial:Boolean=false final:Boolean=false timeStamp:Date duration:double Edu-PML@1 de Lara, Guerra, Sánchez Cuadrado. Model-driven engineering with domain-specific meta- modelling languages. Software and System Modeling 14(1): 429-459 (2015)
  • 28. 28 DSPM@2 Attend :TaskKind name=“attend classes” Study :TaskKind name=“study” Preparation:TaskKind name=“preparation” P2P:Seq Exam :TaskKind name=“do exam” S2E:Seq Subject name: String level: int subs 1 on 1 src tar src tar TaskKind Resource Kind Performer Kind Artefact Kind GatewayKind Seq Join Fork ins outs * src tar perfBy * * * * name@1: String initial:Boolean=false final:Boolean=false timeStamp:Date duration:double Maths: Subject name: “Maths” level: 1 : Attend : Study : Exam :P2P :S2E initial=true timeStamp=1/07/12 duration=2 timeStamp=08/07/12 duration=2 final=true timeStamp=10/07/12 duration=1 Edu-PML@1 Proc@0
  • 29. DOMAIN SPECIFIC PROCESS MODELLING 29 TaskKind Resource Kind Performer Kind Artefact Kind GatewayKind Seq Join Fork ins outs * src tar perfBy * * * * name@1: String initial:Boolean=false final:Boolean=false timeStamp:Date duration:double DSPM@2
  • 30. DOMAIN SPECIFIC PROCESS MODELLING 30 DSPM@2 TaskKind Resource Kind Performer Kind Artefact Kind GatewayKind Seq Join Fork ins outs * src tar perfBy * * * * name@1: String initial:Boolean=false final:Boolean=false timeStamp:Date duration:double Soft-PML@1 Coding: TaskKind tests: next 1..* Testing: TaskKind name=“testing” SoftwareEngineer: PerformerKind actor: perfBy @1 SETask: TaskKind * Programmer: PerformerKind Tester: PerformerKind skills: String[*] name=“se-task”
  • 31. ADVANTAGES The top level can be customized for the process domain • Family of DSLs for process modelling Transformations can be defined over the top level and reused across the whole family • Code generators • Model-to-model transformations • In-place transformations • Queries 31
  • 33. COLLABORATIVE WEB APPLICATIONS 33 de Lara, Guerra, Cobos, Moreno-Llorena: Extending Deep Meta-Modelling for Practical Model-Driven Engineering. Comput. J. 57(1): 36-58 (2014)
  • 34. ARCADE/ADVENTURE GAMES 34 Sabre Wulf Pacman Atic atac Gauntlet Commando
  • 35. 35 TileKind ElementKind CharacterKind EvilKind HeroKind TreasureKind initLives@1: int = 3 lives: int = 3 score: int = 0 next * elements * ArcadeGame@2 MLM FOR ARCADE GAMES Cell: TileKind nextCell: next * coin: elements 0..1 Castle: TileKind Coin: TreasureKind value: int = 10 Pacman: HeroKind Ghost: EvilKind pacman: elements 0..1 ghosts: elements * Pacman@1
  • 36. 36 RuntimePacman@0 MLM FOR ARCADE GAMES c0: Cell c1: Cell c2: Cell c3: Castle c4: Cell :nextCell :nextCell :nextCell :nextCell :nextCell :nextCell :nextCell :nextCell :nextCell :nextCell co1: Coin co2: Coin co3: Coin value=20 co4: Coin co0: Coin g: Ghost p: Pacman
  • 37. AGENDA 37 Basic concepts of (potency-based) multi-level modelling • Motivation • Clabjects, potency, levels, OCA • Examples Tool Support: MetaDepth • Case study: game development Multi-level model management • Constraints, transformations, code generation • Multi-level DSLs Advanced concepts
  • 38. TOOLS! 38 ... (and more!) Jácome-Guerrero, de Lara: TOTEM: Reconciling multi-level modelling with standard two-level modelling. Comput. Stand. Interfaces 69: 103390 (2020)
  • 39. Textual multi-level modelling tool with a REPL • Started in 2009 • Deep characterization based on clabjects/potency • Orthogonal Classification Architecture • http://metaDepth.org Integrated with the Epsilon Languages for model management • Constraints in EOL/EVL • Derived attributes in EOL • In-place transformations in EOL • Model-to-model transformations in ETL • Code generation in EGL 39 de Lara, Guerra: Deep Meta-modelling with MetaDepth. TOOLS (48) 2010: 1-20
  • 40. METADEPTH 40 Model Ecommerce@2 { Node ProductType { vat@1 : double=10; price : double=7.5; } } Ecommerce BookStore{ ProductType Book { vat = 4.0; } } BookStore WHSmith { Book GoF { price = 35; } } ProductType Book: ProductType GoF: Book vat@1: double=10 price: double=7.5 vat=4.0 price = 35 @2 @1 @0
  • 41. SAMPLE SESSION > load “ProductSimple” :: loading ../metadepth.samples/ProductSimple.mdepth (6 clabjects created in 0.22 s). > dump :: dumping all … (shows the models in memory) > compile PlantUML Executing... :: compiling all models to PlantUML format, generated file ./Ecommerce.txt 41 (generated png by PlantUML)
  • 43. DERIVED FIELDS Model Store@2 { Node ProductType{ vat@1 : double = 7.5; price : double = 10; /finalPrice@2: double = $self.vat*self.price/100 +self.price$; } } 43 Computation expressions for derived fields using the Epsilon Object Language (EOL) Derived fields with primitive type, or references
  • 44. RUNNING EXAMPLE (1) 44 Model ArcadeGame@2 { Node TileKind { next : TileKind[*]; elements : ElementKind[*]; } abstract Node ElementKind{} abstract Node CharacterKind : ElementKind { } Node HeroKind : CharacterKind { initLives@1 : int = 3; lives : int = 3; score : int = 0; } Node EvilKind : CharacterKind {} Node TreasureKind : ElementKind {} }
  • 45. RUNNING EXAMPLE (2) 45 ArcadeGame PacMan { TileKind Cell { nextCell : Cell[*] {next}; coin : Coin[0..1] {elements}; pacman : Pacman[0..1] {elements}; ghosts : Ghost[*] {elements}; } TileKind Castle : Cell {} TreasureKind Coin { value : int=10; } HeroKind Pacman { initLives = 3; } EvilKind Ghost {} } TileKind Element Kind elements * Cell: TileKind Coin: Element Kind coin: elements 0..1 @2 Pacman: Element Kind 0..1 pacman: elements ...
  • 46. RUNNING EXAMPLE (3) 46 PacMan RuntimePacman { Cell c0 { nextCell = [c1, c4]; coin = co0; pacman = p; } Cell c1 { nextCell = [c2, c0]; coin = co1; } Cell c2 { nextCell = [c3, c1]; coin = co2; } Castle c3{ nextCell = [c4, c2]; coin = co3; ghosts = g; } Cell c4 { nextCell = [c0, c3]; coin = co4;} Pacman p {} Ghost g {} Coin co0 {} Coin co1 {} Coin co2 {} Coin co3 { value = 20; } Coin co4 {} }
  • 47. AGENDA 47 Basic concepts of (potency-based) multi-level modelling • Motivation • Clabjects, potency, levels, OCA • Examples Tool Support: MetaDepth • Case study: game development Multi-level model management • Constraints, transformations, code generation • Multi-level DSLs Advanced concepts
  • 48. CONSTRAINTS MetaDepth uses the Epsilon Object Language (EOL) to express constraints • Also for operations and expressions for derived fields EOL is a variant of OCL • Permits side effects (assignments, object creation) • Has imperative constructs (e.g., loops) The basis of other Epsilon languages • ETL for model-to-model transformation • EGL for code generation 48
  • 49. DEEP CONSTRAINT LANGUAGE Level at which the constraint is defined vs level at which we want to evaluate it • Constraints have “potency” 49 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0 posPrice@2: self.price>0 defined evaluated
  • 50. DEEP CONSTRAINT LANGUAGE Level at which the constraint is defined vs level at which we want to evaluate it • Constraints have “potency” 50 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 0 @2 @1 @0 posPrice@2: self.price>0 defined evaluated
  • 51. 51 TRANSITIVE TYPING We might not know type names at intermediate levels ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0 lotsOfProducts@2: ProductType.allInstances()-> size()>10 defined CD: ProductType vat=10.0 Disintegration: CD price = 20 evaluated TYPE.allInstances() returns all direct and indirect instances of TYPE at the current level
  • 52. LEVEL NAVIGATION Make (upwards) meta-level navigation implicit • At level 0: > GoF.vat.println(); > 4.0 Fields with instance facet in clabjects can be accessed in instance clabjects. 52 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0
  • 53. LINGUISTIC META- MODEL Transparent access to the linguistic meta-model in constraint expressions 53 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0 lotsOfProducts@2: self.type.allInstances()-> size()>10 defined evaluated Node * supers Instance Type potency: int type * * Linguistic meta-model (simplified) * Feature «ling. instanceOf» ^ prefix can be used to prevent name collisions: self.^type…
  • 54. LINGUISTIC META- MODEL Transparent access to the linguistic meta-model in constraint expressions 54 ProductType Book: ProductType GoF: Book vat@1: double price: double vat=4.0 price = 35 @2 @1 @0 lotsOfProducts@2: self.type.allInstances()-> size()>10 defined evaluated Node * supers Instance Type potency: int type * * Linguistic meta-model (simplified) * Feature «ling. instanceOf» lotsOfProducts2@2: ProductType.allInstances()-> size()>10 vs. evaluated lotsOfNodes@2: Node.allInstances()-> size()>10 vs.
  • 55. RUNNING EXAMPLE We’ll add a few constraints to ensure that: • There are no isolated tiles at level 0 • Treasures, Heroes and Evils are connected to one tile at level 0 • There is at least one hero at level 0 • There are no less evils than heroes at level 0 • There can be no Pacman in the castle A derived attribute to calculate the number of (direct) reachable tiles at level 0. 55
  • 56. 56 Model ArcadeGame@2 { Node TileKind { next : TileKind[*]; elements : ElementKind[*]; /numReachable : int = $self.next.size()$; noIsolated : $self.numReachable>0 or TileKind.all.exists( t | t.next.includes(self))$ } abstract Node ElementKind{ connected : $TileKind.all.one( t | t.elements.includes(self))$ } abstract Node CharacterKind : ElementKind { } Node HeroKind : CharacterKind { initLives@1 : int = 3; lives : int = 3; score : int = 0; } Node EvilKind : CharacterKind {} Node TreasureKind : ElementKind {} someHero@2 : $HeroKind.all.size()>=1$ moreEvils@2 : $EvilKind.all.size() >= HeroKind.all.size()$ } RUNNING EXAMPLE (LEVEL 2) no isolated tiles at level 0 treasures, heores and evils are connected to exactly one tile (global constraints) at least one hero, more evils than heroes
  • 57. 57 ArcadeGame PacMan { TileKind Cell { nextCell : Cell[*] {next}; coin : Coin[0..1] {elements}; pacman : Pacman[0..1] {elements}; ghosts : Ghost[*] {elements}; } TileKind Castle : Cell { noPacmans : $not self.pacman.isDefined()$ } TreasureKind Coin { value : int=10; } HeroKind Pacman { initLives = 3; } EvilKind Ghost { } } Conflicts and consistency of (ML) constraints can be analyzed: Guerra, de Lara: Automated analysis of integrity constraints in multi-level models. Data Knowl. Eng. 107: 1-23 (2017) RUNNING EXAMPLE (LEVEL 1) no Pacman in the Castle
  • 59. IN-PLACE MODEL TRANSFORMATION 59 Infrastructure for a family of DSLs • Operations can be attached to meta-classes • Operations with potency Design similar to an object oriented framework • Common operations • Operations expected to be overriden at next meta-level For the running example: • A game engine for the DSL (autonomous play) • Core of the engine will be common (basic movement rules, game over and winning condition) • Some operations can be overriden at level 1 (ie., particular to Pacman)
  • 60. 60 ElementKind EvilKind HeroKind ArcadeGame@2 ARCADE GAME SIMULATOR Pacman: HeroKind Ghost: EvilKind Pacman@1 main() checkDamaged(h: HeroKind) : Boolean isDamaged(): Boolean TileKind elements hasEvils(): Boolean removeHero(h: HeroKind) addHero(h: HeroKind) * getCurrentTile(): TileKind ... Cell: TileKind eatCoin(h: HeroKind) removeHero(h: HeroKind) addHero(h: HeroKind) 0..1 pacman: elements 0..1 ghosts: elements ... return TileKind.all.select( t | t.elements.includes(self)). first(); return getCurrentTile().hasEvils(); return elements.exists( e | e.isKindOf(EvilKind)); self.pacman:=null; self.pacman:= h; self.eatCoin(h);
  • 61. OTHER APPROACHES Multecore (https://ict.hvl.no/multecore/) • A tool for MLM within Eclipse • Graphical modelling • Formal theory based on graph transformation [WMR20] • By translation into rewriting logic (MAUDE) 61 Wolter, Macías, Rutle: Multilevel Typed Graph Transformations. ICGT 2020, 163-182
  • 62. MODEL-TO-MODEL TRANSFORMATION Many scenarios: • Deep transformations (eg. defined at @2, applied at @0) • Co-transformations (eg. defined at @2, applied at @1 and @0) • Refining transformations (overriding rules at @1) • Reflective & linguistic transformations (generic, using linguistic types) • Multi-level target (eg. creating models at @1 and @0) For the running example: • A (deep) transformation into Petri nets • Reusable for any concrete adventure game 62 de Lara, Guerra, Sánchez Cuadrado. Model-driven engineering with domain-specific meta-modelling languages. SoSyM 14(1): 429-459 (2015)
  • 63. MODEL-TO-MODEL TRANSFORMATION 63 @metamodel(name=ArcadeGame,file=Arcade.mdepth,domain=source) @metamodel(name=PetriNet,file=PetriNet.mdepth,domain=target) rule CharacterToToken transform h : SLevel0!CharacterKind to p : Target!Token { p.^name := h.^type+'_'+h.^name; } rule TileToPlace transform t : SLevel0!TileKind to p : Target!Place { p.name := t.type.name+'_'+t.^name; p.^name := t.type.name+'_'+t.^name; p.tokens ::= t.elements;// implicit call to equivalents() for ( n in t.next) { var tr := new Target!Transition; tr.name := t.^name+' to '+n.^name; tr.^name := t.^name+'_to_'+n.^name; p.outTr := tr; n.equivalents().first().inTr := tr; } } c1: Cell h: Pacman c2: Cell :nextCell :pacman Pacman_h : Token Cell_c1: Place Cell_c2: Place :tokens : Transition :outTr :inTr @0 ArcadeG Pacman Game Petri nets Net @2 @1 @0 rules @1 @0
  • 64. MODEL-TO-MODEL TRANSFORMATION 64 @metamodel(name=ArcadeGame,file=Arcade.mdepth,domain=source) @metamodel(name=PetriNet,file=PetriNet.mdepth,domain=target) rule CharacterToToken transform h : SLevel0!CharacterKind to p : Target!Token { p.^name := h.^type+'_'+h.^name; } rule TileToPlace transform t : SLevel0!TileKind to p : Target!Place { p.name := t.type.name+'_'+t.^name; p.^name := t.type.name+'_'+t.^name; p.tokens ::= t.elements;// implicit call to equivalents() for ( n in t.next) { var tr := new Target!Transition; tr.name := t.^name+' to '+n.^name; tr.^name := t.^name+'_to_'+n.^name; p.outTr := tr; n.equivalents().first().inTr := tr; } } c1: Cell h: Pacman c2: Cell :nextCell :pacman
  • 65. OTHER APPROACHES Melanee (http://www.melanee.org) • A tool for MLM within Eclipse • Graphical modelling (and more) • Enhancement of the ATL transformation language for multi-level modelling [AGT15] 65 Atkinson, Gerbig, Tunjic. Enhancing classic transformation languages to support multi- level modeling. Softw. Syst. Model. 14(2): 645-666 (2015) …
  • 66. CODE GENERATION 66 <!doctype html> <html> <head> … <script type="text/javascript"> // create an array with nodes var nodes = new vis.DataSet([ [% var counter : Integer := 0; // Generic for(t in Level0!Node.all) { counter := counter+1; %] [%if (counter > 1) {%], [%}%] {id: [%=counter%], label: '[%=t.type%] [%=counter%]'} [% t.~identif := counter; %] [%}%] ]); … </html> Visualization of the game • vis.js (http://visjs.org) Code generator • Deep (reusable for the DSL) • Generic (linguistic types) ArcadeG Pacman Game @2 @1 @0 code gen def apply html+js
  • 67. GENERATED CODE 67 <script type="text/javascript"> // create an array with nodes var nodes = new vis.DataSet([ {id: 1, label: 'Coin 1'} , {id: 2, label: 'Coin 2'} , {id: 3, label: 'Coin 3'} , {id: 4, label: 'Coin 4'} , {id: 5, label: 'Coin 5'} , {id: 6, label: 'Pacman 6'} , {id: 7, label: 'Ghost 7'} , {id: 8, label: 'Castle 8'} , {id: 9, label: 'Cell 9'} , {id: 10, label: 'Cell 10'} , {id: 11, label: 'Cell 11'} , {id: 12, label: 'Cell 12'} ]);
  • 68. AGENDA 68 Basic concepts of (potency-based) multi-level modelling • Motivation • Clabjects, potency, levels, OCA • Examples Tool Support: MetaDepth • Case study: game development Multi-level model management • Constraints, transformations, code generation • Multi-level DSLs Advanced concepts
  • 69. CUSTOMIZING THE TEXTUAL SYNTAX 69 MetaDepth supports a uniform textual concrete syntax accross meta-levels. Define customized syntax • Pen(8%) instead of • Product Pen {VAT=8;} Challenges imposed by a multi-level setting. DSMM model @2 DSML model @1 Model @0 Syntax Templates @1 Syntax Templates @2 Refining Templates @1 defined on defines syntax for
  • 70. TEXTUAL CONCRETE SYNTAX 70 Syntax for Ecommerce [".ecommerce_mm"] { template@1 TEcommerce for Model Ecommerce: “id ‘{’ &TProduct * ‘}’ ” template@1 TProduct for Node Product: “id ‘(’ #VAT ‘%’ ‘)’ ” } strict Model Ecommerce@2 { strict Node Product { VAT@1 : double; price : double; } } Syntax for Ecommerce [".ecommerce"] { template@2 DeepProds for Model Ecommerce: “typename id ‘{’ &DeepProd * ‘}’ ” template@2 DeepProd for Node Product: “typename id ‘(’ #price ‘€’ ‘)’ ” } Stationer { Pen(8%) } Stationer WHSmith { Pen parker(5.0€) } Meta-Level 2 Meta-Level 1 Meta-Level 0
  • 71. REFINEMENT TEMPLATES 71 template@1 TNail for Node Nail: “id ‘(’ #price ‘€’ ‘,’ #caliber ‘,’ #length ‘)’ ” strict Model Ecommerce@2 { Node Product { VAT@1 : double; price : double; } } Hardware { Nail (8.0%){ caliber: double; length: double; bigger: $self.caliber>=0.1$ } } We can design a special syntax for specific clabjects of potency 1 Hardware DoItBest { n1(0.1€, 0.1, 10) }
  • 72. GRAPHICAL CONCRETE SYNTAXES Melanee • Graphical • Form-based • Virtual Reality 72 Atkinson, Gerbig: Aspect-oriented Concrete Syntax Definition for Deep Modeling Languages. MULTI@MoDELS 2015: 13-22 Gerbig: Deep, Seamless, Multi-format, Multi-notation Definition and Use of Domain-specific Languages. University of Mannheim, Germany, Dr. Hut 2017
  • 73. AGENDA 73 Basic concepts of (potency-based) multi-level modelling • Motivation • Clabjects, potency, levels, OCA • Examples Tool Support: MetaDepth • Case study: game development Multi-level model management • Constraints, transformations, code generation • Multi-level DSLs Advanced concepts
  • 74. MULTI-LEVEL REFACTORINGS 74 Refactoring multi-level models. 2018. Juan de Lara, Esther Guerra. ACM Transactions on Software Engineering and Methodology, Vol 27(4)
  • 75. 75 MULTI-LEVEL REFACTORINGS Refactoring multi-level models. 2018. Juan de Lara, Esther Guerra. ACM Transactions on Software Engineering and Methodology, Vol 27(4)
  • 76. MULTI-LEVEL MODEL PRODUCT LINES ML languages with variability Users can configure the 76 de Lara, J., Guerra, E. Language Family Engineering with Product Lines of Multi-level Models. Form Asp Comp (2021). languages at different levels using a multi-level feature model Open variability: instantiation Closed variability: configuration
  • 77. 77 Language Family Designer DSL-2 Designer DSL-1 Designer instantiates Language family MM Model ProcessLanguage Gateways object simple initial enactment Tasks @0 @1 @2 variability ProcessLanguage enactment Tasks @0 variability DSL-2 Users Level 2 Level 1 creates Level 0 DSL-1 Users 1 4b Specialized language family MM variability 2b specializes DSL-2 MM variability 3b Specialized DSL-2 MM variability ProcessLanguage enactment Tasks @1 5b Model variability 6b specialize specialize 2a DSL-1 MM variability instantiates 3a Fully specialized language family MM variability Model variability instantiate 4a instantiate ProcessLanguage initial enactment Tasks @1 @0 specializes empty empty empty empty USING MULTI-LEVEL MODEL PRODUCT LINES
  • 78. CONCLUSIONS AND SUMMARY Multi-level modelling • Simplifies modelling in some scenarios • Relevant in practice (OMG specs, process modelling, architectural languages) Families of DSLs • Common semantics and services • Defined through MDE techniques Tooling • MetaDepth (but many others are available) 78
  • 79. WHAT’S NEXT? Use in real projects • (Large) case study reports • Is potency flexible enough in practice? Bridges with two-level modelling • EMF • Automated rearchitecture from 2-level into multi-level Bridges between multi-level modelling tools • Interoperability with other tools 79