Skip to content

Commit

Permalink
Update notebook instructions and parameter comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bergam0t committed Dec 12, 2023
1 parent 9d49e66 commit 2d1e100
Showing 1 changed file with 77 additions and 25 deletions.
102 changes: 77 additions & 25 deletions nb_4_full_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"outputs": [],
"source": [
"!git clone https://github.com/hsma-programme/Teaching_DES_Concepts_Streamlit.git\n",
"!pip install simpy\n",
"%pip install simpy\n",
"\n",
"import gc\n",
"import pandas as pd\n",
"import plotly.express as px\n",
"import plotly.graph_objects as go"
"import plotly.graph_objects as go\n",
"from IPython.display import Markdown as md"
]
},
{
Expand All @@ -23,7 +24,26 @@
"source": [
"%cd /content/Teaching_DES_Concepts_Streamlit\n",
"from model_classes import Scenario, multiple_replications\n",
"from output_animation_functions import reshape_for_animations, animate_activity_log"
"from output_animation_functions import reshape_for_animations, animate_activity_log\n",
"pd.options.mode.chained_assignment = None # default='warn'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Set Parameters"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Change the values after the equals signs in the cell below.\n",
"\n",
"Once you have done this, click 'runtime' and then 'run all'.\n",
"\n",
"It will take about 90 seconds for all of the outputs to update."
]
},
{
Expand All @@ -32,25 +52,42 @@
"metadata": {},
"outputs": [],
"source": [
"n_triage = 4\n",
"prob_trauma = 0.3\n",
"n_trauma = 6\n",
"n_cubicles_2 = 6\n",
"n_reg = 3\n",
"n_exam = 3\n",
"n_cubicles_1 = 2 \n",
"non_trauma_treat_p = 0.7 \n",
"\n",
"seed = 42\n",
"n_reps = 3\n",
"run_time_days = 5"
"# General Details\n",
"\n",
"n_triage = 4 # Number of triage cubicles. DEFAULT: 4\n",
"prob_trauma = 0.3 # Probability that generated patient is a trauma patient (set between 0 and 1). DEFAULT: 0.3\n",
"\n",
"###################################\n",
"\n",
"# Trauma pathway details\n",
"\n",
"n_trauma = 6 # Number of trauma stabilisaton cubicles. DEFAULT: 6\n",
"n_cubicles_2 = 6 # Number of trauma treatment cubicles. DEFAULT: 6\n",
"\n",
"###################################\n",
"\n",
"# Non-trauma pathway details\n",
"\n",
"n_reg = 3 # Number of non-trauma registration cubicles. DEFAULT: 3\n",
"n_exam = 3 # Number of examination rooms for non-trauma patients. DEFAULT: 3\n",
"n_cubicles_1 = 2 # Number of treatment cubicles for non-trauma patients. DEFAULT: 2\n",
"non_trauma_treat_p = 0.7 # Probability that a generated non-trauma patient is a trauma patient (set between 0 and 1). DEFAULT: 0.7\n",
"\n",
"###################################\n",
"\n",
"# Model Settings\n",
"# WARNING: Adjusting the n_reps and run_time days upwards will make the model take significantly longer to run. \n",
"\n",
"seed = 42 # Random seed the model will start from. DEFAULT: 42\n",
"n_reps = 3 # Number of replications to run the model for. DEFAULT: 3\n",
"run_time_days = 5 # Length of time to run the model for. DEFAULT: 5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Animated Log"
"## Animated Log"
]
},
{
Expand Down Expand Up @@ -169,7 +206,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Simple Metrics"
"## Simple Metrics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Utilisation"
]
},
{
Expand All @@ -182,20 +226,28 @@
"in_range_wait = sum((results.mean().filter(like=\"wait\")<120))\n",
" \n",
"\n",
"print(\":bed: **Utilisation Metrics in Ideal Range**\", value=\"{} of {}\".format(in_range_util, len(results.mean().filter(like=\"util\"))))\n",
"\n",
"#util_fig_simple = px.bar(results.mean().filter(like=\"util\"), opacity=0.5)\n",
"print(\n",
"\"\"\"\n",
"md(\"**Utilisation Metrics in Ideal Range**: {} of {}\".format(in_range_util, len(results.mean().filter(like=\"util\"))))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The emergency department wants to aim for an average of 65% to 85% utilisation across all resources in the emergency department. \n",
"\n",
"The green box shows this ideal range. If the bars overlap with the green box, utilisation is ideal. \n",
"\n",
"If utilisation is below this, you might want to **reduce** the number of those resources available. \n",
"\n",
"If utilisation is above this point, you may want to **increase** the number of that type of resource available.\n",
"\"\"\"\n",
")\n",
"If utilisation is above this point, you may want to **increase** the number of that type of resource available."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"util_fig_simple = go.Figure()\n",
"# Add optimum range\n",
"util_fig_simple.add_hrect(y0=0.65, y1=0.85,\n",
Expand Down

0 comments on commit 2d1e100

Please sign in to comment.