programmed graph rewriting with devs
DESCRIPTION
Eugene Syriani and Hans Vangheluwe. Programmed Graph Rewriting with DEVS. School of Computer Science. McGill University. Overview. In the context Overview of the Discrete EVent system Specification (DEVS) formalism Building example with AToM 3 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/1.jpg)
McGill UniversitySchool of Computer Science
1
‘07
Programmed Graph Rewriting with DEVS
Eugene Syrianiand
Hans Vangheluwe
McGill UniversitySchool of Computer Science
![Page 2: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/2.jpg)
Programmed Graph Rewriting with DEVS
2
‘07
OVERVIEW
In the context
Overview of the Discrete EVent system
Specification (DEVS) formalism
Building example with AToM3
Graph Rewriting Control Flow (GRCF):
Mimic AToM3 and beyond
Summary
![Page 3: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/3.jpg)
Programmed Graph Rewriting with DEVS
3
‘07
IN THE CONTEXT• Model transformation: Programmed Graph
Rewriting
• At least as expressive as: GreAT, VMTS, Fujaba, ProGreS, MOFLONSequencing, Branching, Looping, Hierarchy, Parallelism
• Cleanly tear apart– Transformation entities– Control flow, structure, hierarchy
• DEVS gives us time and modularity too
![Page 4: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/4.jpg)
Programmed Graph Rewriting with DEVS
4
‘07
OVERVIEW
In the context
Overview of the Discrete EVent system
Specification (DEVS) formalism
Building example with AToM3
Graph Rewriting Control Flow (GRCF):
Mimic AToM3 and beyond
Summary
![Page 5: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/5.jpg)
Programmed Graph Rewriting with DEVS
5
‘07
OVERVIEW OF THE DEVS FORMALISM• Bernard Zeigler, late ‘70s
• Basis for compositional modelling and simulation of discrete event systems
• Design, performance analysis and implementation
![Page 6: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/6.jpg)
Programmed Graph Rewriting with DEVS
6
‘07
OVERVIEW OF THE DEVS FORMALISM
• Block: Atomic / Coupled
• Port: Inport / Outport
• Event
• Global time
![Page 7: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/7.jpg)
Programmed Graph Rewriting with DEVS
7
‘07
OVERVIEW OF THE DEVS FORMALISM
Atomic DEVS:– Time Advance– Output Function– Internal Transition– External Transition
ATOMIC
![Page 8: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/8.jpg)
Programmed Graph Rewriting with DEVS
8
‘07
OVERVIEW OF THE DEVS FORMALISMCoupled DEVS
CA1
A2
A3
![Page 9: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/9.jpg)
Programmed Graph Rewriting with DEVS
9
‘07
C
OVERVIEW OF THE DEVS FORMALISM
Coupled DEVS:– Select Function
A1
A2
![Page 10: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/10.jpg)
Programmed Graph Rewriting with DEVS
10
‘07
OVERVIEW OF THE DEVS FORMALISM
class AExample(AtomicDEVS):
def __init__(self):
self.state = ExampleState() self.in = self.addInPort()
self.out = self.addOutPort()
def extTransition(self):
X = self.peak(self.in)
...
return self.state
def intTransition(self):
...
return self.state
def outputFnc(self):
...
self.poke(self.out, Y)
def timeAdvance(self):
return 1
Our implementation: pythonDEVSclass CExample(CoupledDEVS):
def __init__(self):
self.M1 = self.addSubModel(Example())
self.M2 = self.addSubModel(Example())
self.connectPorts(self.M1.out, self.M2.in)
def select(self, immList):
return immList[0]
![Page 11: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/11.jpg)
Programmed Graph Rewriting with DEVS
11
‘07
OVERVIEW
In the context
Overview of the Discrete EVent system
Specification (DEVS) formalism
Building example with AToM3
Graph Rewriting Control Flow (GRCF):
Mimic AToM3 and beyond
Summary
![Page 12: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/12.jpg)
Programmed Graph Rewriting with DEVS
12
‘07
BUILDING EXAMPLE WITH ATOM3 [1]
Simplified PacMan formalism [2]
[1] de Lara J., Vangheluwe H., AToM3: A tool for multi-formalism and meta-modelling, LNCS (2002), 174-188[ 2] Heckel R., Graph Transformation in a nutshell, ENTCS (2006), 187-198
![Page 13: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/13.jpg)
Programmed Graph Rewriting with DEVS
13
‘07
BUILDING EXAMPLE WITH ATOM3
Build the Meta-Model of the PacMan formalism
![Page 14: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/14.jpg)
Programmed Graph Rewriting with DEVS
14
‘07
BUILDING EXAMPLE WITH ATOM3
Build the Graph Grammar
![Page 15: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/15.jpg)
Programmed Graph Rewriting with DEVS
15
‘07
BUILDING EXAMPLE WITH ATOM3
Build the Graph Grammar
14
2
1
2
5 pacLink
3
ghostLink
3
ghostLink
1: return self.LHS.nodeWithLabel(1).score + 1
1
2
3
1
2
35
4
pacLink
foodLink
6
4
pacLink
P 1
P 2
![Page 16: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/16.jpg)
Programmed Graph Rewriting with DEVS
16
‘07
BUILDING EXAMPLE WITH ATOM3
Build the Graph Grammar
4
1 2
36
gridLeft
ghostLink
1 2
3
4
7
gridLeft
ghostLink
4
1 2
5
gridRight
pacLink
1 2
4
6
gridRight
pacLink
33
P 3
P 3
![Page 17: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/17.jpg)
Programmed Graph Rewriting with DEVS
17
‘07
BUILDING EXAMPLE WITH ATOM3
![Page 18: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/18.jpg)
Programmed Graph Rewriting with DEVS
18
‘07
BUILDING EXAMPLE WITH ATOM3
• Capture a trace of execution– Keep log of used rules
![Page 19: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/19.jpg)
Programmed Graph Rewriting with DEVS
19
‘07
OVERVIEW
In the context
Overview of the Discrete EVent system
Specification (DEVS) formalism
Building example with AToM3
Graph Rewriting Control Flow (GRCF):
Mimic AToM3 and beyond
Summary
![Page 20: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/20.jpg)
Programmed Graph Rewriting with DEVS
20
‘07
GRAPH REWRITING CONTROL FLOW• DEVS blocks– Atomic block: encapsulate the graph rewriting rule
– Coupled block: encapsulate the graph grammar
• Events– Inport: recieve the host graph
– Outport(s): send the transformed graph
![Page 21: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/21.jpg)
Programmed Graph Rewriting with DEVS
21
‘07
GRAPH REWRITING CONTROL FLOW
![Page 22: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/22.jpg)
Programmed Graph Rewriting with DEVS
22
‘07
Trace
GRAPH REWRITING CONTROL FLOW
Model AToM3’s graph transformation engineUserInput
Control
Graph Transformation
Rules
Input graph Step
Send graph to transform
Transformed graph
Rules used
![Page 23: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/23.jpg)
Programmed Graph Rewriting with DEVS
23
‘07
GRAPH REWRITING CONTROL FLOW
Graph transformation engineUserInput
g_out out_stepdone_rcv
Controllerg_init done_send in_step
g_out
g_modified
g_unmodified
Trace
g_in g_succeed
match_fail
match_succeed
g_in
match_fail
trace
trace
g_in
g_fail
trace
GGRule
GGRule
match_succeed
GGRules
![Page 24: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/24.jpg)
Programmed Graph Rewriting with DEVS
24
‘07
GRAPH REWRITING CONTROL FLOWManaging priorities
g_in
GGRules
Synchronizer
match_fail
g_in
g_in
abort
match_succeed
Priority ng_in
abort
abort
out_fail
match_failGGRule GGRule
match_succeed
in_success in_fail
out_success g_succeed
g_fail
GGRule
Priority n+1
Non-determinism:Randomize select function
![Page 25: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/25.jpg)
Programmed Graph Rewriting with DEVS
25
‘07
GRAPH REWRITING CONTROL FLOWUse compiled version of AToM3’s rule
class pacDie:
...
![Page 26: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/26.jpg)
Programmed Graph Rewriting with DEVS
26
‘07
import compiled rules…
GRAPH REWRITING CONTROL FLOW
class AExample(AtomicDEVS):
def __init__(self):
self.state = ExampleState() self.in = self.addInPort()
self.out = self.addOutPort()
def extTransition(self):
X = self.peak(self.in)
...
return self.state
def intTransition(self):
...
return self.state
def outputFnc(self):
...
self.poke(self.out, Y)
def timeAdvance(self):
return 1
![Page 27: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/27.jpg)
Programmed Graph Rewriting with DEVS
27
‘07
GRAPH REWRITING CONTROL FLOWExtension of AToM3’s graph transformation engine
g_out out_step
g_init done_send in_step
done_rcv
g_out
g_succeed
g_failg_in
AutonomousRules
Usercontrolled
Rules
g_fail
g_modifiedg_unmodified
g_in
out_control
control_out
control_in
Controller
User
in_control
![Page 28: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/28.jpg)
Programmed Graph Rewriting with DEVS
28
‘07
GRAPH REWRITING CONTROL FLOWExtension of AToM3’s graph transformation engine
Up Down Left Right
g_incontrol_in
key g_in
g_up
g_down
g_in
match_succeedmatch_fail
g_in
match_succeedmatch_fail
g_in
match_succeedmatch_fail
g_in
match_fail
Dispatchg_left
out_fail
in_successin_fail
out_success
g_succeedg_fail
User controlled Rules
match_succeed
g_right
![Page 29: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/29.jpg)
Programmed Graph Rewriting with DEVS
29
‘07
Autonomous Rules
match_fail
g_in
match_fail
g_in
GRAPH REWRITING CONTROL FLOWExtension of AToM3’s graph transformation engine
g_in g_succeed
match_succeed
g_in
g_fail
Kill
Eat
Ghost Move
match_succeed
match_fail
match_succeed
![Page 30: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/30.jpg)
Programmed Graph Rewriting with DEVS
30
‘07
OVERVIEW
In the context
Overview of the Discrete EVent system
Specification (DEVS) formalism
Building example with AToM3
Graph Rewriting Control Flow (GRCF):
Mimic AToM3 and beyond
Summary
![Page 31: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/31.jpg)
Programmed Graph Rewriting with DEVS
31
‘07
SUMMARY
SequenceBranchingLoopingHierarchy + ModularityParallelism
Control flow structure properties satisfied
![Page 32: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/32.jpg)
Programmed Graph Rewriting with DEVS
32
‘07
Are we at the right level of abstraction?Is it the way industry should go in
model transformation?
![Page 33: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/33.jpg)
Programmed Graph Rewriting with DEVS
33
‘07
“[...] the rule execution semantics is similar to the execution semantics of asynchronous
dataflow graphs and DEVS, but with a difference in the hierarchical rule execution.
[...] the class diagrams Figs. 14 and 15 introduce the same concepts as found in DEVS.”
A. Agrawal et al. The design of a language for model transformations. SoSym, 2006
![Page 34: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/34.jpg)
Programmed Graph Rewriting with DEVS
34
‘07
CONCLUSION AND FUTURE WORK
• DEVS is a sequential, deterministic formalism
• Parallel-DEVS
• Kiltera (CSP-like languages)
Parallelism
![Page 35: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/35.jpg)
Programmed Graph Rewriting with DEVS
35
‘07
CONCLUSION AND FUTURE WORK
• Metric, Statistics
• Timed graph transformation
• Real-Time DEVS
Time
![Page 36: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/36.jpg)
Programmed Graph Rewriting with DEVS
36
‘07
CONCLUSION AND FUTURE WORK
• Event-driven Graph Rewriting
• Modelling of the user
User - Events
![Page 37: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/37.jpg)
Programmed Graph Rewriting with DEVS
37
‘07
CONCLUSION AND FUTURE WORK
• Optimization hints
• Information on the flow
• Replace python code by... Statechart?
• Multi-formalism
• Add an AI block in the autonomous rules
Some Extensions
![Page 38: Programmed Graph Rewriting with DEVS](https://reader038.vdocuments.mx/reader038/viewer/2022110101/56812b26550346895d8f2b72/html5/thumbnails/38.jpg)
Programmed Graph Rewriting with DEVS
38
‘07
GRAPH REWRITING CONTROL FLOW
class AExample(AtomicDEVS):
def __init__(self):
self.state = ExampleState()
self.in = self.addInPort()
self.out =
self.addOutPort()
def extTransition(self):
X = self.peak(self.in)
...
return self.state
return 1
e(AtomicDEVS):
def ___(self):
self.state = ExampleState()
self.in = self.addInPort()
self.out = hsdhfjhb
Sdvjvkv
Ds
v
return 1
classself.state =
ExampleState()sdvv
self.in = self.addInPort()
self.out =
self.addOutPort()
def extTransition(self):
X = self.peak(self.in)
...
return sdsdfsdfsdfsfsdfsdf
In AToM3 Outside AToM3