Operations Research — Simulation to decrease wait time

Grocery store operation is stressed with the high demand and social distancing. Here, I demonstrate how a simulation can be used to make decisions which decrease wait times for customers waiting to check-out. These ideas can be extended to examine other operation metrics. In subsequent posts, I may extend on the ideas presented here. The simulation is written in R and has a user interface in Rshiny.

Simulation Basics

3 independent variables are considered: Maximum number of customers arriving per minute, Maximum time at counter, and Number of Cashier lines. The customer arrival pattern is based on a variable number of customers arriving each minute with the maximum number of customers arriving per minute set to a fixed limit. A uniform distribution in number of customers is used, although other possible distributions include the normal distribution and Poisson distribution. Similarly, the checkout time at counter varies for each customer. The maximum time for checkout is set to a fixed limit. A uniform distribution of times is used. Other types of distributions for checkout time can also be considered.

User controlled variables
Customer Arrival Pattern

Simulation Algorithm

Create a distribution representing number of customers which arrive to check out at each time increment

Create a distribution representing number of minutes each customer spends at the check-out counter

Create a customer table

Create a list of counters, 0 indicates counter is empty, x indicates counter is occupied for x minutes

Create a for loop to run through each time step

Assign each incoming customer an ID

Add rows to the customer table based on number of incoming customers

Fill each row in customer table

Number of customers waiting to check out are customers waiting at time, t-1, and new arrivals

The first timestep has no customers waiting at check out lines

Create a for loop to run through each customer waiting to check out

Find the customer id for a waiting customer

Find an empty counter

Choose amount of time, x, customer takes at check out counter by sampling from a distribution of times

Release counter after x minutes

If no empty counter is found, add customer to number of waiting customers

Go to the next time increment

Return customer table

The customer table will be similar to this:

Customer Table

Simulation Results

Results from the simulation show number of customers waiting to checkout at a given time.

Different Scenarios

Depending on the interplay of the independently controlled variables, Maximum number of customers arriving per minute, Maximum time at counter, and Number of Cashier lines, scenarios with short and long wait times can result.

Results from the simulation show wait times based on customer arrival time with (left) 15 cashier lanes and (right) 12 cashier lines.

Evaluating resource and process requirements for different solutions

If the scenario is long wait times, two solutions can be considered.

Solution 1: Opening another cashier line for 10 minutes

Solution 2: Process change to decrease time at counter by 1 minute per transaction

Simulations provide us a way to examine the expected results for different solutions prior to implementation, serving as guidelines for decision-making.

I will post the R code on Github in the near future.

I am interested in tech, yoga, art, math, travel, environment, and social development. Casual conversations with potential for collaboration are invited.