From 161cac51b85110e6bf0a3428e0b368759df8724b Mon Sep 17 00:00:00 2001 From: Bergam0t Date: Tue, 12 Dec 2023 11:51:43 +0000 Subject: [PATCH] Add markdown to form --- nb_4_full_model.ipynb | 345 ++++++++++++++++++++++-------------------- 1 file changed, 181 insertions(+), 164 deletions(-) diff --git a/nb_4_full_model.ipynb b/nb_4_full_model.ipynb index 7a7e9e4..3388ee0 100644 --- a/nb_4_full_model.ipynb +++ b/nb_4_full_model.ipynb @@ -5,16 +5,16 @@ "execution_count": 59, "metadata": { "cellView": "form", - "id": "5Wxf8MyRn8kC", - "outputId": "585c099b-354a-4384-f2fd-62fbe14d7ecf", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "5Wxf8MyRn8kC", + "outputId": "585c099b-354a-4384-f2fd-62fbe14d7ecf" }, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "fatal: destination path 'Teaching_DES_Concepts_Streamlit' already exists and is not an empty directory.\n", "Requirement already satisfied: simpy in /usr/local/lib/python3.10/dist-packages (4.1.1)\n", @@ -85,32 +85,45 @@ "# @title Model Parameters\n", "# General Details\n", "\n", - "n_triage = 5 # @param {type:\"slider\", min:1, max:10, step:1}\n", - "prob_trauma = 0.4 # @param {type:\"slider\", min:0, max:1, step:0.01}\n", + "# @markdown ---\n", + "# @markdown ### Set the number of triage bays\n", + "n_triage = 3 # @param {type:\"slider\", min:1, max:10, step:1}\n", + "# @markdown ### Set the probability that a client arriving is a trauma patient (0 = no-one is a trauma patient, 1 = everyone is a trauma patient)\n", + "prob_trauma = 0.3 # @param {type:\"slider\", min:0, max:1, step:0.01}\n", "\n", "###################################\n", "\n", "# Trauma pathway details\n", - "\n", + "# @markdown ---\n", + "# @markdown ### Set the number of trauma stabilisation cubicles\n", "n_trauma = 6 # @param {type:\"slider\", min:1, max:10, step:1}\n", + "# @markdown ### Set the number of trauma treatment cubicles\n", "n_cubicles_2 = 6 # @param {type:\"slider\", min:1, max:10, step:1}\n", "\n", "###################################\n", "\n", "# Non-trauma pathway details\n", - "\n", + "# @markdown ---\n", + "# @markdown ### Set the number of non-trauma registration bays\n", "n_reg = 3 # @param {type:\"slider\", min:1, max:10, step:1}\n", + "# @markdown ### Set the number of non-trauma examination rooms\n", "n_exam = 7 # @param {type:\"slider\", min:1, max:10, step:1}\n", + "# @markdown ### Set the number of non-trauma treatment cubicles\n", "n_cubicles_1 = 2 # @param {type:\"slider\", min:1, max:10, step:1} # Probability that a generated non-trauma patient is a trauma patient (set between 0 and 1). DEFAULT: 0.7\n", + "# @markdown ### Set the probability that a client arriving is a trauma patient (0 = no-one on the non-trauma pathway needs treatment, 1 = everyone on the non-trauma pathway needs treatment)\n", "non_trauma_treat_p = 0.7 # @param {type:\"slider\", min:0, max:1, step:0.01}\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", + "# @markdown ---\n", + "# @markdown ## Model Settings\n", + "# @markdown WARNING: Adjusting the n_reps and run_time days upwards will make the model take significantly longer to run.\n", + "# @markdown ### Set the random seed\n", "seed = 42 # @param {type:\"integer\"}\n", + "# @markdown ### Set the number of model replications\n", "n_reps = 3 # @param {type:\"slider\", min:0, max:10, step:1}\n", + "# @markdown ### Set the number of simulated days the model will run for\n", "run_time_days = 5 # @param {type:\"slider\", min:0, max:30, step:1}" ] }, @@ -119,16 +132,15 @@ "execution_count": 61, "metadata": { "cellView": "form", - "id": "_XgF0YbKn8kF", - "outputId": "9a6792fd-2edb-4991-f396-feb880ccf43c", "colab": { "base_uri": "https://localhost:8080/", "height": 937 - } + }, + "id": "_XgF0YbKn8kF", + "outputId": "9a6792fd-2edb-4991-f396-feb880ccf43c" }, "outputs": [ { - "output_type": "display_data", "data": { "text/html": [ "\n", @@ -166,7 +178,8 @@ "" ] }, - "metadata": {} + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -295,24 +308,26 @@ "execution_count": 69, "metadata": { "cellView": "form", - "id": "j5-HCarDn8kG", - "outputId": "bb802520-d557-49aa-e9cf-49d0f868e47a", "colab": { "base_uri": "https://localhost:8080/", "height": 46 - } + }, + "id": "j5-HCarDn8kG", + "outputId": "bb802520-d557-49aa-e9cf-49d0f868e47a" }, "outputs": [ { - "output_type": "execute_result", "data": { + "text/markdown": [ + "**Utilisation Metrics in Ideal Range**: 0 of 6" + ], "text/plain": [ "" - ], - "text/markdown": "**Utilisation Metrics in Ideal Range**: 0 of 6" + ] }, + "execution_count": 69, "metadata": {}, - "execution_count": 69 + "output_type": "execute_result" } ], "source": [ @@ -345,16 +360,15 @@ "execution_count": 70, "metadata": { "cellView": "form", - "id": "jv72nX2-n8kH", - "outputId": "f219db54-4f7b-46a8-cb9e-89a5a58379b6", "colab": { "base_uri": "https://localhost:8080/", "height": 542 - } + }, + "id": "jv72nX2-n8kH", + "outputId": "f219db54-4f7b-46a8-cb9e-89a5a58379b6" }, "outputs": [ { - "output_type": "display_data", "data": { "text/html": [ "\n", @@ -390,7 +404,8 @@ "" ] }, - "metadata": {} + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -431,84 +446,62 @@ }, { "cell_type": "code", - "source": [ - "# @title Waits In Range\n", - "md(\"**Wait Metrics in Ideal Range**: {} of {}\".format(in_range_wait, len(results.mean().filter(like=\"wait\"))))" - ], + "execution_count": 72, "metadata": { "cellView": "form", - "id": "y7Rb400bz9TE", - "outputId": "0e9067ad-f6cb-409c-ce72-0a8d51b38983", "colab": { "base_uri": "https://localhost:8080/", "height": 46 - } + }, + "id": "y7Rb400bz9TE", + "outputId": "0e9067ad-f6cb-409c-ce72-0a8d51b38983" }, - "execution_count": 72, "outputs": [ { - "output_type": "execute_result", "data": { + "text/markdown": [ + "**Wait Metrics in Ideal Range**: 5 of 6" + ], "text/plain": [ "" - ], - "text/markdown": "**Wait Metrics in Ideal Range**: 5 of 6" + ] }, + "execution_count": 72, "metadata": {}, - "execution_count": 72 + "output_type": "execute_result" } + ], + "source": [ + "# @title Waits In Range\n", + "md(\"**Wait Metrics in Ideal Range**: {} of {}\".format(in_range_wait, len(results.mean().filter(like=\"wait\"))))" ] }, { "cell_type": "markdown", + "metadata": { + "id": "VixJQCMkz9rQ" + }, "source": [ "The emergency department wants to ensure people wait no longer than 2 hours (120 minutes) at any point in the process.\n", " \n", "This needs to be balanced with the utilisation graphs on the left.\n", "\n", "The green box shows waits of less than two hours. If the bars fall within this range, the number of resources does not need to be changed." - ], - "metadata": { - "id": "VixJQCMkz9rQ" - } + ] }, { "cell_type": "code", - "source": [ - "# @title Wait Graph\n", - "\n", - "wait_fig_simple = go.Figure()\n", - "wait_fig_simple.add_hrect(y0=0, y1=60*2, fillcolor=\"#5DFDA0\",\n", - " opacity=0.3, line_width=0)\n", - "\n", - "wait_fig_simple.add_bar(x=results.mean().filter(like=\"wait\").index.tolist(),\n", - " y=results.mean().filter(like=\"wait\").tolist())\n", - "\n", - "wait_fig_simple.update_xaxes(labelalias={\n", - " \"01a_triage_wait\": \"Triage\",\n", - " \"02a_registration_wait\": \"Registration\",\n", - " \"03a_examination_wait\": \"Examination\",\n", - " \"04a_treatment_wait(non_trauma)\": \"Treatment
(non-trauma)\",\n", - " \"06a_trauma_wait\": \"Stabilisation\",\n", - " \"07a_treatment_wait(trauma)\": \"Treatment
(trauma)\"\n", - "}, tickangle=0)\n", - "# wait_fig_simple.data = wait_fig_simple.data[::-1]\n", - "wait_fig_simple.update_yaxes(title_text='Wait for Treatment Stage (Minutes)')\n", - "\n", - "wait_fig_simple" - ], + "execution_count": 71, "metadata": { - "id": "Spiuc7tpz99m", - "outputId": "79a81155-5299-44c8-f8af-897905812289", "colab": { "base_uri": "https://localhost:8080/", "height": 542 - } + }, + "id": "Spiuc7tpz99m", + "outputId": "79a81155-5299-44c8-f8af-897905812289" }, - "execution_count": 71, "outputs": [ { - "output_type": "display_data", "data": { "text/html": [ "\n", @@ -544,12 +537,39 @@ "" ] }, - "metadata": {} + "metadata": {}, + "output_type": "display_data" } + ], + "source": [ + "# @title Wait Graph\n", + "\n", + "wait_fig_simple = go.Figure()\n", + "wait_fig_simple.add_hrect(y0=0, y1=60*2, fillcolor=\"#5DFDA0\",\n", + " opacity=0.3, line_width=0)\n", + "\n", + "wait_fig_simple.add_bar(x=results.mean().filter(like=\"wait\").index.tolist(),\n", + " y=results.mean().filter(like=\"wait\").tolist())\n", + "\n", + "wait_fig_simple.update_xaxes(labelalias={\n", + " \"01a_triage_wait\": \"Triage\",\n", + " \"02a_registration_wait\": \"Registration\",\n", + " \"03a_examination_wait\": \"Examination\",\n", + " \"04a_treatment_wait(non_trauma)\": \"Treatment
(non-trauma)\",\n", + " \"06a_trauma_wait\": \"Stabilisation\",\n", + " \"07a_treatment_wait(trauma)\": \"Treatment
(trauma)\"\n", + "}, tickangle=0)\n", + "# wait_fig_simple.data = wait_fig_simple.data[::-1]\n", + "wait_fig_simple.update_yaxes(title_text='Wait for Treatment Stage (Minutes)')\n", + "\n", + "wait_fig_simple" ] }, { "cell_type": "markdown", + "metadata": { + "id": "kbY11K1d0luJ" + }, "source": [ "# Advanced Graphs\n", "\n", @@ -558,13 +578,13 @@ "This can give us a better idea of how robust the system is.\n", "\n", "Each dot indicates a single model run. The number of runs can be increased under the advanced options." - ], - "metadata": { - "id": "kbY11K1d0luJ" - } + ] }, { "cell_type": "markdown", + "metadata": { + "id": "Wr-5rycV0jKY" + }, "source": [ "## Average utilisation\n", "\n", @@ -575,13 +595,61 @@ "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." - ], - "metadata": { - "id": "Wr-5rycV0jKY" - } + ] }, { "cell_type": "code", + "execution_count": 73, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "iWlGO0rc0jRd", + "outputId": "0c3fdf96-6733-4966-dbc0-e18ae4b9d683" + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + "\n", + "
\n", + "
\n", + "\n", + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# @title Utilisation Boxplot\n", "\n", @@ -619,29 +687,45 @@ "utilisation_boxplot.update_layout(xaxis_tickformat = '.0%')\n", "\n", "utilisation_boxplot" - ], + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "aZQ2JH9i0_cZ" + }, + "source": [ + "## Average Waits\n", + "\n", + "The emergency department wants to ensure people wait no longer than 2 hours (120 minutes) at any point in the process.\n", + " \n", + "This needs to be balanced with the utilisation graphs on the left.\n", + "\n", + "The green box shows waits of less than two hours. If the bars fall within this range, the number of resources does not need to be changed." + ] + }, + { + "cell_type": "code", + "execution_count": 79, "metadata": { - "cellView": "form", - "id": "iWlGO0rc0jRd", - "outputId": "0c3fdf96-6733-4966-dbc0-e18ae4b9d683", "colab": { "base_uri": "https://localhost:8080/", "height": 542 - } + }, + "id": "4Arwemg_1F5d", + "outputId": "b0b4e93e-3b2b-4a70-e2af-b64343d35489" }, - "execution_count": 73, "outputs": [ { - "output_type": "display_data", "data": { "text/html": [ "\n", "\n", "\n", "
\n", - "
\n", - "
\n", - "\n", - "" - ] - }, - "metadata": {} - } ] } ], "metadata": { - "language_info": { - "name": "python" - }, "colab": { "provenance": [] }, "kernelspec": { - "name": "python3", - "display_name": "Python 3" + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +}