Meta-model are Models Too Hans Vangheluwe School of Computer - - PowerPoint PPT Presentation

meta model are models too
SMART_READER_LITE
LIVE PREVIEW

Meta-model are Models Too Hans Vangheluwe School of Computer - - PowerPoint PPT Presentation

Wintersim 2002 San Diego, CA 9 December 2002 Meta-model are Models Too Hans Vangheluwe School of Computer Science, McGill University, Montr eal, Canada Juan de Lara E.T.S. de Inform atica, Universidad Auton oma de Madrid, Madrid,


slide-1
SLIDE 1

Wintersim 2002 San Diego, CA 9 December 2002

Meta-model are Models Too

Hans Vangheluwe

School of Computer Science, McGill University, Montr´ eal, Canada

Juan de Lara

E.T.S. de Inform´ atica, Universidad Auton´

  • ma de Madrid, Madrid, Spain

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 1/34

slide-2
SLIDE 2

Meta-modelling and XML

  • modelling and simulation

meta-modelling

meta-modelling and XML

  • Experiences with

A Tool for Multi-formalism, Meta-Modelling AToM3: http://atom3.cs.mcgill.ca

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 2/34

slide-3
SLIDE 3

Modelling and Simulation Wishlist

  • Meaningful exchange and re-use of models

Syntax and Semantics !

  • Domain/problem-specific (visual) modelling & simulation environments

Syntax and Semantics !

  • Model transformation

– simulation (state changes) – code-generation (syntax changes) – simplification (level of abstraction changes) – formalism transformation (formalism changes)

  • Meaningful multi-formalism modelling

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 3/34

slide-4
SLIDE 4

Petri Net model of Producer Consumer

P.Calculating 1 Wait4Cons Buffer Buffer−p 1 Wait4Prod 1 C.Calculating Produce Put in Buffer Rem.from buffer Consume

reachability analysis + simplification + simulation + code generation

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 4/34

slide-5
SLIDE 5

Statechart model of Producer Consumer

Empty Full Producing Wait4Prod Wait4Cons Computing

Buff Producer Consumer

buffer++ buffer−− Produce / buffer++ [in Buff.Empty] / buffer−− [in Buff.Full] Consume

simulation + code generation + transformation to equivalent Petri Net

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 5/34

slide-6
SLIDE 6

Timed Automata model of a Traffic Light

show(R) R show(O) O show(G) G show(O) CO PCR show(OFF) OFF after 60 after 10 pi pi pi after 50 pi pcr pcr after 10

  • ff
  • ff
  • ff
  • ff
  • ff

smulation + code generation

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 6/34

slide-7
SLIDE 7

Generated Application

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 7/34

slide-8
SLIDE 8

GPSS model of Manufacturing system

5 .1 1 1 1 INSPECTR 1 INSPECTR 9 12 INSPECTR 3 INSPQ INSPQ TRANSIT Name: Low.Limit: Int.Size: Num.Intervals: TRANSIT 10 5 5

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 8/34

slide-9
SLIDE 9

Generated GPSS code

* Manufacturing shop model 4 *

  • G. Gordon Figure 11-9/9-8

SIMULATE L0 GENERATE 5 ; Create parts L7 QUEUE INSPQ ; Queue for an inspector L5 ENTER INSPECTR,1 ; A single inspector becomes busy L8 DEPART INSPQ ; Leave the inspector queue L9 MARK ; Start counting transit time L1 ADVANCE 12,9 ; Inspect L6 LEAVE INSPECTR,1 ; Make the inspector idle again L10 TABULATE TRANSIT ; Tabulate parts’ transit time L2 TRANSFER .1,ACC,REJ ; Randomly determine defective parts ACC TERMINATE 1 ; Accepted parts REJ TERMINATE 1 ; Rejected parts TRANSIT TABLE M1,5,5,10 INSPECTR STORAGE 3 START 1000 END Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 9/34

slide-10
SLIDE 10

Forrester System Dynamics model of Predator-Prey

Predator Prey Grazing_efficiency uptake_predator loss_prey predator_surplus_DR prey_surplus_BR

2−species predator−prey system

transformation to Ordinary Differential Equations + analysis

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 10/34

slide-11
SLIDE 11

Causal Block Diagram model of Harmonic Oscillator

x0 0.0 y0 1.0

IC

x

IC

y −

I OUT

K 1.0 0.0 PLOT

analysis + simplification + simulation

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 11/34

slide-12
SLIDE 12

Event Scheduling DAE model of a Train

Train_at_rest AcceleratingODE

x v v k * ( v − v_init + 5 )

FrictionODE

x v v − k * ( v − 20 )

BrakingODE

x v v − k * ( v + 3 )

START EVENT

x = x_0 v = v_0 passengers = 0

Initialize_Model

passengers = passengers

Passenger_arrive

print "Train is leaving i

Train_is_full

print "Train is leaving a

Train_starts Stop_Accelerating Start_Accelerating Start_Braking

print "Train arrived at t

DepartureStart

passengers = passengers −

Departure_Event

monitoring fct.: v_max − v +−

testmax

monitoring fct.: v − v_min +−

testmin

monitoring fct.: stopping_x − x +−

test_arrival

monitoring fct.: v +−

Test_zerospeed IF 1 AFTER IF passengers < 10 AFTER random.uniform ( 1 , 10 ) IF 1 AFTER 5 IF passengers >= 10 AFTER IF 1 AFTER IF passengers > 0 AFTER 5

code generation

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 12/34

slide-13
SLIDE 13

What is Meta-modelling ?

  • A meta-model is a model of a modelling formalism
  • A meta-model is itself a model. Its syntax and semantics are

governed by the formalism it is described in. That formalism can be modelled in a meta-meta-model.

  • As a meta-model is a model, we can reason about it, manipulate it, . . .

In particular, properties of (all models in) a formalism can be formally proven.

  • Formalism-specific modelling and simulation tools can automatically

be generated from a meta-model (e.g., in AToM3 A Tool for Multi-formalism Meta-Modelling).

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 13/34

slide-14
SLIDE 14
  • Formalisms can be tailored to specific needs by modifying the

meta-model (possibly through inheritance if specializing).

Building domain/application specific, possibly graphical modelling and simulation environments becomes affordable.

  • Semantics of new formalisms through extension or transformation.

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 14/34

slide-15
SLIDE 15

FSA model of Even Binary Number recognizer

Init End_1 End_0 1 1 1

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 15/34

slide-16
SLIDE 16

ER model of the FSA formalism syntax (meta-model)

Name type=String init.val isInitial type=Boolean in isFinal type=Boolean init FSAState current FSATransition points_to

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 16/34

slide-17
SLIDE 17

ER formalism + constraints (OCL/Python)

# check for unique input labels (FSA) for transition1 in state.out_connections: for transition2 in state.out_connections: if transition1 != transition2: if transition1.in == transition2.in: return("Non-determinism: input "+transition1.in)

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 17/34

slide-18
SLIDE 18

ER model of the ER formalism (meta-meta-model)

name type=String init.val attributes type=List init ERentity ERrelationship

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 18/34

slide-19
SLIDE 19

Meta-meta-. . .

meta-meta model meta-model processor meta-model user input a model of a class of models (the formalism MF) semantics within formalism MMF describes: structure and constraints a model in formalism MF

  • create
  • delete
  • verify (local, global)

meta-model processor model user input a model of a class of models (the formalism F) semantics within formalism MF describes: structure and constraints a model in formalism F

  • create
  • delete
  • verify (local, global)

MMF MF F (ER) (ER) (FSA) Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 19/34

slide-20
SLIDE 20

Causal Block Diagram Semantics ?

x0 0.0 y0 1.0

IC

x

IC

y −

I OUT

K 1.0 0.0 PLOT

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 20/34

slide-21
SLIDE 21

Causal Block Diagram Denotational Semantics

✄ ☎ ☎ ✆ ☎ ☎ ✝

dx dt

y x

✟ ✠ ✞

dy dt

✞ ✡

Kx y

✟ ✠ ✞

1 K

1

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 21/34

slide-22
SLIDE 22

FSA model Operational Semantics ?

Init End_1 End_0 1 1 1

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 22/34

slide-23
SLIDE 23

Simulation steps

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 23/34

slide-24
SLIDE 24

Init End_1 End_0 1 1 1 Current State Init End_1 End_0 1 1 1 Current State Init End_1 End_0 1 1 1 Current State Init End_1 End_0 1 1 1 Current State

Rule 1 Rule 2 Rule 2 Rule 2 Final Action

"Accept Input"

input 0 input 1 input 0 end of input

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 24/34

slide-25
SLIDE 25

Graph Grammar model of FSA OpSem

/ <ANY> <ANY> <ANY> Current State 2 4 3 1 / <COPIED> <COPIED> <COPIED> Current State 2 4 3 1 <ANY> 1 / <ANY> <ANY> <ANY> <ANY> Current State 2 4 3 5 1

/ <COPIED> <COPIED> <COPIED> <COPIED> Current State 2 4 3 5 1

::= ::= ::=

Rule 1 (priority 3) Rule 2 (priority 1) Rule 3 (priority 2) Locate Initial Current State State Transition Local State Transition condition: matched(4).input == input[0] action: remove(input[0]) condition: matched(4).input == input[0] action: remove(input[0])

<COPIED> Current State 3 1 2

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 25/34

slide-26
SLIDE 26

Model Transformation meta-specification

meta-model a model in formalism ER meta-model processor model user input a model of a class of models (the formalism NFA) semantics within formalism ER a model in formalism NFA

  • create
  • delete
  • verify (local, global)

MF F (ER) (NFA) meta-model a model in formalism MF meta-model processor model user input a model of a class of models (the formalism F) semantics within formalism MF describes: structure and constraints a model in formalism FSA

  • create
  • delete
  • verify (local, global)

MF F (ER) (FSA) (multi-formalism) model transformer = meta-model processor transformation meta-model MF (GGR)

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 26/34

slide-27
SLIDE 27

Model Transformation Uses (1)

  • Code generation
  • Operational Semantics (reference simulator)
  • Denotational Semantics

May model transformation as Graph Grammar

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 27/34

slide-28
SLIDE 28

Formalism transformation uses (2)

  • Add new formalisms without much effort (only ∆).
  • Re-use lower level modelling/simulation environment.
  • Answer questions at “optimal” level.
  • Optimization possible at every level.
  • Semantics of coupled multi-formalism models.

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 28/34

slide-29
SLIDE 29

Formalism Transformation Graph

DEVS

Process Interaction Discrete Event state trajectory data (observation frame) Petri Nets Statecharts 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

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 29/34

slide-30
SLIDE 30

Saving (meta-)models: core-XML

document ::= prolog element misc* prolog ::= VERSION? ENCODING? misc* misc ::= COMMENT | attribute_decl attribute_decl ::= ATTDEF NAME attribute+ ENDDEF element ::= START attribute* empty_or_content empty_or_content ::= SLASH CLOSE | CLOSE content END NAME? CLOSE content ::= (DATA | misc | element)* attribute ::= NAME (EQ VALUE)?

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 30/34

slide-31
SLIDE 31

XML and Meta-modelling

XML XML AToM3 Python format core XML F G lexical & syntactic analysis write Python load write syntax check transform

core XML syntax (in lex & yacc) ER+constr GraphGram ER+constr GraphGram GraphGram formalism F syntax formalism F syntax model of transformation model of XML generation model of Python generation

< DTD, XMLSchema < XSLT Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 31/34

slide-32
SLIDE 32

Alternatives

  • 1. Generate DTDs from meta-model to describe model syntax
  • 2. Models are attributed typed directed graphs

Graph Exchange Language (GXL) http://www.grupo.de/GXL

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 32/34

slide-33
SLIDE 33

GXL Example

<gxl> <node id="Customers" type="GENERATE"> <attr name="A" value="50"/> <attr name="B" value="10"/> </node> <node id="End" type="TERMINATE"> <attr name="A" value="1"/> </node> <edge begin="Customers" end="End" type="ConnectBlock"> <attr colour="BLUE"> </edge> </gxl>

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 33/34

slide-34
SLIDE 34

Conclusions

  • Meta-model formalism syntax
  • Graph Grammars models for all model Transformations
  • Variations (flavours) of formalisms (syntax and semantics)
  • Simulator (reference implementation)
  • Model exchange with XML, GXL
  • Meta-modelling Environment (ATOM3)

Wintersim 2002, 9 December, San Diego hv@cs.mcgill.ca Meta-model are Model Too 34/34