McGill UniversitySchool of Computer Science
Ph.D. Student in the Modelling, Simulation and Design Lab
Programmed Graph Rewriting with Time for
Simulation-Based Design
Eugene SyrianiHans Vangheluwe
McGill UniversitySchool of Computer Science
Ph.D. Student in the Modelling, Simulation and Design Lab
Programmed Graph Rewriting with Time for
Simulation-Based Design
Eugene SyrianiHans Vangheluwe
Programmed Graph Rewriting with Time for Simulation-Based Design
OVERVIEW
Background
In the context
The Modular Timed Graph Transformation (MoTiF) language
Case Study: Reactive PacMan Game
Modelling, Simulation and Synthesis
Modelling of transformation and its environment
Simulation for optimization
Synthesis of application
Conclusion and Future Work3
Programmed Graph Rewriting with Time for Simulation-Based Design
IN THE CONTEXT• Model Transformation Graph Transformation
• Controlled Graph Rewriting (rewriting rules)
• Control Primitives :Sequencing, Branching, Looping, Parallelism, Hierarchy
• Time is inherent in our transformation models
Modelling, Simulation and Synthesis4
Programmed Graph Rewriting with Time for Simulation-Based Design
IN THE CONTEXTModel of System
Model of Environment
Simulation Experiments
Synthesis of Application
5
Programmed Graph Rewriting with Time for Simulation-Based Design
MoTiF: SEMANTIC DOMAIN• The Discrete Event System Specification [1]
(DEVS) formalism
• Highly compositional simulation framework
• DEVS:– Blocks
– Ports
– Events
• Semantics: Parallel composition of blocks/models
6[1] Zeigler B.P., Multifacetted Modelling and Discrete Event Simulation/ Academic Press, London (1984)
Programmed Graph Rewriting with Time for Simulation-Based Design
MoTiF: SEMANTIC DOMAIN
Atomic DEVS:– Time Advance– Output Function– Internal Transition– External Transition
ATOMIC
7
Programmed Graph Rewriting with Time for Simulation-Based Design
MoTiF: SEMANTIC DOMAINCoupled DEVS
8
C1A1
A2
C2
Programmed Graph Rewriting with Time for Simulation-Based Design
MoTiF [2]• Blocks– Atomic: encapsulate a graph rewriting rule
– Coupled: encapsulate a set of rules (graph grammar)
• Events– Inport: receive the host graph
– Outport(s): send the transformed graph
9[2] Syriani E. and Vangheluwe H.: Programmed Graph Rewriting with DEVS. AGTIVE 2007, LNCS (2008)
Programmed Graph Rewriting with Time for Simulation-Based Design
MoTiFMODELLING ENVIRONMENT IN AToM3 [3]
10[3] de Lara J., Vangheluwe H., AToM3: A tool for multi-formalism and meta-modelling. FASE, LNCS 2306 (2002), 174-188
Programmed Graph Rewriting with Time for Simulation-Based Design
MoTiF EXECUTION
COMPILE
GENERATE
IMPORT
SIMULATE
class Pacmaneat: def match(): … def execute(): …
class Kill(ARule): def __init__(self): ARule.__init__(self, name=‘Kill') self.state = ARuleState(Pacdie()) def weightFunction(self): return 1.0
class Pacmanmoveri: def match(): … def execute(): …
class Pacmandie: def match(): … def execute(): …
11
Programmed Graph Rewriting with Time for Simulation-Based Design
CASE STUDY: REACTIVE PACMAN GAMESimplified PacMan formalism [4]
[4] Heckel R., Graph Transformation in a nutshell. FoVMT, ENTCS 148 (2006), 187-198 12
Programmed Graph Rewriting with Time for Simulation-Based Design
CASE STUDY: REACTIVE PACMAN GAMEBuild the Graph Rewriting Rules
13
14
2
1
2
5 pacLink
3
ghostLink
3
ghostLink
1: Match[1].score + 1
1
2
3
1
2
35
4
pacLink
foodLink
6
4
pacLink
Programmed Graph Rewriting with Time for Simulation-Based Design
CASE STUDY: REACTIVE PACMAN GAMEBuild the Graph Rewriting Rules
14
4
1 2
35
gridLeft
ghostLink
1 2
3
4
6
gridLeft
ghostLink
4
1 2
6
gridRight
pacLink
1 2
4
5
gridRight
pacLink
33
Programmed Graph Rewriting with Time for Simulation-Based Design
15
Simulation Experiments
Synthesis of Application
Model of System
Model of Environment
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF THE TRANSFORMATION: SYSTEM
• User – Controller – Autonomous loop
• Feed-back to User
• On User interrupt: User Controlled
• Feed-back to User
Autonomous UserControlled
16
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF THE TRANSFORMATION: AUTONOMOUS CRule
Priorities
17
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF THE TRANSFORMATION: GHOSTMOVE CRule
Decider finds the next move for the ghost
Decider consumes time
18
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF TRANSFORMATION: SYSTEM
Autonomous UserControlled
19
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF THE TRANSFORMATION: USERCONTROLLED CRule
Conditional rule execution20
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF THE TRANSFORMATION: SYSTEM
Autonomous UserControlled
21
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF ENVIRONMENT: USER CoupledBlock
UserBehavior
UserInteraction
•Customization
•Modularity
22
Programmed Graph Rewriting with Time for Simulation-Based Design
MODEL OF THE PLAYER: STRATEGY
23
DummyRandom Smart
class Key: up = 'u' down = 'd' left = 'l' right = 'r' keys = [up, down, left, right]
def nextRandom(self): import random return random.Random().choice(Key.keys)
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF ENVIRONMENT: USERBEHAVIOR CoupledBlock
Back-tracking
Collector consumes time
24
Programmed Graph Rewriting with Time for Simulation-Based Design
MODELLING OF ENVIRONMENT: TRYMOVE CRule
4
1 2
5
gridRight
pacLink
1 2
4
6
gridRight
pacLink
33
1
78
ghostLink
25Non-determinism
Programmed Graph Rewriting with Time for Simulation-Based Design
MODEL OF THE PLAYER: SPEEDPlayer reaction time [5]:– Thinking time
– Motorics time
26
𝑭ሺ𝒙ሻ= 𝒆−𝒆𝒃−𝒙𝒂
[5] Zaitev A.V., Skorik Y.A., Mathematical description of sensorimotor reaction time distribution, Human Psychology 28(4) (2002), 494-497
Slow Normal FastVery Fast
Programmed Graph Rewriting with Time for Simulation-Based Design
27
Simulation Experiments
Synthesis of Application
Model of System
Model of Environment
Programmed Graph Rewriting with Time for Simulation-Based Design
WHY DO WE NEED SIMULATION?
• A.I. StrategyRandom – Smart – Very Smart
• SpeedToo Slow – … – Too Fast
Fix Strategy: Very Smart
Find optimal speed
We want to build a “playable” game
28
Programmed Graph Rewriting with Time for Simulation-Based Design
SIMULATION RESULTSFinding the optimal game speed
29
Programmed Graph Rewriting with Time for Simulation-Based Design
30
Synthesis of Application
Simulation Experiments
Model of System
Model of Environment
Programmed Graph Rewriting with Time for Simulation-Based Design
SYNTHESIS OF APPLICATION• Synthesis of a reactive game
• Discard the UserBehavior block
• Runs on a web browser using AJAX and SVG
• Real-time model transformation
31
UserInteractionUser
BehaviorUser
Interaction
Programmed Graph Rewriting with Time for Simulation-Based Design
SUMMARYMoTiF allows for
• Modelling and Simulation-Based Design– Graph transformation rules
– Timed transformation system
– User
• Synthesis of applications– Reactive
– Real-time
32
Autonomous UserControlled
Model E
veryth
ing
Programmed Graph Rewriting with Time for Simulation-Based Design
FUTURE WORK
• Model A.I. behavior: backtracking
• Re-use and parametrisation of transformation models
• MORE COMPLEX EXAMPLES
33
Programmed Graph Rewriting with Time for Simulation-Based Design
34
?
Top Related