Adding Final Touches to the Simulation
Now that you’ve defined all that you need to define for the simulation to work, it’s time to make the main function to actually run the simulation. Here, you’re going to collect user input, run the simulation, and then print the results to the terminal. So define a
And you’ll say
num_cashiers (number of cashiers),
num_servers (number of servers), and
num_ushers (number of ushers), is going to equal
get_user_input() to use that function that you just defined.
env.process(). You’re going to run the theater, so pass in the
num_servers, and the
num_ushers to get all the employees in there. And then to run the environment, you’ll do
env.run() and then say
And what this is referring to is the number of minutes that you run the simulation. Now, you won’t actually have to wait 90 minutes, but it will be
90 minutes within the environment for the simulation.
Okay! So now that the simulation is completed, you will want to view the results, so the
mins and the
secs are going to equal
calculate_wait_times(), so let me get rid of this. And there we go,
calculate_wait_times(). And you’ll pass in the
"Running simulation..." And you can do some f-string formatting, so after a newline (
f"The average wait time is " and then pass in the
"minutes", and then pass it in the
But your simulation is working, and you just tested it out for
90 minutes and it took less than a second to run. Okay! So that’s great. In the next lesson, you’re going to start experimenting with these parameters and seeing if you can get the wait times down to below 10 minutes, as that’s what the goal is.
Become a Member to join the conversation.