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 thesingle_run()function. To see howsingle_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 | 1.319782 | 89.639845 | 33.380122 | 97.049530 |
| 2 | 4.302142 | 93.237355 | 71.507717 | 97.122986 |
| 3 | 3.107235 | 93.550804 | 83.747724 | 95.536969 |
| 4 | 2.275225 | 90.486654 | 44.769433 | 97.242503 |
| 5 | 3.544098 | 92.255403 | 26.263742 | 97.620733 |
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.909696 | 91.834012 | 51.933748 | 96.914544 |
| std | 1.152256 | 1.712021 | 24.747641 | 0.800881 |
| min | 1.319782 | 89.639845 | 26.263742 | 95.536969 |
| 25% | 2.275225 | 90.486654 | 33.380122 | 97.049530 |
| 50% | 3.107235 | 92.255403 | 44.769433 | 97.122986 |
| 75% | 3.544098 | 93.237355 | 71.507717 | 97.242503 |
| max | 4.302142 | 93.550804 | 83.747724 | 97.620733 |
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.894323 | 93.161093 | 46.279491 | 97.181621 |
| std | 1.036465 | 1.562844 | 23.985800 | 0.616801 |
| min | 1.759460 | 91.167445 | 17.008498 | 96.555626 |
| 25% | 2.454142 | 92.167426 | 33.934782 | 96.838734 |
| 50% | 2.562117 | 93.110410 | 43.988936 | 96.923999 |
| 75% | 3.182290 | 94.371362 | 55.525038 | 97.483583 |
| max | 4.513608 | 94.988825 | 80.940201 | 98.106165 |
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 | 4.804836 | 94.485572 | 63.127092 | 97.338956 |
| std | 2.011857 | 1.250878 | 13.886811 | 0.652213 |
| min | 2.449658 | 92.943156 | 40.943340 | 96.347719 |
| 25% | 3.377995 | 93.768985 | 60.577650 | 97.046899 |
| 50% | 4.714585 | 94.609132 | 64.597415 | 97.582732 |
| 75% | 5.998619 | 94.821548 | 74.677588 | 97.728423 |
| max | 7.483321 | 96.285041 | 74.839469 | 97.989007 |