BU CAS CS 113
Introduction to Computer Science II with Intensive C
Fall 1997


HW6 FAQ


Last Modified: Mon Nov 17 00:30:48 1997
Q. I am still kind of confused on how to replace the random number with data from a file. For example, the book has:
static void RunSimulation(simDataT *sdp)
{
    for (sdp->time = 0; sdp->time < SimulationTime; sdp->time++) {
        if (RandomChance(ArrivalProbability)) {
            EnqueueCustomer(sdp);
        }
        ProcessQueue(sdp);
    }
}
A. You want something like
    nextCustomer = GetCustomerFromFile(file);
    for (sdp->time = 0; sdp->time < SimulationTime; sdp->time++) {
        if (nextCustomer->arrival = sdp->time){
            EnqueueCustomer(sdp);
	    nextCustomer = GetCustomerFromFile(file);
        }
        ProcessQueue(sdp);
Of course the data types will depend on your program and the file must be opened, etc. But this is one possible structure for solving your problem.


Q. I am having trouble getting started with this assignment (or maybe fear I won't finish), what should I do?

A. Begin by making the following simplifications:

From here you can improve your program as you have time.


Q. What do we do with customers which arrive before the start or after the stop time? What about customers in queues at the end?

A. Ignore customers who come before the start (don't put them into queues). This means that before you start your simulation, you need to read through the data file until you get to a customer who arrives after the start time.

Once the stop time has been reached, you may stop processing. Count up the people in queues, but you do not continue processing them. You can calculate the statistics at that point and free or empty the queues. (Alternatively, if you want, you may treat the stop time as "closing time", processing the remaining customers in line, but not allowing any new ones to joing. In this case, you need to wait until all the queues empty "naturally". Depending on how you have coded things, this may be easier.)


Q. For the table, we have to supply longest wait, and then time of longest wait. Do you want the number of the customer who had the longest wait, how long he waited, or the time at which the longest wait occured for these two, and which for which ?

A. Time is the arrival time of the person who waited longest.

Length is the length of that person's wait.


Q. For average wait, this would be a float, but it doesn't seem like something that we need that much precision on, just a general idea of the average, so if I left these as integers, truncating the number, would that be OK ?

A. For the averages, give a place or two after the decimal: like 3.2


Q. I was just wondering is there a good way to compare all the length of the queues and find the shortest one easily?

A. Just loop thru them all holding onto the index of the shortest queue seen so far, updating as you see shorter ones. At the end of the loop you will have the shortest queue.


Q. Is 10 the maximum number of queues a user can enter?

A. Although it is not difficult to program this so that there is no maximum (using dynamic allocation), it is acceptable to have a constant maximum. You may set that value to 10. Thus you can have an array of queues (for example) without using dynamic allocation if you like. This may make things a bit quicker to program and debug.


Q. Is the customer entering the line with the least customers or the line with the shortest wait...or neither?

A. The line with the least number of customers.