Event Calendar Usage for Queue-Server Model

Overview of Example

To see how the event calendar drives the simulation of a simple event-based model, consider the queue-server model depicted below.

Assume that the blocks are configured so that:

  • The Time-Based Entity Generator block generates an entity at = 0.9, 1.7, 3.8, 3.9, and 6.

  • The queue has infinite capacity.

  • The server uses service times of 1.3, 2.0, and 0.7 seconds for the first three entities.

The sections below indicate how the event calendar and the system's states change during the simulation.

Start of Simulation

When the simulation starts, the queue and server are empty. The entity generator schedules an event for = 0.9. The event calendar looks like the table below.

Time of Event (s)Type of Event
0.9Time-Based Entity Generator block generates an entity.

Generation of First Entity

At = 0.9,

  • The entity generator generates an entity and attempts to output it.

  • The queue is empty, so the entity advances from the entity generator to the queue.

  • The queue schedules an event that indicates that the entity has been placed at the head of the queue. This event is called a NewHeadOfQueue event.

  • The server is empty, so the entity advances from the queue to the server.

  • The server's entity input port becomes temporarily unavailable to future entities.

  • The server schedules an event that indicates when the entity's service time is completed. The service time is 1.3 seconds, so service is complete at = 2.2.

  • The entity generator schedules its next entity-generation event, at = 1.7.

In the schematic below, the circled notation "e1" depicts the first entity and the dashed arrow is meant to indicate that this entity advances from the entity generator through the queue to the server.

The event calendar looks like this.

Time of Event (s)Event Description
0.9FIFO Queue block schedules a NewHeadOfQueue event that indicates arrival of first entity at empty queue.
1.7Time-Based Entity Generator block generates second entity.
2.2Single Server block completes service on the first entity.

Generation of Second Entity

At = 1.7,

  • The entity generator generates an entity and attempts to output it.

  • The queue is empty, so the entity advances from the entity generator to the queue.

  • The queue schedules a NewHeadOfQueue event that indicates arrival of second entity at empty queue.

  • The server's entity input port is unavailable, so the entity stays in the queue. The queue's entity output port is said to be blocked because an entity has tried and failed to depart via this port.

  • The entity generator schedules its next entity-generation event, at = 3.8.

Time of Event (s)Event Description
1.7FIFO Queue block schedules a NewHeadOfQueue event.
2.2Single Server block completes service on the first entity.
3.8Time-Based Entity Generator block generates the third entity.

Completion of Service Time

At = 2.2,

  • The server finishes serving its entity and attempts to output it. The server queries the next block to determine whether it can accept the entity.

  • The sink block accepts all entities by definition, so the entity advances from the server to the sink.

  • The server's entity input port becomes available. The server executes an event to notify the queue about the newly available entity input port. This event is called an entity request event.

  • The queue is now able to output the second entity to the server. As a result, the queue becomes empty and the server becomes busy again.

  • The server's entity input port becomes temporarily unavailable to future entities.

  • The server schedules an event that indicates when the second entity's service time is completed. The service time is 2.0 seconds.

    Note:   The server's entity input port started this time instant in the unavailable state, became available (when the first entity departed from the server), and then became unavailable once again (when the second entity arrived at the server). It is not uncommon for a state to change more than once in the same time instant.

Time of Event (s)Event Description
3.8Time-Based Entity Generator block generates the third entity.
4.2Single Server block completes service on the second entity.

Generation of Third Entity

At = 3.8,

  • The entity generator generates an entity and attempts to output it.

  • The queue is empty, so the entity advances from the entity generator to the queue.

  • The queue schedules a NewHeadOfQueue event that indicates arrival of third entity at empty queue.

  • The server's entity input port is unavailable, so the entity stays in the queue. The queue's entity output port is said to be blocked because an entity has tried and failed to depart via this port.

  • The entity generator schedules its next entity-generation event, at = 3.9.

Time of Event (s)Event Description
3.8FIFO Queue block schedules a NewHeadOfQueue event.
3.9Time-Based Entity Generator block generates the fourth entity.
4.2Single Server block completes service on the second entity.

Generation of Fourth Entity

At = 3.9,

  • The entity generator generates an entity and attempts to output it.

  • The queue is not full, so the entity advances from the entity generator to the queue.

  • The server's entity input port is still unavailable, so the queue cannot output an entity. The queue length is currently two.

  • The entity generator schedules its next entity-generation event, at = 6.

Time of Event (s)Event Description
4.2Single Server block completes service on the second entity.
6Time-Based Entity Generator block generates the fifth entity.

Completion of Service Time

At = 4.2,

  • The server finishes serving its entity and attempts to output it.

  • The sink block accepts all entities by definition, so the entity advances from the server to the sink.

  • The server's entity input port becomes available, so it executes an entity request event. The queue's entity output port becomes unblocked. The queue is now able to output the third entity to the server. As a result, the queue length becomes one, and the server becomes busy.

  • The server's entity input port becomes temporarily unavailable to future entities.

  • The server schedules an event that indicates when the entity's service time is completed. The service time is 0.7 seconds.

  • The queue attempts to output the fourth entity. However, the server's entity input port is unavailable, so this entity stays in the queue. The queue's entity output port becomes blocked.

    Note:   The queue's entity output port started this time instant in the blocked state, became unblocked (when it sensed that the server's entity input port became available), and then became blocked once again (when the server began serving the third entity).

Time of Event (s)Event Description
4.9Single Server block completes service on the third entity.
6Time-Based Entity Generator block generates the fifth entity

Was this topic helpful?