34
McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Programmed Graph Rewriting with Time for Simulation-Based Design Eugene Syriani Hans Vangheluwe

McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Embed Size (px)

Citation preview

Page 1: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans 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

Page 2: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans 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

Page 3: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans 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

Page 4: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 5: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

IN THE CONTEXTModel of System

Model of Environment

Simulation Experiments

Synthesis of Application

5

Page 6: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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)

Page 7: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MoTiF: SEMANTIC DOMAIN

Atomic DEVS:– Time Advance– Output Function– Internal Transition– External Transition

ATOMIC

7

Page 8: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MoTiF: SEMANTIC DOMAINCoupled DEVS

8

C1A1

A2

C2

Page 9: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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)

Page 10: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 11: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 12: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 13: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 14: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 15: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

15

Simulation Experiments

Synthesis of Application

Model of System

Model of Environment

Page 16: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 17: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MODELLING OF THE TRANSFORMATION: AUTONOMOUS CRule

Priorities

17

Page 18: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 19: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MODELLING OF TRANSFORMATION: SYSTEM

Autonomous UserControlled

19

Page 20: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MODELLING OF THE TRANSFORMATION: USERCONTROLLED CRule

Conditional rule execution20

Page 21: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MODELLING OF THE TRANSFORMATION: SYSTEM

Autonomous UserControlled

21

Page 22: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MODELLING OF ENVIRONMENT: USER CoupledBlock

UserBehavior

UserInteraction

•Customization

•Modularity

22

Page 23: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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)

Page 24: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

MODELLING OF ENVIRONMENT: USERBEHAVIOR CoupledBlock

Back-tracking

Collector consumes time

24

Page 25: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 26: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 27: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

27

Simulation Experiments

Synthesis of Application

Model of System

Model of Environment

Page 28: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 29: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

SIMULATION RESULTSFinding the optimal game speed

29

Page 30: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

30

Synthesis of Application

Simulation Experiments

Model of System

Model of Environment

Page 31: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 32: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 33: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

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

Page 34: McGill University School of Computer Science Ph.D. Student in the Modelling, Simulation and Design Lab Eugene Syriani Hans Vangheluwe

Programmed Graph Rewriting with Time for Simulation-Based Design

34

?