The analysis for part C should be done for just one inter-arrival
time. The value is 9 seconds. You can run the coffee break
simulation with the following input for the first parameters:
100 1200 5 7
and for all possible numbers of express cashiers.
A couple of messages from Carl and Mike Molloy (thanks!).
> I had a few questions regarding the implementation of exactly how we
> start a coffee break off. The handout says that we must first wait
> for the cashier to finish serving the current customer before break
> time is invoked.
>
> According to the starter code, the actual end of service of this
> customer is denoted by a departureEvent, in which if the queue is
> not empty, the next cusotmer is then processed. Thus, if a cashier
> is set to take her break but is still serving a customer, then we
> would have to wait until we reach the departure event in the
> eventlist. Thus, would we have to modify the departureEvent to make
> sure that when infact we reach this event, that we are NOT to take
> anymore customers even if the queue is nto empty, since the cashier
> is past due for her break?
You are free to implement this either way. That is, either stop
accepting new customers to the queue when there is a pending break, or
allow more customers to be added until the break actually starts.
On the other hand, we prefer you stop accepting new customers to the
queue (by using a flag or something) so try to do it this way.
----
> When cycling thru the cashiers for coffee breaks should express go before
> regular or vice versa? There are no specifications on the assign handout.
We have already recommended express before regular in the newsgroup.
This is a recommendation (not a requirement).
The following is an important posting from the nesgroup (thanks Carl).
----
After consultation with the course instructor's, here's an update on
my previous posting on this topic
> I read the Q&A webpage. I think there would be a big hole in the
> simulation if we seed the 3rd random stream with the same seed value for
> the itemsStream. Because these two random streams are always used together
> and only used in instantiating class Cust, the two random streams always
> give the same value of a particular type in each use. Then in this
> simulation, expCustomers would never buy more than 3 items, while
> regularCustomers would never buy less than 32 items. In the other word, #
> of the items bought by a individual customer would never be between 4 and
> 31 in this simulation.
Good point!!!
Thanks for pointing this out.
> A simple way to correct the problem may be to set the seed for the 3rd
> random stream to be the seed value of the itemsStream plus one.
Or better yet, a multiplication of seed 1 and 2.
This may be why those you have added the 3rd stream are finding the
customer served numbers to be lower than expected (because the regular
customers have too many items).
Since this 3rd stream idea is turning out to be a bad one, I suggest
the following option:
1) Use 2 streams for the 3 decisions.
2) Use 3 streams and seed the third with a multiplication of the first
2 seeds.
3) Use 3 streams and read the 3rd seed from 'cin' as is done with the
seeds for the other 2 streams.
USING OPTION 2 IS RECOMMENDED, but if you've completed part 1 using
option 1 or 3, then leave it as you have it.
My apologies for the confusion.
Carl.
We will override our comment of Friday November 12 about the bug
caused by the pointer custInService being not set to NULL. The
new comment reads as follows:
> Another bug is that custInService isn't being set to NULL in the
> constructor. Maybe in GCC it is automatically set to NULL, but
> in others it might not be, and this has the side effect that no
> customer will ever get served since freeCashier will always
> return false.
Yes, it's a bug that the pointer isn't being set to NULL. To fix
this, make sure you make the following change:
In cashier.h, change the constructor from
Cashier(typeCashier cType = regular ) { type = cType; }
to
Cashier(typeCashier cType = regular ) { type = cType; custInService = NULL; }
----
> I am a Scarborough student.
> I have the following problem: the make utility doesn't work.
> When I am trying to launch it from the UNIX shell, it says:
>
> Makefile:4: *** missing separator. Stop.
>
> That is, right at the place where OBJS list has a line break
(a backslash).
> Do you have any ideas how I could handle this?
> I did not modify the file in any way.
This seems to be happening to a few people, so we'll add this to the
Q&A page.
It's very important that the last character at the end of line 4 in
the Makefile:
OBJS = main.o random.o stats.o cust.o custqueue.o cashier.o cashierstand.o \
is the '\' character. That is, check to make sure that a space or
carraige return (from converting to DOS format) hasn't been
inadvertently added after the '\' character. The make utility is very
picky about this.
Carl.
----
> We were told make modifications to the stats.C file. I made the changes
> and I cannot compile it says maxWaitingTime has not been declared. I
> searched the entire code and could not find where maxWaitingTime is from.
> Is there an error or am I missing something.....
Since it's a required statistical parameter, you will have to add it
to the 'Stats' class and compute its value. See the "CODE" comment in
Stats.h.
Read a message posted in the newsgroup
about adding random streams (thanks Carl). Note: the contents of
this message apply ONLY to St. George Campus.
----
Probably you remember that we said:
You WILL have to add stuff to the starter code to complete ANY part of
the assignment. There is no restriction on which parts you are to change.
Simply make sure your additions are done in good style.
This applies to adding accessor functions whenever you need
access to private data from "sim" class.
----
The statistics in stats.C were computing seconds and not minutes.
In stats.C, started near line 82, make the following changes, from
cout << 0;
cout.width(8);
cout << totalWaitingTime/customersServed;
cout.width(8);
cout << totalServiceTime/customersServed;
cout.width(8);
cout << ( totalWaitingTime + totalServiceTime ) / customersServed
<<"\n";
to
cout.width(8);
cout << totalWaitingTime/(60*customersServed); // converting to minutes
cout.width(8);
cout << totalServiceTime/(60*customersServed); // converting to minutes
cout.width(8);
cout << ( totalWaitingTime + totalServiceTime ) / (60*customersServed)
<<"\n"; // converting to minutes
Read a message about a loop to run
the simulation from 1 to 19 express cashiers; it includes an
script for doing this (thanks Carl).
----
Read the details about the submission process
(html page) for assignment 3 in the St. George Campus ONLY.
----
> What Random stream should we be using (if any) to determine if a
> Customer is an Express/Normal. In particular I'm looking at
> implementing the Items Bought algorithm.
You would probably have to add another random stream to the
SupermarketSim class and use it for making the decision.
----
A student pointed out a couple bugs to me in the starter code. They
shouldn't affect your solution to the assignment, but here they are
for your reference. I would recomend you make the change shown below.
> For example, the line
>
> totalEmptyQueueTime += sim->getTime();
>
> makes no sense, since sim->getTime returns the actual time in the
> simulation, not the time elapsed since the ueue became empty. I did post
> one bug to the newsgroup though, regarding the fact that if a customer is
> cheduled to depart after the end of simulation, his presence and items
> bought will not be recorded.
You're right about this. The calculation of the empty queue time
makes no sense. Also, as you mention, the empty queue time stat is
not used in the assignment, so it doesn't matter. Simply ignore it.
> Another bug is that custInService isn't being set to NULL in the
> constructor. Maybe in GCC it is automatically set to NULL, but in
> others it might not be, and this has the side effect that no
> customer will ever get served since freeCashier will always return
> false.
Yes, it's a bug that the pointer isn't being set to NULL. Looking
through the code, the reason this doesn't seem trigger any errors is
that the only place that this matters is in the freeCashier()
function. This function is only used in the CashierStand class:
if ((cashierToGo->getCustQueue()->getQueueSize() ==0) &&(cashierToGo->freeCashier()) ) ...
where the getQueueSize() call will always return 0 right after a
'Cashier' class is created. Therefore the freeCashier() call will
never be used in the 'if' statement (this is called lazy evaluation in
C/C++).
IF, ON THE OTHER HAND, YOU DO PLAN ON USING Cashier::freeCashier() in
other places, then make sure you make the following change:
In cashier.h, change the constructor from
Cashier(typeCashier cType = regular ) { type = cType; }
to
Cashier(typeCashier cType = regular ) { type = cType; custInService = NULL; }
Carl.
The assignment handout states that you have to take the opening
time of the supermarket into account when scheduling the coffee
breaks. In hind-sight, this is an unnecessary complication, and you
are allowed to make the (realistic) assumption that the supermarket
always opens at 7:00. That is, simply schedule the first coffee
break to start 0:30 simulation time (it may start later if the
relevant cashier is serving a customer at 0:30). If on the other
hand, you have already implemented your solution to include the
supermarket opening time as a parameter, then leave it as you have
it. (Thanks Carl.)
----
Question: In the lecture notes, we have a formula that is
used to generate a random number from an exponential distribution
with rate r. Is r equal to the mean interarrival time, i.e. 8, 9, or 10?
Answer: No. r measures the average number of arrivals
per unit of time (in this case, seconds). The mean interarrival
time measures the average number of seconds between arrivals.
It is not hard to see that r is equal to the inverse of the mean
interarrival time. For example, if we expect that, on average,
another customer will show up every 8 seconds, then we average 1
customer per 8 second period, or 1/8 of a customer every second.
Therefore, the formula in the lecture notes: -(1/r) * ln(y)
translates to: - mean interarrival time * ln(y).
Or if you prefer, you can use the equivalent-in-distribution formula:
- mean interarrival time * ln(1-y). (Thanks Mike.)
> In the SupermarketSim class, member variable itemsBoughtMax is declared
> as a double; I think it should be an integer (its value represents the
> maximum number of items that can be bought).
Good point. Feel free to make the change, but it's not mandatory.
----
You WILL have to add stuff to the starter code to complete ANY part of
the assignment. There is no restriction on which parts you are to change.
Simply make sure your additions are done in good style.
We will include in this page questions and answers about assignment 3. These questions will be collected by the profs and tutors of the course. This page is maintained by Daniel Panario.
Back to csc270 St. George (day Section)
page
Back to csc270 St. George
(evening Section) page
Back to
csc270 Erindale Campus page
Back to
cscB70 Scarborough Campus page