This lab is designed to give you experience using priority queues and to give you experience writing simulations.
You may use either the Fields library or C++ iostreams for this lab. I would recommend using the Fields.h and the Fields.cpp files from practice homework 4.
You should use the C++ STL priority_queue class.
www.cppreference.com is
a pretty self-explanatory reference for the priority queue class and my
stl notes show
you how to declare the priority queue class.
In the remainder of this
lab you will implement the banking simulation described in class. The
class notes serve as an important resource for this lab so whenever you
have questions about design or implementation, the class notes are a
good place to look. The goal of running the simulation will be to
determine the minimal number of tellers required in order to ensure
that no more than x% of
customers have to wait more than y minutes in
line. Once you have completed the simulation program, you will
be able to experimentally increase or decrease the number of tellers in
order to determine the minimal number of tellers.
The program you will write will be named bankSimulator and will take the
following arguments:
An example invocation of the simulation program would look as follows:
The binary for simulation can be found in
/home/bvz/courses/302/labs/lab6/bankSimulator. If you
have any questions about how your program should execute, the way
the format of the output should look, or what the correct values for
the output are, you should execute the simulation binary. The
bankSimulator in my directory has an optional additional argument, called
doprint which goes at the end of the argument list. By default
it is 'no' and you do not have to include it. If you say 'yes', then
my simulator will print out certain information about the events as
they are processed. This information might help you in creating and
debugging your simulation program.
Each execution of your simulation program should produce five outputs,
formatted as shown above:
Although some of these statistics are not required to answer the minimal
teller question, they would be useful to a bank executive trying to make
decisions about the number of tellers to hire. For example, a bank executive
probably would also want to factor into his or her decision the average
time that a customer spends waiting for a teller and the maximum time a
customer has to wait for a teller.
You should use the implementation scheme described in class for the bank
teller problem (also see pages 224-225 of Weiss). In other words, you
should have a priority queue that is ordered by timestamped events. If
your simulation has k tellers, then the priority queue will
have up to k departure events and some number of arrival events.
You should also use the classes shown
in class and you should use inheritance to handle the events.
Specifically you will need to write the following routines:
Some of the routines might be lumped together into the main
procedure. For example routines 2-4 might go into the main procedure.
In order to help get you started, some code has already been prepared
for you. This code can be found in the following files:
Here is some other information you need to know about include files and
linking as well as a couple hints:
You need to submit two different things for this lab:
Simulation
bankSimulator time_limit num_tellers wait_threshold
mean_transaction_time dist_file seed
The arguments have the following meaning:
cetus3> bankSimulator 72000 3 100 120 expon_120 53
Number of customers = 577
Average customer waiting time = 4
Maximum customer wait = 125
Percentage of customers who waited longer than 100 seconds for a teller: 0.7
Teller Idle Time Idle
0 49459 68.7
1 47918 66.6
2 48850 67.8
Output
Details
What Has Already Been Done For You
uniformTest 100 20
histogramTest 100 expon_120
Other Helpful Information
list<Event *> a;
will get the unintelligable linker messages if a is a global
variable. However, the following declaration and initialization will
work just fine:
list<Event *> *a = new list<Event *>();
What to Submit
x = 5, y = 180, mean_transaction_time = 120, seed = 53
x = 5, y = 180, mean_transaction_time = 240, seed = 137
x = 2, y = 180, mean_transaction_time = 300, seed = 333
x = 2, y = 300, mean_transaction_time = 240, seed = 217
All simulations should be run for 144000 seconds and your answers
should be placed in a file called answers.