One of the most common uses of computers is to run simulations. A simulation is a program designed to model some real system of interest. By setting parameters and selecting appropriate input values, results are produced that mimic the behavior of the real system. If the simulation is a valid representation of the real system, it can even predict the future performance of the real system.

In this project, you will construct a Java program to simulate the drive-thru area of a fast food restaurant. Our restaurant will consist of two types of components: drive-thru service stations and customers.

The restaurant is described by the following variables and parameters:

Order Station: station
Payment Station: station
Food Collection Station: station
Mean Interarrival Time: double
Mean Order Size: integer
Time To Order An Item: double
Mean Time To Pay: double
Time To Process Item: double

An order, payment and food collection stations are described by the following variables and parameters:

Server Status: Boolean
Waiting Customers: queue (statistical queue – see lab 8)

A customer is described by the following variables and parameters:

Customer Number: integer
Order Size: integer

When customers arrive at the restaurant, they perform the following activities:

  • They get in the order station line and wait to reach the front of the line. Once they reach the front of the line they place their order. The time spent ordering is determined by the size of their order. The size of an order is determined by a Poisson distributed random variable. The time spent ordering is equal to the product of the order size and the time to order an item (order size * time to order an item).
  • When they finish ordering, if there is space to move forward they leave the order station and enter the payment line (queue).
  • When a customer reaches the front of the payment line, they are checked out by a cashier. The time spent checking out is sampled from an exponentially distributed random variable with a mean time Mean Time To Pay. Once the customer completes payment if there is room to move forward, the customer enters the food collection line.
  • When a customer reaches the front of the food collection line, they wait to receive their food and leave. The time spent waiting to collect the food is determined by the size of their order. The size of an order is the same value referred to in step 1. The time spent waiting to collect the food is equal to the product of the order size and the time to process, package and collect the order (order size * time to process an item).

We will use a discrete event simulation to model the restaurant. This means time is managed by using a simulation clock (simClock) that is advanced whenever an interesting event occurs. For example, if the simulation time is 357.0 minutes and a customer enters the order line at a time 4 minutes later, we will mark the passage of time by advancing the simulation clock to 361.0 minutes (357 + 4). If a customer reaches the payment window 3 minutes later, we advance the clock to 364.0 (361 + 3). Our assumption is no interesting activities occur between events (i.e. nothing significant happens in the intervals (357.0, 361.0) or (361.0, 364.0) so we can record the passage of time by moving the simulation clock forward to the time when the next important event occurs).

To model this system, we will need the following events to describe the customers’ interactions with the restaurant:

Arrival
FinishOrder
FinishPayment
FinishFoodCollection

An event consists of two or more pieces of information:

event type ( enumeration )
event time ( double )
event parameter ( information about a customer )

A few sample events might be:

event type: Arrival
event time: 25.2
event parameter: none
event type: EndOrder
event time: 30.5
event parameter: a customer object
event type: EndCheckout
event time: 37.1
event parameter: a customer object

The diagram shown below outlines the flow of events in our simulation. See image.

To begin, we set the simulation clock to 0.0 and schedule a customer arrival at time 0.0. We place each new event on a list that contains the sequence of pending activities ordered by increasing simulation time. The setup after scheduling the first customer Arrival event might appears as follows:

simClock = 0.0
event list = ( {Arrival, 0.0} )

To process an event, simply remove the first event from the list, update the simulation clock to the time of the event and perform the action needed to simulate the event. For example, to process the first event:

simClock = 0.0 Note, the time of the first event is zero so the clock does not move
event list = ( )

Since the first event is an arrival, perform the actions associated with a new arrival. Create a customer, generate the number of items the customer will order and compute the time the customer spends ordering food. Assume the customer picks up 6 items and it takes 15 seconds to order each item so the total time to process the order is 1.5 minute so schedule a customer finish ordering event at simClock + 1.5 minutes. Also, whenever a customer arrives, we need to schedule the time for next customer arrival. Let’s assume the next arrival is in 1.0 minute so we need to schedule an arrival event at time simClock + 1.0. Now the event list looks like this:

simClock = 0.0
event list = ( {Arrival, 1.0}, {FinishOrder, 1.5, customer object {1,6}} )

The information in a customer object {1,6} is {customer number, number of items ordered}. Let’s process another event. Remove the first event from the list and update the simClock.

simClock = 1.0 Note simulation time has advanced to the time of the event
event list = ( {FinishOrder, 1.5, pointer to customer object {1,6}} )

Since the next event is another customer arrival, we perform the same activities again. Assume the new customer selects 5 items so the time to process the order is 1.25 minutes. Also assume the third customer will arrive in 2.0 minutes, now the event list appears as follows:

simClock = 1.0 Note simulation time has advanced to the time of the event
event list = ( {FinishOrder, 1.5, pointer to customer object {1,6}},
{Arrival, 2.0}
)

Notice that the 2nd customer {2, 5} is not in the event list. The customer who just arrived, the one who wants to order 5 items, is waiting in the order queue for their turn to place an order.

We will assume that we are only simulating the operation of the restaurant during the peak lunch hours from 10:30 AM until 2:30 PM. We have to be careful when scheduling more customer arrivals because if the next customer arrival will occur after the peak hour, we need to ignore the event or not place it on the event list. Assuming the simulation runs from 10:30 AM to 2:30 PM, we can run the simulation from time 0.0 – 240.0 (4 hours * 60 min/hour). We should not allow anyone to arrive after 240.0.

Let’s process one more event. Since this event is a FinishOrder event, we have to move the customer 1’s car forward into the payment line. If the cashier is already busy or there are too many cars ahead of the current car, do nothing -- just wait. Let’s assume the line is empty so this customer is ready to pay. Assume the time to pay is 0.5 minutes so we need to schedule a FinishPayment Event. Also since the order station is now open, the next customer waiting to order can move forward so we need to schedule an FinishOrder Event for customer 2 in 1.25 minutes.

simClock = 1.5 Note simulation time has advanced to the time of the event
event list = ( {Arrival, 2.0}
{FinishPayment, 2.0, pointer to customer object {1,6}},
{FinishOrder, 2.75, pointer to customer object {2,5}},
)

To summarize, the actions to perform for each event are:

Arrival -- When an arrival occurs, create a customer, determine the number of items the customer will order, enter the order queue. The size of the order is determined by a Poisson distributed random variable with a mean value of Mean Order Size (the mean determines the average size of the order). If the customer is first in line, the schedule the FinishOrder event in an amount of time equal to Order Size * Time To Order An Item. If it is not after time 240.0 (shut down time), then schedule the next arrival in a random amount of time using an exponential distribution with a mean of Mean Interarrival Time value.

FinishOrder – When a customer finishes ordering, if there fewer than 3 cars in line ahead of the current car (2 waiting and 1 at the payment window), the car can move forward into the payment queue. If the cashier is not busy (check the cashier’s status variable) schedule the customer to Finish Payment at a future time determined by sampling an exponentially distributed random variable with a mean value of Mean Time To Pay.

FinishPayment – When a customer finishes paying, if there fewer than 2 cars in line ahead of the current car (1 waiting and 1 at the food collection window), the car can move forward into the food collection queue. If the food collection server is not busy (check the server’s status variable) schedule the customer to FinishFoodCollection at a future time determined by the value of Order Size * Time To Process An Item. If a car moves forward from the payment window and another car is waiting in the payment line, you will have to schedule another FinishPayment event. This may also result in a car being able to move forward from the order station so you may also need to schedule another FinishOrder event.

FinishFoodCollection -- Remove the customer from the system and display statistics. If there are more customers in the line, schedule the next customer to FinishFoodCollection at a future time as described above. Again if customer moves forward, you may need to schedule other events. If there are no customers waiting set the server’s status to idle.

When the simulation ends print the statistics part of the system. The basic design of this program will be discussed in class. If you miss class make sure you get a classmate’s notes before you begin.

The following values represent the initial conditions for our simulation:

Restaurant:

Restaurant:
Mean Interarrival Time: 90 seconds
Mean Order Size: 5
Time to Order an Item: 15 seconds
Mean Time To Pay: 60 seconds
Time to Process Item: 20
Total Customers: 0

We will discuss how to generate random numbers in class and also talk about how to implement the simulation clock.

As a customer moves through the system display the following information in a log file: the customer number, order size, arrival time, finish order time, finish payment time, and finish food collection time. At the end of the simulation, display the total number of customers served, average queue lengths, maximum queue lengths and the average waiting time for each stations (order, payment and food collection).

Some fast food restaurants are now adding a second order station. Conduct a series of simulation experiments to determine whether or not it would be a “good” idea to add a second order station to this system. Write a short 2-3 page paper (typed) supporting your position. Make sure to cite your results (use tables and plots) to support your argument. Remember, a fast food restaurant owner would hire you to conduct such a study and their concern is twofold: (1) to increase customer throughput and (2) to avoid underutilized stations.

For this assignment, you will need to submit the following items: a program that correctly simulates the drive-thru process according to the specifications above, and a paper describing the results of the experiment and arguing for or against the installation of a second order station.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.