Example: How to use the terminology in practice


Building a simulation gas station with a single pump served by a single service man. Assume that arrival of cars as well their service time are random. At first identify the:

States: number of cars waiting for service and number of cars served at any moment

Events: arrival of cars, start of service, end of service

Entities: these are the cars

Queue: the queue of cars in front of the pump, waiting for service

Random variates: interarrival times, service times

Distributions: we shall assume exponential distributions for both the interarrival time and service time.


Next, specify what to do at each event. The above example would look like this: At event of entity arrival: Create next arrival. If the server is free, send entity for start of service. Otherwise it joins the queue. At event of service start: Server becomes occupied. Schedule end of service for this entity. At event of service end: Server becomes free. If any entities waiting in queue: remove first entity from the queue; send it for start of service.


Some initiation (initial values) is still required. For example, creation of the first arrival. Lastly, the above is translated into code. This is easy with an appropriate library which has subroutines for creation, scheduling, proper timing of events, queue manipulations, random variate generation and statistics collection.


How to simulate? Besides the above, the program records the number of cars in the system before and after every change, together with the lenght of each event.