next up previous
Next: About this document ...

CSCE 146 Matthews Lab 8 June 27, 2002

Piggly Wiggly Simulation

In this Lab we will do a discrete event simulation using some queues. We will be running a simulation of a Piggly Wiggly. In particular we want to know how many cashiers do we need to have working on the late shift, midnight to 6:00AM, time to keep the queue lengths manageable. In this run we will consider having two cash registers open and thus need two queues.

Input Parameters

  1. number of customers, , entering during a typical late shift midnight to 6:00AM.
  2. the average number of items purchased, , and the standard deviation of such purchases, .


From this input we estimate the probability, that a cutomer will arrive during a time slot. This is done by dividing by the number of time slots. This probability is then used to compare to a random number generated by the nextFloat method of the Random class of the JCL.

Output Produced:

  1. the number of simulated customers, and
  2. the average amount of time a customer waits in line


In a given time step, which is 5 seconds, we need to generate a new random number ranNumber (float) and compare it to , the estimate of the probability that a customer will arrive in this time slot. We will assume that in any time slot at most one customer will arrive. If a customer arrives then we will use the nextGaussian method of Random to return a value, , sampled from a N(0,1), i.e., a Gaussian (normal) distribution with mean 0 and standard deviation 1. To convert this to a Gaussian N() we use the formula

(1)

to generate the number of items to purchase. Your program should round or truncate this to an integer value and ensure that it is at least 1.

Then assume that the customers will take 45 seconds to find and place each item in their shopping cart. Assume that a customer will when finished will proceed to the checkout. When the customer gets there he will choose the smaller line. Assume that it takes 5 seconds per item to checkout.

For each customer we should measure how long they are in line and report this to an Averager, as in the CarWash example. Questions:

  1. What variables does the class Customer need to have?
  2. Assuming you use a ObjectQueue from edu.colorado.collections what would the narrowing conversions look like for assigning currentCustomer the front value of queue ?


Imports: Find these in the documentation online.



References:




next up previous
Next: About this document ...
Manton Matthews 2002-06-26