Spring 2005

HW6: 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 `Server` object for serving customers, and a queue of customers
waiting to be served. The
`addCustomer` method should create a new customer, add him/her to the
waiting queue, and display
information about the customer. The `doBusiness` method should increment the
current time and 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. In addition, the `getTime` method should return the current simulation
time, and `customersRemaining` should return true if there are any customers
currently in the system.

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

Once you have the simulation working correctly, add a method named
`displayStats` that displays
statistics on the simulation. You should modify the `ServiceCenter` class so
that it 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
*whose job has been completed*.

The `displayStats` member function, when called, should display these
statistics in a readable form. Add
a call to the main method of `BankSimulator` so that `displayStats` is called
at
the end of the simulation to
display statistics.

- Assuming a banking day of 8 hours (480 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.