A Simple Discrete-Event Simulation: Part 15

Today I wanted to describe a few additional methods for generating arrivals over a given time span. Last week we divided the arrivals evenly over the span without placing any at the beginning or end. The next possibility is generating entities in order by ID and giving them random time offsets into the span. This means that the entities will arrive in the simulation out of order by ID. The next possibility is to randomly generate a list of offset times into the span, sort them in time order, and *then* assign them to the entities as they are generated in order by ID. In this case the new entities arrive in order by both ID and time.

Here’s the relevant code snippet.

Again, this situation can be complicated by how arrivals are generated across multiple entry components, if applicable.

Here’s the output for the second case, where the entities are generated in order by ID but out of order by time.

360.000000 minutes

Entry component 1 generates 0 new entities at time 0
Entry component 1 generates 0 new entities at time 30
entity 2 created at time 60
Entry component 1 generates 1 new entities at time 60
entity 2 updated at time 73.99298622427338
entity 2 terminated at time 75.99298622427338
entity 3 created at time 90
entity 4 created at time 90
entity 5 created at time 90
Entry component 1 generates 3 new entities at time 90
entity 3 updated at time 90.65448947567586
entity 3 terminated at time 92.65448947567586
entity 5 updated at time 102.45876143380077
entity 5 terminated at time 104.45876143380077
entity 4 updated at time 119.38927621505289
entity 6 created at time 120
entity 7 created at time 120
entity 8 created at time 120
entity 9 created at time 120
Entry component 1 generates 4 new entities at time 120
entity 4 terminated at time 121.38927621505289
entity 9 updated at time 123.9335770886767
entity 6 updated at time 125.66906431405235
entity 9 terminated at time 125.9335770886767
entity 6 terminated at time 127.66906431405235
entity 8 updated at time 130.20640371951362
entity 8 terminated at time 132.20640371951362
entity 7 updated at time 148.20505933816443
...
Entry component 1 generates 6 new entities at time 210
entity 22 updated at time 210.33055244386358
entity 22 terminated at time 212.33055244386358
entity 23 updated at time 218.17391645202767
entity 20 updated at time 220.06975372967392
entity 23 terminated at time 220.17391645202767
entity 20 terminated at time 222.06975372967392
entity 21 updated at time 226.5677482735777
entity 24 updated at time 226.65044172930732
entity 19 updated at time 228.05749230023298
entity 21 terminated at time 228.5677482735777
entity 24 terminated at time 228.65044172930732
entity 19 terminated at time 230.05749230023298
...
Entry component 1 generates 0 new entities at time 330
Entry component 1 terminated at time 360

This entry was posted in Simulation and tagged , . Bookmark the permalink.

Leave a Reply