Get startedGet started for free

Restaurant model: Set up, run and analyze results

In the previous exercise, you defined the generator that simulates table requests and customer decisions to wait or leave based on waiting times.

Now let's set up the model, run it, and analyze the results. Recall that the objective of building this model is to determine the appropriate number of tables and kitchen capacity to serve the maximum number of customers while minimizing initial investment and running costs.

To set up your model in a meaningful way, you decided to visit restaurants in the area and observe customer behavior.

You noticed that on average:

  • During peak hours, new customers arrived every 10 minutes
  • Customers had the patience to wait between 1 to 10 minutes for a table (MIN_PATIENCE and MAX_PATIENCE)
  • Customers left if the waiting time was longer than 10 min
  • Customers occupied the tables for 40 to 90 minutes (MIN_SEATING_TIME and MAX_SEATING_TIME)

The time in the model is in minutes.

This exercise is part of the course

Discrete Event Simulation in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

INTERVAL_CUSTOMERS = 10

# Assign the appropriate values to the model parameters
MIN_PATIENCE = 1
MAX_PATIENCE = ____
MIN_SEATING_TIME = 40
MAX_SEATING_TIME = ____

customers_served = 0
customers_quiting_waiting = 0

env = simpy.Environment()

# Create the SimPy resource
tables = simpy.____(env, capacity=____)
env.process(source(env, NEW_CUSTOMERS, INTERVAL_CUSTOMERS, tables))

# Run the model
env.____(until=240)
print(f"Total number of tables served: {customers_served:02d}")
print(f"Total number of customers quiting waiting: {customers_quiting_waiting:02d}")
Edit and Run Code