173k views
3 votes
20.7 CIST2362 Lab: Simulating Cashiers

This lab performs a simulation of customers having to see a cashier to checkout. To understand this type of programming, here is a short primer.
Discrete Event Simulation (DES)
A DES is where a system is modeled by programming as a sequence of events that happen at given times. So in the case of a retail location, there will be events such as customer arrives, customer shops, customer gets in line, etc. These are events that describe a customer's interaction at a retail location and can be used to develop a simulation. A simulation could have more or less events depending on the requirements for the simulation.
There are basically two ways to implement a DES
next-event time progression: This is where each event carries a timestamp. Events are ordered in a queue by time and then events are taken from the queue and acted upon in order of time. This means that time will advance based on the time stamps in the queue. For example, event-A may have at time 124 and the next event, named event-X may happen at time 135. So the 11 time steps in between have no events and it's as if the clock just jumps 11 time steps between these two events.
incremental time progression: This is where you break up time into small increments, and the simulation iterates from one time mark to the next like loop. At each time increment, the program determines if an event should happen. Based on this, the program would iterate to time 124 perhaps 1 time step at a time. At time 124 event-A would be executed, and then the program would go to times 125, 126, ..., 134 and it would not do anything at each of these steps. At time 135, the program would execute event-X.
In general, it is usually easier to understand the incremental time progression style of DES, and thus this is the approach taken in this lab.
Specifications
This lab contains a main() and several supporting classes: one for Cashiers and one for Customers. Your goal is to implement main() by filling in the missing code.
There are 3 input parameters to the program:
Number of Cashiers: The number of cashiers on duty to serve customers.
Busy: This captures how busy the store will be during the simulation 0 (very light) to 10 (extremely busy).
Number of Minutes: This is the total number of time increments that simulation will run. Each iteration is 1 minute.
The program uses the Busy parameter to determine how often a new customer comes into the location. The simulation will give each customer a service time, which is how long they need to be waited on by a cashier. Then the customer is added to the checkout line, where they wait for a cashier. Finally, when a customer is paired with a cashier, their service time determines how many iterations they spend with the cashier before leaving the store.
You will complete the main() to make the above happen. Keep in mind that some of the functionality is already implemented in the classes: Customer and Cashier. Therefore, you need to spend time understanding what capabilities already exist.
In addition, the simulation outputs status logs throughout that will look as follows. This example assumes there is only 1 cashier:
Time 0:
++Customer 0 Arrives { Customer: 0 arrived at: 0, Remaining service time: 2}
**Customer 0 serviced { Customer: 0 arrived at: 0, Remaining service time: 2} by cashier #0
Length of Line: 0
Cashier Status
========================================
Cashier #0 Servicing: Customer 0
Time 1:
++Customer 1 Arrives { Customer: 1 arrived at: 1, Remaining service time: 4}
Length of Line: 1
Cashier Status
========================================
Cashier #0 Servicing: Customer 0
The sample output above shows that the first customer, Customer 0, arrives at Time 0. They have been assigned a service time of 2 time units or iterations. Since the cashier is not busy they are immediately paired with the cashier #0. The line for cashiers is empty, and because of the pairing, the cashier #0 is serving Customer 0. Then the program moves to Time 1. Customer 1 arrives at this time with a service time of 4. This means Customer 1 has twice as much service time requirements than Customer 0. And because Customer 0 is still being served by the one cashier, Customer 1 is placed in line to wait.
Tasks
Complete the code in main.cpp. You are free to add any helper functions to main.cpp as needed. Do not change any of the code in the Customer or Cashier classes.

1 Answer

1 vote

Final answer:

The subject of this question is Computer Science and specifically Discrete Event Simulation. The lab is about implementing a simulation of customers interacting with cashiers at a retail location.

Step-by-step explanation:

The subject of this question is Computer Science and more specifically, Discrete Event Simulation. The goal of the lab is to implement a simulation of customers interacting with cashiers at a retail location. The simulation can be implemented using either next-event time progression or incremental time progression. The lab requires filling in the missing code in the main function to make the simulation work.

The question is about completing a programming lab exercise to simulate cashier interactions in a retail setting using Discrete Event Simulation, focusing mainly on the main function implementation without altering existing classes.

The student is tasked with implementing a Discrete Event Simulation (DES) for simulating cashiers in a retail setting as part of a programming lab exercise. The simulation involves events like customer arrivals and cashier interactions, represented by either next-event time progression or incremental time progression, with this lab adopting the latter approach. Using input parameters like the number of cashiers, store busyness, and the time the simulation runs, the student must complete the main function of the program to process customer service times and manage the cashier queue.

For instance, when considering the arrival of customers, one may use the exponential distribution to model the time between arrivals, which aids in understanding the dynamics of customer flow in the simulation. The student is to focus on the main.cpp implementation, refraining from modifying existing classes for Customers and Cashiers.

User Unholysampler
by
7.6k points