diff --git a/content/02_model_code/04_model.ipynb b/content/02_model_code/04_model.ipynb index ac7fae0..51030aa 100644 --- a/content/02_model_code/04_model.ipynb +++ b/content/02_model_code/04_model.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "9864ff04", + "id": "f3f10bdd", "metadata": {}, "source": [ "# SimPy: Treatment Centre\n", @@ -16,7 +16,7 @@ }, { "cell_type": "markdown", - "id": "67d378b9", + "id": "5344ce91", "metadata": {}, "source": [ "## 1. Imports\n", @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "7d374b31", + "id": "ca232cb6", "metadata": {}, "outputs": [ { @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "11fac8cf", + "id": "ece07572", "metadata": {}, "outputs": [], "source": [ @@ -63,7 +63,7 @@ }, { "cell_type": "markdown", - "id": "559ee23e", + "id": "66f25c4f", "metadata": {}, "source": [ "## 2. Constants and defaults for modelling **as-is**" @@ -71,7 +71,7 @@ }, { "cell_type": "markdown", - "id": "87c119bd", + "id": "933ecf77", "metadata": {}, "source": [ "### 2.1 Distribution parameters" @@ -80,7 +80,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "6f01d888", + "id": "3d0d7972", "metadata": {}, "outputs": [], "source": [ @@ -115,7 +115,7 @@ }, { "cell_type": "markdown", - "id": "7bb06c1d", + "id": "6533d97e", "metadata": {}, "source": [ "### 2.2 Time dependent arrival rates data\n", @@ -126,7 +126,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "e55e450a", + "id": "006f81bc", "metadata": {}, "outputs": [ { @@ -154,7 +154,7 @@ }, { "cell_type": "markdown", - "id": "18ce33a2", + "id": "65d93ada", "metadata": {}, "source": [ "### 2.3 Resource counts\n", @@ -165,7 +165,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "93644445", + "id": "3a930c2f", "metadata": {}, "outputs": [], "source": [ @@ -183,7 +183,7 @@ }, { "cell_type": "markdown", - "id": "814e3a78", + "id": "58a31996", "metadata": {}, "source": [ "### 2.4 Simulation model run settings" @@ -192,7 +192,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "0038a24f", + "id": "b9aa15a8", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ }, { "cell_type": "markdown", - "id": "4df7855a", + "id": "652b6cd9", "metadata": {}, "source": [ "## 3. Utility functions" @@ -222,7 +222,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "9e150cb9", + "id": "9515f479", "metadata": {}, "outputs": [], "source": [ @@ -243,7 +243,7 @@ }, { "cell_type": "markdown", - "id": "dab518e5", + "id": "0bae94d8", "metadata": {}, "source": [ "## 4. Distribution classes\n", @@ -261,7 +261,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "48e2c282", + "id": "93ad8937", "metadata": {}, "outputs": [], "source": [ @@ -387,7 +387,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "ffd5ca32", + "id": "f7ca81c7", "metadata": {}, "outputs": [], "source": [ @@ -469,7 +469,7 @@ }, { "cell_type": "markdown", - "id": "da4e0ca7", + "id": "a12b49e7", "metadata": {}, "source": [ "## 5. Model parameterisation\n", @@ -480,7 +480,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "4cbd58d2", + "id": "907f92f0", "metadata": {}, "outputs": [], "source": [ @@ -694,7 +694,7 @@ }, { "cell_type": "markdown", - "id": "e3cb73a1", + "id": "92caa2c3", "metadata": {}, "source": [ "## 6. Patient Pathways Process Logic\n", @@ -705,7 +705,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "34edd733", + "id": "17c275b0", "metadata": {}, "outputs": [], "source": [ @@ -771,7 +771,7 @@ " f'{self.env.now:.3f}')\n", " \n", " # sample triage duration.\n", - " self.triage_duration = args.triage_dist.sample()\n", + " self.triage_duration = self.args.triage_dist.sample()\n", " yield self.env.timeout(self.triage_duration)\n", " self.triage_complete()\n", " \n", @@ -786,7 +786,7 @@ " self.wait_trauma = self.env.now - start_wait\n", " \n", " # sample stablisation duration.\n", - " self.trauma_duration = args.trauma_dist.sample()\n", + " self.trauma_duration = self.args.trauma_dist.sample()\n", " yield self.env.timeout(self.trauma_duration)\n", " \n", " self.trauma_complete()\n", @@ -804,7 +804,7 @@ " f'{self.env.now:.3f}')\n", " \n", " # sample treatment duration.\n", - " self.treat_duration = args.treat_dist.sample()\n", + " self.treat_duration = self.args.treat_dist.sample()\n", " yield self.env.timeout(self.treat_duration)\n", " \n", " self.treatment_complete()\n", @@ -837,7 +837,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "30185f46", + "id": "bb9701a8", "metadata": {}, "outputs": [], "source": [ @@ -911,7 +911,7 @@ " f'{self.env.now:.3f}')\n", " \n", " # sample triage duration.\n", - " self.triage_duration = args.triage_dist.sample()\n", + " self.triage_duration = self.args.triage_dist.sample()\n", " yield self.env.timeout(self.triage_duration)\n", " \n", " trace(f'triage {self.identifier} complete {self.env.now:.3f}; '\n", @@ -930,7 +930,7 @@ " f'{self.env.now:.3f}')\n", " \n", " # sample registration duration.\n", - " self.reg_duration = args.reg_dist.sample()\n", + " self.reg_duration = self.args.reg_dist.sample()\n", " yield self.env.timeout(self.reg_duration)\n", " \n", " trace(f'patient {self.identifier} registered at'\n", @@ -950,7 +950,7 @@ " f'{self.env.now:.3f}')\n", " \n", " # sample examination duration.\n", - " self.exam_duration = args.exam_dist.sample()\n", + " self.exam_duration = self.args.exam_dist.sample()\n", " yield self.env.timeout(self.exam_duration)\n", " \n", " trace(f'patient {self.identifier} examination complete ' \n", @@ -975,7 +975,7 @@ " f'{self.env.now:.3f}')\n", "\n", " # sample treatment duration.\n", - " self.treat_duration = args.nt_treat_dist.sample()\n", + " self.treat_duration = self.args.nt_treat_dist.sample()\n", " yield self.env.timeout(self.treat_duration)\n", "\n", " trace(f'patient {self.identifier} treatment complete '\n", @@ -988,7 +988,7 @@ }, { "cell_type": "markdown", - "id": "39bb1a70", + "id": "b63dc313", "metadata": {}, "source": [ "## 7. Main model class\n", @@ -999,7 +999,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "32fe1593", + "id": "eb818845", "metadata": {}, "outputs": [], "source": [ @@ -1141,7 +1141,7 @@ }, { "cell_type": "markdown", - "id": "b697a7f0", + "id": "20371a7d", "metadata": {}, "source": [ "### 8. Logic to process end of run results.\n", @@ -1152,7 +1152,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "91cb2537", + "id": "84b6ba9c", "metadata": {}, "outputs": [], "source": [ @@ -1343,7 +1343,7 @@ }, { "cell_type": "markdown", - "id": "2ed1e0a7", + "id": "66903748", "metadata": {}, "source": [ "## 9. Model execution\n", @@ -1356,7 +1356,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "9dcc164b", + "id": "ee84259b", "metadata": {}, "outputs": [], "source": [ @@ -1404,7 +1404,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "3320cd7c", + "id": "821b19c0", "metadata": {}, "outputs": [], "source": [ @@ -1442,7 +1442,7 @@ }, { "cell_type": "markdown", - "id": "c2773977", + "id": "95ceb94f", "metadata": {}, "source": [ "### 9.1 Single run of the model\n", @@ -1458,7 +1458,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "ab928ff2", + "id": "7fbd36ef", "metadata": {}, "outputs": [ { @@ -1605,7 +1605,7 @@ }, { "cell_type": "markdown", - "id": "7ce7a397", + "id": "f28faeb9", "metadata": {}, "source": [ "### 9.2 Multiple independent replications\n", @@ -1616,7 +1616,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "7d1bd513", + "id": "bc86afc7", "metadata": {}, "outputs": [ { @@ -1625,8 +1625,8 @@ "text": [ "Running multiple replications => done.\n", "\n", - "CPU times: user 3.21 s, sys: 25 ms, total: 3.23 s\n", - "Wall time: 5.8 s\n" + "CPU times: user 3.11 s, sys: 34.6 ms, total: 3.14 s\n", + "Wall time: 4.56 s\n" ] }, { @@ -1807,7 +1807,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "0964cfc9", + "id": "bd73717a", "metadata": {}, "outputs": [ { @@ -1844,7 +1844,7 @@ }, { "cell_type": "markdown", - "id": "f3d13d68", + "id": "e16a5004", "metadata": {}, "source": [ "### 9.3 Visualise replications" @@ -1853,7 +1853,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "83bb0cb6", + "id": "d6aa0e6f", "metadata": {}, "outputs": [ { @@ -1877,7 +1877,7 @@ }, { "cell_type": "markdown", - "id": "1cdb9f2c", + "id": "dee26e8c", "metadata": {}, "source": [ "## 10. Scenario Analysis\n", @@ -1890,7 +1890,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "938b1851", + "id": "a9a407df", "metadata": {}, "outputs": [], "source": [ @@ -1925,7 +1925,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "ffc0b669", + "id": "e5e5dd90", "metadata": {}, "outputs": [], "source": [ @@ -1967,7 +1967,7 @@ }, { "cell_type": "markdown", - "id": "702e13a3", + "id": "83369fd0", "metadata": {}, "source": [ "### 10.1 Script to run scenario analysis" @@ -1976,7 +1976,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "36a7271a", + "id": "3bf68f8b", "metadata": {}, "outputs": [ { @@ -2016,7 +2016,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "ae7a3a51", + "id": "0688e4e9", "metadata": {}, "outputs": [], "source": [ @@ -2047,7 +2047,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "7c370630", + "id": "560b8a99", "metadata": {}, "outputs": [ { @@ -2089,42 +2089,42 @@ " \n", " \n", " 01a_triage_wait\n", - " 29.52\n", - " 1.17\n", - " 29.47\n", - " 23.99\n", - " 1.21\n", + " 32.56\n", + " 1.26\n", + " 32.56\n", + " 32.56\n", + " 1.26\n", " \n", " \n", " 01b_triage_util\n", - " 0.60\n", - " 0.30\n", - " 0.59\n", - " 0.58\n", - " 0.30\n", + " 0.61\n", + " 0.31\n", + " 0.61\n", + " 0.61\n", + " 0.31\n", " \n", " \n", " 02a_registration_wait\n", - " 101.88\n", - " 128.14\n", - " 101.09\n", - " 109.70\n", - " 125.47\n", + " 104.69\n", + " 131.82\n", + " 104.69\n", + " 104.69\n", + " 131.82\n", " \n", " \n", " 02b_registration_util\n", - " 0.84\n", " 0.85\n", - " 0.84\n", - " 0.84\n", - " 0.84\n", + " 0.85\n", + " 0.85\n", + " 0.85\n", + " 0.85\n", " \n", " \n", " 03a_examination_wait\n", - " 25.34\n", - " 24.93\n", - " 0.16\n", - " 24.03\n", + " 23.36\n", + " 24.44\n", + " 0.14\n", + " 23.36\n", " 0.14\n", " \n", " \n", @@ -2132,16 +2132,16 @@ " 0.86\n", " 0.86\n", " 0.67\n", - " 0.85\n", + " 0.86\n", " 0.67\n", " \n", " \n", " 04a_treatment_wait(non_trauma)\n", - " 134.19\n", - " 134.80\n", - " 148.81\n", - " 2.10\n", - " 150.61\n", + " 130.73\n", + " 133.09\n", + " 144.50\n", + " 2.15\n", + " 147.81\n", " \n", " \n", " 04b_treatment_util(non_trauma)\n", @@ -2153,59 +2153,59 @@ " \n", " \n", " 05_total_time(non-trauma)\n", - " 226.57\n", - " 223.52\n", - " 213.47\n", - " 184.42\n", - " 210.25\n", + " 229.04\n", + " 226.38\n", + " 218.29\n", + " 187.98\n", + " 215.06\n", " \n", " \n", " 06a_trauma_wait\n", - " 171.44\n", - " 182.96\n", - " 139.42\n", - " 166.51\n", - " 178.34\n", + " 166.98\n", + " 189.67\n", + " 166.98\n", + " 166.98\n", + " 189.67\n", " \n", " \n", " 06b_trauma_util\n", - " 0.88\n", - " 0.88\n", - " 0.83\n", - " 0.87\n", + " 0.84\n", + " 0.86\n", + " 0.84\n", + " 0.84\n", " 0.86\n", " \n", " \n", " 07a_treatment_wait(trauma)\n", - " 20.38\n", - " 22.61\n", - " 19.24\n", - " 16.89\n", - " 19.46\n", + " 14.39\n", + " 14.77\n", + " 14.39\n", + " 14.39\n", + " 14.77\n", " \n", " \n", " 07b_treatment_util(trauma)\n", " 0.52\n", " 0.52\n", " 0.52\n", - " 0.51\n", + " 0.52\n", " 0.52\n", " \n", " \n", " 08_total_time(trauma)\n", - " 316.94\n", - " 298.88\n", - " 271.56\n", - " 297.58\n", - " 288.86\n", + " 306.46\n", + " 298.22\n", + " 306.46\n", + " 306.46\n", + " 298.22\n", " \n", " \n", " 09_throughput\n", - " 166.15\n", - " 167.45\n", - " 169.15\n", + " 165.85\n", + " 166.65\n", + " 169.10\n", " 196.85\n", - " 170.40\n", + " 169.85\n", " \n", " \n", "\n", @@ -2214,21 +2214,21 @@ "text/plain": [ " base triage+1 exam+1 treat+1 triage+exam\n", "00_arrivals 227.25 227.25 227.25 227.25 227.25\n", - "01a_triage_wait 29.52 1.17 29.47 23.99 1.21\n", - "01b_triage_util 0.60 0.30 0.59 0.58 0.30\n", - "02a_registration_wait 101.88 128.14 101.09 109.70 125.47\n", - "02b_registration_util 0.84 0.85 0.84 0.84 0.84\n", - "03a_examination_wait 25.34 24.93 0.16 24.03 0.14\n", - "03b_examination_util 0.86 0.86 0.67 0.85 0.67\n", - "04a_treatment_wait(non_trauma) 134.19 134.80 148.81 2.10 150.61\n", + "01a_triage_wait 32.56 1.26 32.56 32.56 1.26\n", + "01b_triage_util 0.61 0.31 0.61 0.61 0.31\n", + "02a_registration_wait 104.69 131.82 104.69 104.69 131.82\n", + "02b_registration_util 0.85 0.85 0.85 0.85 0.85\n", + "03a_examination_wait 23.36 24.44 0.14 23.36 0.14\n", + "03b_examination_util 0.86 0.86 0.67 0.86 0.67\n", + "04a_treatment_wait(non_trauma) 130.73 133.09 144.50 2.15 147.81\n", "04b_treatment_util(non_trauma) 0.88 0.88 0.88 0.62 0.88\n", - "05_total_time(non-trauma) 226.57 223.52 213.47 184.42 210.25\n", - "06a_trauma_wait 171.44 182.96 139.42 166.51 178.34\n", - "06b_trauma_util 0.88 0.88 0.83 0.87 0.86\n", - "07a_treatment_wait(trauma) 20.38 22.61 19.24 16.89 19.46\n", - "07b_treatment_util(trauma) 0.52 0.52 0.52 0.51 0.52\n", - "08_total_time(trauma) 316.94 298.88 271.56 297.58 288.86\n", - "09_throughput 166.15 167.45 169.15 196.85 170.40" + "05_total_time(non-trauma) 229.04 226.38 218.29 187.98 215.06\n", + "06a_trauma_wait 166.98 189.67 166.98 166.98 189.67\n", + "06b_trauma_util 0.84 0.86 0.84 0.84 0.86\n", + "07a_treatment_wait(trauma) 14.39 14.77 14.39 14.39 14.77\n", + "07b_treatment_util(trauma) 0.52 0.52 0.52 0.52 0.52\n", + "08_total_time(trauma) 306.46 298.22 306.46 306.46 298.22\n", + "09_throughput 165.85 166.65 169.10 196.85 169.85" ] }, "execution_count": 25, @@ -2245,7 +2245,7 @@ }, { "cell_type": "markdown", - "id": "e1075c3a", + "id": "f0975eb0", "metadata": {}, "source": [ "## 11. Script to produce formatted LaTeX table for paper" @@ -2254,7 +2254,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "9d4388bd", + "id": "74eeca17", "metadata": {}, "outputs": [ { @@ -2290,56 +2290,56 @@ " \n", " 0\n", " Triage\n", - " 29.52\n", - " 1.17\n", - " 29.47\n", - " 23.99\n", - " 1.21\n", + " 32.56\n", + " 1.26\n", + " 32.56\n", + " 32.56\n", + " 1.26\n", " \n", " \n", " 1\n", " Registation\n", - " 101.88\n", - " 128.14\n", - " 101.09\n", - " 109.70\n", - " 125.47\n", + " 104.69\n", + " 131.82\n", + " 104.69\n", + " 104.69\n", + " 131.82\n", " \n", " \n", " 2\n", " Examination\n", - " 25.34\n", - " 24.93\n", - " 0.16\n", - " 24.03\n", + " 23.36\n", + " 24.44\n", + " 0.14\n", + " 23.36\n", " 0.14\n", " \n", " \n", " 3\n", " Non-trauma treatment\n", - " 134.19\n", - " 134.80\n", - " 148.81\n", - " 2.10\n", - " 150.61\n", + " 130.73\n", + " 133.09\n", + " 144.50\n", + " 2.15\n", + " 147.81\n", " \n", " \n", " 4\n", " Trauma stabilisation\n", - " 171.44\n", - " 182.96\n", - " 139.42\n", - " 166.51\n", - " 178.34\n", + " 166.98\n", + " 189.67\n", + " 166.98\n", + " 166.98\n", + " 189.67\n", " \n", " \n", " 5\n", " Trauma treatment\n", - " 20.38\n", - " 22.61\n", - " 19.24\n", - " 16.89\n", - " 19.46\n", + " 14.39\n", + " 14.77\n", + " 14.39\n", + " 14.39\n", + " 14.77\n", " \n", " \n", "\n", @@ -2347,12 +2347,12 @@ ], "text/plain": [ " Mean waiting time (mins) base triage+1 exam+1 treat+1 triage+exam\n", - "0 Triage 29.52 1.17 29.47 23.99 1.21\n", - "1 Registation 101.88 128.14 101.09 109.70 125.47\n", - "2 Examination 25.34 24.93 0.16 24.03 0.14\n", - "3 Non-trauma treatment 134.19 134.80 148.81 2.10 150.61\n", - "4 Trauma stabilisation 171.44 182.96 139.42 166.51 178.34\n", - "5 Trauma treatment 20.38 22.61 19.24 16.89 19.46" + "0 Triage 32.56 1.26 32.56 32.56 1.26\n", + "1 Registation 104.69 131.82 104.69 104.69 131.82\n", + "2 Examination 23.36 24.44 0.14 23.36 0.14\n", + "3 Non-trauma treatment 130.73 133.09 144.50 2.15 147.81\n", + "4 Trauma stabilisation 166.98 189.67 166.98 166.98 189.67\n", + "5 Trauma treatment 14.39 14.77 14.39 14.39 14.77" ] }, "execution_count": 26, @@ -2382,7 +2382,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "12fbe03a", + "id": "e997f352", "metadata": {}, "outputs": [ { @@ -2397,12 +2397,12 @@ "\\toprule\n", "Mean waiting time (mins) & base & triage+1 & exam+1 & treat+1 & triage+exam \\\\\n", "\\midrule\n", - " Triage & 29.52 & 1.17 & 29.47 & 23.99 & 1.21 \\\\\n", - " Registation & 101.88 & 128.14 & 101.09 & 109.70 & 125.47 \\\\\n", - " Examination & 25.34 & 24.93 & 0.16 & 24.03 & 0.14 \\\\\n", - " Non-trauma treatment & 134.19 & 134.80 & 148.81 & 2.10 & 150.61 \\\\\n", - " Trauma stabilisation & 171.44 & 182.96 & 139.42 & 166.51 & 178.34 \\\\\n", - " Trauma treatment & 20.38 & 22.61 & 19.24 & 16.89 & 19.46 \\\\\n", + " Triage & 32.56 & 1.26 & 32.56 & 32.56 & 1.26 \\\\\n", + " Registation & 104.69 & 131.82 & 104.69 & 104.69 & 131.82 \\\\\n", + " Examination & 23.36 & 24.44 & 0.14 & 23.36 & 0.14 \\\\\n", + " Non-trauma treatment & 130.73 & 133.09 & 144.50 & 2.15 & 147.81 \\\\\n", + " Trauma stabilisation & 166.98 & 189.67 & 166.98 & 166.98 & 189.67 \\\\\n", + " Trauma treatment & 14.39 & 14.77 & 14.39 & 14.39 & 14.77 \\\\\n", "\\bottomrule\n", "\\end{tabular}\n", "\\end{table}\n", @@ -2431,7 +2431,7 @@ }, { "cell_type": "markdown", - "id": "c3098904", + "id": "aea6dfee", "metadata": {}, "source": [ "## End" diff --git a/content/02_model_code/output/table_3.txt b/content/02_model_code/output/table_3.txt index 21d335f..06ef3b0 100644 --- a/content/02_model_code/output/table_3.txt +++ b/content/02_model_code/output/table_3.txt @@ -6,12 +6,12 @@ \toprule Mean waiting time (mins) & base & triage+1 & exam+1 & treat+1 & triage+exam \\ \midrule - Triage & 29.52 & 1.17 & 29.47 & 23.99 & 1.21 \\ - Registation & 101.88 & 128.14 & 101.09 & 109.70 & 125.47 \\ - Examination & 25.34 & 24.93 & 0.16 & 24.03 & 0.14 \\ - Non-trauma treatment & 134.19 & 134.80 & 148.81 & 2.10 & 150.61 \\ - Trauma stabilisation & 171.44 & 182.96 & 139.42 & 166.51 & 178.34 \\ - Trauma treatment & 20.38 & 22.61 & 19.24 & 16.89 & 19.46 \\ + Triage & 32.56 & 1.26 & 32.56 & 32.56 & 1.26 \\ + Registation & 104.69 & 131.82 & 104.69 & 104.69 & 131.82 \\ + Examination & 23.36 & 24.44 & 0.14 & 23.36 & 0.14 \\ + Non-trauma treatment & 130.73 & 133.09 & 144.50 & 2.15 & 147.81 \\ + Trauma stabilisation & 166.98 & 189.67 & 166.98 & 166.98 & 189.67 \\ + Trauma treatment & 14.39 & 14.77 & 14.39 & 14.39 & 14.77 \\ \bottomrule \end{tabular} \end{table}