<<Back

Lab 2: The Gas Station Example

Supplementary Lecture Notes on Simulation and Modeling

These notes describe the development of a "gas station" model as a detailed example of an event-driven simulation program. Beware that this example program is written in an obscure (but vastly underappreciated!) programming language called Turing. However, this same "gas station" program was later translated into several other languages that you may be more familiar with, namely:

Try to compile and run a C or C++ example in the lab, and get an idea about how a general event-driven simulation program works.

Analysis of the Gas Station Example:

Program Structure for Event Driven Simulation

Entities:    

    Cars (dynamic): arrival time, how much gas needed

    Pumps (static): time to the completion of service to the current customer

Groupings:

    Pump array, pump availability, busy pumps and free pumps

    Car queues: how many queues?

Events:

    car-arrival: the first arrival event is scheduled during initialization; and remaining arrivals are handled by letting each invocation of the arrival routine schedule the next arrival event

    start-of-service: if a pump is available, it is scheduled in the arrival routine; otherwise, it is scheduled in the completion-of-service routine of the previous car

    completion-of-service: scheduled in the start-of-service routine

Pseudo-Events: 

    end-of-simulation: scheduled during initialization, used to initiate the final output of the statistics and measurements

    progress-report: report a summary of the statistics and measurements once for a while

Relationships:

    Non-similar entities may also by related, for example, a busy pump is related to a car in service

Random Number Generator

Statistics and Measurements

<<Back


Last Update: 04/22/2004