75
Classic DEVS Practical Modelling Techniques Using PythonPDEVS Yentl Van Tendeloo, Hans Vangheluwe

Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Classic DEVSPractical Modelling Techniques Using PythonPDEVS

Yentl Van Tendeloo, Hans Vangheluwe

Page 2: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

IntroductionBrief recap of introductory DEVS tutorial

Page 3: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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.

Page 4: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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.

Page 5: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Our presentation uses initialized DEVS models, which

contain an initial total state. This was left implicit in

the original DEVS specification.

Yentl Van Tendeloo and Hans Vangheluwe. Extending the DEVS

Formalism with Initialization Information, 2018. ArXiv e-prints.

Page 6: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

𝑋 : set of input events

𝑌 : set of output events

𝑆 : set of sequential states

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

𝛿𝑖𝑛𝑡 : 𝑆 → 𝑆𝛿𝑒𝑥𝑡: 𝑄 × 𝑋 → 𝑆𝜆 : 𝑆 → 𝑌 ∪ 𝜙𝑡𝑎 : 𝑆 → ℝ0,+∞

+

Atomic DEVS Specification

Page 7: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

𝑋 : set of input events

𝑌 : set of output events

𝑆 : set of sequential states

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

𝛿𝑖𝑛𝑡 : 𝑆 → 𝑆𝛿𝑒𝑥𝑡: 𝑄 × 𝑋 → 𝑆𝜆 : 𝑆 → 𝑌 ∪ 𝜙𝑡𝑎 : 𝑆 → ℝ0,+∞

+

Atomic DEVS Specification

Page 8: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

S

t

(𝑠𝑖 , 0)

𝑡𝑎 𝑠𝑖

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

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

𝛿𝑒𝑥𝑡

𝛿𝑖𝑛𝑡

output 𝜆(𝑠𝑖)

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

𝑒

Page 9: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝐶 = 𝑋𝑠𝑒𝑙𝑓, 𝑌𝑠𝑒𝑙𝑓, 𝐷,𝑀𝑆, 𝐼𝑆, 𝑍𝑆, 𝑠𝑒𝑙𝑒𝑐𝑡

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

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

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

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

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

𝑠𝑒𝑙𝑒𝑐𝑡 ∶ 2𝐷 → 𝐷∀ 𝐸 ⊆ 𝐷, 𝐸 ≠ ∅: 𝑠𝑒𝑙𝑒𝑐𝑡 𝐸 ∈ 𝐸

𝑀𝑆 = 𝑀𝑖 𝑖 ∈ 𝐷

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

Coupled DEVS Specification

Page 10: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

(done, t)

(*, t)

(y, t)

(x, t)(*, t)

(done, t) (done, t)

Root coordinator

Coordinator

SimulatorSimulator

Coupled DEVS

Atomic DEVS Atomic DEVS

(i, t)

(done, t)

(done, t)

(i, t)

(done, t)

Page 11: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society
Page 12: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society
Page 13: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society
Page 14: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society
Page 15: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Closure Under CouplingDenotational semantics for Coupled DEVS models

Page 16: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑴𝒍𝒊𝒈𝒉𝒕𝟏𝑴𝒑𝒐𝒍𝟏

𝒔𝒆𝒍𝒇

take_break toAuto

go_to_work toManual

?

Page 17: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

?𝐶𝑀 = 𝑋𝑠𝑒𝑙𝑓 , 𝑌𝑠𝑒𝑙𝑓 , 𝐷,𝑀𝑆, 𝐼𝑆, 𝑍𝑆 𝑓𝑙𝑎𝑡𝑡𝑒𝑛 𝐶𝑀 = 𝑋, 𝑌, 𝑆, 𝑞𝑖𝑛𝑖𝑡, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝜆, 𝑡𝑎

flatten

Page 18: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

Page 19: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

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

CM

21

𝑋 = 𝑋𝐶𝑀𝑌 = 𝑌𝐶𝑀

Page 20: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑠1, 𝑒1

𝑠2, 𝑒2𝑒2

𝑒1

Page 21: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

𝑆 = ×𝑖∈𝐷 𝑄𝑖

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑠1, 𝑒1

𝑠2, 𝑒2𝑒2

𝑒1

Page 22: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑠1, 𝑒1 = 𝑞𝑖𝑛𝑖𝑡,1

𝑠2, 𝑒2 = 𝑞𝑖𝑛𝑖𝑡,2𝑒2

𝑒1

𝑡𝑎1 𝑠1

𝑡𝑎2 𝑠2

Page 23: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21

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

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑠1, 𝑒1 = 𝑞𝑖𝑛𝑖𝑡,1

𝑠2, 𝑒2 = 𝑞𝑖𝑛𝑖𝑡,2𝑒2

𝑒1

𝑡𝑎1 𝑠1

𝑡𝑎2 𝑠2

Page 24: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21

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

𝑠𝑖𝑛𝑖𝑡 = … , 𝑠𝑖𝑛𝑖𝑡,𝑖 , 𝑒𝑖𝑛𝑖𝑡,𝑖 − 𝑒𝑖𝑛𝑖𝑡 , …

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑠1, 𝑒1 = 𝑞𝑖𝑛𝑖𝑡,1

𝑠2, 𝑒2 = 𝑞𝑖𝑛𝑖𝑡,2𝑒2

𝑒1

𝑡𝑎1 𝑠1

𝑡𝑎2 𝑠2

Page 25: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑒𝑖𝑛𝑖𝑡 = min𝑖∈𝐷

𝑒𝑖𝑛𝑖𝑡,𝑖

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

CM

21

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

𝑠𝑖𝑛𝑖𝑡 = … , 𝑠𝑖𝑛𝑖𝑡,𝑖 , 𝑒𝑖𝑛𝑖𝑡,𝑖 − 𝑒𝑖𝑛𝑖𝑡 , …

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑠1, 𝑒1 = 𝑞𝑖𝑛𝑖𝑡,1

𝑠2, 𝑒2 = 𝑞𝑖𝑛𝑖𝑡,2𝑒2

𝑒1

𝑡𝑎1 𝑠1

𝑡𝑎2 𝑠2

Page 26: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑒𝑖𝑛𝑖𝑡 = min𝑖∈𝐷

𝑒𝑖𝑛𝑖𝑡,𝑖

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

CM

21

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

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

𝑠𝑖𝑛𝑖𝑡 = … , 𝑠𝑖𝑛𝑖𝑡,𝑖 , 𝑒𝑖𝑛𝑖𝑡,𝑖 − 𝑒𝑖𝑛𝑖𝑡 , …

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑠1, 𝑒1 = 𝑞𝑖𝑛𝑖𝑡,1

𝑠2, 𝑒2 = 𝑞𝑖𝑛𝑖𝑡,2𝑒2

𝑒1

𝑡𝑎1 𝑠1

𝑡𝑎2 𝑠2

Page 27: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡𝑎1

𝑡𝑎2

𝑡

𝑒1 𝑓𝑙𝑎𝑡𝑡𝑒𝑛 𝐶𝑀 = 𝑋, 𝑌, 𝑆, 𝑞𝑖𝑛𝑖𝑡, 𝛿𝑖𝑛𝑡, 𝛿𝑒𝑥𝑡, 𝜆, 𝑡𝑎

CM

21

Page 28: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑡𝑎 ∶ 𝑆 → ℝ0,+∞+

𝑡𝑎 𝑠 = min𝑖∈𝐷

𝜎𝑖 = 𝑡𝑎𝑖 𝑠𝑖 − 𝑒𝑖

𝜎1

𝜎2

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡𝑎1

𝑡𝑎2

𝑡

𝑒1

Page 29: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑡𝑎 ∶ 𝑆 → ℝ0,+∞+

𝑡𝑎 𝑠 = min𝑖∈𝐷

𝜎𝑖 = 𝑡𝑎𝑖 𝑠𝑖 − 𝑒𝑖

𝐼𝑀𝑀 𝑠 = 𝑖 ∈ 𝐷 𝜎𝑖 = 𝑡𝑎(𝑠)𝑠𝑒𝑙𝑒𝑐𝑡(𝐼𝑀𝑀 𝑠 ) = 𝑖∗

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

CM

21

𝜎1

𝜎2

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡𝑎1

𝑡𝑎2

𝑡

𝑒1

Page 30: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡

Page 31: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2𝜆 𝑠 = ൝

𝑍𝑖∗,𝑠𝑒𝑙𝑓 𝜆𝑖∗ 𝑠𝑖∗

𝑖𝑓 𝑠𝑒𝑙𝑓 ∈ 𝐼𝑖∗

𝑖𝑓 𝑠𝑒𝑙𝑓 ∉ 𝐼𝑖∗

𝑡

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

CM

21

𝑦2

Page 32: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡

𝑠1, 0

𝑠1, 𝑡𝑎1 𝑠1

𝑠2, 𝑒2𝑠2, 𝑒2 + 𝑡𝑎 𝑠 = 𝑡𝑎2(𝑠2)

𝑠2′ , 0

𝑡𝑎 𝑠

Page 33: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝛿𝑖𝑛𝑡 𝑠 = … , 𝑠𝑗′, 𝑒𝑗

′ , …

𝑠𝑗′, 𝑒𝑗

′ =

𝛿𝑖𝑛𝑡,𝑗 𝑠𝑗 , 0 𝑓𝑜𝑟 𝑗 = 𝑖∗

? 𝑓𝑜𝑟 𝑗 ∈ 𝐼𝑖∗ ∖ 𝑠𝑒𝑙𝑓

𝑠𝑗 , 𝑒𝑗 + 𝑡𝑎 𝑠 𝑒𝑙𝑠𝑒

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡

𝑠1, 0

𝑠1, 𝑡𝑎1 𝑠1

𝑠2, 𝑒2𝑠2, 𝑒2 + 𝑡𝑎 𝑠 = 𝑡𝑎2(𝑠2)

𝑠2′ , 0

𝑡𝑎 𝑠

Page 34: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑡

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2 𝛿𝑖𝑛𝑡 𝑠 = … , 𝑠𝑗′, 𝑒𝑗

′ , …

𝑠𝑗′, 𝑒𝑗

′ =

𝛿𝑖𝑛𝑡,𝑗 𝑠𝑗 , 0 𝑓𝑜𝑟 𝑗 = 𝑖∗

𝛿𝑒𝑥𝑡,𝑗 𝑠𝑗 , 𝑒𝑗 + 𝑡𝑎 𝑠 , 𝑍𝑖∗,𝑗 𝜆𝑖∗ 𝑠𝑖∗ , 0 𝑓𝑜𝑟 𝑗 ∈ 𝐼𝑖∗ ∖ 𝑠𝑒𝑙𝑓

𝑠𝑗 , 𝑒𝑗 + 𝑡𝑎 𝑠 𝑒𝑙𝑠𝑒

𝑠1, 𝑒1𝑠1, 𝑒1 + 𝑡𝑎 𝑠 = 𝑡𝑎1(𝑠1)

𝑠2, 𝑒2𝑠2, 𝑒2 + 𝑡𝑎 𝑠 ≤ 𝑡𝑎2 𝑠2

𝛿𝑖𝑛𝑡

𝛿𝑒𝑥𝑡

𝑠1′ , 0

𝑠2′ , 0

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

CM

21𝑦1

𝑥2

Page 35: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

CM

21𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡

𝑒

𝑒1

Page 36: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝛿𝑒𝑥𝑡 𝑠, 𝑒 , 𝑥 = … , 𝑠𝑖′, 𝑒𝑖

′ , …

𝑠𝑖′, 𝑒𝑖

′ = ቐ𝛿𝑒𝑥𝑡,𝑖 𝑠𝑖 , 𝑒𝑖 + 𝑒 , 𝑍𝑠𝑒𝑙𝑓,𝑖 𝑥 , 0 𝑓𝑜𝑟 𝑖 ∈ 𝐼𝑠𝑒𝑙𝑓

𝑠𝑖 , 𝑒𝑖 + 𝑒 𝑒𝑙𝑠𝑒

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

CM

21

𝑦𝑠𝑒𝑙𝑓

𝑋𝐶𝑀

𝑌𝐶𝑀

𝑆1

𝑆2

𝑡

𝑒

𝑒1

Page 37: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑆 = ×𝑖∈𝐷 𝑄𝑖

𝑡𝑎 𝑠 = min𝑖∈𝐷

𝜎𝑖 = 𝑡𝑎𝑖 𝑠𝑖 − 𝑒𝑖

𝐼𝑀𝑀 𝑠 = 𝑖 ∈ 𝐷 𝜎𝑖 = 𝑡𝑎(𝑠)

𝜆 𝑠 = ൝𝑍𝑖∗,𝑠𝑒𝑙𝑓 𝜆𝑖∗ 𝑠𝑖∗

𝜙

𝑖𝑓 𝑠𝑒𝑙𝑓 ∈ 𝐼𝑖∗

𝑖𝑓 𝑠𝑒𝑙𝑓 ∉ 𝐼𝑖∗

𝛿𝑖𝑛𝑡 𝑠 = … , 𝑠𝑗′, 𝑒𝑗

′ , …

𝑠𝑖′, 𝑒𝑖

′ = ቐ𝛿𝑒𝑥𝑡,𝑖 𝑠𝑖 , 𝑒𝑖 + 𝑒 , 𝑍𝑠𝑒𝑙𝑓,𝑖 𝑥 , 0 𝑓𝑜𝑟 𝑖 ∈ 𝐼𝑠𝑒𝑙𝑓

𝑠𝑖 , 𝑒𝑖 + 𝑒 𝑒𝑙𝑠𝑒

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

𝑒𝑖𝑛𝑖𝑡 = min𝑖∈𝐷

𝑒𝑖𝑛𝑖𝑡,𝑖

𝑞𝑖𝑛𝑖𝑡 = 𝑠𝑖𝑛𝑖𝑡 , 𝑒𝑖𝑛𝑖𝑡 ∈ 𝑄

𝑠𝑗′, 𝑒𝑗

′ =

𝛿𝑖𝑛𝑡,𝑗 𝑠𝑗 , 0 𝑓𝑜𝑟 𝑗 = 𝑖∗

𝛿𝑒𝑥𝑡,𝑗 𝑠𝑗 , 𝑒𝑗 + 𝑡𝑎 𝑠 , 𝑍𝑖∗,𝑗 𝜆𝑖∗ 𝑠𝑖∗ , 0 𝑓𝑜𝑟 𝑗 ∈ 𝐼𝑖∗

𝑠𝑗 , 𝑒𝑗 + 𝑡𝑎 𝑠 𝑒𝑙𝑠𝑒

𝑋 = 𝑋𝐶𝑀𝑌 = 𝑌𝐶𝑀

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

𝑠𝑖𝑛𝑖𝑡 = (… , 𝑠𝑖𝑛𝑖𝑡,𝑖 , 𝑒𝑖𝑛𝑖𝑡,𝑖 − 𝑒𝑖𝑛𝑖𝑡 , … )

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

𝑖∗ = 𝑠𝑒𝑙𝑒𝑐𝑡(𝐼𝑀𝑀 𝑠 )

𝛿𝑒𝑥𝑡 𝑠, 𝑒 , 𝑥 = … , 𝑠𝑖′, 𝑒𝑖

′ , …

Page 38: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Applications of DEVSDEVS in practice

Page 39: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society
Page 40: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

http://irh.inf.unideb.hu/user/jsztrik/education/09/english/3f.html

Page 41: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

http://irh.inf.unideb.hu/user/jsztrik/education/09/english/3f.html

Page 42: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society
Page 43: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society
Page 44: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

𝑐𝑜𝑠𝑡 = 10 × #𝑙𝑖𝑔ℎ𝑡𝑠 + 𝑎𝑣𝑔(𝑡𝑡𝑟𝑎𝑣𝑒𝑙)

Page 45: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Generator StatisticsQueue

Notifier

Poller

Queue

Notifier

Poller

Page 46: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Custom Atomic DEVS ModelsExtending a DEVS repository

Page 47: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

𝑋 : set of input events

𝑌 : set of output events

𝑆 : set of sequential states

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

𝛿𝑖𝑛𝑡 : 𝑆 → 𝑆𝛿𝑒𝑥𝑡: 𝑄 × 𝑋 → 𝑆𝜆 : 𝑆 → 𝑌 ∪ 𝜙𝑡𝑎 : 𝑆 → ℝ0,+∞

+

Atomic DEVS Specification

Page 48: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

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

𝑋 : set of input events

𝑌 : set of output events

𝑆 : set of sequential states

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

𝛿𝑖𝑛𝑡 : 𝑆 → 𝑆𝛿𝑒𝑥𝑡: 𝑄 × 𝑋 → 𝑆𝜆 : 𝑆 → 𝑌 ∪ 𝜙𝑡𝑎 : 𝑆 → ℝ0,+∞

+

Atomic DEVS Specification

Page 49: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 1: Ignore an Event

X

Page 50: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 1: Ignore an Event

0.1 seconds

later

X Y

Page 51: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 1: Ignore an Event

𝑡𝑎(𝑠𝑖)

Page 52: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 1: Ignore an Event

𝑡𝑎(𝑠𝑖)

Page 53: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 1: Ignore an Event

𝑡𝑎(𝑠𝑖′)𝑒

𝑡𝑎 𝑠𝑖′ = 𝑡𝑎 𝑠𝑖 − 𝑒

Page 54: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 1: Ignore an Event

class RailwaySegmentState():

def __init__(self):

self.timer = INFINITY

class RailwaySegment(AtomicDEVS):

def extTransition(self, inputs):

self.state.timer -= self.elapsed

def timeAdvance(self):

return self.state.timer

Page 55: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑥 seconds

later

𝑡 = 𝑏 𝑡 = 𝑏 + 𝑥

Page 56: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑥 seconds

later

𝑡 = 𝑏 𝑡 = 𝑏 + 𝑥

𝑡𝑡𝑟𝑎𝑛𝑠𝑖𝑡 = 𝑥

Page 57: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑥 seconds

later

𝑡 = 𝑏 𝑡 = 𝑏 + 𝑥

𝑡𝑡𝑟𝑎𝑛𝑠𝑖𝑡 = 𝑥

𝑡 = ?

Page 58: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑡𝑠𝑖𝑚 = 𝑥

Page 59: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑡𝑎(𝑠𝑖)

𝑡𝑠𝑖𝑚 = 𝑥

Page 60: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑡𝑎(𝑠𝑖)

𝑡𝑠𝑖𝑚 = 𝑥

𝑡𝑠𝑖𝑚 = 𝑥 + 𝑡𝑎 𝑠𝑖

Page 61: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑒

𝑡𝑠𝑖𝑚 = 𝑥

Page 62: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

𝑒

𝑡𝑠𝑖𝑚 = 𝑥

𝑡𝑠𝑖𝑚 = 𝑥 + 𝑒

Page 63: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 2: Simulated Time

class GeneratorState:

def __init__(self):

self.t_sim = 0.0

class Generator(AtomicDEVS):

def __init__(self):

self.state = GeneratorState()

def intTransition(self):

self.state.t_sim += self.timeAdvance()

def extTransition(self, inputs):

self.state.t_sim += self.elapsed

Page 64: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 3: Multiple Timers

Page 65: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 3: Multiple Timers

𝑡𝑡𝑟𝑎𝑖𝑛

𝑡𝑞𝑢𝑒𝑟𝑦

?

𝑡𝑎(𝑠𝑖)

Page 66: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 3: Multiple Timers

𝑡𝑡𝑟𝑎𝑖𝑛

𝑡𝑞𝑢𝑒𝑟𝑦

?

𝑡𝑎(𝑠𝑗)𝑡𝑎(𝑠𝑖)

Page 67: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 3: Multiple Timers

𝑡𝑡𝑟𝑎𝑖𝑛

𝑡𝑞𝑢𝑒𝑟𝑦

?

𝑡𝑎(𝑠𝑗)

Page 68: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 3: Multiple Timers

class RailwaySegmentState:

def __init__(self):

self.t_query = INFINITY

self.t_train = INFINITY

class RailwaySegment(AtomicDEVS):

def timeAdvance(self):

return min(self.state.t_query, \

self.state.t_train)

def extTransition(self, inputs):

self.state.t_query -= self.elapsed

self.state.t_train -= self.elapsed

def intTransition(self):

self.state.t_query -= self.timeAdvance()

self.state.t_train -= self.timeAdvance()

if (self.state.t_query == 0):

… # process query

elif (self.state.t_train == 0):

… # process train

Page 69: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 4: Statistics Gathering

[1815.7; 1901.1; 1801.4; 1867.3; 1911.8; 1846.4; 1844.3; 1873.5; …]

𝑛 trains = 𝑛 doubles = 8𝑛 bytes

Page 70: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 4: Statistics Gathering

[1815.7; 1901.1; 1801.4; 1867.3; 1911.8; 1846.4; 1844.3; 1873.5; …]

𝑠𝑢𝑚 =

𝑖

𝑡𝑡𝑟𝑎𝑣𝑒𝑙 = 36,902,140.45

𝑐𝑜𝑢𝑛𝑡 = 𝑎𝑟𝑟𝑖𝑣𝑎𝑙𝑠 = 20,000

𝑎𝑣𝑔 =𝑠𝑢𝑚

𝑐𝑜𝑢𝑛𝑡

𝑛 trains = 𝑛 doubles = 8𝑛 bytes

𝑛 trains = 1 double + 1 long long int = 16 bytes

Page 71: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 4: Statistics Gathering

class CollectorState():

def __init__(self):

self.counter = 0

self.accum = 0.0

self.t_sim = 0.0

class Collector(AtomicDEVS):

def extTransition(self, inputs):

left = inputs[self.train].left

transit = self.state.t_sim – left

self.accum += transit

self.counter += 1

Page 72: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 5: Complex State/Event

𝑆 𝑋, 𝑌

Page 73: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 5: Complex State/Event

𝑆 𝑋, 𝑌

𝑆 = 𝑡𝑖𝑚𝑒𝑟𝑡𝑟𝑎𝑖𝑛, 𝑡𝑖𝑚𝑒𝑟𝑞𝑢𝑒𝑟𝑦 , 𝑣𝑡𝑟𝑎𝑖𝑛, 𝑡𝑡𝑟𝑎𝑖𝑛, 𝑎𝑡𝑟𝑎𝑖𝑛 𝑡𝑖𝑚𝑒𝑟𝑡𝑟𝑎𝑖𝑛 ∈ ℝ+, …

𝑋, 𝑌 = 𝑡, 𝑣, 𝑎 𝑡 ∈ ℝ+, … ∪ query ∪ 𝑐𝑜𝑙𝑜𝑢𝑟 𝑐𝑜𝑙𝑜𝑢𝑟 ∈ 𝑟𝑒𝑑, 𝑔𝑟𝑒𝑒𝑛

Page 74: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Pattern 5: Complex State/Event

class Train:

def __init__(self, t, a):

self.t = t

self.a = a

self.v = 0.0

class Query:

def __init__(self):

pass

class QueryAck:

def __init__(self, colour):

self.colour = colour

class RailwaySegmentState:

def __init__(self):

self.train = None

class RailwaySegment(AtomicDEVS):

def __init__(self):

self.state = RailwaySegmentState()

def extTransition(self, inputs):

self.state.train = inputs[self.train_in]

Page 75: Classic DEVSmsdl.cs.mcgill.ca/people/yentl/files/18.SpringSim...Yentl Van Tendeloo and Hans Vangheluwe. An Evaluation of DEVS Simulation Tools. Simulation: Transactions of the Society

Conclusion

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