CSCI 151 Lab 11: Ice Cream Store


Overview

In this lab, we will use a heap-based priority queue to implement a discrete event simulation. This lab will:

Description

You are the manager of a new ice cream store, and you are trying to decide how many seats to put in your store so as to maximize your profit. In order to help you decide, you want to write a simulation that will test the outcome for different possibilities. Based on your observations of other ice cream stores, you have decided on the following scenario for your simulation.

Every so often, one or more groups of 1–6 people enter your store. You may assume that the number of groups entering at each time step follows a Poisson distribution with average 0.2 (that is, on average, one group of people enters your store every five time steps; you do not need to know what a Poisson distribution is). However, if there are not enough empty seats for everyone in a group, the group will leave. Also, if there are too many empty seats, they may assume that your store isn’t cool and leave to go to a different ice cream store. In particular, if the ratio of empty seats to the total number of seats is \(e\), then they will leave with probability \(C e\), where \(C\) is the “coolness parameter”. We will use a value of \(C = 3/4\). For example, if your store has 10 seats and 4 of them are occupied, then \(e = 6/10 = 3/5\), and a new group entering your store will leave with probability \(3/4 \cdot 3/5 = 9/20\).

If there are enough seats and the group thinks your store is cool, they will sit down. After a few minutes (a random number from 1–5) they will order some ice cream. Each person in the group will order a random number of scoops from 1–4 (you can decide how much to charge per scoop). Then they will stay while they eat their ice cream; you may assume that the amount of time a group stays follows a Poisson distribution with an average of 10 time steps. After they finish their ice cream, they will leave, vacating their seats.

Setup

Notes

What to implement

You have three main tasks to complete; there is no particular order in which you must complete them, since each ends up depending on one of the others in some way.

Here is some sample output from my solution, when an ice cream store with 10 seats is simulated for 20 time steps. Yours does not have to look exactly like this, but should contain similar information.

-- Time 3 -------------------
A group of size 1 enters.
  They sit down.
  There are now 9 available seats.
  They will order in 4 minutes.

-- Time 7 -------------------
A group of 1 people is ready to order.
  #1 orders 1 scoops.
  They will leave in 9 minutes.

-- Time 9 -------------------
A group of size 2 enters.
  They decide your store is not cool.

-- Time 11 -------------------
A group of size 5 enters.
  They sit down.
  There are now 4 available seats.
  They will order in 4 minutes.

-- Time 13 -------------------
A group of size 6 enters.
  There are not enough seats.  They leave.

-- Time 15 -------------------
A group of 5 people is ready to order.
  #1 orders 3 scoops.
  #2 orders 1 scoops.
  #3 orders 4 scoops.
  #4 orders 3 scoops.
  #5 orders 4 scoops.
  They will leave in 13 minutes.

-- Time 16 -------------------
A group of size 1 leaves.
  There are now 5 available seats.

The store made a total profit of $5.

Evaluation

Simulate the ice cream store with every possible number of seats from 1 to 100. For each number of seats, run ten simulations of 5000 steps each, and average the results.

Make a graph of your results. What is the optimal number of seats? How do you think this depends on the “coolness parameter” \(C\)? What else might affect the optimal number of seats? Write up your answers in an evaluation document.