Spring 2004

HW5: Queues and Simulation

For this assignment, you are to complete the bank simulation project, which uses a queue to simulate customers arriving and being served in a small bank. Recall the following assumptions:

- There is only one teller, and customers are served on a first-come-first-served basis.
- At any given minute of the day, there is a fixed probability of a customer arriving at the bank. For example, if the arrival probability is 15, then there is a 15% chance that a customer will arrive at any given minute.
- The length of the transaction for a given customer, in minutes, is a random integer between 1 and some fixed constant (initially set to 8 minutes).

To complete the simulation, you are to implement the `ServiceCenter` class.
An object of this class
contains a single `Teller` object for serving customers, and a queue of customers
waiting to be served. The
`addCustomer` member function should create a new customer, add them to the
waiting queue, and display
information about the customer. The `serveCustomers` member function should
perform a step in the
simulation, checking to see if the teller has finished with a customer and, if so,
whether a new customer can be
served. It should also display a message if the teller finishes or begins serving a
customer.

For example, the output of the simulation should look like the following:

Once you have the simulation working correctly, add a member function named
`DisplayStats` that displays
statistics on the simulation. You should modify the `ServiceCenter` class so
that an object keeps track of:

- the number of customers whose jobs have been completed,
- the average waiting time for all customers whose jobs have been completed, and
- the longest waiting time for any customer.

The `DisplayStats` member function, when called, should display these
statistics in a readable form. Add
a call to the `banksim.cpp` program so that `DisplayStats` is called at
the end of the simulation to
display statistics.

- Assuming a banking day of 8 hours (240 minutes), how many customers would you expect to serve if the arrival probability were 20%. Do your simulations support this answer?
- Assuming a banking day of 8 hours and an arrival probability of 15%, what is the average wait time for customers at the bank. Run several simulations and comment on the consistency of the results.
- Assuming a banking day of 8 hours, what arrival probability can the bank handle and still keep the maximum wait time for customers under 10 minutes. Explain how you came up with this number.