CS203 Final project

Write a program to simulate a checkout counter at a supermarket.

Customers arrive in random intervals of 1 to n minutes. Allow the user to set the maximum interarrival time n for each run.

Checkout counter servers take a random interval between 1 and m minutes to service each customer. Allow the user to set the maximum service time m for each run.

The simulation will run for 12 hours (720 minutes).

Simulate the checkout counter line as an STL queue.

Use an STL list to record all the events in the simulation. For each arrival an event is generated at arrival time, the start of service, and the end of service. The list is kept ordered by time.

When a customer is finished being served the program outputs a line of text stating the customer number, arrival time (in minutes), start-of-service time, and end-of-service time.

When the run is done, we will use the event list to generate some statistics for the run. We would like to compute and display:

  1. The total number of customers
  2. The average throughput, or number of customers per hour.
  3. The maximum and average waiting times, where waiting time is the interval between arrival and start of service.
  4. The maximum and average turnaround times, where turnaround time is the interval between arrival and end of service.

We will probably need at least a customer class for the queue, an event class for the event list, and a server class for the checkout server.

The simulation runs as follows:

We generate an interarrival time representing the time the first customer arrives. An arrival event is generated and stored. The customer is put on the queue. The server starts serving by generating a start-of-service event for customer 1, then determines the service interval and generates an end-of-service event for that customer.

We can keep an iterator on the list. We can process the list during the simulation using the iterator.

When a customer arrival event is processed (including the first customer) the next customer arrival time is generated. The current customer goes on the queue and the next arrival event is put on the list(in order). If the queue was empty before the arrival (then is must have one customer on the queue now), then the server must be told to start servicing (since it was idle while the queue was empty).

If the next event on the list is an end-of-service event the server dequeues the current customer and if the queue is not empty generates a start-of-service event at the same time for the next customer and an end-of-service event for that customer.

If the next event is an arrival we put the current customer on the queue, generate the next arrival event, and the put the next arrival event on the event list.

Notes:

  • The description above is intended to be taken a set of suggestions. If you have another way of approaching the problem, or a different implementation . . . variety is the spice of life! At least one student is generating all the arrivals at once, then proceeding with the simulation. Some students are generating only one event per customer, and that event will contain arrival, start-of-service, and departure times as well as the customer number.
  • You may find it useful to try a small run by hand before you start programming to help you understand how the algorithm works.
  • Create a makefile for the project early on, and update it as the project progresses.
  • Test the program by setting max interarrival time to 6 and max service time to 6.
  • Try another run with 6 and 5.
  • What happens if you try 5 and 6?
courses/cs203-200903/assignments/final_project.txt · Last modified: 2009/12/08 10:46 by jones
VCCS Top Events Extended Site Search Login Vassar Science Web Vassar Home Driven by DokuWiki Valid XHTML 1.0