1. Learn
  2. /
  3. Courses
  4. /
  5. Discrete Event Simulation in Python

Exercise

Restaurant model: Managing tables and waiting times

Imagine you want to open a restaurant in a popular area of San Francisco. Deciding the number of tables and kitchen capacity is extremely important to ensure the maximum number of customers are served while minimizing initial investment and running costs. A discrete-event model can help in this investment decision by simulating the level of table occupancy, customer waiting times, and the number of customers leaving the queue due to excessive waiting times.

Let's first define the generator that simulates table requests and customer decisions to wait or leave based on waiting times. In the next exercise, you will set up the model, run it and analyze the results. The time in the model is in minutes.

Instructions

100 XP
  • Open a table request as req when a customer arrives at the restaurant.
  • Use a bitwise-or operator to wait until there is a table free (req) or until the customer runs out of patience (env.timeout(patience)).
  • Yield the time the table is occupied by the customer, which is given by variable time_at_tables.