Wrapper functions#

Here we demonstrate how to use the Experiment class with the multiple_replications() function.

To see how the multiple_replications() function works see the replications notebook. This function simply wraps the the single_run() function. To see how single_run() initiates a simpy model replication see the experiments notebook

1. Imports#

To use and configure the model we need to import the Experiment class and the multiple_replications() function.

import pandas as pd
from model import Experiment, multiple_replications

2. Setup and run an experiment#

2.1 An experiment using default settings#

default_scenario = Experiment()
results = multiple_replications(default_scenario, n_reps=5)
results
01_mean_waiting_time 02_operator_util 03_mean_nurse_waiting_time 04_nurse_util
rep
1 4.032401 93.761575 50.092524 97.541681
2 2.628744 91.617261 60.588240 97.407842
3 3.504268 91.365164 81.756798 98.103936
4 1.502595 90.089506 27.332423 97.626912
5 2.385005 93.032452 43.179129 97.441977
results.describe()
01_mean_waiting_time 02_operator_util 03_mean_nurse_waiting_time 04_nurse_util
count 5.000000 5.000000 5.000000 5.000000
mean 2.810603 91.973192 52.589823 97.624469
std 0.987301 1.446116 20.294217 0.281505
min 1.502595 90.089506 27.332423 97.407842
25% 2.385005 91.365164 43.179129 97.441977
50% 2.628744 91.617261 50.092524 97.541681
75% 3.504268 93.032452 60.588240 97.626912
max 4.032401 93.761575 81.756798 98.103936

2.2 An experiment with an extra operator#

extra_operator = Experiment(n_operators=14)
results = multiple_replications(default_scenario, n_reps=5)
results.describe()
01_mean_waiting_time 02_operator_util 03_mean_nurse_waiting_time 04_nurse_util
count 5.000000 5.000000 5.000000 5.000000
mean 2.423828 92.490441 38.212863 97.347011
std 0.806572 1.468232 8.690894 1.071531
min 1.660902 91.048813 27.397949 95.610922
25% 1.914756 91.291814 34.389086 97.013883
50% 1.999089 92.495369 37.751444 97.872397
75% 3.006529 92.903855 40.456161 98.117843
max 3.537864 94.712353 51.069675 98.120008

2.3 An experiment based on python script using variables#

Here we create a basic script for where a user can manually hard code parameters and run the simulation model.

# set number of resources
n_operators = 13
n_nurses = 9

# set chance of nurse
chance_callback = 0.4

# set number of replications
n_reps = 5

# create experiment
exp = Experiment(n_operators=n_operators, n_nurses=n_nurses,
                 chance_callback=chance_callback)

# run multiple replications of experment
results = multiple_replications(exp, n_reps=n_reps)

# show results
results.describe()
01_mean_waiting_time 02_operator_util 03_mean_nurse_waiting_time 04_nurse_util
count 5.000000 5.000000 5.000000 5.000000
mean 3.453959 94.337602 48.307115 96.338778
std 1.340730 1.427327 6.255277 0.347502
min 2.065725 92.818765 38.326350 95.762584
25% 2.667628 93.305977 46.674184 96.267565
50% 2.867994 93.923787 49.964547 96.490678
75% 4.338695 95.493226 52.305169 96.578688
max 5.329755 96.146255 54.265326 96.594373