A Simple Discrete-Event Simulation: Part 62

Today I added the ability for the user to control how the display is updated. Two new buttons have been added to the button row between the 2D display and the 3D display. The second button from the right, labeled “Time” when the page is initialized, indicating that the animations will only be updated on a time interval determined by a new display control timer component. The base multiple is set to 0.5 so the model will process as many discrete-event items during each interval of that length, at which time it will update the appropriate displays. This is done once per screen refresh cycle. This makes the animation much easier to watch, and it also ensure that simulated time advances at a consistent rate. Clicking on that button will change the display to “Ops,” short for Operations, indicating that only one discrete-event item will be processed per screen refresh, and the displays will be updated in the manner we’ve seen up until now.

The rightmost button, labeled “x1” to start, governs the multiplier for the time interval. Clicking on it changes the display to “x2” and multiplies the default time interval for time-based updates by two. The multiplier applies to whatever the base time interval is. If the base interval is set to 0.25 time units then setting the multiplier to two will result in updates occurring every 0.5 time units. The multiplier value does not apply when the display is in “Ops” mode. In theory the multiplier could be set to any positive value above zero (including fractional values) but the demo uses one and two for simplicity.

Last but not least notice that changing the multiplier value takes effect after the next update is completed. This is because the next discrete-event item that triggers the display update has already been inserted into the future events queue using the old multiplier value.

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

Leave a Reply