ComenzarEmpieza gratis

Developing a discrete-event model

You have been asked to develop a discrete-event model for a farming operation to help allocate resources, increase productivity and identify-eliminate bottlenecks.

You are still discussing the different processes involved with your colleagues and in what detail they should be represented in the model. Thus, you have agreed that the information will be compiled in a dictionary named process_dict with the following structure. The idea is that this dictionary will be updated as more information about the processes becomes available.

process_dict = {
    "Process name 1":  <duration>,
    "Process name 2":  <duration>,
    ...
}

Let's build a generic discrete event model named discrete_model_farm() that can schedule any number of discrete events defined in the dictionary.

The input arguments of the model are (in order):

  1. process_dict: Dictionary with information about the processes
  2. simulation_time: Simulation period

Time in the model will be measured in days.

Este ejercicio forma parte del curso

Discrete Event Simulation in Python

Ver curso

Instrucciones del ejercicio

  • Initiate the state variables of the model, time (tracks time) and supply_chain (tracks number of cycles) and set them to zero.
  • Define the ending condition so that the model runs while time is less than simulation_time.
  • Add the duration of the process to the state-variable time.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

def discrete_model_farm(process_dict, simulation_time):
  # Initiate variables
  time = ____
  supply_chain = ____

  # Define ending condition
  while ____ < ____:

    supply_chain += 1
    process_names = list(process_dict.keys())

    for p in range(len(process_names)):
		  
      event_duration = process_dict[process_names[p]]
          
      # Add the process duration
      ____ += event_duration
      print(f"{process_names[p]}  (completed): time = {time}")
          
    print(f"COMPLETED: Production cycle #{supply_chain} | Time = {time} days")  
Editar y ejecutar código