Python package#
The model is available to install from the Python Package Index (PyPI). If you wish to use the model in your own code or package this is the simplest way to include it. It can be installed from a terminal or included in an conda environment or Python virtual environment. To install at run time use:
pip install treat-sim
Running multiple replications of the treat-sim
model#
To create a custom experiment and run multiple replications of it using the m~odel you need to import the Scenario
and multiple_replications
functions from the model
module. Example code is below
from treat_sim.model import Scenario, multiple_replications
# use all default parameter values
base_case = Scenario()
# run replications (defaults to 5 if parameter ignored.)
results = multiple_replications(base_case, n_reps=5)
# show results (use print() if not using Jupyter notebooks)
results.describe().round(2).T
count | mean | std | min | 25% | 50% | 75% | max | |
---|---|---|---|---|---|---|---|---|
00_arrivals | 5.0 | 231.80 | 5.07 | 227.00 | 229.00 | 230.00 | 233.00 | 240.00 |
01a_triage_wait | 5.0 | 30.51 | 15.39 | 17.68 | 24.28 | 24.80 | 28.66 | 57.12 |
01b_triage_util | 5.0 | 0.61 | 0.03 | 0.57 | 0.61 | 0.61 | 0.62 | 0.64 |
02a_registration_wait | 5.0 | 106.13 | 11.72 | 90.00 | 103.24 | 103.61 | 112.24 | 121.54 |
02b_registration_util | 5.0 | 0.86 | 0.01 | 0.84 | 0.85 | 0.85 | 0.87 | 0.87 |
03a_examination_wait | 5.0 | 24.84 | 7.07 | 14.69 | 21.37 | 25.51 | 31.09 | 31.56 |
03b_examination_util | 5.0 | 0.86 | 0.01 | 0.85 | 0.86 | 0.86 | 0.87 | 0.88 |
04a_treatment_wait(non_trauma) | 5.0 | 134.87 | 27.08 | 94.02 | 120.25 | 150.35 | 152.48 | 157.26 |
04b_treatment_util(non_trauma) | 5.0 | 0.90 | 0.02 | 0.87 | 0.89 | 0.89 | 0.91 | 0.93 |
05_total_time(non-trauma) | 5.0 | 232.00 | 14.87 | 208.36 | 233.30 | 233.88 | 234.76 | 249.69 |
06a_trauma_wait | 5.0 | 209.37 | 63.74 | 133.81 | 149.37 | 236.51 | 250.71 | 276.42 |
06b_trauma_util | 5.0 | 0.90 | 0.08 | 0.83 | 0.86 | 0.87 | 0.88 | 1.03 |
07a_treatment_wait(trauma) | 5.0 | 11.08 | 4.89 | 3.72 | 9.23 | 12.25 | 13.70 | 16.52 |
07b_treatment_util(trauma) | 5.0 | 0.50 | 0.13 | 0.37 | 0.42 | 0.46 | 0.61 | 0.66 |
08_total_time(trauma) | 5.0 | 350.13 | 63.75 | 281.06 | 301.52 | 346.70 | 380.83 | 440.52 |
09_throughput | 5.0 | 167.00 | 4.64 | 161.00 | 164.00 | 167.00 | 171.00 | 172.00 |
Custom experiments#
Simply modify the default parameters of the Scenario
class if you would like to run different experiments
# an extra non trauma treatment cubicle
extra_cubicle_experiment = Scenario(n_cubicles_1=2)
# experiment results
results_extra_cubicle = multiple_replications(extra_cubicle_experiment, n_reps=5)
# show results of experiment
results_extra_cubicle.describe().round(2).T
count | mean | std | min | 25% | 50% | 75% | max | |
---|---|---|---|---|---|---|---|---|
00_arrivals | 5.0 | 231.80 | 5.07 | 227.00 | 229.00 | 230.00 | 233.00 | 240.00 |
01a_triage_wait | 5.0 | 30.51 | 15.39 | 17.68 | 24.28 | 24.80 | 28.66 | 57.12 |
01b_triage_util | 5.0 | 0.61 | 0.03 | 0.57 | 0.61 | 0.61 | 0.62 | 0.64 |
02a_registration_wait | 5.0 | 106.13 | 11.72 | 90.00 | 103.24 | 103.61 | 112.24 | 121.54 |
02b_registration_util | 5.0 | 0.86 | 0.01 | 0.84 | 0.85 | 0.85 | 0.87 | 0.87 |
03a_examination_wait | 5.0 | 24.84 | 7.07 | 14.69 | 21.37 | 25.51 | 31.09 | 31.56 |
03b_examination_util | 5.0 | 0.86 | 0.01 | 0.85 | 0.86 | 0.86 | 0.87 | 0.88 |
04a_treatment_wait(non_trauma) | 5.0 | 1.93 | 0.14 | 1.71 | 1.92 | 1.95 | 1.99 | 2.08 |
04b_treatment_util(non_trauma) | 5.0 | 0.64 | 0.02 | 0.61 | 0.62 | 0.64 | 0.65 | 0.68 |
05_total_time(non-trauma) | 5.0 | 188.56 | 8.52 | 177.58 | 184.76 | 187.32 | 192.98 | 200.16 |
06a_trauma_wait | 5.0 | 209.37 | 63.74 | 133.81 | 149.37 | 236.51 | 250.71 | 276.42 |
06b_trauma_util | 5.0 | 0.90 | 0.08 | 0.83 | 0.86 | 0.87 | 0.88 | 1.03 |
07a_treatment_wait(trauma) | 5.0 | 11.08 | 4.89 | 3.72 | 9.23 | 12.25 | 13.70 | 16.52 |
07b_treatment_util(trauma) | 5.0 | 0.50 | 0.13 | 0.37 | 0.42 | 0.46 | 0.61 | 0.66 |
08_total_time(trauma) | 5.0 | 350.13 | 63.75 | 281.06 | 301.52 | 346.70 | 380.83 | 440.52 |
09_throughput | 5.0 | 199.40 | 4.67 | 193.00 | 198.00 | 200.00 | 200.00 | 206.00 |
Pre-configured experiments#
The package also includes a selection of pre-configured experiments to run. The following code runs all experiments and display a summary of the results.
from treat_sim.model import (get_scenarios, run_scenario_analysis,
scenario_summary_frame,
DEFAULT_RESULTS_COLLECTION_PERIOD)
results = run_scenario_analysis(get_scenarios(), DEFAULT_RESULTS_COLLECTION_PERIOD,
n_reps=50)
Scenario Analysis
No. Scenario: 6
Replications: 50
Running base =>
done.
Running triage+1 =>
done.
Running exam+1 =>
done.
Running treat+1 =>
done.
Running swap_exam_treat =>
done.
Running short_exam =>
done.
Scenario analysis complete.
scenario_summary_frame(results)
base | triage+1 | exam+1 | treat+1 | swap_exam_treat | short_exam | |
---|---|---|---|---|---|---|
00_arrivals | 227.720000 | 227.720000 | 227.720000 | 227.720000 | 227.720000 | 227.720000 |
01a_triage_wait | 35.243019 | 1.325176 | 35.243019 | 35.243019 | 1.325176 | 1.325176 |
01b_triage_util | 0.607039 | 0.303519 | 0.607039 | 0.607039 | 0.303519 | 0.303519 |
02a_registration_wait | 105.572644 | 135.915119 | 105.572644 | 105.572644 | 135.915119 | 135.915119 |
02b_registration_util | 0.840613 | 0.843954 | 0.840613 | 0.840613 | 0.843954 | 0.843954 |
03a_examination_wait | 25.552525 | 26.688866 | 0.146565 | 25.552525 | 148.865965 | 66.003847 |
03b_examination_util | 0.850448 | 0.853567 | 0.667856 | 0.850448 | 0.893629 | 0.868998 |
04a_treatment_wait(non_trauma) | 136.660635 | 138.575405 | 151.808204 | 2.280962 | 33.568594 | 111.337103 |
04b_treatment_util(non_trauma) | 0.867238 | 0.869324 | 0.867691 | 0.629346 | 0.836384 | 0.871039 |
05_total_time(non-trauma) | 234.335783 | 232.133275 | 223.063821 | 192.191909 | 280.729440 | 244.797808 |
06a_trauma_wait | 151.680557 | 175.135269 | 151.680557 | 151.680557 | 175.135269 | 175.135269 |
06b_trauma_util | 0.826941 | 0.840977 | 0.826941 | 0.826941 | 0.840977 | 0.840977 |
07a_treatment_wait(trauma) | 14.305044 | 14.997287 | 14.305044 | 14.305044 | 14.997287 | 14.997287 |
07b_treatment_util(trauma) | 0.501010 | 0.506908 | 0.501010 | 0.501010 | 0.506908 | 0.506908 |
08_total_time(trauma) | 292.280487 | 282.783517 | 292.280487 | 292.280487 | 282.783517 | 282.783517 |
09_throughput | 162.160000 | 162.920000 | 165.880000 | 195.300000 | 138.540000 | 156.600000 |