Parallel DEVS - The Modelling, Simulation and Design Lab...

58
Parallel DEVS An Introduction Using PythonPDEVS Yentl Van Tendeloo, Hans Vangheluwe

Transcript of Parallel DEVS - The Modelling, Simulation and Design Lab...

Parallel DEVSAn Introduction Using PythonPDEVS

Yentl Van Tendeloo, Hans Vangheluwe

Introduction

Bernard P. Zeigler.

Theory Of Modelling And Simulation.

1st ed. Wiley, 1976.

Bernard P. Zeigler, Herbert Praehofer,

and Tag Gon Kim.

Theory Of Modelling And Simulation.

2nd ed. Academic Press, 2000.

Bernard P. Zeigler.

Multifacetted Modelling and

Discrete Event Simulation.

1st ed. Academic Press, 1984.

Alex ChungHen Chow.

Parallel DEVS: a parallel, hierarchical, modular

modeling formalism and its distributed simulator.

Transactions of the Society for Computer

Simulation. 1996; 13(2): 55-68.

Alex ChungHen Chow, Bernard P. Zeigler and Doo

Hwan Kim.

Abstract simulator for the parallel DEVS formalism.

Fifth Annual Conference on AI, and Planning in High

Autonomy Systems. 1994, pp. 157-163.

Yentl Van Tendeloo and Hans Vangheluwe.

An Evaluation of DEVS Simulation Tools.

Simulation: Transactions of the Society

for Modeling and Simulation International.

2017, 93(2): 103-121

Yentl Van Tendeloo and Hans Vangheluwe.

An Overview of PythonPDEVS.

In Proceedings of Journées DEVS

Francophones (JDF), pages 59-66, 2016.

Our presentation uses initialized DEVS models, which

contain an initial state. The initial state was left

implicit in the original DEVS specification.

DEVS

GPSS

Meijin++

SimScript

Sequential Discrete Event Language

= modular simulation assembly language

Vangheluwe, Hans. DEVS as a common denominator for multi-formalism hybrid systems modelling.In proceedings of the International Symposium on Computer-Aided Control System Design, pp. 129-134. 2000.

t

t

X

Y

𝑥1

𝑥2

𝑦1𝑦2

finite number of non-𝜙 events

𝜙

𝜙

in a finite time interval

t

t

t

X

S

Y

𝑥1

𝑥2

𝑦1𝑦2

𝑠1

𝑠2

𝑠3

𝑠4

𝜙

𝜙

Experimentation

Simulation

Experiment

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑 = 60𝑠𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤 = 3𝑠

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛 = 57𝑠

𝑐𝑜𝑛𝑑𝑡𝑒𝑟𝑚𝑖𝑛𝑎𝑡𝑖𝑜𝑛 = (𝑡𝑠𝑖𝑚 ≥ 𝑡𝑒𝑛𝑑)𝑡𝑒𝑛𝑑 = 24ℎ

Trace

Model

Solver

Model

Simulator

from pypdevs.simulator import Simulator

from mymodel import MyModel

model = MyModel()

simulator = Simulator(model)

simulator.setVerbose()

simulator.simulate()

simple_experiment.pyConcrete Syntax

__ Current Time: 0.00 ______________________________________

INITIAL CONDITIONS in model <trafficSystem.trafficLight>

Initial State: red

Next scheduled internal transition at time 58.50

INITIAL CONDITIONS in model <trafficSystem.policeman>

Initial State: idle

Next scheduled internal transition at time 200.00

__ Current Time: 58.50 ______________________________________

INTERNAL TRANSITION in model <trafficSystem.trafficLight>

New State: green

Output Port Configuration:

port <OBSERVED>:

grey

Next scheduled internal transition at time 108.50

__ Current Time: 108.50 ______________________________________

INTERNAL TRANSITION in model <trafficSystem.trafficLight>

New State: yellow

Output Port Configuration:

port <OBSERVED>:

yellow

Next scheduled internal transition at time 118.50

Atomic Models

t

t

X

Y

𝑥1

𝑥2

𝑦1𝑦2

?𝜙

𝜙

Modelling Discrete Event Behaviour

Finite State Automaton Timed Event Scheduling Graph

toRed

toGreen

toYellow

red

green

yellow schedule

in 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

schedule

in 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

schedule

in 𝑑𝑒𝑙𝑎𝑦_𝑔𝑟𝑒𝑒𝑛

𝑒 = 0𝑠

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

toRed

toYellow

toGreen

𝑒 = 0𝑠

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

X

Y

t

t

S

t5760

120 177

red

yellow

green

𝑆 : set of sequential states

𝑆 = {red, yellow, green}

𝛿𝑖𝑛𝑡 : 𝑆 → 𝑆𝛿𝑖𝑛𝑡 = {red → green,

green → yellow,

yellow → red}

𝑡𝑎 : S → ℝ0,+∞

𝑡𝑎 = {red → 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤}

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑀 = , , ,𝑆 𝛿𝑖𝑛𝑡 𝑡𝑎

Autonomous (no input)

Time Advance: corner cases

𝑡𝑎 : S → ℝ0,+∞

𝑡𝑎 𝑠𝑖 = +∞

passive states

𝑡𝑎 𝑠𝑖 = 0

transient states

!

Elapsed time

e

t

𝑡𝑎(𝑔𝑟𝑒𝑒𝑛)

𝑡𝑎(𝑦𝑒𝑙𝑙𝑜𝑤)

𝑡𝑎(𝑟𝑒𝑑)

… …

Elapsed time

S

t

red

yellow

green

… …

ta(𝑠𝑖)

𝜎𝑖𝑒𝑖

Initialization of Initial State

S

t

red

yellow

green

𝑡𝑎(𝑠0)

𝑒0 𝜎0

𝑠0, 0 𝑞𝑖𝑛𝑖𝑡 = 𝑠0, 𝑒0 𝑠0, 𝑡𝑎 𝑠0

Elapsed time

e

t

𝑡𝑎(𝑔𝑟𝑒𝑒𝑛)

𝑡𝑎(𝑦𝑒𝑙𝑙𝑜𝑤)

𝑡𝑎(𝑟𝑒𝑑)

0

𝑒0

𝑡𝑎 𝑠0

𝑆 : set of sequential states

𝑆 = {red, yellow, green}

𝛿𝑖𝑛𝑡 : 𝑆 → 𝑆𝛿𝑖𝑛𝑡 = {red → green,

green → yellow,

yellow → red}

𝑡𝑎 : S → ℝ0,+∞

𝑡𝑎 = {red → 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤}

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑀 = , , ,𝑆 𝛿𝑖𝑛𝑡 𝑡𝑎𝑞𝑖𝑛𝑖𝑡

𝑞𝑖𝑛𝑖𝑡 : 𝑄 – set of total states

𝑄 = 𝑠, 𝑒 𝑠 ∈ 𝑆, 0 ≤ 𝑒 ≤ 𝑡𝑎(𝑠)𝑞𝑖𝑛𝑖𝑡 = (green, 0)

Autonomous (no output)

𝑒 = 0𝑠

𝑆 = {red, yellow, green}

𝛿𝑖𝑛𝑡 = { red → green,

green → yellow,

yellow → red}

𝑡𝑎 = {red → 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤}

𝑞𝑖𝑛𝑖𝑡 = (green, 0)

time = 0

current_state = initial_state

last_time = -initial_elapsed

while not termination_condition():

time = last_time + ta(current_state)

current_state = 𝛿𝑖𝑛𝑡(current_state)

last_time = time

Operational Semantics

from pypdevs.DEVS import *

class TrafficLightAutonomous(AtomicDEVS):

def __init__(self, delay_green,

delay_yellow, delay_red):

AtomicDEVS.__init__(self, “Light”)

self.state = “green”

self.elapsed = 0

self.delay_green = delay_green

self.delay_yellow = delay_yellow

self.delay_red = delay_red

def intTransition(self):

state = self.state

return {“red”: “green”,

“yellow”: “red”,

“green”: “yellow”}[state]

def timeAdvance(self):

state = self.state

return {“red”: self.delay_red,

“yellow”: self.delay_yellow,

“green”: self.delay_green}[state]

atomic_int.pyConcrete SyntaxAbstract Syntax

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

X

S

Y

t

t

t

5760

120 177

red

yellow

green

show_red

show_yellow

show_green𝑒 = 0𝑠

!show_red

!show_yellow

!show_green

𝑆 = {red, yellow, green}

𝛿𝑖𝑛𝑡 = { red → green,

green → yellow,

yellow → red}

𝑞𝑖𝑛𝑖𝑡 = (green, 0)

𝑡𝑎 = {red → 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤}

𝑌 : set of output events

𝑌 = {“show_red”, “show_green”, “show_yellow”}

𝜆 : 𝑆 → 𝑌𝑏

𝜆 = { green → [“show_yellow”],

yellow → [“show_red”],

red → [“show_green”]}

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑀 = , 𝑆, 𝑞𝑖𝑛𝑖𝑡, 𝛿𝑖𝑛𝑡, , 𝑡𝑎𝑌 𝜆

Autonomous (with output)

𝑒 = 0𝑠

𝑆 = {red, yellow, green}

𝑞𝑖𝑛𝑖𝑡 = (green, 0)

𝛿𝑖𝑛𝑡 = { red→ green,

green → yellow,

yellow → red}

𝑡𝑎 = {red→ 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤}

𝑌 = {“show_red”,

“show_green”,

“show_yellow”}

𝜆 = {green → [“show_yellow”],

yellow → [“show_red”],

red → [“show_green”]}

time = 0

current_state = initial_state

last_time = -initial_elapsed

while not termination_condition():

time = last_time + ta(current_state)

output(𝜆(current_state))

current_state = 𝛿𝑖𝑛𝑡(current_state)

last_time = time

Operational Semantics

from pypdevs.DEVS import *

class TrafficLightWithOutput(AtomicDEVS):

def __init__(self):

AtomicDEVS.__init__(self, “light”)

self.observe = self.addOutPort(“observer”)

def outputFnc(self):

state = self.state

if state == “red”:

return {self.observe: [“show_green”]}

elif state == “yellow”:

return {self.observe: [“show_red”]}

elif state == “green”:

return {self.observe: [“show_yellow”]}

atomic_out.pyConcrete Syntax

Abstract Syntax

!show_red

!show_yellow

!show_green

?manual

?manual

?manual

?auto

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

∞ 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

X

S

Y

t

t

t

red

manual

green

show_green

manual

auto

𝑒 = 0𝑠

yellow

!show_red

!show_yellow

!show_green

?manual

?manual

?manual

?auto

𝑌 = {“show_red”, “show_green”, “show_yellow”}

𝑆 = {red, yellow, green, manual}

𝑞𝑖𝑛𝑖𝑡 = (green, 0)

𝛿𝑖𝑛𝑡 = {red → green,

green → yellow,

yellow → red}

𝜆 = {green → [“show_yellow”],

yellow → [“show_red”],

red → [“show_green”]}

𝑡𝑎 = {red → 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤,

manual → ∞}

𝛿𝑒𝑥𝑡 : Q × 𝑋𝑏 → 𝑆𝑄 = 𝑠, 𝑒 𝑠 ∈ 𝑆, 0 ≤ 𝑒 ≤ 𝑡𝑎(𝑠)𝛿𝑒𝑥𝑡 = {( (*, *), [“toManual”])→ “manual”,

( (“manual”, *), [“toAuto”]) → “red”}

𝑋 : set of input events

𝑋 = {“toAuto”, “toManual”}

𝑋 𝛿𝑒𝑥𝑡

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

∞ 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑀 = , 𝑌, 𝑆, 𝑞𝑖𝑛𝑖𝑡, 𝛿𝑖𝑛𝑡, , 𝜆, 𝑡𝑎

Reactive

𝑒 = 0𝑠

𝑌 = {“show_red”, “show_green”, “show_yellow”}

𝑆 = {red, yellow, green, manual}

𝑞𝑖𝑛𝑖𝑡 = (green, 0)

𝛿𝑖𝑛𝑡 = {red → green,

green → yellow,

yellow → red}

𝜆 = {green → [“show_yellow”],

yellow → [“show_red”],

red → [“show_green”]}

𝑡𝑎 = {red → 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤,

manual→ ∞}

𝑋 = {“toAuto”, “toManual”}

𝛿𝑒𝑥𝑡 = {( (*, *), [“toManual”])→ “manual”,

( (“manual”, *), [“toAuto”]) → “red”}

time = 0

cur_state = initial_state

last_time = -initial_elapsed

while not termination_condition():

next_time = last_time + ta(cur_state)

if time_next_ev <= next_time:

e = time_next_ev – last_time

time = time_next_ev

cur_state = 𝛿𝑒𝑥𝑡((cur_state, e), next_ev)

else:

time = next_time

output(𝜆(current_state))

current_state = 𝛿_𝑖𝑛𝑡(current_state)

last_time = time

Operational Semantics

Abstract Syntax

from pypdevs.DEVS import *

class TrafficLight(AtomicDEVS):

def __init__(self):

AtomicDEVS.__init__(self, “light”)

self.interrupt = self.addInPort(“interrupt”)

def extTransition(self, inputs):

inp = inputs[self.interrupt][0]

if inp == “toManual”:

return “manual”

elif inp == “toAuto”:

if self.state == “manual”:

return “red”

atomic_ext.pyConcrete Syntax

𝑌 = {“show_red”, “show_green”, “show_yellow”}

𝑆 = {red, yellow, green, manual}

𝑞𝑖𝑛𝑖𝑡 = (green, 0)

𝛿𝑖𝑛𝑡 = {red → green,

green → yellow,

yellow → red}

𝜆 = {green → [“show_yellow”],

yellow → [“show_red”],

red → [“show_green”]}

𝑡𝑎 = {red → 𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑,

green → 𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛,

yellow → 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤,

manual→ ∞}

𝑋 = {“toAuto”, “toManual”}

𝛿𝑒𝑥𝑡 = {( (*, *), [“toManual”])→ “manual”,

( (“manual”, *), [“toAuto”]) → “red”}

Abstract Syntax

!show_red

!show_yellow

!show_green

?toManual/

!turn_off

?toManual/

!turn_off

?toManual/

!turn_off

?toAuto/

!show_red

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛

∞ 𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

X

S

Y

t

t

t

red

manual

green

show_green

toManual

toAuto

yellow

show_red

turn_off

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0

!show_red

!turn_off

?toAuto?toManual

?toManual

?toManual

X

S

Y

t

t

t

red

manual

green

show_green

toManual

toAuto

going_auto

show_red

turn_off

going_manual

𝑄 = 𝑠, 𝑒 𝑠 ∈ 𝑆, 0 ≤ 𝑒 ≤ 𝑡𝑎(𝑠)

𝑒 = 0 0 < 𝑒 < 𝑡𝑎(𝑠) 𝑒 = 𝑡𝑎 𝑠

?

𝛿𝑐𝑜𝑛𝑓 : 𝑆 × 𝑋𝑏 → 𝑆

from pypdevs.DEVS import *

class TrafficLight(AtomicDEVS):

def confTransition(self, inputs):

self.elapsed = 0.0

self.state = self.intTransition()

self.state = self.extTransition(inputs)

return self.state

atomic_conf.py

𝑀 = 𝑋, 𝑌, 𝑆, 𝑞𝑖𝑛𝑖𝑡, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝛿𝑐𝑜𝑛𝑓, 𝜆, 𝑡𝑎

𝑋 : set of input events

𝑌 : set of output events

𝑆 : set of sequential states

𝑞𝑖𝑛𝑖𝑡 : 𝑄𝑄 = 𝑠, 𝑒 𝑠 ∈ 𝑆, 0 ≤ 𝑒 ≤ 𝑡𝑎(𝑠)

𝛿𝑖𝑛𝑡 : 𝑆 → 𝑆𝛿𝑒𝑥𝑡: 𝑄 × 𝑋𝑏 → 𝑆𝛿𝑐𝑜𝑛𝑓: 𝑆 × 𝑋𝑏 → 𝑆

𝜆 : 𝑆 → 𝑌𝑏

𝑡𝑎 : 𝑆 → ℝ0,+∞+

Full Atomic DEVS Specification

S

t

(𝑠𝑖 , 0)

𝑡𝑎 𝑠𝑖

(𝛿𝑒𝑥𝑡 𝑠𝑖 , 𝑒 , 𝑥 , 0)

(𝛿𝑖𝑛𝑡(𝑠𝑖), 0)

𝛿𝑒𝑥𝑡

𝛿𝑖𝑛𝑡

output 𝜆(𝑠𝑖)

𝑡𝑖 𝑡𝑖 + 𝑒 𝑡𝑖 + 𝑡𝑎 𝑠𝑖

𝑒

Coupled Models

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0

!show_red

!turn_off

?toAuto?toManual

?toManual

?toManual

work

3600s

idle

300s

!go_to_work !take_break

𝑒 = 0𝑠

work

3600s

idle

300s

𝑀𝑖 𝑖 ∈ 𝐷𝑀𝑖 = 𝑋, 𝑌, 𝑆, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝜆, 𝑡𝑎 , ∀ 𝑖 ∈ 𝐷

𝐶 = 𝐷, 𝑀𝑖

!go_to_work !take_break

𝑒 = 0𝑠

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0!show_red

!turn_off

?toAuto ?toManual

?toManual

?toManual

work

3600s

idle

300s

𝑀𝑖 𝑖 ∈ 𝐷𝑀𝑖 = 𝑋, 𝑌, 𝑆, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝜆, 𝑡𝑎 , ∀ 𝑖 ∈ 𝐷

𝐶 = 𝑋𝑠𝑒𝑙𝑓 , 𝑌𝑠𝑒𝑙𝑓 , 𝐷, 𝑀𝑖

!go_to_work !take_break

𝑒 = 0𝑠

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0!show_red

!turn_off

?toAuto ?toManual

?toManual

?toManual

work

3600s

idle

300s

𝑀𝑖 𝑖 ∈ 𝐷𝑀𝑖 = 𝑋, 𝑌, 𝑆, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝜆, 𝑡𝑎 , ∀ 𝑖 ∈ 𝐷

𝐶 = 𝑋𝑠𝑒𝑙𝑓 , 𝑌𝑠𝑒𝑙𝑓 , 𝐷, 𝑀𝑖 , 𝐼𝑖

𝐼𝑖 𝑖 ∈ 𝐷 ∪ 𝑠𝑒𝑙𝑓∀ 𝑖 ∈ 𝐷 ∪ 𝑠𝑒𝑙𝑓 ∶ 𝐼𝑖 ⊆ 𝐷 ∪ 𝑠𝑒𝑙𝑓

∀ 𝑖 ∈ 𝐷 ∪ 𝑠𝑒𝑙𝑓 ∶ 𝑖 ∉ 𝐼𝑖

!go_to_work !take_break

𝑒 = 0𝑠

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0!show_red

!turn_off

?toAuto ?toManual

?toManual

?toManual

!go_to_work !take_break

work

3600s

idle

300s

𝑀𝑖 𝑖 ∈ 𝐷𝑀𝑖 = 𝑋, 𝑌, 𝑆, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝜆, 𝑡𝑎 , ∀ 𝑖 ∈ 𝐷

𝐶 = 𝑋𝑠𝑒𝑙𝑓 , 𝑌𝑠𝑒𝑙𝑓 , 𝐷, 𝑀𝑖 , 𝐼𝑖 , 𝑍𝑖,𝑗

𝐼𝑖 𝑖 ∈ 𝐷 ∪ 𝑠𝑒𝑙𝑓∀ 𝑖 ∈ 𝐷 ∪ 𝑠𝑒𝑙𝑓 ∶ 𝐼𝑖 ⊆ 𝐷 ∪ 𝑠𝑒𝑙𝑓

∀ 𝑖 ∈ 𝐷 ∪ 𝑠𝑒𝑙𝑓 ∶ 𝑖 ∉ 𝐼𝑖

𝑍𝑖,𝑗 𝑖 ∈ 𝐷 ∪ 𝑠𝑒𝑙𝑓 , 𝑗 ∈ 𝐼𝑖𝑍𝑠𝑒𝑙𝑓,𝑗 ∶ 𝑋𝑠𝑒𝑙𝑓 → 𝑋𝑗 , ∀ 𝑗 ∈ 𝐷

𝑍𝑖,𝑠𝑒𝑙𝑓 ∶ 𝑌𝑖 → 𝑌𝑠𝑒𝑙𝑓 , ∀ 𝑖 ∈ 𝐷

𝑍𝑖,𝑗 ∶ 𝑌𝑖 → 𝑋𝑗 , ∀ 𝑖, 𝑗 ∈ 𝐷take_break toAuto

go_to_work toManual

𝑒 = 0𝑠

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0!show_red

!turn_off

?toAuto ?toManual

?toManual

?toManual

from pypdevs.DEVS import *

from trafficlight import TrafficLight

from policeman import Policeman

def translate(in_evt):

mapping = {“take_break”: “toAuto”,

“go_to_work”: “toManual”}

return mapping[in_evt]

class TrafficLightSystem(CoupledDEVS):

def __init__(self):

CoupledDEVS.__init__(self, “system”)

self.light = self.addSubModel(TrafficLight())

self.police = self.addSubModel(Policeman())

self.connectPorts(self.police.out, self.light.interrupt, translate)

trafficlight_system.pyConcrete Syntax

Closure under Coupling

!go_to_work !take_break

work

3600s

idle

300s

?

𝑒 = 0𝑠

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0!show_red

!turn_off

?toAuto ?toManual

?toManual

?toManual

!go_to_work !take_break

work

3600s

idle

300s ?𝐶𝑀 = 𝑋𝑠𝑒𝑙𝑓 , 𝑌𝑠𝑒𝑙𝑓 , 𝐷, 𝑀𝑖 , 𝐼𝑖 , 𝑍𝑖,𝑗

𝑀𝑖 = 𝑋𝑖 , 𝑌𝑖 , 𝑆𝑖 , 𝛿𝑖𝑛𝑡,𝑖 , 𝛿𝑒𝑥𝑡,𝑖 , 𝜆𝑖 , 𝑡𝑎𝑖 , ∀ 𝑖 ∈ 𝐷𝐶𝑀 = 𝑋, 𝑌, 𝑆, 𝑞𝑖𝑛𝑖𝑡, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝛿𝑐𝑜𝑛𝑓, 𝜆, 𝑡𝑎

𝑒 = 0𝑠

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0!show_red

!turn_off

?toAuto ?toManual

?toManual

?toManual

Hierarchical Simulator

(done, t)

(*, t)

(done, t)

(y, t)

(x, t)

(@,t)

(@,t)

(*, t)

(done, t) (done, t)

(*, t)

Root coordinator

Coordinator

SimulatorSimulator

Coupled DEVS

Atomic DEVS Atomic DEVS

DEVS Semantics

Atomic DEVS

Coupled DEVS

Operational

Semantics

Denotational

Semantics

Abstract

Simulator[1]

Hierarchical

Simulator

Closure under

Coupling

[1] Ashvin Radiya and Robert G. Sargent. A logic-based foundation of discrete event modeling

and simulation. ACM Transactions on Modeling and Computer Simulation, 1(1):3-51, 1994.

Conclusions

Atomic DEVS

Coupled DEVS

Closure under coupling

Abstract Simulator

(@,t) (X, t)(Y, t) (*, t) (done, t)

!go_to_work !take_break

work

3600s

idle

300s

!show_red

!show_yellow

!show_green

𝑑𝑒𝑙𝑎𝑦𝑟𝑒𝑑

𝑑𝑒𝑙𝑎𝑦𝑔𝑟𝑒𝑒𝑛0

𝑑𝑒𝑙𝑎𝑦𝑦𝑒𝑙𝑙𝑜𝑤

𝑒 = 0𝑠

0!show_red

!turn_off

?toAuto ?toManual

?toManual

?toManual

http://msdl.cs.mcgill.ca/projects/PythonPDEVS

Formalisms

Dynamic Structure

Real-time

Cell DEVS

Verification

Standardization

Tools

Languages

Interoperable

Performance

Algorithms

Activity

Distribution

Parallel

Model libraries

Example

Reusable

Applications

http://msdl.cs.mcgill.ca/projects/PythonPDEVS