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", "