+ All Categories
Home > Documents > Meta-Modelling and Graph Rewriting, Enablers for Domain...

Meta-Modelling and Graph Rewriting, Enablers for Domain...

Date post: 04-Sep-2019
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
78
SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and Graph Rewriting, Enablers for Domain-Specific (Visual) Modelling “model everything” Hans Vangheluwe Modelling, Simulation and Design Lab (MSDL) School of Computer Science, McGill University, Montr ´ eal, Canada Hans Vangheluwe [email protected] MM, GG, DSVM 1/78
Transcript
Page 1: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

SOCS Software Engineering Meeting23 September 2004

Meta-Modelling and Graph Rewriting,

Enablers for

Domain-Specific (Visual) Modelling

“model everything”

Hans Vangheluwe

Modelling, Simulation and Design Lab (MSDL)School of Computer Science, McGill University, Montreal, Canada

Hans Vangheluwe [email protected] MM, GG, DSVM 1/78

Page 2: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Overview

1. Domain-Specific (Visual) Modelling – DS(V)M� What/Why of DS(V)M (and DS(V)Ls) ?

� Examples

2. Building DS(V)M Tools Effectively

(a) Specifying textual/visual syntax of DS(V)Ls:

meta-modelling

(b) Specifying DS(V)L semantics

(c) Modelling (and executing) transformations:

graph rewriting

(d) Traffic, a domain-specific modelling formalism

Hans Vangheluwe [email protected] MM, GG, DSVM 2/78

Page 3: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

3. AToM3, A Tool for Multi-formalism Meta-Modelling� Different “aspects” of AToM3

� A plethora of applications

� Current and future work

Hans Vangheluwe [email protected] MM, GG, DSVM 3/78

Page 4: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Domain-Specific (Visual) Modelling

DS(V)M “Domain-Specific (Visual) Modelling”

DS(V)Ls “Domain-Specific (Visual) Languages”

Some starting points:

� www.dsmforum.org

� OOPSLA Workshops on DSM

� Juan de Lara and Hans Vangheluwe. Defining visual notations and their manipulation

through meta-modelling and graph transformation. Journal of Visual Languages and

Computing, 15(3 - 4):309-330, June - August 2004. Special Issue on

Domain-Specific Modeling with Visual Languages.

� The OMG’s Model Driven Architecture (MDA) www.omg.org/mda

Hans Vangheluwe [email protected] MM, GG, DSVM 4/78

Page 5: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Why DS(V)M ?

Hans Vangheluwe [email protected] MM, GG, DSVM 5/78

Page 6: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

DS(V)M Example 1: smart phones, the model

MetaEdit+ (www.metacase.com)

Hans Vangheluwe [email protected] MM, GG, DSVM 6/78

Page 7: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

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

MetaEdit+ (www.metacase.com)

Hans Vangheluwe [email protected] MM, GG, DSVM 7/78

Page 8: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Why DS(V)M ?� match the user’s mental model of the problem domain

� maximally constrains users

� separate domain-expert’s

from transformation expert’s work,

from target domain (e.g., code libraries) expert’s work

� re-use transformation knowledge

� model everything (nothing left implicit)

Hans Vangheluwe [email protected] MM, GG, DSVM 8/78

Page 9: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

How to do DS(V)M ?

Hans Vangheluwe [email protected] MM, GG, DSVM 9/78

Page 10: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

DS(V)M Example 2: Waste Water Treatment Plant

NATO’s Sarajevo WWTPhttp://www.nato.int/sfor/cimic/env-pro/waterpla.htm

Hans Vangheluwe [email protected] MM, GG, DSVM 10/78

Page 11: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

WWTP Block Diagram (domain-specific) model

influentmixer

aeration_tanksettler effluent

f_influent f_mixed f_processed f_out

f_bacteria

Hans Vangheluwe [email protected] MM, GG, DSVM 11/78

Page 12: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Model of the Transformation from WWTP to . . .

influent

f_influent

f_influent

C_influent

0.0

OUT

mixer

f_influent

f_bacteria

f_mixed

f_bacteria

f_influent f_mixed

I OUT

C_aeration

0.9

aeration_tank

f_mixed

aeration_fraction

f_processed

f_processedf_mixed

TR

AN

SF

OR

M

TR

AN

SF

OR

M

TR

AN

SF

OR

M

Hans Vangheluwe [email protected] MM, GG, DSVM 12/78

Page 13: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

... its meaning (in the steady-state abstraction):Causal Block Diagram (CBD)

C_influent

10.0 OUT

C_settling

0.6

I OUT

I OUT

1.0

OUT

effluentI OUT

f_influent

f_bacteria

f_mixed

settling_fraction

one

negated dump_fractionf_out

C_aeration

0.9

aeration_fraction

f_processed

Hans Vangheluwe [email protected] MM, GG, DSVM 13/78

Page 14: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Multi-step Transformation: meaning of the CBD������

�������

C_influent

10.0 OUT

C_bacteria

1.0

C_settling

0.6

I OUT

I OUT

1.0

OUT

effluent

dump

I OUT

f_influent

f_bacteria

f_mixed

settling_fraction

one

negated

dump_fraction

f_dump

f_out

C_aeration

0.9

aeration_fraction

f_processed

� ������

� ������

��

f in f luent � C in f luent

f bacteria � C bacteria

f mixed � f in f luent f bacteria

aeration f raction � C aeration

f processed � aeration f raction� f mixed

settling f raction � C settling

negated � � settling f raction

one � 1

dump f raction � one negated

f dump � f processed� dump f raction

f out � settling f raction� f processed

Hans Vangheluwe [email protected] MM, GG, DSVM 14/78

Page 15: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

WWTP Simulation Environment

www.hemmis.com/products/west/

Henk Vanhooren, Jurgen Meirlaen, Youri Amerlinck, Filip Claeys, Hans Vangheluwe, and

Peter A. Vanrolleghem. WEST: Modelling biological wastewater treatment. Journal of

Hydroinformatics, 5(1):27-50, 2003.

Hans Vangheluwe [email protected] MM, GG, DSVM 15/78

Page 16: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Building DS(V)M Tools Effectively� development cost of DS(V)M Tools may be prohibitive !

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

specify and generate/execute:

– DS(V)Ls

– (reactive) behaviour of DS(V)M environments

– transformations

model everything

Hans Vangheluwe [email protected] MM, GG, DSVM 16/78

Page 17: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Building DS(V)M Tools Effectively

1. Specifying textual/visual syntax of DS(V)Ls:

meta-modelling

2. Specifying DS(V)L semantics

3. Modelling (and executing) transformations:

graph rewriting

4. Traffic, a domain-specific modelling formalism

Hans Vangheluwe [email protected] MM, GG, DSVM 17/78

Page 18: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Specifying textual/visual syntax of DS(V)Ls� abstract syntax:

– meta-model (� type graph)

– syntax grammar (SableCC text grammar, AToM3 Graph Grammar)

� concrete syntax:

– textual (SableCC lexing)

– visual (AToM3 “icons” + connections)

Hans Vangheluwe [email protected] MM, GG, DSVM 18/78

Page 19: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Meta-modelling

Hans Vangheluwe [email protected] MM, GG, DSVM 19/78

Page 20: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Meta-modelling: model-instance morphism

name type=String init.value=tokens type=Integer init.value=0

PNPlacename type=String init.value=PNTransition

mapping mapping mappingmapping

place10

place20

transition

level M2: model

a model of the Petri Net formalism,an INSTANCE of the Entity Relationship formalism

level M1: data

a Petri Net,an INSTANCE of the Petri Net formalism

tran2pl

pl2tran

mappingmapping

Hans Vangheluwe [email protected] MM, GG, DSVM 20/78

Page 21: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Meta-modelling: model-instance morphism ctd.

name type=String init.value=attributes type=List init.value=

ERentity

name type=String init.value=tokens type=Integer init.value=0

PNPlacename type=String init.value=PNTransition

level M3: meta−model

a model of the Entity Relationship formalism,an INSTANCE of the Core formalism(Core == Entity Relationship)

level M2: model

a model of the Petri Net formalism,an INSTANCE of the Entity Relationship formalism

level M1: data

a Petri Net,an INSTANCE of the Petri Net formalism

mappingmapping

mappingmapping

mapping

mapping mapping mappingmapping

mapping

place10

place20

transition

ERrelationship

tran2pl

pl2tran

Hans Vangheluwe [email protected] MM, GG, DSVM 21/78

Page 22: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

How to break the meta-* chain ?

name type=String init.valattributes type=List init

ERentity

ERrelationship

bootstrap ER (Core == Entity Relationship)

note: interpret or compile meta-models

Hans Vangheluwe [email protected] MM, GG, DSVM 22/78

Page 23: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Example: the Traffic domain

Hans Vangheluwe [email protected] MM, GG, DSVM 23/78

Page 24: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

a (domain-specific) model in the Traffic formalism

0bot_W2E

0turn1

0to_N_or_W

0turn2

0bot_N2S

2cars

1bot_CAP 1

turn1_CAP

1top_CAP

1turn2_CAP

Hans Vangheluwe [email protected] MM, GG, DSVM 24/78

Page 25: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

A Traffic meta-model(an Entity Relationship model)

name type=String init.valnum_vehicles type=Integer

RoadSection

name type=String init.valnum_vehicles type=Integerinfinite_supply type=Enum

Source

name type=String init.valnum_vehicles type=Integer

Sink

capacity type=Integer ininame type=String init.val

Capacity

CapacityOf

FlowTo

Source2Section Section2Sink

Hans Vangheluwe [email protected] MM, GG, DSVM 25/78

Page 26: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic meta-model notes

1. ER was extended with constraints

(OCL soon, now Python code)

2. alternative meta-formalisms: could use UML Class Diagrams

3. the given meta-model only specifies the Abstract Syntax of Traffic,

need to add Concrete (Visual) Syntax

Hans Vangheluwe [email protected] MM, GG, DSVM 26/78

Page 27: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic Concrete Syntax (the Capacity Entity)

Hans Vangheluwe [email protected] MM, GG, DSVM 27/78

Page 28: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

The generated Traffic visual modelling environment

Hans Vangheluwe [email protected] MM, GG, DSVM 28/78

Page 29: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Caveat: specifying the GUI’s Reactive Behaviour

Hans Vangheluwe [email protected] MM, GG, DSVM 29/78

Page 30: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

The GUI’s reactive behaviour in action

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

Hans Vangheluwe [email protected] MM, GG, DSVM 30/78

Page 31: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

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 that denotational and operational semantics

correspond if both are given !

Hans Vangheluwe [email protected] MM, GG, DSVM 31/78

Page 32: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic, the Big Picture

neglect time

Timed Transition Petri Nets

Traffic (timed)

Traffic (un-timed)

Place-Transition Petri Nets

Coverability Graph

desc

ribe

sem

antic

s

by m

appi

ng o

nto

describe semanticsby mapping onto

compute allpossible behaviours

simulate

simulate

simulate

analyze:reachability,coverability, ...

simulateanalyze

Hans Vangheluwe [email protected] MM, GG, DSVM 32/78

Page 33: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic’s semantics in terms of Petri Nets (PN)� need a meta-model of Traffic (shown before)

� need a meta-model of Petri Nets (shown before)

� need a model of the mapping: Traffic � Petri Nets

Hans Vangheluwe [email protected] MM, GG, DSVM 33/78

Page 34: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Graph Grammars to Specify Model Transformations

References:

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

of graph grammars and computing by graph transformation. World

Scientific.

. . .

Tools:

AGG, PROGRES, GME, AToM3, Fujaba, . . .

Hans Vangheluwe [email protected] MM, GG, DSVM 34/78

Page 35: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

INITIAL ACTION:for node in graph.listNodes["RoadSection"]: node.vehiclesPNPlaceGenerated=False

Hans Vangheluwe [email protected] MM, GG, DSVM 35/78

Page 36: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

A very simple Traffic model

2segment1

1segment2

4capacity

Hans Vangheluwe [email protected] MM, GG, DSVM 36/78

Page 37: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

<ANY><ANY>

1

LHS

rule1: RoadSection2PNPlace

CONDITION:node = LHS.nodeWithLabel(1)return not node.vehiclesPNPlaceGenerated

ACTION:node = RHS.nodeWithLabel(1)node.vehiclesPNPlaceGenerated = True

<COPIED><COPIED>

<SPECIFIED><SPECIFIED>

1

2

3

RHS

LHS.nodeWithLabel(1)).name

LHS.nodeWithLabel(1)).num_vehicles

Hans Vangheluwe [email protected] MM, GG, DSVM 37/78

Page 38: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Road Sections converted to Petri Net Places

2segment1

1segment2

4capacity

segment12

segment21

Hans Vangheluwe [email protected] MM, GG, DSVM 38/78

Page 39: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

<ANY><ANY>

<ANY><ANY>

<ANY><ANY>

<ANY><ANY>

1 27

3 4

5 6

LHS

<COPIED><COPIED>

<COPIED><COPIED>

<COPIED><COPIED>

<COPIED><COPIED>

0

1 2

103 4

9

5 6

8

RHS

rule 2: Flow2PNTransition

CONDITION:node = getMatched(LHS.nodeWithLabel(1))return node.in_connections_ == []

ACTION:node = RHS.nodeWithLabel(1)node.capacityPNPlaceGenerated = True

Hans Vangheluwe [email protected] MM, GG, DSVM 39/78

Page 40: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic Flow to Petri Net Transitions

2segment1

1segment2

4capacity

segment12

segment21

Hans Vangheluwe [email protected] MM, GG, DSVM 40/78

Page 41: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

rule 3: Capacity2PNPlace<COPIED>

<COPIED> <SPECIFIED><SPECIFIED>

1 23

RHS LHS.nodeWithLabel(1)).name

LHS.nodeWithLabel(1)).capacity

<ANY><ANY>

1

LHS

Hans Vangheluwe [email protected] MM, GG, DSVM 41/78

Page 42: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic Capacity to Petri Net Place

2segment1

1segment2

4capacity

segment12

segment21

capacity4

Hans Vangheluwe [email protected] MM, GG, DSVM 42/78

Page 43: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

<ANY><ANY>

<ANY><ANY> <ANY>

<ANY>

4

1

5

23

LHS

<COPIED><COPIED>

<COPIED><COPIED> <COPIED>

<COPIED>

4

1

6

23

RHS

rule 4: Capacity2PNPlaceLinks

Hans Vangheluwe [email protected] MM, GG, DSVM 43/78

Page 44: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic Capacity to Petri Net Place (links)

2segment1

1segment2

4capacity

segment12

segment21

capacity4

Hans Vangheluwe [email protected] MM, GG, DSVM 44/78

Page 45: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

<ANY><ANY> <ANY>

<ANY>1 2

3

LHS <COPIED><COPIED>

2

RHS

rule 5: Capacity2PNPlaceCleanup

Hans Vangheluwe [email protected] MM, GG, DSVM 45/78

Page 46: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic Capacity to Petri Net Place cleanup

2segment1

1segment2

segment12

segment21

capacity4

Hans Vangheluwe [email protected] MM, GG, DSVM 46/78

Page 47: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

<ANY><ANY>

<ANY><ANY>

<ANY><ANY>

<ANY>

<ANY>

17

2

6

5

3

4

LHS

<COPIED><COPIED>

<COPIED><COPIED>

<COPIED><COPIED>

<COPIED>

<COPIED>

1

8

7

2

6

5

3

4

RHS

rule 6: CapacityConstraintOnPl2Tr

CONDITION:cap_place = LHS.nodeWithLabel(6)out_trans = LHS.nodeWithLabel(4)capacity_transition_absent = Truefor in_link in cap_place.in_connections_: for out_link in out_trans.out_connections_: if (in_link == out_link) and isinstance(in_link,tran2pl): capacity_transition_absent = False breakreturn capacity_transition_absent

Hans Vangheluwe [email protected] MM, GG, DSVM 47/78

Page 48: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Capacity Constraint on Place to Transition

2segment1

1segment2

segment12

segment21

capacity4

Hans Vangheluwe [email protected] MM, GG, DSVM 48/78

Page 49: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

<ANY><ANY>

<ANY><ANY>

<ANY>

<ANY><ANY>

<ANY>

1

5

7

2

6

4

3

LHS

<COPIED><COPIED>

<COPIED><COPIED>

<COPIED><COPIED>

<COPIED>

1

5

7

2

6

4

8

3

RHS

rule 7: CapacityConstraintOnTr2Pl

CONDITION:cap_place = LHS.nodeWithLabel(6)in_trans = LHS.nodeWithLabel(4)capacity_transition_absent = Truefor out_link in cap_place.out_connections_: for in_link in in_trans.in_connections_: if (in_link == out_link) and isinstance(in_link, pl2tran): capacity_transition_absent = False breakreturn capacity_transition_absent

Hans Vangheluwe [email protected] MM, GG, DSVM 49/78

Page 50: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Capacity Constraint on Transition to Place

2segment1

1segment2

segment12

segment21

capacity4

Hans Vangheluwe [email protected] MM, GG, DSVM 50/78

Page 51: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

rule 8: InitialCapacity

<COPIED><COPIED> <COPIED>

<SPECIFIED>1

2

RHS

initial_num_vehicles = LHS.nodeWithLabel(1).num_vehiclescapacity_tokens = LHS.nodeWithLabel(2).tokensreturn capacity_tokens-initial_num_vehicles

<ANY><ANY> <ANY>

<ANY>1

32

LHS

Hans Vangheluwe [email protected] MM, GG, DSVM 51/78

Page 52: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Model Initial Capacity (applied rule twice)

2segment1

1segment2

segment12

segment21

capacity1

Hans Vangheluwe [email protected] MM, GG, DSVM 52/78

Page 53: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic to Petri Net Graph Grammar rules

<ANY><ANY>

1

2LHS RHS

rule 9: RemoveRoadSection

Hans Vangheluwe [email protected] MM, GG, DSVM 53/78

Page 54: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Removed Traffic Road Section, now only Petri Net

segment12

segment21

capacity1

Hans Vangheluwe [email protected] MM, GG, DSVM 54/78

Page 55: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Static Analysis of the Transformation Model

The transformation specified by the Graph Grammar model must satisfy

the following requirements:

� Convergence: the transformation process is finite

� Uniqueness: the transformation results in a single target model

� Syntactic Consistency: the target model must be exclusively in the

target formalism

Hans Vangheluwe [email protected] MM, GG, DSVM 55/78

Page 56: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Traffic, the Big Picture

neglect time

Timed Transition Petri Nets

Traffic (timed)

Traffic (un-timed)

Place-Transition Petri Nets

Coverability Graph

desc

ribe

sem

antic

s

by m

appi

ng o

nto

describe semanticsby mapping onto

compute allpossible behaviours

simulate

simulate

simulate

analyze:reachability,coverability, ...

simulateanalyze

Hans Vangheluwe [email protected] MM, GG, DSVM 56/78

Page 57: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

A less trivial 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] MM, GG, DSVM 57/78

Page 58: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

the Petri Net describing its behaviourobtained by Graph Rewriting

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] MM, GG, DSVM 58/78

Page 59: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Analysis: a Coverability Graph for the Petri Net[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] MM, GG, DSVM 59/78

Page 60: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

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] MM, GG, DSVM 60/78

Page 61: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Model-Based Development, Modify the Model

model

model’ app’

apptransformation

transformation

small modification

Hans Vangheluwe [email protected] MM, GG, DSVM 61/78

Page 62: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Model-Based Development, Modify theTransformation

model

model app’

apptransformation

small modification

transformation’

Hans Vangheluwe [email protected] MM, GG, DSVM 62/78

Page 63: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

AToM3, A Tool for Multi-formalism Meta-Modelling

atom3.cs.mcgill.ca

Hans Vangheluwe [email protected] MM, GG, DSVM 63/78

Page 64: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Forrester System Dynamics modelof Predator-Prey behaviour

Predator Prey

Grazing_efficiency

uptake_predatorloss_prey

predator_surplus_DR

prey_surplus_BR

2−species predator−prey system

Hans Vangheluwe [email protected] MM, GG, DSVM 64/78

Page 65: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Causal Block Diagram modelof a Harmonic Oscillator

x0

0.0

y0

1.0

ICx

ICy

− I OUT

K

1.0

0.0

PLOT

Hans Vangheluwe [email protected] MM, GG, DSVM 65/78

Page 66: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Petri Net model of a Producer-Consumer system

P.Calculating1

Wait4Cons0

Buffer0

Buffer−p1

Wait4Prod1

C.Calculating0

Produce

Put in Buffer

Rem.from buffer

Consume

Hans Vangheluwe [email protected] MM, GG, DSVM 66/78

Page 67: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Statechart model of a Producer-Consumer system

Empty

Full

Producing Wait4Prod

Wait4Cons

Computing

Buff Producer Consumer

buffer++

buffer−−

Produce

/ buffer++

[in Buff.Empty]

/ buffer−−

[in Buff.Full]Consume

Hans Vangheluwe [email protected] MM, GG, DSVM 67/78

Page 68: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

GPSS model of a Telephone Exchange

FN112

0

2V2

V1 PH1

LR PH1

V1 H2

P2NEP1

S PH1

LNKS

R PH1

1

LR PH2 R PH1

LNKS

1

S PH2

FN1120

Function: 1LNKS10

Hans Vangheluwe [email protected] MM, GG, DSVM 68/78

Page 69: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Generated GPSS code

1 FUNCTION RN1,C24

0.0,0.0/0.1,0.104/0.2,0.222/0.3,0.355/0.4,0.509/0.5,0.69

0.6,0.915/0.7,1.2/0.75,1.38/0.8,1.6/0.84,1.83/0.88,2.12

0.9,2.13/0.92,2.52/0.94,2.81/0.95,2.99/0.96,3.2/0.97,3.5

0.98,3.9/0.99,4.6/0.995,5.3/0.998,6.2/0.999,7.0/0.9997,8.0

*

L1 GENERATE 12,FN1

L3 TEST G V2,2,OUT

L4 ASSIGN 1,V1,H

L5 GATE LR PH1,L4 L17 ADVANCE 120,FN1

L6 ASSIGN 2,V1,H L18 LOGIC R PH1

L7 TEST NE P1,P2,L6 L19 LOGIC R PH2

L0 LOGIC R PH1 L20 LEAVE LNKS

L8 TRANSFER BOTH,L9,L11 L21 TERMINATE 1

L9 LOGIC R PH1 L13 LOGIC R PH1

L10 TERMINATE 1 L14 LEAVE LNKS

OUT TERMINATE 0 L15 TERMINATE 1

L11 ENTER LNKS LNKS STORAGE 10

L12 GATE LR PH2,L13 1 VARIABLE XH1*RN1/1000+1

L16 LOGIC S PH2 2 VARIABLE XH1-2*S$LNKS

Hans Vangheluwe [email protected] MM, GG, DSVM 69/78

Page 70: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

HS=ES+ODE, a Hybrid Formalism� To demonstrate the ease with which an HS-specific modelling

environment can be built

� HS combines

– Event Scheduling (ES)

to describe discrete-event behaviour

– Ordinary Differential Equations (ODEs)

to describe continuous-time behaviour

– Constructs to link ES and ODE

Hans Vangheluwe [email protected] MM, GG, DSVM 70/78

Page 71: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Example: Personalized Rapid Transit (PRT)� Discrete-event behaviour: loading and unloading passengers

� Continuous-time behaviour: accelerating, decelerating

� Control: keep velocity between boundaries

by switching between continuous “modes”

Hans Vangheluwe [email protected] MM, GG, DSVM 71/78

Page 72: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Passenger Arrival

Train_at_rest

START EVENT

x = x_0v = v_0passengers = 0

Initialize_Model

passengers = passengers Passenger_arrive

print "Train is leaving iTrain_is_full

IFpassengers < 10

AFTERrandom.uniform ( 1 , 10 )

IF1

AFTER0

IF1

IFpassengers >= 10

AFTER0

Hans Vangheluwe [email protected] MM, GG, DSVM 72/78

Page 73: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Train Motion

AcceleratingODE

xv

vk * ( v − v_init + 5 )

FrictionODE

xv

v− k * ( v − 20 )

BrakingODE

xv

v− k * ( v + 3 )

print "Train is leaving a

Train_starts

Stop_Accelerating

Start_Accelerating

Start_Braking

monitoring fct.:

v_max − v

+−

testmax

monitoring fct.:

stopping_x − x

+−

test_arrival

monitoring fct.:

v − v_min

+−

testmin

AFTER5

Hans Vangheluwe [email protected] MM, GG, DSVM 73/78

Page 74: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Train Arrival and Unloading

Train_at_rest

BrakingODE

xv

v− k * ( v + 3 )

print "Train arrived at t

DepartureStartpassengers = passengers −

Departure_EventIF

passengers > 0

AFTER5

IF1

AFTER0

monitoring fct.:

v

+−

Test_zerospeed

Hans Vangheluwe [email protected] MM, GG, DSVM 74/78

Page 75: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

The Complete Model

Train_at_rest

AcceleratingODE

xv

vk * ( v − v_init + 5 )

FrictionODE

xv

v− k * ( v − 20 )

BrakingODE

xv

v− k * ( v + 3 )

START EVENT

x = x_0v = v_0passengers = 0

Initialize_Model

passengers = passengers Passenger_arrive

print "Train is leaving iTrain_is_full

print "Train is leaving a

Train_starts

Stop_Accelerating

Start_Accelerating

Start_Braking

print "Train arrived at t

DepartureStartpassengers = passengers −

Departure_Event

IFpassengers < 10

AFTERrandom.uniform ( 1 , 10 )

IF1

AFTER0

IFpassengers > 0

AFTER5

monitoring fct.:

v_max − v

+−

testmax

monitoring fct.:

stopping_x − x

+−

test_arrival

monitoring fct.:

v − v_min

+−

testmin

IF1

AFTER5

IF1

AFTER0

IFpassengers >= 10

AFTER0

monitoring fct.:

v

+−

Test_zerospeed

Hans Vangheluwe [email protected] MM, GG, DSVM 75/78

Page 76: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Simulating the (compiled) Model

Hans Vangheluwe [email protected] MM, GG, DSVM 76/78

Page 77: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Train Passengers

Hans Vangheluwe [email protected] MM, GG, DSVM 77/78

Page 78: Meta-Modelling and Graph Rewriting, Enablers for Domain ...hv/publications/04.McGill.SE.presentation.pdf · SOCS Software Engineering Meeting 23 September 2004 Meta-Modelling and

Train Velocity

Hans Vangheluwe [email protected] MM, GG, DSVM 78/78


Recommended