CPSC 420 -- Lab Exercise
The purpose of this lab exercise is to get you familiar with
the C++ implementation of the single server queuing system
handed out in class. You should have your print out of the program
with you for reference. The updated .cc and .h files and a Makefile
for the program are in the tar file
mm1tar.tgz.
Modifying the Program to Find the Maximum in the Queue
Study the program carefully and determine how to modify the code to
find the maximum queue length. Implement your changes.
Modifying the Program to Model Two Servers in Series
Modify the program to do problem 1.14 on page 100 of the text.
Do the problem incrementally
(as follows), first working to get the system logic correct, then
worrying about things such as the stopping condition and the performance
measures.
When you are ready to implement this, make a new directory for
the files (separate from the mm1) AND rename the mm1System class
(and file) AND put your name in the documentation!!!!
- First determine the state variables you should use and the
best way to implement them in the program. After doing that,
- Add the declarations to the program
- Add the initializations (note that some initialization is done
by the initialization routine and some by the constructor for an mm1System
object)
- We decided in class that there should be three events: an arrival
to the system (an arrival at the first server) which is basically the
same as the current arrival event, moving from the first to the second
server (departing first server, arriving at second), and departing
the system (departure from the second server). To add these events,
do the following:
- Think of a name for the new event and add that name to the eventType
enumerated type (in the system declaration)
- Add a declaration for a method to process that event
- Recall that the updateState method is the one in charge of
calling the correct routine to process an event. Add a case to the
list in the switch statement to call the new method in the case
that the event is the new event type.
- Modify the current processArrival and processDeparture
to use the correct server. You will also need to modify
scheduleDeparture to schedule the departure from the correct server
(you should add a parameter to send the server number).
- Write a stub for the process routine for the new event. Have it
do something simple like print a message and schedule a departure from
the second server.
- The printReport routine has a reference to the customerQ which should
now be a subscripted variable, so for now subscript it with 0 (for the
first server's queue).
- Compile the program and run it to see if all seems well so
far. Is there any way to tell at this point if all is well?
- After all the bugs are out, go back and fill in the logic for the
routine that processes the new event. Compile and run the program.
- Now, we need to fix the statistical counters. Since we already
have two queues and queue statistics (area under the Q(t) function) are
kept track of by the Queue object, we don't need to worry about that.
- We do need to now keep track of total delay in each queue, so change the
totalDelay variable to a subscripted variable in the declaration and
modify the code in the appropriate places (where is totalDelay updated,
where is it used to calculate final statistics?).
- We should also compute the number of customers who complete their
delay in the two queues (the numbers will be almost the same for both
queues but not quite). So the numCustomers variable needs to be
subscripted. Make all necessary changes. (NOTE: in continueSim, use
the number of customers who completed their delay at the second server --
numCustomers[1]).
- There are now two different service times (still just one interarrival
time), so the serviceTime randNum object needs to be subscripted. The means
for the two mean service times should be read in in the initialization
routine and the two objects initialized there. Then, the program
must be modified in the place (and
there is only one place!!!) where the random number
generator is called to get a service time. The report printing routine
prints out the service times so it must be modified.
- Compile, run, and clean up any details I may have forgotten to
point out to you. (NOTE: For now leave the stopping condition to be
when a certain number of customers complete their delay at the second
server. The book says to stop after exactly 1000 minutes of simulated
time. We'll talk about stopping conditions Thursday.)