15-121 SPRING 2010 [CORTINA]

LAB 6

In this lab, you will work on a simulation that uses queues to analyze a problem for a supermarket. The manager of the supermarket wants to analyze whether there should be a separate line (queue) of customers for each cash register or a single line that serves all cash registers so that once a cash register is available, the next person on line goes directly to that cash register to check out.

EXERCISES

Download the MarketSimulation.zip project file.

This project contains a Customer class that models a customer in the supermarket. Each customer keeps track of the time when the customer enters the queue and how long it will take for the customer to check out once the customer arrives at the cash register.

There are also two simulator classes, Simulation1 and Simulation2. Each simulation has three parameters, the probability that a customer arrives each minute, the number of registers in the market, and the total number of simulated minutes. The simulation then has a loop that simulates one minute of time in the market.

  1. Read the comments in each Simulation class and complete the required code.

  2. Run each simulator with the given parameters and see what the average waiting time is for a customer. Then increase the arrival probability by 0.1 at a time and look at the average waiting time. (The probability should not exceed 1.0 total.) Try to decide which queue policy is better for the customers.

HANDIN

If you worked with another student, put both of your names in a comment at the beginning of your program. At the end of lab, create a zip file of your program and submit it to the handin server http://handin.intro.cs.cmu.edu/v1. (If you worked together, you only have to submit one program.)

FUTURE WORK: FUN STUFF FOR LATER