diff --git a/binder/environment.yml b/binder/environment.yml index 7f9412f..db32028 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -12,5 +12,4 @@ dependencies: - scipy=1.6.1 - simpy=4.0.1 - pip: - - jupyter-book==0.15.1 - + - jupyter-book==0.15.1 \ No newline at end of file diff --git a/content/02_model_code/04_model.ipynb b/content/02_model_code/04_model.ipynb index e5dba27..ac7fae0 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": "e251ce0d", + "id": "9864ff04", "metadata": {}, "source": [ "# SimPy: Treatment Centre\n", @@ -16,7 +16,7 @@ }, { "cell_type": "markdown", - "id": "6ab38314", + "id": "67d378b9", "metadata": {}, "source": [ "## 1. Imports\n", @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "f9b9d8c8", + "id": "7d374b31", "metadata": {}, "outputs": [ { @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "956f9cb7", + "id": "11fac8cf", "metadata": {}, "outputs": [], "source": [ @@ -63,7 +63,7 @@ }, { "cell_type": "markdown", - "id": "3a04b23d", + "id": "559ee23e", "metadata": {}, "source": [ "## 2. Constants and defaults for modelling **as-is**" @@ -71,7 +71,7 @@ }, { "cell_type": "markdown", - "id": "4b7ab380", + "id": "87c119bd", "metadata": {}, "source": [ "### 2.1 Distribution parameters" @@ -80,7 +80,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "b98c91df", + "id": "6f01d888", "metadata": {}, "outputs": [], "source": [ @@ -115,7 +115,7 @@ }, { "cell_type": "markdown", - "id": "d1dba095", + "id": "7bb06c1d", "metadata": {}, "source": [ "### 2.2 Time dependent arrival rates data\n", @@ -126,7 +126,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "31132d08", + "id": "e55e450a", "metadata": {}, "outputs": [ { @@ -154,7 +154,7 @@ }, { "cell_type": "markdown", - "id": "8a8eccec", + "id": "18ce33a2", "metadata": {}, "source": [ "### 2.3 Resource counts\n", @@ -165,7 +165,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "9f97c46b", + "id": "93644445", "metadata": {}, "outputs": [], "source": [ @@ -183,7 +183,7 @@ }, { "cell_type": "markdown", - "id": "bbb220c8", + "id": "814e3a78", "metadata": {}, "source": [ "### 2.4 Simulation model run settings" @@ -192,7 +192,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "3b44984a", + "id": "0038a24f", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ }, { "cell_type": "markdown", - "id": "c2f5d0d5", + "id": "4df7855a", "metadata": {}, "source": [ "## 3. Utility functions" @@ -222,7 +222,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "91481550", + "id": "9e150cb9", "metadata": {}, "outputs": [], "source": [ @@ -243,7 +243,7 @@ }, { "cell_type": "markdown", - "id": "44840021", + "id": "dab518e5", "metadata": {}, "source": [ "## 4. Distribution classes\n", @@ -261,7 +261,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "ee8a6b21", + "id": "48e2c282", "metadata": {}, "outputs": [], "source": [ @@ -387,7 +387,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "e3662ea3", + "id": "ffd5ca32", "metadata": {}, "outputs": [], "source": [ @@ -469,7 +469,7 @@ }, { "cell_type": "markdown", - "id": "21f34196", + "id": "da4e0ca7", "metadata": {}, "source": [ "## 5. Model parameterisation\n", @@ -480,7 +480,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "6a261de8", + "id": "4cbd58d2", "metadata": {}, "outputs": [], "source": [ @@ -659,7 +659,7 @@ " \n", " # treatment of trauma patients\n", " self.treat_dist = Lognormal(self.trauma_treat_mean, \n", - " np.sqrt(self.non_trauma_treat_var),\n", + " np.sqrt(self.trauma_treat_var),\n", " random_seed=self.seeds[5])\n", " \n", " # probability of non-trauma patient requiring treatment\n", @@ -694,7 +694,7 @@ }, { "cell_type": "markdown", - "id": "a627b72f", + "id": "e3cb73a1", "metadata": {}, "source": [ "## 6. Patient Pathways Process Logic\n", @@ -705,7 +705,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "11700ff1", + "id": "34edd733", "metadata": {}, "outputs": [], "source": [ @@ -804,7 +804,7 @@ " f'{self.env.now:.3f}')\n", " \n", " # sample treatment duration.\n", - " self.treat_duration = args.trauma_dist.sample()\n", + " self.treat_duration = 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": "fc633380", + "id": "30185f46", "metadata": {}, "outputs": [], "source": [ @@ -988,7 +988,7 @@ }, { "cell_type": "markdown", - "id": "284188bc", + "id": "39bb1a70", "metadata": {}, "source": [ "## 7. Main model class\n", @@ -999,7 +999,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "03770c5a", + "id": "32fe1593", "metadata": {}, "outputs": [], "source": [ @@ -1141,7 +1141,7 @@ }, { "cell_type": "markdown", - "id": "cb89619b", + "id": "b697a7f0", "metadata": {}, "source": [ "### 8. Logic to process end of run results.\n", @@ -1152,7 +1152,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "f6a4fd58", + "id": "91cb2537", "metadata": {}, "outputs": [], "source": [ @@ -1343,7 +1343,7 @@ }, { "cell_type": "markdown", - "id": "5b4b5208", + "id": "2ed1e0a7", "metadata": {}, "source": [ "## 9. Model execution\n", @@ -1356,7 +1356,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "2dfa5971", + "id": "9dcc164b", "metadata": {}, "outputs": [], "source": [ @@ -1404,7 +1404,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "3adde6ad", + "id": "3320cd7c", "metadata": {}, "outputs": [], "source": [ @@ -1442,7 +1442,7 @@ }, { "cell_type": "markdown", - "id": "6cfd29ba", + "id": "c2773977", "metadata": {}, "source": [ "### 9.1 Single run of the model\n", @@ -1458,7 +1458,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "1c592473", + "id": "ab928ff2", "metadata": {}, "outputs": [ { @@ -1535,27 +1535,27 @@ " \n", " \n", " 06a_trauma_wait\n", - " 240.846123\n", + " 201.144403\n", " \n", " \n", " 06b_trauma_util\n", - " 0.952202\n", + " 0.919830\n", " \n", " \n", " 07a_treatment_wait(trauma)\n", - " 87.200272\n", + " 22.620880\n", " \n", " \n", " 07b_treatment_util(trauma)\n", - " 0.740196\n", + " 0.493576\n", " \n", " \n", " 08_total_time(trauma)\n", - " 422.158076\n", + " 310.384648\n", " \n", " \n", " 09_throughput\n", - " 150.000000\n", + " 155.000000\n", " \n", " \n", "\n", @@ -1573,12 +1573,12 @@ "04a_treatment_wait(non_trauma) 172.435861\n", "04b_treatment_util(non_trauma) 0.845652\n", "05_total_time(non-trauma) 248.848441\n", - "06a_trauma_wait 240.846123\n", - "06b_trauma_util 0.952202\n", - "07a_treatment_wait(trauma) 87.200272\n", - "07b_treatment_util(trauma) 0.740196\n", - "08_total_time(trauma) 422.158076\n", - "09_throughput 150.000000" + "06a_trauma_wait 201.144403\n", + "06b_trauma_util 0.919830\n", + "07a_treatment_wait(trauma) 22.620880\n", + "07b_treatment_util(trauma) 0.493576\n", + "08_total_time(trauma) 310.384648\n", + "09_throughput 155.000000" ] }, "execution_count": 17, @@ -1605,7 +1605,7 @@ }, { "cell_type": "markdown", - "id": "75df4e4d", + "id": "7ce7a397", "metadata": {}, "source": [ "### 9.2 Multiple independent replications\n", @@ -1616,7 +1616,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "592c20b9", + "id": "7d1bd513", "metadata": {}, "outputs": [ { @@ -1625,8 +1625,8 @@ "text": [ "Running multiple replications => done.\n", "\n", - "CPU times: user 1.5 s, sys: 17.2 ms, total: 1.51 s\n", - "Wall time: 4.44 s\n" + "CPU times: user 3.21 s, sys: 25 ms, total: 3.23 s\n", + "Wall time: 5.8 s\n" ] }, { @@ -1700,12 +1700,12 @@ " 152.483394\n", " 0.890904\n", " 234.759918\n", - " 191.391047\n", - " 0.812900\n", - " 239.889716\n", - " 0.929002\n", - " 393.725433\n", - " 157.0\n", + " 236.508444\n", + " 1.028887\n", + " 13.701783\n", + " 0.607996\n", + " 346.698079\n", + " 171.0\n", " \n", " \n", " 2\n", @@ -1719,12 +1719,12 @@ " 120.245474\n", " 0.912127\n", " 233.882040\n", - " 198.986555\n", - " 0.790265\n", - " 91.161308\n", - " 0.699481\n", - " 406.292519\n", - " 156.0\n", + " 133.813901\n", + " 0.834124\n", + " 3.715446\n", + " 0.367507\n", + " 301.521195\n", + " 161.0\n", " \n", " \n", " 3\n", @@ -1738,12 +1738,12 @@ " 94.019885\n", " 0.868888\n", " 208.361290\n", - " 284.853607\n", - " 0.896077\n", - " 156.650713\n", - " 0.699029\n", - " 524.843569\n", - " 161.0\n", + " 276.422566\n", + " 0.874245\n", + " 12.252175\n", + " 0.464740\n", + " 440.515502\n", + " 167.0\n", " \n", " \n", "\n", @@ -1770,21 +1770,21 @@ "\n", " 05_total_time(non-trauma) 06a_trauma_wait 06b_trauma_util \\\n", "rep \n", - "1 234.759918 191.391047 0.812900 \n", - "2 233.882040 198.986555 0.790265 \n", - "3 208.361290 284.853607 0.896077 \n", + "1 234.759918 236.508444 1.028887 \n", + "2 233.882040 133.813901 0.834124 \n", + "3 208.361290 276.422566 0.874245 \n", "\n", " 07a_treatment_wait(trauma) 07b_treatment_util(trauma) \\\n", "rep \n", - "1 239.889716 0.929002 \n", - "2 91.161308 0.699481 \n", - "3 156.650713 0.699029 \n", + "1 13.701783 0.607996 \n", + "2 3.715446 0.367507 \n", + "3 12.252175 0.464740 \n", "\n", " 08_total_time(trauma) 09_throughput \n", "rep \n", - "1 393.725433 157.0 \n", - "2 406.292519 156.0 \n", - "3 524.843569 161.0 " + "1 346.698079 171.0 \n", + "2 301.521195 161.0 \n", + "3 440.515502 167.0 " ] }, "execution_count": 18, @@ -1807,7 +1807,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "a2977d15", + "id": "0964cfc9", "metadata": {}, "outputs": [ { @@ -1823,12 +1823,12 @@ "04a_treatment_wait(non_trauma) 136.66\n", "04b_treatment_util(non_trauma) 0.87\n", "05_total_time(non-trauma) 234.34\n", - "06a_trauma_wait 147.42\n", + "06a_trauma_wait 151.68\n", "06b_trauma_util 0.83\n", - "07a_treatment_wait(trauma) 169.61\n", - "07b_treatment_util(trauma) 0.81\n", - "08_total_time(trauma) 395.08\n", - "09_throughput 153.60\n", + "07a_treatment_wait(trauma) 14.31\n", + "07b_treatment_util(trauma) 0.50\n", + "08_total_time(trauma) 292.28\n", + "09_throughput 162.16\n", "dtype: float64" ] }, @@ -1844,7 +1844,7 @@ }, { "cell_type": "markdown", - "id": "f356c85f", + "id": "f3d13d68", "metadata": {}, "source": [ "### 9.3 Visualise replications" @@ -1853,7 +1853,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "03f0caf3", + "id": "83bb0cb6", "metadata": {}, "outputs": [ { @@ -1877,7 +1877,7 @@ }, { "cell_type": "markdown", - "id": "31679e4b", + "id": "1cdb9f2c", "metadata": {}, "source": [ "## 10. Scenario Analysis\n", @@ -1890,7 +1890,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "87fa1b65", + "id": "938b1851", "metadata": {}, "outputs": [], "source": [ @@ -1925,7 +1925,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "079a12b9", + "id": "ffc0b669", "metadata": {}, "outputs": [], "source": [ @@ -1967,7 +1967,7 @@ }, { "cell_type": "markdown", - "id": "679b9dc1", + "id": "702e13a3", "metadata": {}, "source": [ "### 10.1 Script to run scenario analysis" @@ -1976,7 +1976,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "51a9bfbf", + "id": "36a7271a", "metadata": {}, "outputs": [ { @@ -2016,7 +2016,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "77d20748", + "id": "ae7a3a51", "metadata": {}, "outputs": [], "source": [ @@ -2047,7 +2047,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "4e63a89b", + "id": "7c370630", "metadata": {}, "outputs": [ { @@ -2161,51 +2161,51 @@ " \n", " \n", " 06a_trauma_wait\n", - " 144.23\n", - " 163.29\n", - " 153.04\n", - " 151.20\n", - " 189.95\n", + " 171.44\n", + " 182.96\n", + " 139.42\n", + " 166.51\n", + " 178.34\n", " \n", " \n", " 06b_trauma_util\n", - " 0.85\n", - " 0.85\n", - " 0.89\n", - " 0.80\n", " 0.88\n", + " 0.88\n", + " 0.83\n", + " 0.87\n", + " 0.86\n", " \n", " \n", " 07a_treatment_wait(trauma)\n", - " 176.13\n", - " 208.33\n", - " 192.61\n", - " 165.71\n", - " 191.00\n", + " 20.38\n", + " 22.61\n", + " 19.24\n", + " 16.89\n", + " 19.46\n", " \n", " \n", " 07b_treatment_util(trauma)\n", - " 0.84\n", - " 0.86\n", - " 0.80\n", - " 0.84\n", - " 0.85\n", + " 0.52\n", + " 0.52\n", + " 0.52\n", + " 0.51\n", + " 0.52\n", " \n", " \n", " 08_total_time(trauma)\n", - " 393.36\n", - " 389.83\n", - " 400.76\n", - " 383.26\n", - " 408.64\n", + " 316.94\n", + " 298.88\n", + " 271.56\n", + " 297.58\n", + " 288.86\n", " \n", " \n", " 09_throughput\n", - " 156.25\n", - " 157.50\n", - " 159.85\n", - " 187.85\n", - " 159.80\n", + " 166.15\n", + " 167.45\n", + " 169.15\n", + " 196.85\n", + " 170.40\n", " \n", " \n", "\n", @@ -2223,12 +2223,12 @@ "04a_treatment_wait(non_trauma) 134.19 134.80 148.81 2.10 150.61\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 144.23 163.29 153.04 151.20 189.95\n", - "06b_trauma_util 0.85 0.85 0.89 0.80 0.88\n", - "07a_treatment_wait(trauma) 176.13 208.33 192.61 165.71 191.00\n", - "07b_treatment_util(trauma) 0.84 0.86 0.80 0.84 0.85\n", - "08_total_time(trauma) 393.36 389.83 400.76 383.26 408.64\n", - "09_throughput 156.25 157.50 159.85 187.85 159.80" + "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" ] }, "execution_count": 25, @@ -2245,7 +2245,7 @@ }, { "cell_type": "markdown", - "id": "7cb09bfb", + "id": "e1075c3a", "metadata": {}, "source": [ "## 11. Script to produce formatted LaTeX table for paper" @@ -2254,7 +2254,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "82a91037", + "id": "9d4388bd", "metadata": {}, "outputs": [ { @@ -2326,20 +2326,20 @@ " \n", " 4\n", " Trauma stabilisation\n", - " 144.23\n", - " 163.29\n", - " 153.04\n", - " 151.20\n", - " 189.95\n", + " 171.44\n", + " 182.96\n", + " 139.42\n", + " 166.51\n", + " 178.34\n", " \n", " \n", " 5\n", " Trauma treatment\n", - " 176.13\n", - " 208.33\n", - " 192.61\n", - " 165.71\n", - " 191.00\n", + " 20.38\n", + " 22.61\n", + " 19.24\n", + " 16.89\n", + " 19.46\n", " \n", " \n", "\n", @@ -2351,8 +2351,8 @@ "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 144.23 163.29 153.04 151.20 189.95\n", - "5 Trauma treatment 176.13 208.33 192.61 165.71 191.00" + "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" ] }, "execution_count": 26, @@ -2382,7 +2382,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "cc53c15f", + "id": "12fbe03a", "metadata": {}, "outputs": [ { @@ -2401,8 +2401,8 @@ " 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 & 144.23 & 163.29 & 153.04 & 151.20 & 189.95 \\\\\n", - " Trauma treatment & 176.13 & 208.33 & 192.61 & 165.71 & 191.00 \\\\\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", "\\bottomrule\n", "\\end{tabular}\n", "\\end{table}\n", @@ -2431,7 +2431,7 @@ }, { "cell_type": "markdown", - "id": "ea8a95ab", + "id": "c3098904", "metadata": {}, "source": [ "## End" diff --git a/content/02_model_code/output/table_3.txt b/content/02_model_code/output/table_3.txt index c8034c3..21d335f 100644 --- a/content/02_model_code/output/table_3.txt +++ b/content/02_model_code/output/table_3.txt @@ -10,8 +10,8 @@ Mean waiting time (mins) & base & triage+1 & exam+1 & treat+1 & triage+exa 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 & 144.23 & 163.29 & 153.04 & 151.20 & 189.95 \\ - Trauma treatment & 176.13 & 208.33 & 192.61 & 165.71 & 191.00 \\ + Trauma stabilisation & 171.44 & 182.96 & 139.42 & 166.51 & 178.34 \\ + Trauma treatment & 20.38 & 22.61 & 19.24 & 16.89 & 19.46 \\ \bottomrule \end{tabular} \end{table} diff --git a/src/full_model.ipynb b/src/full_model.ipynb index ab28841..453d537 100644 --- a/src/full_model.ipynb +++ b/src/full_model.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "5f6bc1fb", + "id": "1e38665a", "metadata": {}, "source": [ "# SimPy: Treatment Centre\n", @@ -26,7 +26,7 @@ }, { "cell_type": "markdown", - "id": "75ac3244", + "id": "d05a6590", "metadata": {}, "source": [ "## Imports\n", @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "d7fe643e", + "id": "d7666c05", "metadata": {}, "outputs": [], "source": [ @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "a5aaf4aa", + "id": "fa57807c", "metadata": {}, "outputs": [ { @@ -74,7 +74,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "d5cfef2a", + "id": "458d9a2a", "metadata": {}, "outputs": [], "source": [ @@ -87,7 +87,7 @@ }, { "cell_type": "markdown", - "id": "83fbca98", + "id": "6eed558f", "metadata": {}, "source": [ "---\n", @@ -115,7 +115,7 @@ }, { "cell_type": "markdown", - "id": "1a9f16c7", + "id": "38e248b9", "metadata": {}, "source": [ "## Constants and defaults for modelling **as-is**" @@ -123,7 +123,7 @@ }, { "cell_type": "markdown", - "id": "e09c1788", + "id": "4a2dc494", "metadata": {}, "source": [ "### Distribution parameters" @@ -132,7 +132,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "ed8cdf44", + "id": "af9b52b0", "metadata": {}, "outputs": [], "source": [ @@ -167,7 +167,7 @@ }, { "cell_type": "markdown", - "id": "5b625648", + "id": "2ff84174", "metadata": {}, "source": [ "### Time dependent arrival rates data\n", @@ -178,7 +178,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "f47e4be1", + "id": "cb740899", "metadata": {}, "outputs": [ { @@ -205,7 +205,7 @@ }, { "cell_type": "markdown", - "id": "7babe87a", + "id": "84b59c1a", "metadata": {}, "source": [ "### Resource counts\n", @@ -216,7 +216,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "356da7d2", + "id": "35eb6883", "metadata": {}, "outputs": [], "source": [ @@ -234,7 +234,7 @@ }, { "cell_type": "markdown", - "id": "75343958", + "id": "92029642", "metadata": {}, "source": [ "### Simulation model run settings" @@ -243,7 +243,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "9a060e54", + "id": "5dfc4485", "metadata": {}, "outputs": [], "source": [ @@ -264,7 +264,7 @@ }, { "cell_type": "markdown", - "id": "d47270ec", + "id": "f40e7e85", "metadata": {}, "source": [ "## Utility functions" @@ -273,7 +273,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "a2213696", + "id": "d7cf8c8c", "metadata": {}, "outputs": [], "source": [ @@ -294,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "badf738d", + "id": "967e028b", "metadata": {}, "source": [ "## Distribution classes\n", @@ -312,7 +312,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "cc39928e", + "id": "ebd41c67", "metadata": {}, "outputs": [], "source": [ @@ -438,7 +438,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "476d5c38", + "id": "e026c878", "metadata": {}, "outputs": [], "source": [ @@ -520,7 +520,7 @@ }, { "cell_type": "markdown", - "id": "0bab8888", + "id": "e4409446", "metadata": {}, "source": [ "## Model parameterisation\n", @@ -531,7 +531,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "7dd430d1", + "id": "32f5d71c", "metadata": {}, "outputs": [], "source": [ @@ -710,7 +710,7 @@ " \n", " # treatment of trauma patients\n", " self.treat_dist = Lognormal(self.trauma_treat_mean, \n", - " np.sqrt(self.non_trauma_treat_var),\n", + " np.sqrt(self.trauma_treat_var),\n", " random_seed=self.seeds[5])\n", " \n", " # probability of non-trauma patient requiring treatment\n", @@ -745,7 +745,7 @@ }, { "cell_type": "markdown", - "id": "dcfa40d2", + "id": "f12d6437", "metadata": {}, "source": [ "## Patient Pathways Process Logic\n", @@ -756,7 +756,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "eb3bbfbd", + "id": "fb7c10a8", "metadata": {}, "outputs": [], "source": [ @@ -855,7 +855,7 @@ " f'{self.env.now:.3f}')\n", " \n", " # sample treatment duration.\n", - " self.treat_duration = args.trauma_dist.sample()\n", + " self.treat_duration = args.treat_dist.sample()\n", " yield self.env.timeout(self.treat_duration)\n", " \n", " self.treatment_complete()\n", @@ -888,7 +888,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "23e9b8d7", + "id": "b0a44de1", "metadata": {}, "outputs": [], "source": [ @@ -1039,7 +1039,7 @@ }, { "cell_type": "markdown", - "id": "631df16c", + "id": "5fbfaa7d", "metadata": {}, "source": [ "## Main model class\n", @@ -1050,7 +1050,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "15d766a1", + "id": "d8aedd4b", "metadata": {}, "outputs": [], "source": [ @@ -1192,7 +1192,7 @@ }, { "cell_type": "markdown", - "id": "a99826b4", + "id": "0c02ce95", "metadata": {}, "source": [ "### Logic to process end of run results.\n", @@ -1203,7 +1203,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "aaadd8ea", + "id": "a156e0ea", "metadata": {}, "outputs": [], "source": [ @@ -1394,7 +1394,7 @@ }, { "cell_type": "markdown", - "id": "8a750b27", + "id": "67791f48", "metadata": {}, "source": [ "## Executing a model\n", @@ -1407,7 +1407,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "6f41f4f7", + "id": "31e48ba5", "metadata": {}, "outputs": [], "source": [ @@ -1455,7 +1455,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "bcf70118", + "id": "99072a5b", "metadata": {}, "outputs": [], "source": [ @@ -1493,7 +1493,7 @@ }, { "cell_type": "markdown", - "id": "e8d512aa", + "id": "4c8165b1", "metadata": {}, "source": [ "### Single run of the model\n", @@ -1509,7 +1509,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "fbf01ef1", + "id": "adf424ed", "metadata": {}, "outputs": [ { @@ -1656,7 +1656,7 @@ }, { "cell_type": "markdown", - "id": "c5b39c68", + "id": "1697b886", "metadata": {}, "source": [ "### Multiple independent replications\n", @@ -1670,7 +1670,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "9c562f1d", + "id": "c4b750a7", "metadata": {}, "outputs": [ { @@ -1861,7 +1861,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "4415bf56", + "id": "97e9a462", "metadata": {}, "outputs": [ { @@ -1898,7 +1898,7 @@ }, { "cell_type": "markdown", - "id": "0466c5fa", + "id": "0016c383", "metadata": {}, "source": [ "### Visualise replications" @@ -1907,7 +1907,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "dd4f71a8", + "id": "3bae82ea", "metadata": {}, "outputs": [ { @@ -1931,7 +1931,7 @@ }, { "cell_type": "markdown", - "id": "5e0b10e3", + "id": "9ff1142b", "metadata": {}, "source": [ "## Scenario Analysis\n", @@ -1944,7 +1944,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "04872409", + "id": "215502ef", "metadata": {}, "outputs": [], "source": [ @@ -1983,7 +1983,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "e625868c", + "id": "7b3788f7", "metadata": {}, "outputs": [], "source": [ @@ -2025,7 +2025,7 @@ }, { "cell_type": "markdown", - "id": "1d3e4611", + "id": "c0fae650", "metadata": {}, "source": [ "### Script to run scenario analysis" @@ -2034,7 +2034,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "efc44373", + "id": "3bf9953e", "metadata": {}, "outputs": [ { @@ -2074,7 +2074,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "e59417c4", + "id": "002db425", "metadata": {}, "outputs": [], "source": [ @@ -2105,7 +2105,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "9bf4e8fc", + "id": "169f2723", "metadata": {}, "outputs": [ { @@ -2303,7 +2303,7 @@ }, { "cell_type": "markdown", - "id": "c9363822", + "id": "fc1bc9f4", "metadata": {}, "source": [ "## End" diff --git a/src/treat_sim/model.py b/src/treat_sim/model.py index d911574..39b9508 100644 --- a/src/treat_sim/model.py +++ b/src/treat_sim/model.py @@ -300,11 +300,13 @@ def init_sampling(self): ''' Create the distributions used by the model and initialise the random seeds of each. - ''' - # create random number streams - rng_streams = np.random.default_rng(self.random_number_set) - self.seeds = rng_streams.integers(0, 999999999, size=N_STREAMS) - + ''' + # MODIFICATION. Better method for producing n non-overlapping streams + seed_sequence = np.random.SeedSequence(self.random_number_set) + + # Generate n high quality child seeds + self.seeds = seed_sequence.spawn(N_STREAMS) + # create distributions # Triage duration @@ -332,7 +334,7 @@ def init_sampling(self): # treatment of trauma patients self.treat_dist = Lognormal(self.trauma_treat_mean, - np.sqrt(self.non_trauma_treat_var), + np.sqrt(self.trauma_treat_var), random_seed=self.seeds[5]) # probability of non-trauma patient requiring treatment @@ -430,7 +432,7 @@ def execute(self): f'{self.env.now:.3f}') # sample triage duration. - self.triage_duration = self.args.triage_dist.sample() + self.triage_duration = args.triage_dist.sample() yield self.env.timeout(self.triage_duration) self.triage_complete() @@ -445,7 +447,7 @@ def execute(self): self.wait_trauma = self.env.now - start_wait # sample stablisation duration. - self.trauma_duration = self.args.trauma_dist.sample() + self.trauma_duration = args.trauma_dist.sample() yield self.env.timeout(self.trauma_duration) self.trauma_complete() @@ -463,7 +465,7 @@ def execute(self): f'{self.env.now:.3f}') # sample treatment duration. - self.treat_duration = self.args.trauma_dist.sample() + self.treat_duration = args.treat_dist.sample() yield self.env.timeout(self.treat_duration) self.treatment_complete() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy