Page 343 - ExtendSim User Guide
P. 343

Tips and Techniques 317
Event scheduling
instance, an Activity block holding an item until a particular time will cause an event to be posted to the ExtendSim internal event calendar. When the time is reached, the event occurs and the model recalculates its data.
Blocks that do not generate events allow the blocks after them to pull items during a single event. Thus a single event can cause an item to pass through many blocks if those blocks do not stop them. For instance, a Set block could set the item’s attribute and pass the item to the next block in the same event.
Discrete event and discrete rate simulations use the same method for updating the simulation clock. Simulation models of this type are driven forward by event and the state of the model changes only at event times.
At each event, blocks that have posted an event to the event calendar for the current time receive a message notifying them that the time has arrived. Once all of the blocks have received their messages, the time for the next event is determined. Through this event schedul- ing mechanism the simulation clock jumps from one event to the next.
Event calendars
ExtendSim utilizes a two-stage event calendaring method – the Executive block maintains a list of all events for the model and time-delay blocks maintain their own event calendars.
☞ This two-stage event calendar is very efficient and flexible. Unlike single stage event calen- dars, relatively little time is spent by the Executive in maintaining and searching the event list.
The Executive
The Executive block maintains a list of all event times for the model in its event calendar. At the beginning of each simulation event, the Executive locates the next future event and sends a message to each of the blocks in sequence that posted an event for that time. Once a block has completed processing its event, it will post its next event time to the Executive. If the block does not have a future event time, it will post a very large value as its next event time, effec- tively removing it from the list of pending events.
Blocks may have two or more entries on the Executive’s event calendar. This is because they have different types of events that need to be processed. For example the Convey Item block has an event that occurs when an item is able to enter the block and an event for when the item leaves the block.
For more information about the Executive block, see page 313.
Internal event calendars
Each block that has a time delay associated with it (for example the Create, Activity, Pulse, and Shutdown blocks in the Item library) maintains its own, independent next event time.
Blocks such as the Activity, Convey, or Shutdown block can have multiple future events (one event for each item in the block) ongoing simultaneously. In this case, the blocks maintain their own internal event calendar, posting only the earliest of these events to the Executive's event calendar.
Zero time events
As the simulation progresses, there are many times when it is useful to generate a zero time event. This is done to allow an item to complete the process of moving into a block before the block attempts to perform additional actions on the item. For this purpose, the Executive main-
Discrete Event

   341   342   343   344   345