Transcript
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


Recommended