aspects of campammsdl.cs.mcgill.ca/people/hv/conferences/07.campam/...dissecting (and modelling)...

81
2007 Bellairs CAMPaM Workshop 24 April 2006 Aspects of CAMPaM Hans Vangheluwe Modelling, Simulation and Design Lab (MSDL) School of Computer Science, McGill University, Montr´ eal, Canada Hans Vangheluwe [email protected] Model Everything ! 1

Upload: others

Post on 03-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

2007 Bellairs CAMPaM Workshop

24 April 2006

Aspects of CAMPaM

Hans Vangheluwe

Modelling, Simulation and Design Lab (MSDL)

School of Computer Science, McGill University, Montreal, Canada

Hans Vangheluwe [email protected] Model Everything ! 1

Page 2: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Overview

1. Multi-Paradigm Modelling, by example

2. Domain-Specific Modelling

3. Dissecting (and modelling) Modelling Languages

4. Building CAMPaM tools effectively

5. Challenges

6. Conclusions

Hans Vangheluwe [email protected] Model Everything ! 2

Page 3: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Multi-Paradigm Modelling . . .

• Intuitive notion (relative): OO paradigm, dataflow paradigm, . . .

• Thomas Kuhn, The Structure of Scientific Revolutions, 1962.

• Need to define more precisely . . .

Hans Vangheluwe [email protected] Model Everything ! 3

Page 4: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Multi-Paradigm Modelling . . .

Hans Vangheluwe [email protected] Model Everything ! 4

Page 5: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling Variety of Complex Systems . . .

Need to be modelled

• at most appropriate level of abstraction

• in most appropriate formalism(s)

• with transformations as first-class models

Pieter J. Mosterman and Hans Vangheluwe. Computer Automated Multi-Paradigm Modeling: An Introduction. Simulation:

Transactions of the Society for Modeling and Simulation International, 80(9):433-450, September 2004. Special Issue on Grand

Challenges for Modeling and Simulation.

Hans Vangheluwe [email protected] Model Everything ! 5

Page 6: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Multi-Paradigm Dimensions

(note: dimensions are not totally ordered)

Hans Vangheluwe [email protected] Model Everything ! 6

Page 7: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Available Information, Questions to be Answered, . . .

⇒ choice of Abstraction Level/Formalism

Hans Vangheluwe [email protected] Model Everything ! 7

Page 8: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Choice of Abstraction Level/FormalismOrder Processing

order1

received_order0

filling_order0

payment0

process_payment0

payment_accepted0

close_order0

shipping_order0

receive

accept_order reject_order

end_filling

sending_invoice0

receive_invoice

send_payment

accept_payment reject_payment

shippedNpaid

Hans Vangheluwe [email protected] Model Everything ! 8

Page 9: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Need Multiple Formalisms: Power Window

Hans Vangheluwe [email protected] Model Everything ! 9

Page 10: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

The Model Couples different Formalisms

www.mathworks.com/products/demos/simulink/PowerWindow/html/PowerWindow1.html

Hans Vangheluwe [email protected] Model Everything ! 10

Page 11: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Semantics of Coupled Models

• Super-formalism subsumes all formalisms

• Co-simulation (coupling resolved at trajectory level)

• Transform to common formalism

Hans Vangheluwe [email protected] Model Everything ! 11

Page 12: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Multi-formalism coupled model:co-simulation

Msub_1Msub_2

CoupledModel

CouplingGraph

Msub_3

Hans Vangheluwe [email protected] Model Everything ! 12

Page 13: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Co-simulation of multi-formalism coupledmodels

• Sub-models simulated with formalism-specific simulators.

• Interaction due to coupling is resolved at trajectory level.

→ Loss of information.

→ Questions can only be answered at trajectory level.

→ Speed and numerical accuracy problems

for continuous formalisms.

→ Meaningful for discrete-event formalisms (beware of legitimacy !).

Basis of the DoD High Level Architecture (HLA)

for simulator interoperability.

Hans Vangheluwe [email protected] Model Everything ! 13

Page 14: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Multi-formalism coupled model:multi-formalism modelling

Msub_1Msub_2

CoupledModel

CouplingGraph

Msub_3

Hans Vangheluwe [email protected] Model Everything ! 14

Page 15: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Formalism Transformation Graph

DEVS

Process Interaction Discrete Event

state trajectory data (observation frame)

Petri NetsStatecharts

scheduling-hybrid-DAE

Bond Graph a-causal

Bond Graph causal

DAE non-causal set

DAE causal set

PDE

Transfer Function

Difference Equations

System Dynamics

KTG Cellular Automata

Event Scheduling Discrete Event

3 Phase Approach Discrete Event

DAE causal sequence (sorted)

DEVS&DESS

Activity Scanning Discrete Event

Timed Automata

Causal Block Diagram

Hans Vangheluwe [email protected] Model Everything ! 15

Page 16: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Multi-formalism modelling 6= co-simulation

1. Start from a coupled multi-formalism model. Check consistency of

this model (e.g., whether causalites and types of connected ports

match).

2. Cluster all formalisms described in the same formalism.

3. For each cluster, implement closure under coupling.

4. Look for the best common formalism in the Formalism

Transformation Graph all the remaining different formalisms can

be transformed to. Worst case: trajectory level (fallback to

co-simulation).

5. Transform all the sub-models to the common formalism.

6. Implement closure under coupling of the common formalism.

Hans Vangheluwe [email protected] Model Everything ! 16

Page 17: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Multiple (consistent !) Views(possibly in 6= Formalisms)

(work by Esther Guerra and Juan de Lara using projections of a “repository”)

Hans Vangheluwe [email protected] Model Everything ! 17

Page 18: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

View: Runtime Diagram

Hans Vangheluwe [email protected] Model Everything ! 18

Page 19: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

View: Events Diagram

Hans Vangheluwe [email protected] Model Everything ! 19

Page 20: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

View: Protocol Statechart

Hans Vangheluwe [email protected] Model Everything ! 20

Page 21: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

The need for (modelled) TransformationsModel/Analyze/Simulate Traffic Networks

Hans Vangheluwe [email protected] Model Everything ! 21

Page 22: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

An un-timed Traffic model

0bot_W2E

0turn1

0to_N_or_W

0turn2

0bot_N2S

2cars

1bot_CAP 1

turn1_CAP

1top_CAP

1turn2_CAP

Hans Vangheluwe [email protected] Model Everything ! 22

Page 23: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling Traffic’s Semantics

• choices: timed, un-timed, . . . (level of abstraction)

• denotational: map onto known formalism (TTPN, PN)

. . . good for analysis purposes

• operational: procedure to execute/simulate model

. . . may act as a reference implementation

• note: need to prove consistency between denotational and

operational semantics if both are given !

Hans Vangheluwe [email protected] Model Everything ! 23

Page 24: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling Traffic’s (un-timed) semanticsin terms of Petri Nets

• need a (meta-)model of Traffic

• need a (meta-)model of Petri Nets

• need a model of the mapping: Traffic ⇒ Petri Net

Hans Vangheluwe [email protected] Model Everything ! 24

Page 25: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Input to semantic mapping transformation

0bot_W2E

0turn1

0to_N_or_W

0turn2

0bot_N2S

2cars

1bot_CAP 1

turn1_CAP

1top_CAP

1turn2_CAP

Hans Vangheluwe [email protected] Model Everything ! 25

Page 26: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

The Petri Net describing its behaviourobtained by automatic transformation

bot_W2E0

turn10

to_N_or_W0

turn20

bot_N2S0

cars2

bot_W2E_dep

top_S2W_dep

bot_N2S_dep

top_arrbot_N2S_arr

bot_W2E_arr

top_S2N_dep

bot_CAP1

turn1_CAP1

top_CAP1

turn2_CAP1

Hans Vangheluwe [email protected] Model Everything ! 26

Page 27: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Static Analysis of the Transformation Model

The transformation (specified by a Graph Grammar) model must

satisfy the following requirements (of semantic mapping):

• Termination:

the transformation process is finite

• Convergence/Uniqueness:

the transformation results in a single target model

• Syntactic Consistency:

the target model must be exclusively in the target formalism

These properties can often (but not always)

be statically checked/proved.

Hans Vangheluwe [email protected] Model Everything ! 27

Page 28: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

More transformations:Liveness Analysis on Coverability Graph

[turn1_CAP, cars(2), bot_CAP, top_CAP, turn2_CAP]

[turn1_CAP, cars, bot_W2E, top_CAP, turn2_CAP]

bot_W2E_arr

[cars, turn1, bot_CAP, top_CAP, turn2_CAP]

bot_W2E_dep

[turn1_CAP, cars, bot_CAP, turn2_CAP, to_N_or_W]

top_arr

[turn1_CAP, turn2, cars, bot_CAP, top_CAP]

top_S2W_dep

[turn1_CAP, cars, top_CAP, turn2_CAP, bot_N2S]

bot_N2S_arrbot_N2S_dep

[turn1_CAP, turn2, bot_W2E, top_CAP]

bot_W2E_arr

[turn2, turn1, bot_CAP, top_CAP]

bot_W2E_dep

[turn1_CAP, turn2, bot_CAP, to_N_or_W]

top_arr

[turn1_CAP, turn2_CAP, bot_N2S, to_N_or_W]

bot_N2S_arr

[turn1_CAP, turn2, top_CAP, bot_N2S]

top_S2W_dep

bot_N2S_dep

bot_N2S_dep

top_S2N_dep

top_S2N_dep

[turn1, top_CAP, turn2_CAP, bot_N2S]

bot_N2S_arrbot_N2S_dep

top_arr

[turn1_CAP, bot_W2E, turn2_CAP, to_N_or_W]

bot_W2E_arr

[turn1, bot_CAP, turn2_CAP, to_N_or_W]

bot_W2E_dep

top_S2W_dep

top_S2N_dep

top_S2W_dep

top_S2N_dep

top_S2N_dep

[turn1, bot_W2E, top_CAP, turn2_CAP]

bot_W2E_arr

top_arr

Hans Vangheluwe [email protected] Model Everything ! 28

Page 29: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Conservation Analysis

1.0 x[turn1_CAP] + 1.0 x[turn1] = 1.0

1.0 x[cars] + 1.0 x[bot_W2E] + 1.0 x[turn1] +

1.0 x[to_N_or_W] + 1.0 x[turn2] + 1.0 x[bot_N2S] = 2.0

1.0 x[top_CAP] + 1.0 x[to_N_or_W] = 1.0

1.0 x[turn2_CAP] + 1.0 x[turn2] = 1.0

1.0 x[bot_CAP] + 1.0 x[bot_W2E] + 1.0 x[bot_N2S] = 1.0

Hans Vangheluwe [email protected] Model Everything ! 29

Page 30: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

The Big Picture: Transform Everything!

neglect time

Traffic (un-timed)

Place-Transition Petri Nets

Coverability Graph

describe semanticsby mapping onto

compute allpossible behaviours

simulate

simulate

analyze:reachability,coverability, ...

describe semantics

by mapping onto

simulate

DEVS

map onto

map onto Timed Transition Petri Nets

desc

ribe

sem

antic

s

by m

appi

ng o

nto

simulateanalyze

describe semanticsby mapping onto

TINA

simulateanalyze

pythonDEVS

simulate

DEVSJava

simulate

TimedTraffic

simulate

Hans Vangheluwe [email protected] Model Everything ! 30

Page 31: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Software Development Process:Transformations (refinement vs. translation)

Hans Vangheluwe [email protected] Model Everything ! 31

Page 32: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Domain-Specific (Visual) Modelling

Hans Vangheluwe [email protected] Model Everything ! 32

Page 33: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

DS(V)M Example: smart phones,the application

MetaEdit+ (www.metacase.com)

Hans Vangheluwe [email protected] Model Everything ! 33

Page 34: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

DS(V)M Example: smart phones,the Domain-Specific model

Hans Vangheluwe [email protected] Model Everything ! 34

Page 35: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Why DS(V)M ?(as opposed to General Purpose modelling)

• match the user’s mental model of the problem domain

• maximally constrain the user (to the problem at hand)

⇒ easier to learn

⇒ avoid errors

• separate domain-expert’s work

from analysis/transformation expert’s work

Anecdotal evidence of 5 to 10 times speedup

Hans Vangheluwe [email protected] Model Everything ! 35

Page 36: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Model-Based Development:Modify the Model

model

model’ app’

apptransformation

transformation

small modification

Hans Vangheluwe [email protected] Model Everything ! 36

Page 37: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Model-Based Development:Modify the Transformation (model)

model

model app’

apptransformation

small modification

transformation’

Hans Vangheluwe [email protected] Model Everything ! 37

Page 38: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Transformation may be multi-step

• divide-and-conquer, modularity, re-use, . . . ;

• re-use existing transformations;

• potential for optimization at every level;

• multi-formalism modelling by transforming

onto a common formalism;

• in case of Domain-Specific formalisms: usually small

transformation onto known (syntax & semantics) formalism.

Hans Vangheluwe [email protected] Model Everything ! 38

Page 39: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Building DS(V)M Tools Effectively . . .

• development cost of DS(V)M Tools may be prohibitive !

• we want to effectively (rapidly, correctly, re-usably, . . . )

1. Specify DS(V)L syntax:

– abstract ⇒ meta-modelling

– concrete (textual/visual)

2. Specify DS(V)L semantics:

transformation

3. Model (and analyze and execute) model transformations:

⇒ graph rewriting

⇒ model everything

(in the most appropriate formalism,

at the appropriate level of abstraction)

Hans Vangheluwe [email protected] Model Everything ! 39

Page 40: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Dissecting a Modelling Language(tool builder’s view)

Hans Vangheluwe [email protected] Model Everything ! 40

Page 41: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Deciding on terminology

Hans Vangheluwe [email protected] Model Everything ! 41

Page 42: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

What’s in a name ? Language

Hans Vangheluwe [email protected] Model Everything ! 42

Page 43: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

What’s in a name ? Formalism

Hans Vangheluwe [email protected] Model Everything ! 43

Page 44: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

What’s in a name ? Base Formalism

Hans Vangheluwe [email protected] Model Everything ! 44

Page 45: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

What’s in a name ? Concrete Language

Hans Vangheluwe [email protected] Model Everything ! 45

Page 46: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

What’s in a name ? Concrete Formalism

Hans Vangheluwe [email protected] Model Everything ! 46

Page 47: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling a Modelling Language/Formalism

Hans Vangheluwe [email protected] Model Everything ! 47

Page 48: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling a Modelling Language/Formalism

Hans Vangheluwe [email protected] Model Everything ! 48

Page 49: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Example: the PacMan Formalism

0Your score

(thanks to Reiko Heckel)

Hans Vangheluwe [email protected] Model Everything ! 49

Page 50: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

From now on: use AToM3

Hans Vangheluwe [email protected] Model Everything ! 50

Page 51: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling Abstract Syntax (meta-model)

Cardinalities: - To gridBottomV3: 0 to N - From gridBottomV3: 0 to N - From pacLinkV3: 0 to N - From foodLinkV3: 0 to N - From scoreLinkV3: 0 to N - To gridLeftV3: 0 to N - From gridLeftV3: 0 to N - To gridRightV3: 0 to N - From gridRightV3: 0 to N - To gridTopV3: 0 to N - From gridTopV3: 0 to N - From ghostLinkV3: 0 to N

gridNodeCenter

Cardinalities: - To pacLinkV3: 0 to N

pacmanV3

Cardinalities: - To foodLinkV3: 0 to N

pacFoodV3

Attributes: - score :: IntegerActions: > createCardinalities: - To scoreLinkV3: 0 to N

ScoreBoard

Cardinalities: - To ghostLinkV3: 0 to N

ghostV3

gridLeftV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridTopV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridBottomV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridRightV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

ghostLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From ghostV3: 0 to N

scoreLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From ScoreBoard: 0 to N

pacLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From pacmanV3: 0 to N

foodLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From pacFoodV3: 0 to N

Hans Vangheluwe [email protected] Model Everything ! 51

Page 52: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling the Scoreboard Entity

Hans Vangheluwe [email protected] Model Everything ! 52

Page 53: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Synthesis of Code from this Design modelclass ScoreBoard(ASGNode, ATOM3Type):

def __init__(self, parent = None):

ASGNode.__init__(self)

ATOM3Type.__init__(self)

self.graphClass_ = graph_ScoreBoard

self.isGraphObjectVisual = True

self.parent = parent

self.score=ATOM3Integer(0)

self.generatedAttributes = {’score’: (’ATOM3Integer’ ) }

self.directEditing = [1]

def clone(self):

cloneObject = ScoreBoard( self.parent )

for atr in self.realOrder:

cloneObject.setAttrValue(atr, self.getAttrValue(atr).clone() )

ASGNode.cloneActions(self, cloneObject)

return cloneObject

Hans Vangheluwe [email protected] Model Everything ! 53

Page 54: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Meta-modelling: model-instance morphism

Hans Vangheluwe [email protected] Model Everything ! 54

Page 55: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Meta-meta-. . . : Meta-circularity

Hans Vangheluwe [email protected] Model Everything ! 55

Page 56: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Add Concrete Visual Syntax to Classes

Cardinalities: - To gridBottomV3: 0 to N - From gridBottomV3: 0 to N - From pacLinkV3: 0 to N - From foodLinkV3: 0 to N - From scoreLinkV3: 0 to N - To gridLeftV3: 0 to N - From gridLeftV3: 0 to N - To gridRightV3: 0 to N - From gridRightV3: 0 to N - To gridTopV3: 0 to N - From gridTopV3: 0 to N - From ghostLinkV3: 0 to N

gridNodeCenter

Cardinalities: - To pacLinkV3: 0 to N

pacmanV3

Cardinalities: - To foodLinkV3: 0 to N

pacFoodV3

Attributes: - score :: IntegerActions: > createCardinalities: - To scoreLinkV3: 0 to N

ScoreBoard

Cardinalities: - To ghostLinkV3: 0 to N

ghostV3

gridLeftV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridTopV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridBottomV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridRightV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

ghostLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From ghostV3: 0 to N

scoreLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From ScoreBoard: 0 to N

pacLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From pacmanV3: 0 to N

foodLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From pacFoodV3: 0 to N

Hans Vangheluwe [email protected] Model Everything ! 56

Page 57: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modelling Ghost Concrete Visual Syntax

Hans Vangheluwe [email protected] Model Everything ! 57

Page 58: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Add Concrete Visual Syntax to Associations

Cardinalities: - To gridBottomV3: 0 to N - From gridBottomV3: 0 to N - From pacLinkV3: 0 to N - From foodLinkV3: 0 to N - From scoreLinkV3: 0 to N - To gridLeftV3: 0 to N - From gridLeftV3: 0 to N - To gridRightV3: 0 to N - From gridRightV3: 0 to N - To gridTopV3: 0 to N - From gridTopV3: 0 to N - From ghostLinkV3: 0 to N

gridNodeCenter

Cardinalities: - To pacLinkV3: 0 to N

pacmanV3

Cardinalities: - To foodLinkV3: 0 to N

pacFoodV3

Attributes: - score :: IntegerActions: > createCardinalities: - To scoreLinkV3: 0 to N

ScoreBoard

Cardinalities: - To ghostLinkV3: 0 to N

ghostV3

gridLeftV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridTopV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridBottomV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

gridRightV3

Cardinalities: - To gridNodeCenter: 0 to 1 - From gridNodeCenter: 0 to 1

ghostLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From ghostV3: 0 to N

scoreLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From ScoreBoard: 0 to N

pacLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From pacmanV3: 0 to N

foodLinkV3

Cardinalities: - To gridNodeCenter: 0 to N - From pacFoodV3: 0 to N

Hans Vangheluwe [email protected] Model Everything ! 58

Page 59: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

GhostLink Concrete Visual Syntax

# Get n1, n2 end-points of the link

n1 = self.in_connections_[0]

n2 = self.out_connections_[0]

# g1 and g2 are the graphEntity visual objects

g0 = self.graphObject_ # the link

g1 = n1.graphObject_ # first end-point

g2 = n2.graphObject_ # second end-poing

# Get the high level constraint helper and solver

from Qoca.atom3constraints.OffsetConstraints import OffsetConstraints

oc = OffsetConstraints(self.parent.qocaSolver)

# The constraints

oc.CenterX((g1, g2, g0))

oc.CenterY((g1, g2, g0))

oc.resolve()

Hans Vangheluwe [email protected] Model Everything ! 59

Page 60: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Synthesize + Customize Buttons model

New Edit New Help

New gridNodeCenter

New pacmanV3 New pacFoodV3 New ScoreBoardNew ghostV3

Hans Vangheluwe [email protected] Model Everything ! 60

Page 61: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Default generated Buttons code for ghostV3

# This method has as parameters:

# - wherex : X Position in window coordinates where the user clicked.

# - wherey : Y Position in window coordinates where the user clicked.

newPlace = self.createNewghostV3 (self, wherex, wherey)\n’))

Hans Vangheluwe [email protected] Model Everything ! 61

Page 62: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Can now do syntax-directed editing ofPacMan models ?

0Your score

Hans Vangheluwe [email protected] Model Everything ! 62

Page 63: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Model the GUI’s Reactive Behaviour !in the Statechart formalism

Hans Vangheluwe [email protected] Model Everything ! 63

Page 64: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

The GUI’s reactive behaviour in action

challenge: what is the optimal formalism to specify GUI reactive behaviour ?

Hans Vangheluwe [email protected] Model Everything ! 64

Page 65: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Syntax Directed Editing (vs. Freehand)

Hans Vangheluwe [email protected] Model Everything ! 65

Page 66: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modellling PacMan Operational Semantics

note: for Denotational Semantics: map for example onto Petri Net

Hans Vangheluwe [email protected] Model Everything ! 66

Page 67: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Specifying Model Transformations

What is the “optimal” formalism ?

Models are often graph-like ⇒ natural to express model transformation

by means of graph transformation models.

Ehrig, H., G. Engels, H.-J. Kreowski, and G. Rozenberg.

Handbook of graph grammars and computing by graph

transformation.

1999. World Scientific.

Tools:

GME/GReAT, PROGRES, AGG, AToM3, Fujaba, GROOVE, . . .

First two (and Fujaba) used in large industrial applications.

Hans Vangheluwe [email protected] Model Everything ! 67

Page 68: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Model Operational Semantics using GG

Hans Vangheluwe [email protected] Model Everything ! 68

Page 69: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

PacMan Die rule

Hans Vangheluwe [email protected] Model Everything ! 69

Page 70: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

PacMan Die rule LHS

2

4

1

3

5

Hans Vangheluwe [email protected] Model Everything ! 70

Page 71: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

PacMan Die rule RHS

1

3

5

Hans Vangheluwe [email protected] Model Everything ! 71

Page 72: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

PacMan Eat rule LHS

2

5

1

3

4

Hans Vangheluwe [email protected] Model Everything ! 72

Page 73: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

PacMan Eat rule RHS

2

5

1

scoreBoard = None

scoreBoards = atom3i.ASGroot.listNodes[’ScoreBoard’]

if (not scoreBoards):

return

else:

scoreBoard = scoreBoards[0]

scoreVal = scoreBoard.score.getValue()

scoreBoard.score.setValue(scoreVal+1)

scoreBoard.graphObject_.ModifyAttribute(’score’,scoreVal+1)

Hans Vangheluwe [email protected] Model Everything ! 73

Page 74: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

PacMan Move rule LHS

7

8

6 9

10

Hans Vangheluwe [email protected] Model Everything ! 74

Page 75: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

PacMan Move rule RHS

7

1

6 9

10

Hans Vangheluwe [email protected] Model Everything ! 75

Page 76: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Specifying/Executing Trsf. with GGs(+) Models are often Graph-like

(+) Visual specification (documentation)

For insight/debugging: execution + visual display

For performance: execution on data structures in memory

(+) Little or no programming knowledge required (allows

understanding/modification by domain-experts)

(-) Does it scale up ?

Yes, need to use modular GGs (e.g., GReAT, PROGRES)

(-) Performance is bad ! (due to sub-graph matching)

But sometimes no alternative

– model transformation for graph-like models

– don’t want to code matching yourself

But give (domain-specific) hints to kernel (or compile)

But use as specification for manual implementation

– executable specification = reference implementation

– automatic generation of unit tests

(including expected correct result)

Hans Vangheluwe [email protected] Model Everything ! 76

Page 77: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modular Graph Rewriting:GReAT Control Structures: Sequence

Hans Vangheluwe [email protected] Model Everything ! 77

Page 78: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Modular Graph Rewriting:GReAT Control Structures: Nesting

Hans Vangheluwe [email protected] Model Everything ! 78

Page 79: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Model Based Development:some Open Problems

1. deal with concrete syntax (textual, visual) in a unified manner

2. deal with legacy models (code)

3. trace-ability (backward links, use TGGs ?)

4. (meta-) model evolution

5. multi-formalism modelling

6. multi-abstraction modelling

7. multi-view modelling, (semantic) consistency

8. model refinement (cfr. GUI example)

9. automated testing (of models)

10. modularize transformations, mix trsf. formalisms, graft on existing

formalism

Hans Vangheluwe [email protected] Model Everything ! 79

Page 80: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

11. transformation models are first-class models ⇒

higher-order transformation

12. quantify “accidental complexity”, leads to choice of “most appropriate

formalism”

13. mega-modelling

Hans Vangheluwe [email protected] Model Everything ! 80

Page 81: Aspects of CAMPaMmsdl.cs.mcgill.ca/people/hv/conferences/07.CAMPaM/...Dissecting (and modelling) Modelling Languages 4. Building CAMPaM tools effectively 5. Challenges 6. Conclusions

Conclusions

1. Through anecdotal evidence, demonstrated the usefulness of

(Computer Automated) (Domain-Specific) Multi-Paradigm

Modelling.

2. Demonstrated feasibility of rapidly and re-usably building

Domain-Specific Visual Modelling, Analysis, Simulation tools

using meta-modelling and graph rewriting.

3. Many problems have been solved, but . . .

4. Still many open research problems

(good news for researchers, challenge for industry) !

model everything !

Hans Vangheluwe [email protected] Model Everything ! 81