parallel devs
play

Parallel DEVS An Introduction Using PythonPDEVS Yentl Van Tendeloo, - PowerPoint PPT Presentation

Parallel DEVS An Introduction Using PythonPDEVS Yentl Van Tendeloo, Hans Vangheluwe Introduction Process Interaction Cellular Automata Discrete Event Activity Scanning State Charts Petri Nets Discrete Event Event Scheduling Finite State


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

  2. Introduction

  3. Process Interaction Cellular Automata Discrete Event Activity Scanning State Charts Petri Nets Discrete Event Event Scheduling Finite State Automata Discrete Event DEVS

  4. Experimentation

  5. X t S t Y t

  6. simple_experiment.py from pypdevs.simulator import Simulator from mymodel import MyModel model = MyModel() simulator = Simulator(model) simulator.setVerbose() simulator.simulate()

  7. Atomic Models

  8. X Red 60s t S Yellow 3s t 57 120 177 60 Y Green 57s t

  9. Red 60s 𝑁 = 𝑇 , πœ€ π‘—π‘œπ‘’ 𝑒𝑏 , 𝑇 : set of sequential states 𝑇 = {red, yellow, green} πœ€ π‘—π‘œπ‘’ : 𝑇 β†’ 𝑇 Yellow πœ€ π‘—π‘œπ‘’ = {red β†’ green, 3s green β†’ yellow, yellow β†’ red} 𝑒𝑏 : S β†’ ℝ 0,+∞ 𝑒𝑏 = {red β†’ 60, green β†’ 57, yellow β†’ 3} Green 57s

  10. 𝑇 = {red, yellow, green} atomic_int.py πœ€ π‘—π‘œπ‘’ = { red β†’ green, from pypdevs.DEVS import * green β†’ yellow, yellow β†’ red} class TrafficLightAutonomous(AtomicDEVS): 𝑒𝑏 = {red β†’ 60, def __init__(self): green β†’ 57, AtomicDEVS.__init __(self, β€œLight”) yellow β†’ 3} self.state = β€œred” def intTransition(self): state = self.state return {β€œred”: β€œgreen”, β€œyellow”: β€œred”, β€œgreen”: β€œyellow”}[state] def timeAdvance(self): time = 0 state = self.state current_state = green return {β€œred”: 60, while True: β€œyellow”: 3, time += ta(current_state) β€œgreen”: 57}[state] current_state = πœ€ π‘—π‘œπ‘’ (current_state)

  11. X Red 60s t !red S Yellow !green 3s !yellow t 57 120 177 60 Y Green 57s t

  12. Red 𝑁 = , 𝑇, πœ€ π‘—π‘œπ‘’ , , 𝑒𝑏 60s 𝑍 πœ‡ 𝑇 = {red, yellow, green} πœ€ π‘—π‘œπ‘’ = { red β†’ green, !red green β†’ yellow, yellow β†’ red} 𝑒𝑏 = {red β†’ 60, green β†’ 57, Yellow !green yellow β†’ 3} 3s 𝑍 : set of output events 𝑍 = {β€œred”, β€œgreen”, β€œyellow”} !yellow πœ‡ : 𝑇 β†’ 𝑍 𝑐 πœ‡ = { green β†’ [β€œyellow”], yellow β†’ [β€œred”], Green red β†’ [β€œgreen”]} 57s

  13. atomic_out.py 𝑍 = {β€œred”, β€œgreen”, β€œyellow”} from pypdevs.DEVS import * πœ‡ = {green β†’ β€œyellow”, yellow β†’ β€œred”, class TrafficLightWithOutput(AtomicDEVS): red β†’ β€œgreen”} def __init__(self): AtomicDEVS.__init __(self, β€œlight”) self.state = β€œred” self.observe = self.addOutPort (β€œobserver”) … def outputFnc(self): state = self.state if state == β€œred”: v = β€œgreen” time = 0 elif state == β€œyellow”: current_state = green v = β€œred” while True: elif state == β€œgreen”: time += ta(current_state) v = β€œyellow” output( πœ‡ (current_state)) return {self.observe: [v]} current_state = πœ€ π‘—π‘œπ‘’ (current_state)

  14. X Red 60s ?manual t !red ?auto S Manual Yellow !green ∞s 3s ?manual t 57 120 177 !yellow 60 Y Green ?manual 57s t

  15. 𝑁 = π‘Œ , 𝑍, 𝑇, πœ€ π‘—π‘œπ‘’ , πœ€ 𝑓𝑦𝑒 , πœ‡, 𝑒𝑏 𝑍 = {β€œred”, β€œgreen”, β€œyellow”} Red 𝑇 = {red, yellow, green, manual} 60s ?manual πœ€ π‘—π‘œπ‘’ = {red β†’ green, green β†’ yellow, yellow β†’ red} !red πœ‡ = {green β†’ β€œyellow”, ?auto yellow β†’ β€œred”, red β†’ β€œgreen”} 𝑒𝑏 = {red β†’ 60, Manual Yellow !green green β†’ 57, ∞s 3s yellow β†’ 3, ?manual manual β†’ ∞ } π‘Œ : set of input events !yellow π‘Œ = {β€œauto”, β€œmanual”} πœ€ 𝑓𝑦𝑒 : Q Γ— π‘Œ 𝑐 β†’ 𝑇 Green ?manual πœ€ 𝑓𝑦𝑒 = {( (*, *), [β€œmanual”]) β†’ β€œmanual”, 57s ( (β€œmanual”, *), [β€œauto”]) β†’ β€œred”}

  16. π‘Œ = {β€œauto”, β€œmanual”} atomic_ext.py πœ€ 𝑓𝑦𝑒 = {( (*, *), [β€œmanual”]) β†’ β€œmanual”, from pypdevs.DEVS import * ( (β€œmanual”, *), [β€œauto”]) β†’ β€œred”} class TrafficLight(AtomicDEVS): def __init__(self): AtomicDEVS.__init __(self, β€œlight”) self.state = β€œred” self.observe = self.addOutPort (β€œobserver”) self.interrupt = self.addInPort (β€œinterrupt”) time = 0 cur_state = β€œred” … while True: next_time = time + ta(cur_state) def extTransition(self, inputs): if time_next_ev <= next_time: inp = inputs[self.interrupt][0] cur_state = πœ€ 𝑓𝑦𝑒 ((cur_state, e), next_ev) if inp == β€œmanual”: time = time_next_ev return β€œmanual” else: elif inp == β€œauto”: time = next_time if self.state == β€œmanual”: output( πœ‡ (current_state)) return β€œred” current_state = πœ€ _ π‘—π‘œπ‘’ (current_state)

  17. πœ€ π‘‘π‘π‘œπ‘” 𝑁 = π‘Œ, 𝑍, 𝑇, πœ€ π‘—π‘œπ‘’ , πœ€ 𝑓𝑦𝑒 , , πœ‡, 𝑒𝑏 π‘Œ : set of input events 𝑍 : set of output events 𝑇 : set of sequential states πœ€ π‘—π‘œπ‘’ : 𝑇 β†’ 𝑇 πœ€ 𝑓𝑦𝑒 : Q Γ— π‘Œ 𝑐 β†’ 𝑇 πœ‡ : 𝑇 β†’ 𝑍 𝑐 𝑒𝑏 : S β†’ ℝ 0,+∞ πœ€ π‘‘π‘π‘œπ‘” : 𝑇 Γ— π‘Œ 𝑐 β†’ 𝑇

  18. atomic_conf.py 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

  19. Coupled Models

  20. Work 360s !manual !auto Idle 20s

  21. Red Work 60s ?manual 360s !red ?auto !manual !auto Manual Yellow !green ∞s 3s Idle 20s ?manual !yellow Green ?manual M = π‘Œ, 𝑍, 𝐸, 𝑁 𝑗 , 𝐽 𝑗 , π‘Ž 𝑗,π‘˜ 57s

  22. trafficlight_system.py from pypdevs.DEVS import * from trafficlight import TrafficLight from policeman import Policeman 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)

  23. City Traffic House Road Road Commerce light Generator Queue Queue Queue     Queue Processor Processor Collector     Queue Queue  

  24. Root coordinator (done, t) (done, t) (@,t) (*, t) Coupled DEVS Coordinator (x, t) (*, t) (*, t) (@,t) (y, t) (done, t) (done, t) Simulator Simulator Atomic DEVS Atomic DEVS

  25. Applications

  26. Conclusions

  27. Conclusions (@,t) (Y , t) (X, t) (*, t) (done, t)  Atomic DEVS  Coupled DEVS R  Closure under coupling 60s ?manual Work  Abstract Simulator 360s !red ?auto !manual !auto M Y !green ∞s 3s ?manual Idle 20s !yellow G ?manual 57s

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

  29. Formalisms Standardization Performance Model libraries Applications Dynamic Algorithms Structure Tools Example Real-time Activity Languages Cell DEVS Distribution Reusable Interoperable Verification Parallel

Recommend


More recommend