diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..a136fd3 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,36 @@ +# This CITATION.cff file was generated with cffinit. +# Visit https://bit.ly/cffinit to generate yours today! + +cff-version: 1.2.0 +title: >- + Using Large Language Models to support researchers + reproduce and reuse unpublished health care discrete-event + simulation computer models: a feasibility and pilot study + in Python +message: >- + If you use this software, please cite it using the + metadata from this file. +type: software +authors: + - given-names: Thomas + family-names: Monks + orcid: 'https://orcid.org/0000-0003-2631-4481' + affiliation: University of Exeter + email: t.m.w.monks@exeter.ac.uk + - given-names: Alison + family-names: Harper + affiliation: University of Exeter + orcid: 'https://orcid.org/0000-0001-5274-5037' + email: a.l.harper@exeter.ac.uk + - given-names: Amy + family-names: Heather + email: a.heather2@exeter.ac.uk + affiliation: University of Exeter + orcid: 'https://orcid.org/0000-0002-6596-3479' + - given-names: Navonil + family-names: Mustafee + orcid: 'https://orcid.org/0000-0002-2204-8924' + affiliation: University of Exeter + email: n.mustafee@exeter.ac.uk +repository-code: 'https://github.com/pythonhealthdatascience/llm_simpy' +license: MIT diff --git a/README.md b/README.md index c9db2aa..b214e57 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-360+/) -[![PyPI version fury.io](https://badge.fury.io/py/treat-sim.svg)](https://pypi.org/project/treat-sim/) -[![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037) -[![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481) +[![Licence: MIT](https://img.shields.io/badge/Licence-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![Python 3.10+](https://img.shields.io/badge/-Python_≥_3.10-306998?logo=python&logoColor=white)](https://www.python.org/downloads/release/python-360+/) # Using Large Language Models to support researchers reproduce and reuse unpublished health care discrete-event simulation computer models: a feasibility and pilot study in Python ## Authors -* Thomas Monks [![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481) -* Alison Harper [![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037) +* Thomas Monks    [![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481) -* Navonil Mustafee [![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0002-2204-8924) +* Alison Harper    [![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037) -## Creating the virtual environment +* Amy Heather    [![ORCID: Heather](https://img.shields.io/badge/ORCID-0000--0002--6596--3479-brightgreen)](https://orcid.org/0000-0002-6596-3479) + +* Navonil Mustafee    [![ORCID: Mustafee](https://img.shields.io/badge/ORCID-0000--0002--2204--8924-brightgreen)](https://orcid.org/0000-0002-2204-8924) + +## Creating the environment The project uses `conda` to manage dependencies. Navigate your terminal to the directory containing the code @@ -21,7 +21,7 @@ The project uses `conda` to manage dependencies. Navigate your terminal to the d conda env create -f binder/environment.yml ``` -This will create a conda virtual environment called `gen_simpy`. To activate: +This will create a conda environment called `gen_simpy`. To activate: ``` conda activate gen_simpy @@ -36,3 +36,17 @@ jb build . ``` This will build the HTML book locally on your machine. The terminal will display a URL link that you can use to point your browser at the HTML. + +## Citation + +Please cite this repository as: + +> Thomas Monks, Alison Harper, Amy Heather, and Navonil Mustafee. **Using Large Language Models to support researchers reproduce and reuse unpublished health care discrete-event simulation computer models: a feasibility and pilot study in Python**. . + +A `CITATION.cff` file is also provided. + + + +## Funding + + \ No newline at end of file diff --git a/README.md.backup b/README.md.backup deleted file mode 100644 index d814610..0000000 --- a/README.md.backup +++ /dev/null @@ -1,38 +0,0 @@ -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-360+/) -[![PyPI version fury.io](https://badge.fury.io/py/treat-sim.svg)](https://pypi.org/project/treat-sim/) -[![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037) -[![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481) - -# Using Large Language Models to support researchers reproduce and reuse unpublished health care discrete-event simulation computer models: a feasibility and pilot study in Python - -## Authors - -* Thomas Monks [![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481) -* Alison Harper [![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037) - -* Navonil Mustafee [![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0002-2204-8924) - -## Creating the virtual environment - -The project uses `conda` to manage dependencies. Navigate your terminal to the directory containing the code - -``` -conda env create -f binder/environment.yml -``` - -This will create a conda virtual environment called `gen_simpy`. To activate: - -``` -conda activate gen_simpy -``` - -## Building the Juypter Book - -One in the `gen_simpy` environment navigate to the top level directory of the code repository in your terminal and issue the following command: - -``` -jb build . -``` - -This will build the HTML book locally on your machine. The terminal will display a URL link that you can use to point your browser at the HTML. diff --git a/images/llm_study_process_info_graphic.drawio b/images/llm_study_process_info_graphic.drawio index ea92101..07f56f6 100644 --- a/images/llm_study_process_info_graphic.drawio +++ b/images/llm_study_process_info_graphic.drawio @@ -1,303 +1,172 @@ - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + + - - - - - + + - + - - + + - + - - + + - - + + - + - - + + - - + + - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/images/llm_study_process_info_graphic.png b/images/llm_study_process_info_graphic.png index 695ba19..88f97d7 100644 Binary files a/images/llm_study_process_info_graphic.png and b/images/llm_study_process_info_graphic.png differ diff --git a/notebooks/02_CCU/00_stress_report.md b/notebooks/02_CCU/00_stress_report.md index f8d974c..0b6bafa 100644 --- a/notebooks/02_CCU/00_stress_report.md +++ b/notebooks/02_CCU/00_stress_report.md @@ -1,6 +1,6 @@ # STRESS report -It is often difficult to fully understand the design of a simulation model and how it has been implemented. To try an increase the transparency of our work we have followed the Strengthening the Reporting of Empirical Simulation Studies (STRESS) guidelines for Discrete-Event Simulation {cite:p}`stress_guidelines`. While we have attempted to be transparent we welcome queries, suggestions of clarification to improve the documentation. +It is often difficult to fully understand the design of a simulation model and how it has been implemented. To try and increase the transparency of our work we have followed the Strengthening the Reporting of Empirical Simulation Studies (STRESS) guidelines for Discrete-Event Simulation {cite:p}`stress_guidelines`. While we have attempted to be transparent we welcome queries, suggestions of clarification to improve the documentation. ## References diff --git a/notebooks/02_CCU/01_model_stage1/01_ccu_model.ipynb b/notebooks/02_CCU/01_model_stage1/01_ccu_model.ipynb index 6443117..6b88834 100644 --- a/notebooks/02_CCU/01_model_stage1/01_ccu_model.ipynb +++ b/notebooks/02_CCU/01_model_stage1/01_ccu_model.ipynb @@ -7,7 +7,7 @@ "source": [ "# Full model code\n", "\n", - "This notebook contains the **final** model code and docstrings generated by Perplexity.AI between November and December 2024.\n", + "This notebook contains the **final** model code and docstrings generated by Perplexity.AI between November and December 2023.\n", "\n", "The code is stored in a module called `ccu_formatted_code.py`. It has been autoformatted using the tool `black`. This was used to aid PEP8 compliance of the code and help with line wrapping." ] diff --git a/notebooks/02_CCU/04_prompts_stage1/00_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/00_iteration.ipynb index b31f045..e21bdf9 100644 --- a/notebooks/02_CCU/04_prompts_stage1/00_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/00_iteration.ipynb @@ -9,93 +9,20 @@ "\n", "## Plain English Summary\n", "\n", - "The first step in coding a `simpy` model is typically coding the arrivals to the system. In the CCU model there are unplanned(emergency) versus planned (elective) arrivals. Given the logic for unplanned arrivals is the simpler of the two types it is logical to code the arrival of these patients (5 subclasses) first.\n", - "\n" + "The first step in coding a `simpy` model is typically coding the arrivals to the system. In the CCU model there are unplanned (emergency) versus planned (elective) arrivals. Given the logic for unplanned arrivals is the simpler of the two types it is logical to code the arrival of these patients (5 subclasses) first." ] }, { "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", + "id": "323cdbdb", "metadata": {}, "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display" - ] - }, - { - "cell_type": "markdown", - "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", - "metadata": {}, - "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Code a discrete-event simulation model of a critical care unit (CCU) in python 3.10 and simpy 4. \n", - "\n", - "Please code the full model specified. Do not return a simplified version. Show all code.\n", - "\n", - "### General model logic\n", - "\n", - "All time units in the model are in hours.\n", - "\n", - "Each patient in the model has a unique identifier. The first patient to arrive has an identifier of 0. For each subsequent patient increment the identifer by 1.\n", - "\n", - "Patients to arrive at the CCU from five different sources: Accident and Emergency, the Wards, Emergency surgery, other hospitals, or the X-Ray department. Each source had a different inter-arrival time distribution. After patients arrive they immediately leave the model.\n", - "\n", - "All patient types must have their own generator function\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "the model should include a user settable run length. This defaults to 12 months.\n", - "\n", - "\n", - "### Simulation inputs\n", - "\n", - "the interarrival time distributions and parameters of patients are dependent on patient type. For each distribution time is measured in hours.\n", - "\n", - "Accident and Emergency = Exponential: 22.72\n", - "the Wards = Exponential: 26.0\n", - "Emergency surgery = Exponential: 37.0\n", - "other hospitals = Exponential: 47.2\n", - "the X-Ray department = Exponential: 575.0 \n", - "\n", - "\n", - "### simulation methodology\n", - "\n", - "numpy should be use for sampling.\n", - "\n", - "each interarrival distribution should have its own numpy.random.Generator object." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_0.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_0.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/01_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/01_iteration.ipynb index e8c9755..bd12e11 100644 --- a/notebooks/02_CCU/04_prompts_stage1/01_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/01_iteration.ipynb @@ -31,8 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", "import numpy as np\n", "import math" ] @@ -42,60 +40,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in an unplanned admissions treatment process.\n", - "\n", - "Show the full code listing. Do not hide any functions or classes.\n", - "\n", - "### General model logic\n", - "\n", - "The model includes a resource: critical care beds.\n", - "\n", - "After patients have arrived they follow the unplanned admissions process. In the unplanned admissions process patients request and wait for a critical care bed resource to become available in a FIFO queue, and undergo treatment. Following treatment the patient is recorded as \"discharged\", but the bed is not released until intensive cleaning has taken place. \n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "### Simulation inputs\n", - "\n", - "the length of stay (measured in hours) for treatment of patients in the CCU follow source specific distributions\n", - "\n", - "Accident and Emergency: Lognormal: mean 128.79 and standard deviation 267.51\n", - "the Wards = Lognormal: mean 177.89 and standard deviation 276.54\n", - "Emergency surgery = Lognormal: mean 140.15 and standard deviation 218.02\n", - "other hospitals = Lognormal: mean 212.86 and standard deviation 457.67\n", - "the X-Ray department = Lognormal: mean 87.53 and standard deviation 108.67\n", - "\n", - "The mean and standard deviation of the Lognormal distributions must be converted to the mean and standard deviation of the underlying normal distribution.\n", - "\n", - "There are 24 critical care beds in the model. These are shared across all types of patient.\n", - "\n", - "Intensive cleaning takes a fixed amount of time: 5 hours.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_1.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_1.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/02_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/02_iteration.ipynb index 1f7ade0..40473bb 100644 --- a/notebooks/02_CCU/04_prompts_stage1/02_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/02_iteration.ipynb @@ -16,78 +16,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in an elective admissions treatment process.\n", - "\n", - "Show the full code listing for the model. Do not exclude any functions or classes.\n", - "\n", - "### general simulation logic\n", - "\n", - "Add a new arrival source to the CCU: Elective surgery\n", - "\n", - "Elective surgery patients are modelled as a separate process from the unplanned admissions, but share the critical care bed resources. \n", - "\n", - "As an elective patient arrives to the CCU a check is made on the number of critical care beds available. There are two outcomes from this check\n", - "\n", - "Outcome 1: the number of beds in use is equal to the total number of beds available. In this case the elective patient leaves the model immediately. This is called a \"cancelled operation\" event and should be reported to the user.\n", - "\n", - "Outcome 2. the number of beds in use is less than the total number of beds available. In this case the elective patient requests a critical care bed, is treated, and is then discharged. Before the bed is released for another patient there is an additional delay for intensive cleaning of the area and the bed.\n", - "\n", - "### simulation inputs\n", - "\n", - "the interarrival time of elective surgery patients has a normal distribution with mean 17.91 and standard deviation 3.16.\n", - "\n", - "the treatment time of elective surgery patients is exponential mean: 57.34" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_2.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_2.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/03_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/03_iteration.ipynb index d3ee844..ded5131 100644 --- a/notebooks/02_CCU/04_prompts_stage1/03_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/03_iteration.ipynb @@ -16,71 +16,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify the code so that all model parameters are stored within a class called Experiment that is separate from the model's logic. \n", - "\n", - "The list of parameters include:\n", - "\n", - "1. the means of the arrival distributions\n", - "2. the unplanned patient treatment time mean and standard deviations.\n", - "3. the elective patients mean treatment time.\n", - "4. The number of critical care beds available\n", - "5. The duration of intensive cleaning following a patient discharge.\n", - "6. simulation run length\n", - "\n", - "The parameters should be passed to the Experiment class constructor method when it is created. please provide default values\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCModel class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_3.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_3.md\n", + ":::\n", + "::::## LLM Prompt " ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/04_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/04_iteration.ipynb index 78e2753..5d5e580 100644 --- a/notebooks/02_CCU/04_prompts_stage1/04_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/04_iteration.ipynb @@ -14,66 +14,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows\n", - "\n", - "the model should include a user settable warm up period. This defaults to 1 month.\n", - "\n", - "model run length should be renamed results collection period and have the default value of 12 months. \n", - "\n", - "The total run length of the model is the warm up period plus the results collection period.\n", - "\n", - "the Experiment class should also accept a parameter for the warm up period\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_4.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_4.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/05_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/05_iteration.ipynb index 840430b..8172112 100644 --- a/notebooks/02_CCU/04_prompts_stage1/05_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/05_iteration.ipynb @@ -16,68 +16,17 @@ "These calculations only use statistics collected in the results collection period.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows:\n", - "\n", - "The code should calculate performance measures at the end of the simulation run. \n", - "\n", - "The following measures should be calculated.\n", - "\n", - "1. The number of elective operations cancelled. \n", - "\n", - "The code should only collect statistics on this performance measure if the simulation time has exceeded the warm-up period.\n", - "\n", - "After the performance measures are calculated the results should outputted in a pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_5.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_5.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/06_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/06_iteration.ipynb index 5bc230f..3b63f74 100644 --- a/notebooks/02_CCU/04_prompts_stage1/06_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/06_iteration.ipynb @@ -18,64 +18,15 @@ }, { "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", + "id": "dcaafcb2", "metadata": {}, "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", + "## LLM Prompt 1\n", "\n", - "import numpy as np\n", - "import math" - ] - }, - { - "cell_type": "markdown", - "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", - "metadata": {}, - "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "For both unplanned and elective admissions, after a patient has completed treatment, if the simulation time has exceeded the warm-up period, the patient's treatment time should be added to a running total.\n", - "\n", - "Add in a new performance measure that is calculated at the end of the simulation run called \"bed utilization\". This is calculated as follows:\n", - "\n", - "* The total treatment time divided by (the number of beds multiplied by the results collection period). This is a percentage.\n", - "\n", - "Add the result to the pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_6a.md\"))" + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_6a.md\n", + ":::\n", + "::::" ] }, { @@ -6625,32 +6576,12 @@ "id": "cf096cc7-4a4d-40f1-9981-c9adb512557b", "metadata": {}, "source": [ - "## LLM Input 2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "b631f2cf-a618-4221-9a2d-0d247346cd4b", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "all results collection variables should be stored in the Experiment class. \n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_6b.md\"))" + "## LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_6b.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/07_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/07_iteration.ipynb index 2ee6635..0acf6a3 100644 --- a/notebooks/02_CCU/04_prompts_stage1/07_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/07_iteration.ipynb @@ -16,67 +16,17 @@ "These calculations only use statistics collected in the results collection period.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "For unplanned admissions, track the waiting time for critical care bed. After the patient has taken the bed, if the simulation time has exceeded the warm-up period, the patient's waiting time should be added to a running total and the total number of unplanned admissions should be incremented by 1.\n", - "\n", - "Add in a new performance measure calculation at the end of the simulation run:\n", - "\n", - "* The mean time an unplanned admission had to wait for a critical care bed. \n", - "\n", - "Add the result to the pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_7.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_7.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/08_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/08_iteration.ipynb index 20996c0..82c5c13 100644 --- a/notebooks/02_CCU/04_prompts_stage1/08_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/08_iteration.ipynb @@ -18,63 +18,17 @@ "We also make the printing of the simulated trace optional to reduce output when not needed in debugging.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "Create a new generator function in the CCUModel class called \"warmup_complete\". It should be scheduled by simpy to run only once at the end of the warm up period. The logic of the function should set the patient count to zero. \n", - "\n", - "At the end of the simulation run add the patient coun to the pandas dataframe.\n", - "Add the result to the pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_8.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_8.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/09_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/09_iteration.ipynb index d741541..235e6e3 100644 --- a/notebooks/02_CCU/04_prompts_stage1/09_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/09_iteration.ipynb @@ -12,62 +12,17 @@ "The model is already tracking the number of patients. In the paper the authors compare the number of patients generated with real data. We need to reset the patient count when the warm-up period is completed. We do this by introducing a new event that happens only once. This is called \"warm-up complete\"." ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "Create a new generator function in the CCUModel class called \"warmup_complete\". It should be scheduled by simpy to run only once at the end of the warm up period. The logic of the function should set the patient count to zero. If trace is True the model should also print out \"warm-up complete\".\n", - "\n", - "At the end of the simulation run add the patient count to the pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_9.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_9.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/10_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/10_iteration.ipynb index 96f0e1a..3474524 100644 --- a/notebooks/02_CCU/04_prompts_stage1/10_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/10_iteration.ipynb @@ -12,62 +12,17 @@ "Reorganising the code so that it works with multiple replications and is split over multiple steps. The first ensures that all performance measures (e.g. patient counts) are reset to zero at the start of a replication. " ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify Experiment to include a method reset_kpi that resets all of the performance measures to their original values.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class.\n", - "\n", - "\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_10.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_10.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/11_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/11_iteration.ipynb index b2d6ffe..a143a1a 100644 --- a/notebooks/02_CCU/04_prompts_stage1/11_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/11_iteration.ipynb @@ -14,59 +14,15 @@ }, { "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", + "id": "a0459178", "metadata": {}, "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", + "## LLM Prompt\n", "\n", - "import numpy as np\n", - "import math" - ] - }, - { - "cell_type": "markdown", - "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", - "metadata": {}, - "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify CCUModel so that it returns the pandas dataframe instead of printing it out at the end of a run.\n", - "\n", - "Only show the CCUModel class. Do not hide any methods of CCUModel\n", - "\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_11.md\"))" + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_11.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/12_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/12_iteration.ipynb index f73eada..71d91e5 100644 --- a/notebooks/02_CCU/04_prompts_stage1/12_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/12_iteration.ipynb @@ -10,65 +10,17 @@ "## Plain English Summary\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "create a function called \"multiple_replications\". This should be standalone and separate from the CCUModel class. The function accepts an instance of Experiment and the number of replications (default=5) as parameters. The functions logic of each replication is as follows:\n", - "\n", - "1. create a new instance of the model\n", - "2. call the reset KPI function in the experiment \n", - "3. run the model and store the results returned in a \n", - "4. store the returned results of the replication for later use.\n", - "5. add a new column in the results that represent the replication number. This should be the first column of the results table.\n", - "\n", - "After all multiple replications have been completed concatenate all results into a single dataframe. The first column of the dataframe should be an integer representing the replication number. The function returns the results.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_12.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_12.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/13_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/13_iteration.ipynb index 89d3bde..4feadbe 100644 --- a/notebooks/02_CCU/04_prompts_stage1/13_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/13_iteration.ipynb @@ -27,46 +27,20 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math" + "import pandas as pd" ] }, { "cell_type": "markdown", - "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", + "id": "f020e5b9", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Create a new function called \"results_summary\". The function accepts the results dataframe from \"multiple_replications\". The function performs the following:\n", - "\n", - "1. replication column should be dropped\n", - "2. The function calculates the mean, and standard deviation of each column in the dataframe.\n", - "3. The summary function returns as a pandas dataframe containing the results." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_13.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_13.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/14_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/14_iteration.ipynb index 715fb2d..1cb5427 100644 --- a/notebooks/02_CCU/04_prompts_stage1/14_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/14_iteration.ipynb @@ -29,11 +29,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math\n", - "\n", "import simpy" ] }, @@ -42,39 +37,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Add a parameter to Experiment called \"random_number_set\" with default value 0. \n", - "\n", - "Add a method to Experiment called \"setup_streams\". The method should accept an integer parameter called \"random_number_set\". \"setup_streams\" implements the following logic:\n", - "\n", - "1. creates a numpy random number Generator object using \"random_number_set\" as a seed. The generator is used to sample a list of 12 random integer seeds sampled from a uniform distribution with lower bound 0 and an upper bound equal to the systems maximum 64bit integer size.\n", - "2. Loops through \"seeds\" and for each creates a class level instances of numpy random Generator objects passing in each seed as a parameter.\n", - "\n", - "Add a call the \"setup_streams\" method in the __init__ method.\n", - "\n", - "Show the full Experiment class. This should include all methods." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_14.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_14.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/15_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/15_iteration.ipynb index 2b9d9e2..10a491f 100644 --- a/notebooks/02_CCU/04_prompts_stage1/15_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/15_iteration.ipynb @@ -26,12 +26,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -40,34 +34,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the multiple_replications function\n", - "\n", - "before the model is run call the Experiment setup_stream method and pass in the current replication number as an argument.\n", - "\n", - "Show the full multiple_replications function code." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_15.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_15.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/16_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/16_iteration.ipynb index a41abc7..d8f2471 100644 --- a/notebooks/02_CCU/04_prompts_stage1/16_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/16_iteration.ipynb @@ -26,13 +26,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", - "import simpy" + "import pandas as pd" ] }, { @@ -40,34 +34,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the CCUModel class\n", - "\n", - "Each patient generator function should use one of the random number streams from the Experiment class for its sampling.\n", - "\n", - "Show the full Experiment and CCUModel classes including all patient generator and treatment functions.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_16.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_16.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/17_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/17_iteration.ipynb index 6e92834..cdd12ab 100644 --- a/notebooks/02_CCU/04_prompts_stage1/17_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/17_iteration.ipynb @@ -12,63 +12,17 @@ "We now setup the treatment functions to use the r" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", - "import simpy" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the CCUModel class\n", - "\n", - "The treatment functions should use one of the random number streams from the Experiment class for its sampling.\n", - "\n", - "Show the full Experiment and CCUModel classes including all patient generator and treatment functions.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_17.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_17.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/18_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/18_iteration.ipynb index 2ae15e3..9f39e0d 100644 --- a/notebooks/02_CCU/04_prompts_stage1/18_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/18_iteration.ipynb @@ -27,12 +27,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -41,46 +36,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "code a new function called \"get_experiments\". The function should create six Experiment objects. The experiments vary the number of critical care beds. Starting at 23 and increasing to 28. The function should return a dictionary containing an appropriate name for each experiment as the key and the Experiment object as the value.\n", - "\n", - "code a new function called \"run_all_experiments\". The function should accept a dictionary and the number of replications as parameters. The function should loop through each key value pair in the dictionary. On each iteration the following actions are performed:\n", - "\n", - "1. Informs the user of the name of the current experiment\n", - "1. Create an instance of the CCUModel using the current experiment\n", - "2. Call the multiple_replications function\n", - "3. Summarise the results of the experiment using the \"results_summary\" function.\n", - "4. Store the summary dataframe in a dictionary.\n", - "\n", - "Return the summary.\n", - "\n", - "code a new function called \"summary_of_experiments\". The function should accept a dictionary containing a summaries of multiple experiments. The function should combined the summaries into an overall dataframe. The columns of the dataframe should be the name of the experiments. \n", - "\n", - "Return the dataframe.\n", - "\n", - "only show the code for these three functions.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_18.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_18.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/19_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/19_iteration.ipynb index a43ecb1..f0e2c44 100644 --- a/notebooks/02_CCU/04_prompts_stage1/19_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/19_iteration.ipynb @@ -12,68 +12,17 @@ "A streamlit interface will be built in 3 steps. The first step will provide a button for a user to run multiple replications of the model with default values for an experiment. The results are displayed to the user as a simple table.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", - "import simpy" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "write python code that creates an interactive user interface using the package streamlit. \n", - "\n", - "The interface should include a main window.\n", - "\n", - "The main window contains a button labelled \"Simulate\". After the button is pressed the following logic is implemented:\n", - "\n", - "1. display a spinner with the text \"please wait for results\".\n", - "2. call the \"multiple_replications\" function.\n", - "3. call the \"results_summary\" function and the display the results using a dataframe.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_19.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_19.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/20_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/20_iteration.ipynb index 5670c4e..4546db0 100644 --- a/notebooks/02_CCU/04_prompts_stage1/20_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/20_iteration.ipynb @@ -12,66 +12,17 @@ "The first step in creating a streamlit interface adds a sidebar and adds a few parameters to change. Including the \"trace\" option that allows a user to check the simulated log of events.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", - "import simpy" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Add a streamlit sidebar that contains a set of sliders and numeric text boxes that are used to set the parameters in an instance of Experiment. the following parameters should be set:\n", - "\n", - "1. The number of critical care beds\n", - "2. The intensive cleaning duration\n", - "3. Trace\n", - "4. Number of replications\n", - "\n", - "the default values of slider and text boxes should be the same as those in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_20.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_20.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/21_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/21_iteration.ipynb index c705570..1251765 100644 --- a/notebooks/02_CCU/04_prompts_stage1/21_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/21_iteration.ipynb @@ -14,67 +14,17 @@ "The full code listing is available in the [iteration_21.py](iteration_21.py)" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", - "import simpy" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "add the following to the main window of the streamlit interface\n", - "\n", - "1. A title: \"A simulation model of bed-occupancy in a critical care unit\"\n", - "2. Text informing users that the model is a recreation of model reported in a published academic study.\n", - "3. The following citation to the original study \n", - "\n", - "\"J D Griffiths, M Jones, M S Read & J E Williams (2010) A simulation model of bed-occupancy in a critical care unit, Journal of Simulation, 4:1, 52-59, DOI: 10.1057/jos.2009.22\"\n", - " \n", - "3. A link of the original study using this url: https://www.tandfonline.com/doi/full/10.1057/jos.2009.22\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_21.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_21.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/04_prompts_stage1/22_iteration.ipynb b/notebooks/02_CCU/04_prompts_stage1/22_iteration.ipynb index 8fb73b2..2f05b4a 100644 --- a/notebooks/02_CCU/04_prompts_stage1/22_iteration.ipynb +++ b/notebooks/02_CCU/04_prompts_stage1/22_iteration.ipynb @@ -27,12 +27,8 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", "import numpy as np\n", "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -41,32 +37,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the CCUModel class warmup_complete method. After setting patient_count to 0 set the following experiment attributes to zero: total_treatment_time, cancelled_elective_count, mean_waiting_time_unplanned, total_unplanned_admissions\n", - "\n", - "Display all code in the CCUModel class. " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/iteration_22.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/iteration_22.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/00_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/00_iteration_s2.ipynb index 6f7167a..0f605c2 100644 --- a/notebooks/02_CCU/05_prompts_stage2/00_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/00_iteration_s2.ipynb @@ -9,93 +9,21 @@ "\n", "## Plain English Summary\n", "\n", - "The first step in coding a `simpy` model is typically coding the arrivals to the system. In the CCU model there are unplanned(emergency) versus planned (elective) arrivals. Given the logic for unplanned arrivals is the simpler of the two types it is logical to code the arrival of these patients (5 subclasses) first.\n", + "The first step in coding a `simpy` model is typically coding the arrivals to the system. In the CCU model there are unplanned (emergency) versus planned (elective) arrivals. Given the logic for unplanned arrivals is the simpler of the two types it is logical to code the arrival of these patients (5 subclasses) first.\n", "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Code a discrete-event simulation model of a critical care unit (CCU) in python 3.10 and simpy 4. \n", - "\n", - "Please code the full model specified. Do not return a simplified version. Show all code.\n", - "\n", - "### General model logic\n", - "\n", - "All time units in the model are in hours.\n", - "\n", - "Each patient in the model has a unique identifier. The first patient to arrive has an identifier of 0. For each subsequent patient increment the identifier by 1.\n", - "\n", - "Patients to arrive at the CCU from five different sources: Accident and Emergency, the Wards, Emergency surgery, other hospitals, or the X-Ray department. Each source had a different inter-arrival time distribution. After patients arrive they immediately leave the model.\n", - "\n", - "All patient types must have their own generator function\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "the model should include a user settable run length. This defaults to 12 months.\n", - "\n", - "\n", - "### Simulation inputs\n", - "\n", - "the interarrival time distributions and parameters of patients are dependent on patient type. For each distribution time is measured in hours.\n", - "\n", - "Accident and Emergency = Exponential: 22.72\n", - "the Wards = Exponential: 26.0\n", - "Emergency surgery = Exponential: 37.0\n", - "other hospitals = Exponential: 47.2\n", - "the X-Ray department = Exponential: 575.0 \n", - "\n", - "\n", - "### simulation methodology\n", - "\n", - "numpy should be use for sampling.\n", - "\n", - "each interarrival distribution should have its own numpy.random.Generator object." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_0.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_0.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/01_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/01_iteration_s2.ipynb index 26875f9..953bee3 100644 --- a/notebooks/02_CCU/05_prompts_stage2/01_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/01_iteration_s2.ipynb @@ -31,8 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", "import numpy as np\n", "import math" ] @@ -42,60 +40,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in an unplanned admissions treatment process.\n", - "\n", - "Show the full code listing. Do not hide any functions or classes.\n", - "\n", - "### General model logic\n", - "\n", - "The model includes a resource: critical care beds.\n", - "\n", - "After patients have arrived they follow the unplanned admissions process. In the unplanned admissions process patients request and wait for a critical care bed resource to become available in a FIFO queue, and undergo treatment. Following treatment the patient is recorded as \"discharged\", but the bed is not released until intensive cleaning has taken place. \n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "### Simulation inputs\n", - "\n", - "the length of stay (measured in hours) for treatment of patients in the CCU follow source specific distributions\n", - "\n", - "Accident and Emergency: Lognormal: mean 128.79 and standard deviation 267.51\n", - "the Wards = Lognormal: mean 177.89 and standard deviation 276.54\n", - "Emergency surgery = Lognormal: mean 140.15 and standard deviation 218.02\n", - "other hospitals = Lognormal: mean 212.86 and standard deviation 457.67\n", - "the X-Ray department = Lognormal: mean 87.53 and standard deviation 108.67\n", - "\n", - "The mean and standard deviation of the Lognormal distributions must be converted to the mean and standard deviation of the underlying normal distribution.\n", - "\n", - "There are 24 critical care beds in the model. These are shared across all types of patient.\n", - "\n", - "Intensive cleaning takes a fixed amount of time: 5 hours.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_1.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_1.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/02_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/02_iteration_s2.ipynb index 3885960..7c9e175 100644 --- a/notebooks/02_CCU/05_prompts_stage2/02_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/02_iteration_s2.ipynb @@ -16,78 +16,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in an elective admissions treatment process.\n", - "\n", - "Show the full code listing for the model. Do not exclude any functions or classes.\n", - "\n", - "### general simulation logic\n", - "\n", - "Add a new arrival source to the CCU: Elective surgery\n", - "\n", - "Elective surgery patients are modelled as a separate process from the unplanned admissions, but share the critical care bed resources. \n", - "\n", - "As an elective patient arrives to the CCU a check is made on the number of critical care beds available. There are two outcomes from this check\n", - "\n", - "Outcome 1: the number of beds in use is equal to the total number of beds available. In this case the elective patient leaves the model immediately. This is called a \"cancelled operation\" event and should be reported to the user.\n", - "\n", - "Outcome 2. the number of beds in use is less than the total number of beds available. In this case the elective patient requests a critical care bed, is treated, and is then discharged. Before the bed is released for another patient there is an additional delay for intensive cleaning of the area and the bed.\n", - "\n", - "### simulation inputs\n", - "\n", - "the interarrival time of elective surgery patients has a normal distribution with mean 17.91 and standard deviation 3.16.\n", - "\n", - "the treatment time of elective surgery patients is exponential mean: 57.34" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_2.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_2.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/03_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/03_iteration_s2.ipynb index 8fdc295..7147ada 100644 --- a/notebooks/02_CCU/05_prompts_stage2/03_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/03_iteration_s2.ipynb @@ -16,71 +16,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify the code so that all model parameters are stored within a class called Experiment that is separate from the model's logic. \n", - "\n", - "The list of parameters include:\n", - "\n", - "1. the means of the arrival distributions\n", - "2. the unplanned patient treatment time mean and standard deviations.\n", - "3. the elective patients mean treatment time.\n", - "4. The number of critical care beds available\n", - "5. The duration of intensive cleaning following a patient discharge.\n", - "6. simulation run length\n", - "\n", - "The parameters should be passed to the Experiment class constructor method when it is created. please provide default values\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCModel class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_3.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_3.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/04_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/04_iteration_s2.ipynb index 00b6e4d..106434b 100644 --- a/notebooks/02_CCU/05_prompts_stage2/04_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/04_iteration_s2.ipynb @@ -14,66 +14,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows\n", - "\n", - "the model should include a user settable warm up period. This defaults to 1 month.\n", - "\n", - "model run length should be renamed results collection period and have the default value of 12 months. \n", - "\n", - "The total run length of the model is the warm up period plus the results collection period.\n", - "\n", - "the Experiment class should also accept a parameter for the warm up period\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_4.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_4.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/05_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/05_iteration_s2.ipynb index 5c7fb39..999d87f 100644 --- a/notebooks/02_CCU/05_prompts_stage2/05_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/05_iteration_s2.ipynb @@ -16,68 +16,17 @@ "These calculations only use statistics collected in the results collection period.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows:\n", - "\n", - "The code should calculate performance measures at the end of the simulation run. \n", - "\n", - "The following measures should be calculated.\n", - "\n", - "1. The number of elective operations cancelled. \n", - "\n", - "The code should only collect statistics on this performance measure if the simulation time has exceeded the warm-up period.\n", - "\n", - "After the performance measures are calculated the results should outputted in a pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_5.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_5.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/06_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/06_iteration_s2.ipynb index fc599a6..fd88f02 100644 --- a/notebooks/02_CCU/05_prompts_stage2/06_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/06_iteration_s2.ipynb @@ -16,66 +16,17 @@ "These calculations only use statistics collected in the results collection period.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "For both unplanned and elective admissions, after a patient has completed treatment, if the simulation time has exceeded the warm-up period, the patient's treatment time should be added to a running total.\n", - "\n", - "Add in a new performance measure that is calculated at the end of the simulation run called \"bed utilization\". This is calculated as follows:\n", - "\n", - "* The total treatment time divided by (the number of beds multiplied by the results collection period). This is a percentage.\n", - "\n", - "Add the result to the pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_6a.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_6a.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/07_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/07_iteration_s2.ipynb index 31debaf..b51d72a 100644 --- a/notebooks/02_CCU/05_prompts_stage2/07_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/07_iteration_s2.ipynb @@ -16,67 +16,17 @@ "These calculations only use statistics collected in the results collection period.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "For unplanned admissions, track the waiting time for critical care bed. After the patient has taken the bed, if the simulation time has exceeded the warm-up period, the patient's waiting time should be added to a running total and the total number of unplanned admissions should be incremented by 1.\n", - "\n", - "Add in a new performance measure calculation at the end of the simulation run:\n", - "\n", - "* The mean time an unplanned admission had to wait for a critical care bed. \n", - "\n", - "Add the result to the pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_7.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_7.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/08_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/08_iteration_s2.ipynb index f7723f0..95f213d 100644 --- a/notebooks/02_CCU/05_prompts_stage2/08_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/08_iteration_s2.ipynb @@ -18,62 +18,17 @@ "We also make the printing of the simulated trace optional to reduce output when not needed in debugging.\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "Add in a new performance measure that is calculated at the end of the simulation run called \"bed occupancy\". This is calculated by multiplying the bed utilization by the number of critical care beds.\n", - "\n", - "Add the result to the pandas dataframe.\n", - "\n", - "add a new parameter to Experiment called \"trace\". The default value of \"trace\" is False. If \"trace\" is True the model will print out simulated events such as admissions, discharges, or cancellations. The model will always print out the performance at the end of the simulated run." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_8.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_8.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/09_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/09_iteration_s2.ipynb index 78da35b..155b38a 100644 --- a/notebooks/02_CCU/05_prompts_stage2/09_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/09_iteration_s2.ipynb @@ -12,62 +12,17 @@ "The model is already tracking the number of patients. In the paper the authors compare the number of patients generated with real data. We need to reset the patient count when the warm-up period is completed. We do this by introducing a new event that happens only once. This is called \"warm-up complete\"." ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the code as follows: \n", - "\n", - "Create a new generator function in the CCUModel class called \"warmup_complete\". It should be scheduled by simpy to run only once at the end of the warm up period. The logic of the function should set the patient count to zero. If trace is True the model should also print out \"warm-up complete\".\n", - "\n", - "At the end of the simulation run add the patient count to the pandas dataframe.\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the CCUModel class and all code in the Experiment class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_9.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_9.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/10_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/10_iteration_s2.ipynb index 3336c6c..0e6dac8 100644 --- a/notebooks/02_CCU/05_prompts_stage2/10_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/10_iteration_s2.ipynb @@ -12,62 +12,17 @@ "Reorganising the code so that it works with multiple replications and is split over multiple steps. The first ensures that all performance measures (e.g. patient counts) are reset to zero at the start of a replication. " ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify Experiment to include a method reset_kpi that resets all of the performance measures to their original values.\n", - "\n", - "only show the code for Experiment\n", - "\n", - "\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_10.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_10.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/11_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/11_iteration_s2.ipynb index 6f80d50..8f8f0e1 100644 --- a/notebooks/02_CCU/05_prompts_stage2/11_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/11_iteration_s2.ipynb @@ -12,43 +12,17 @@ "Reorganising the code so that it works with multiple replications and is split over multiple steps. The second ensures that a replication of the model returns results as opposed to printing them to the screen." ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_11.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_11.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/12_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/12_iteration_s2.ipynb index 335309a..9e74bad 100644 --- a/notebooks/02_CCU/05_prompts_stage2/12_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/12_iteration_s2.ipynb @@ -25,11 +25,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math" + "import pandas as pd" ] }, { @@ -37,37 +33,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "create a function called \"multiple_replications\". This should be standalone and separate from the CCUModel class. The function accepts an instance of Experiment and the number of replications (default=5) as parameters. The functions logic of each replication is as follows:\n", - "\n", - "1. create a new instance of the model\n", - "2. call the reset_kpi function in the experiment \n", - "3. run the model and store the results returned in a \n", - "4. store the returned results of the replication for later use.\n", - "\n", - "After all multiple replications have been completed concatenate all results into a single dataframe. The first column of the dataframe should be an integer representing the replication number. The function returns the results.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_12.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_12.md\n", + ":::\n", + "::::## LLM Prompt " ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/13_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/13_iteration_s2.ipynb index f0e644a..1e65286 100644 --- a/notebooks/02_CCU/05_prompts_stage2/13_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/13_iteration_s2.ipynb @@ -27,11 +27,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math" + "import pandas as pd" ] }, { @@ -39,17 +35,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_13.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_13.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/14_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/14_iteration_s2.ipynb index cf7ed6a..d2533d0 100644 --- a/notebooks/02_CCU/05_prompts_stage2/14_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/14_iteration_s2.ipynb @@ -29,11 +29,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import math\n", - "\n", "import simpy" ] }, @@ -42,17 +37,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_14.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_14.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/15_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/15_iteration_s2.ipynb index c6101d7..8743e1a 100644 --- a/notebooks/02_CCU/05_prompts_stage2/15_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/15_iteration_s2.ipynb @@ -26,12 +26,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -40,17 +34,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_15.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_15.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/16_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/16_iteration_s2.ipynb index 8c48789..8ca5633 100644 --- a/notebooks/02_CCU/05_prompts_stage2/16_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/16_iteration_s2.ipynb @@ -26,12 +26,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -40,34 +35,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the CCUModel class\n", - "\n", - "Each patient generator function should use one of the random number streams from the Experiment class for its sampling.\n", - "\n", - "Show the full Experiment and CCUModel classes including all patient generator and treatment functions.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_16.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_16.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/17_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/17_iteration_s2.ipynb index 61e0bc1..372ba33 100644 --- a/notebooks/02_CCU/05_prompts_stage2/17_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/17_iteration_s2.ipynb @@ -27,12 +27,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -41,17 +35,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_17.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_17.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/18_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/18_iteration_s2.ipynb index cb157bd..1096228 100644 --- a/notebooks/02_CCU/05_prompts_stage2/18_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/18_iteration_s2.ipynb @@ -27,12 +27,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -41,46 +36,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "code a new function called \"get_experiments\". The function should create six Experiment objects. The experiments vary the number of critical care beds. Starting at 23 and increasing to 28. The function should return a dictionary containing an appropriate name for each experiment as the key and the Experiment object as the value.\n", - "\n", - "code a new function called \"run_all_experiments\". The function should accept a dictionary and the number of replications as parameters. The function should loop through each key value pair in the dictionary. On each iteration the following actions are performed:\n", - "\n", - "1. Informs the user of the name of the current experiment\n", - "1. Create an instance of the CCUModel using the current experiment\n", - "2. Call the multiple_replications function\n", - "3. Summarise the results of the experiment using the \"results_summary\" function.\n", - "4. Store the summary dataframe in a dictionary.\n", - "\n", - "Return the summary.\n", - "\n", - "code a new function called \"summary_of_experiments\". The function should accept a dictionary containing a summaries of multiple experiments. The function should combined the summaries into an overall dataframe. The columns of the dataframe should be the name of the experiments. \n", - "\n", - "Return the dataframe.\n", - "\n", - "only show the code for these three functions.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_18.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_18.md\n", + ":::\n", + "::::## LLM Prompt" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/19_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/19_iteration_s2.ipynb index c2e0110..8a918e3 100644 --- a/notebooks/02_CCU/05_prompts_stage2/19_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/19_iteration_s2.ipynb @@ -27,31 +27,21 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, { "cell_type": "markdown", - "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", - "metadata": {}, - "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", + "id": "8828a575", "metadata": {}, - "outputs": [], "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_19.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_19.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/20_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/20_iteration_s2.ipynb index 33d7b91..38a4026 100644 --- a/notebooks/02_CCU/05_prompts_stage2/20_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/20_iteration_s2.ipynb @@ -27,12 +27,8 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", "import numpy as np\n", "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -41,17 +37,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_20.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_20.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/21_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/21_iteration_s2.ipynb index f35823a..96cc7ea 100644 --- a/notebooks/02_CCU/05_prompts_stage2/21_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/21_iteration_s2.ipynb @@ -29,12 +29,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -43,17 +38,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_21.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_21.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/02_CCU/05_prompts_stage2/22_iteration_s2.ipynb b/notebooks/02_CCU/05_prompts_stage2/22_iteration_s2.ipynb index 14b4f7f..07c6f0c 100644 --- a/notebooks/02_CCU/05_prompts_stage2/22_iteration_s2.ipynb +++ b/notebooks/02_CCU/05_prompts_stage2/22_iteration_s2.ipynb @@ -33,12 +33,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "\n", - "import numpy as np\n", - "import pandas as pd\n", - "import math\n", - "\n", "import simpy" ] }, @@ -47,32 +41,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the CCUModel class warmup_complete method. After setting patient_count to 0 set the following experiment attributes to zero: total_treatment_time, cancelled_elective_count, mean_waiting_time_unplanned, total_unplanned_admissions\n", - "\n", - "Display all code in the CCUModel class. " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../04_prompts_stage1/inputs/iteration_22.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/iteration_22.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/00_stress_report.md b/notebooks/03_stroke/00_stress_report.md index f8d974c..0b6bafa 100644 --- a/notebooks/03_stroke/00_stress_report.md +++ b/notebooks/03_stroke/00_stress_report.md @@ -1,6 +1,6 @@ # STRESS report -It is often difficult to fully understand the design of a simulation model and how it has been implemented. To try an increase the transparency of our work we have followed the Strengthening the Reporting of Empirical Simulation Studies (STRESS) guidelines for Discrete-Event Simulation {cite:p}`stress_guidelines`. While we have attempted to be transparent we welcome queries, suggestions of clarification to improve the documentation. +It is often difficult to fully understand the design of a simulation model and how it has been implemented. To try and increase the transparency of our work we have followed the Strengthening the Reporting of Empirical Simulation Studies (STRESS) guidelines for Discrete-Event Simulation {cite:p}`stress_guidelines`. While we have attempted to be transparent we welcome queries, suggestions of clarification to improve the documentation. ## References diff --git a/notebooks/03_stroke/04_prompts_stage1/01_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/01_iteration.ipynb index 3d74360..6397697 100644 --- a/notebooks/03_stroke/04_prompts_stage1/01_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/01_iteration.ipynb @@ -19,88 +19,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Code a discrete-event simulation model of an Acute Stroke Unit (ACU) in python 3.10 and simpy 4. \n", - "\n", - "Please code the full model specified. Do not return a simplified version. Show all code.\n", - "\n", - "### General model logic\n", - "\n", - "All time units in the model are in days.\n", - "\n", - "The model should count the total number of patient arrivals. The first patient to arrive has an identifier of 0. For each subsequent patient increment the identifier by 1. The model should also maintain counts of the number of patients broken down by their type.\n", - "\n", - "Patients to arrive at the ACU from four different sources: Stroke, TIA, Complex Neurological, or Other. Each source had a different inter-arrival time distribution. After patients arrive they immediately leave the model.\n", - "\n", - "All patient types must have their own generator function.\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "The model should include a user settable run length. This defaults to 5 years.\n", - "\n", - "\n", - "### Simulation inputs\n", - "\n", - "the interarrival time distributions and parameters of patients are dependent on patient type. For each distribution time is measured in days.\n", - "\n", - "Stroke = Exponential: 1.2\n", - "TIA = Exponential: 9.3\n", - "Complex Neurological = Exponential: 3.6\n", - "Other = Exponential: 3.2\n", - "\n", - "\n", - "### simulation methodology\n", - "\n", - "numpy should be use for sampling.\n", - "\n", - "each interarrival distribution should have its own numpy.random.Generator object." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/01_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/01_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/02_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/02_iteration.ipynb index b8402f1..c01b9ab 100644 --- a/notebooks/03_stroke/04_prompts_stage1/02_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/02_iteration.ipynb @@ -13,78 +13,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to sample a patients destination after they have left the acute stroke unit (ASU).\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the ASU class.\n", - "\n", - "### General model logic\n", - "\n", - "After patients have arrived the model immediately samples their destination after the ASU. Destinations are:\n", - "\n", - "1. Rehab\n", - "2. ESD \n", - "3. Other\n", - "\n", - "Create a variable called \"post_asu_destination\". This variable is used to record the sampled destination of the patient.\n", - "\n", - "### Simulation inputs\n", - "\n", - "The sampling distribution are specific to the patient type.\n", - "\n", - "Stroke = Discrete Empirical: 24, 13, 63\n", - "TIA = Discrete Empirical: 1, 1, 98\n", - "Complex-neurological = Discrete Empirical: 11, 5, 84\n", - "Other = Discrete Empirical 5, 10, 85\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/02_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/02_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/03_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/03_iteration.ipynb index 54be90d..a3d2f04 100644 --- a/notebooks/03_stroke/04_prompts_stage1/03_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/03_iteration.ipynb @@ -13,88 +13,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in four new `acute_treatment` methods to the ASU class each patient type i.e. Stroke, TIA, Complex Neurological, and other. Prefix the method names with the patient type e.g. `stroke_acute_treatment`\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the ASU class.\n", - "\n", - "### General model logic\n", - "\n", - "Add the following logic\n", - "\n", - "1. After a patient has been generated call `acute_treatment` as a simpy process. Pass the patient type to the method. Do not use the yield statement when calling this method.\n", - "2. sample a length of stay (measured in days) for treatment of patients\n", - "3. yield a simpy timeout equal to the length of stay for treatment\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "### Simulation inputs\n", - "\n", - "the length of stay (measured in days) for treatment of patients in the ASU follow source specific distributions\n", - "\n", - "if patient type = Stroke and post_asu_destination = Rehab then Lognormal: mean 7.4 and standard deviation 8.6\n", - "\n", - "if patient type = Stroke and post_asu_destination = ESD then Lognormal: mean 4.6 and standard deviation 4.8\n", - "\n", - "if patient type = Stroke and post_asu_destination = Other then Lognormal: mean 7.0 and standard deviation 8.7\n", - "\n", - "if patient type = TIA then Lognormal: mean 1.8 and standard deviation 5.0\n", - "\n", - "if patient type = Complex Neurological then Lognormal: mean 4.0 and standard deviation 5.0\n", - "\n", - "if patient type = Other then Lognormal: mean 3.8 and standard deviation 5.2\n", - "\n", - "The mean and standard deviation of the Lognormal distributions must be converted to the mean and standard deviation of the underlying normal distribution.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/03_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/03_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/04_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/04_iteration.ipynb index 0bd2446..3215c9e 100644 --- a/notebooks/03_stroke/04_prompts_stage1/04_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/04_iteration.ipynb @@ -27,8 +27,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -37,35 +35,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "modify all `acute_treatment `functions to call a function external to the class called `normal_moments_from_lognormal`. The function should accept the mean and standard deviation of a Lognormal distribution and return the mu, sigma of the underlying Normal distribution. The returned values are the correct values to use when sampling from the Lognormal distributions. \n", - "\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the ASU class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/04_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/04_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/05_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/05_iteration.ipynb index 442a250..b14d7af 100644 --- a/notebooks/03_stroke/04_prompts_stage1/05_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/05_iteration.ipynb @@ -29,8 +29,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -39,42 +37,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify the code so that all model parameters are stored within a class called Experiment that is separate from the model's logic. \n", - "\n", - "The list of parameters include:\n", - "\n", - "1. the means of the arrival distributions\n", - "2. the means and standard deviations of the lognormal distributions\n", - "3. simulation run length\n", - "\n", - "The parameters should be passed to the Experiment class constructor method when it is created. please provide default values\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the AcuteStrokeUnit class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/05_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/05_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/06_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/06_iteration.ipynb index 18778c3..a4d211e 100644 --- a/notebooks/03_stroke/04_prompts_stage1/06_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/06_iteration.ipynb @@ -31,8 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -41,33 +39,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `AcuteStrokeUnit` class as follows: create a member variable called `occupancy`. Increment the `occupancy` member variable when a patient arrives to the ASU. Decrement the `occupancy` member variable at the end of the `acute_treatment` functions\n", - "\n", - "output only the AcuteStrokeUnit\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/06_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/06_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/07_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/07_iteration.ipynb index d5bec8c..58e312e 100644 --- a/notebooks/03_stroke/04_prompts_stage1/07_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/07_iteration.ipynb @@ -31,8 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -41,32 +39,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt a" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "add a new parameter to Experiment called \"trace\". The default value of \"trace\" is False. If the AcuteStrokeUnit has \"self.experiment.trace\" set to True the model will print out simulated events such as patient arrivals and discharges. \n", - "\n", - "output only the Experiment class for now. " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/07a_iteration.md\"))" + "## LLM Prompt a\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/07a_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -74,30 +52,12 @@ "id": "a970542d-0848-4cd4-896c-a974d31ab2ea", "metadata": {}, "source": [ - "## LLM Prompt b" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "46d6d48b-ba24-4cde-8abd-aca254485c65", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "now output the modified AcuteStrokeUnit Class" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/07b_iteration.md\"))" + "## LLM Prompt b\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/07b_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/08_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/08_iteration.ipynb index a6cdfdb..a2b2855 100644 --- a/notebooks/03_stroke/04_prompts_stage1/08_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/08_iteration.ipynb @@ -29,8 +29,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -40,32 +38,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Create a new simpy generator function called `audit_acute_occupancy` that accepts parameters `acute_audit_interval`, an instance of the `AcuteStrokeUnit` called `asu`, and an instance `Experiment` called `experiment`. The function repeatedly records the occupancy of `asu` after `acute_audit_interval` time units. The occupancy is appended to a member variable `experiment` python list called `asu_occupancy` \n", - "\n", - "Output the `audit_acute_occupancy` function, modified `Experiment` class, and script to run the model and `audit_acute_occupancy`. `acute_audit_interval` should be set to 1 day." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/08_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/08_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/09_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/09_iteration.ipynb index ebbc8bd..72c62cc 100644 --- a/notebooks/03_stroke/04_prompts_stage1/09_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/09_iteration.ipynb @@ -34,8 +34,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -45,35 +43,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "create a function in python called `calculate_occupancy_frequencies` that accepts a python list of integer values. The function should use numpy to calculate the relative and cumulative frequencies of the numbers. The function should return a tuple containing the relative frequency, cumulative frequency, and the unique values. \n", - "\n", - "The relative frequency, unique values, a string called \"x_label\" (default value = \"No. people in ASU\"), and figure size (default = (12, 5)) should be passed to a function called `occupancy_plot` that creates a matplotlib bar chart of the relative frequency. the x axis values are taken from the unique values parameter. The x axis ticks should run from 0 to 30 and all values should be displayed. the x axis is label is set to the value of \"x_label\" The function `occupancy_plot` returns the matplotlib figure and axis objects to the calling code. \n", - "\n", - "The output should display the full script for creating a default `Experiment` and running the simulation model. Modify the script as follows: After the simulation model experiment is complete the code should call `calculate_occupancy_frequencies` and pass the \"asu_occupancy\" list as a parameter. The code should then use `occupancy_plot` and show the returned plot.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/09_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/09_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/10_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/10_iteration.ipynb index 769ed05..8976335 100644 --- a/notebooks/03_stroke/04_prompts_stage1/10_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/10_iteration.ipynb @@ -34,8 +34,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -45,40 +43,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "code a function `calculate_prob_delay` that accepts to array-like parameters: relative and cumulative frequencies. The function should convert the parameters to numpy arrays and calculate and return relative / cumulative frequency (prob_delay)\n", - "\n", - "The prob_delay, unique values, a string called \"x_label\" (default value = \"No. acute beds available\"), and figure size (default = (12, 5)) should be passed to a function called `prob_delay_plot` that creates a matplotlib step chart of the prob_delay. the x axis values are taken from the unique values parameter. The x axis ticks should run from 0 to 30 and all values should be displayed. the x axis is label is set to the value of \"x_label\" Return the matplotlib figure and axis objects. \n", - "\n", - "Display the new functions and the script to\n", - "\n", - "1. create an experiment,\n", - "2. run the model\n", - "3. calculate the relative and cumulative frequencies\n", - "4. creates the step chart.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/10_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/10_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/11_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/11_iteration.ipynb index d0605c3..15766f0 100644 --- a/notebooks/03_stroke/04_prompts_stage1/11_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/11_iteration.ipynb @@ -31,8 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -42,44 +40,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the patient_generator functions adding back in the sampling of `post_asu_destination` for tia, complex neurological and other patients. \n", - "\n", - "use the following data to sample Rehab, ESD, or Other destinations. \n", - "\n", - "TIA = Discrete Empirical: 0.01, 0.01, 0.98\n", - "Complex-neurological = Discrete Empirical: 0.11, 0.05, 0.84\n", - "Other = Discrete Empirical 0.05, 0.10, 0.85\n", - "\n", - "show all methods in the AcuteStrokeUnit class" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/11_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/11_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/12_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/12_iteration.ipynb index 84ac712..828f414 100644 --- a/notebooks/03_stroke/04_prompts_stage1/12_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/12_iteration.ipynb @@ -43,8 +43,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -60,59 +58,12 @@ "tags": [] }, "source": [ - "(mylabel)=\n", - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Add a class representing the process at a Rehabilitation Unit (RU) called `RehabilitationUnit`\n", - "\n", - "### General model logic\n", - "\n", - "The RehabilitationUnit class should count the total number of patient arrivals. The first patient to arrive has an identifier of 0. For each subsequent patient increment the identifier by 1. The model should also maintain counts of the number of patients broken down by their type.\n", - "\n", - "Patients to arrive at the RU from three different sources: Stroke, Complex Neurological, or Other. Each source had a different inter-arrival time distribution. After patients arrive they immediately leave the model.\n", - "\n", - "All patient types must have their own generator function.\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "### Simulation inputs\n", - "\n", - "the interarrival time distributions and parameters of patients are dependent on patient type. For each distribution time is measured in days.\n", - "\n", - "Stroke = Exponential: 21.8\n", - "Complex Neurological = Exponential: 31.7\n", - "Other = Exponential: 28.6\n", - "\n", - "Add three class member variables for the mean of each distribution. For example `self.stroke_iat_external`" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/12_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/12_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/13_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/13_iteration.ipynb index 392e06c..e1100fe 100644 --- a/notebooks/03_stroke/04_prompts_stage1/13_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/13_iteration.ipynb @@ -49,8 +49,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -66,101 +65,17 @@ "tags": [] }, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify `Experiment` class below. Add three new inter-arrival means for stroke complex neurological and other patient types. These should be called `rehab_stroke_iat`, `rehab_neuro_iat`, `rehab_other_iat`. These inter-arrival means should be passed to the `Experiment` class constructor method when it is created. please provide default values using the values in `RehabilitationUnit`. Do not remove or overwrite any existing parameters.\n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " run_length=1825, trace=False):\n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.run_length = run_length\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - "```\n", - "\n", - "Modify the `RehabilitationUnit` class to accept an instance of `Experiment` and store as a member variable.\n", - "\n", - "\n", - "Display the modified `Experiment` and `RehabilitationUnit` classes.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/13_iteration.md\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "6f6e35f4-8ba0-4e38-a2c8-1cb85c385799", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Modify the script to run the model as follows:\n", - "\n", - "1. create an experiment,\n", - "2. create an instance RehabilitationUnit\n", - "3. run the model" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/13a_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/13_iteration.md\n", + ":::\n", + "::::\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/13a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/14_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/14_iteration.ipynb index b350db7..524765d 100644 --- a/notebooks/03_stroke/04_prompts_stage1/14_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/14_iteration.ipynb @@ -47,8 +47,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,69 +63,12 @@ "tags": [] }, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in three new `rehab_treatment` methods to the `RehabilitationUnit` class each patient type i.e. Stroke, Complex Neurological, and other. Prefix the method names with the patient type e.g. `stroke_rehab_treatment`\n", - "\n", - "Show only the RehabilitationUnit class code: this includes all patient generator functions\n", - "\n", - "### General model logic\n", - "\n", - "Add the following logic\n", - "\n", - "1. After a patient has been generated call `rehab_treatment` as a simpy process. Pass the patient type. Do not use the yield statement when calling this method. \n", - "2. sample a post rehab destination. The options are ESD or Other. Store the result in `post_rehab_destination`\n", - "3. sample a length of stay (measured in days) for treatment of patients. store the result in `length_of_stay`\n", - "4. yield a simpy timeout equal to the length of stay for treatment\n", - "5. Print out information detailing the completion of a patient treatment.\n", - "\n", - "### Simulation inputs\n", - "\n", - "The sampling distribution for post_rehab_destination is specific to the patient type.\n", - "\n", - "Stroke = Discrete Empirical: 40, 60\n", - "Complex-neurological = Discrete Empirical: 9, 91\n", - "Other = Discrete Empirical 12, 88\n", - "\n", - "the length of stay (measured in days) for treatment of patients in the RehabilitationUnit follow source specific distributions\n", - "\n", - "if patient type = Stroke and post_rehab_destination = ESD then Lognormal: mean 30.3 and standard deviation 23.1\n", - "\n", - "if patient type = Stroke and post_rehab_destination = Other then Lognormal: mean 28.4 and standard deviation 27.2\n", - "\n", - "if patient type = Complex Neurological then Lognormal: mean 27.6 and standard deviation 28.4\n", - "\n", - "if patient type = Other then Lognormal: mean 16.1 and standard deviation 14.1\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/14_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/14_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/15_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/15_iteration.ipynb index 3501d72..b6795ab 100644 --- a/notebooks/03_stroke/04_prompts_stage1/15_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/15_iteration.ipynb @@ -49,8 +49,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -66,49 +64,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify the `Experiment` class. Add new parameters that represent\n", - "\n", - "1. the means and standard deviations of the lognormal distributions used in `RehabilitationUnit` class.\n", - "2. the probabilities of the Empirical distributions (represented as python lists)\n", - "\n", - "pre fix all parameters with \"rehab_\"\n", - "\n", - "Do not remove or overwrite any existing parameters in `Experiment`\n", - "\n", - "Modify `RehabilitationUnit` to use the new parameters.\n", - "\n", - "Display only the modified `Experiment` class" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/15_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/15_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -116,30 +77,12 @@ "id": "e4efd9f0-e06a-4937-833b-ae73a69f0d31", "metadata": {}, "source": [ - "## LLM Prompt 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "21234327-9a4e-484d-b424-5916a2523ec2", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Display only the `RehabilitationUnit` class code" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/15a_iteration.md\"))" + "## LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/15a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/16_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/16_iteration.ipynb index 3c0f147..d95710e 100644 --- a/notebooks/03_stroke/04_prompts_stage1/16_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/16_iteration.ipynb @@ -47,8 +47,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,49 +63,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Add a new method the `RehabilitationUnit` class to model TIA patient treatment called `tia_rehab_treatment`. The method should have the same code structure as the other treatment methods in `RehabilitationUnit` and include print statements for events.\n", - "\n", - "Do not add a new TIA patient generator method to the class.\n", - "\n", - "Show only the `RehabilitationUnit` class code.\n", - "\n", - "### Simulation inputs\n", - "\n", - "The sampling distribution for post_rehab_destination of TIA patients is Discrete Empirical: 0, 100\n", - "\n", - "the length of stay (measured in days) for treatment of TIA patients is Lognormal: mean 18.7 and standard deviation 23.5\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/16_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/16_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/17_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/17_iteration.ipynb index 435101f..264c284 100644 --- a/notebooks/03_stroke/04_prompts_stage1/17_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/17_iteration.ipynb @@ -48,8 +48,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -65,40 +64,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `RehabilitationUnit` class as follows: create a member variable called `occupancy`. Increment the `occupancy` member variable when a patient arrives to the `RehabilitationUnit`. Decrement the `occupancy` member variable at the end of the `rehab_treatment` functions\n", - "\n", - "modify the `RehabilitationUnit` class. Only print out events if `self.experiment.trace` is True.\n", - "\n", - "output only the `RehabilitationUnit` class code" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/17_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/17_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/18_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/18_iteration.ipynb index 91ceb07..1a2f09d 100644 --- a/notebooks/03_stroke/04_prompts_stage1/18_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/18_iteration.ipynb @@ -47,8 +47,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,172 +63,25 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Create a new simpy generator function called `audit_rehab_occupancy` that accepts parameters `env`, `rehab_audit_interval`, an instance of the `RehabilitationUnit` called `rehab_unit`, and an instance `Experiment` called experiment. The function repeatedly records the occupancy of `rehab_unit` after `rehab_audit_interval` time units. The occupancy is appended `rehab_occupancy` in the experiment class. Do not append env.now\n", - "\n", - "\n", - "Modify the `Experiment` class below. Add a new python list member variable to `__init__` called `rehab_occupancy` underneath `asu_occupancy`. \n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " run_length=1825, trace=False,\n", - " rehab_stroke_iat=21.8, rehab_neuro_iat=31.7, rehab_other_iat=28.6,\n", - " rehab_stroke_esd_mean=30.3, rehab_stroke_esd_std_dev=23.1,\n", - " rehab_stroke_other_mean=28.4, rehab_stroke_other_std_dev=27.2,\n", - " rehab_neuro_mean=27.6, rehab_neuro_std_dev=28.4,\n", - " rehab_other_mean=16.1, rehab_other_std_dev=14.1,\n", - " rehab_stroke_post_destination_prob=[0.4, 0.6],\n", - " rehab_neuro_post_destination_prob=[0.09, 0.91],\n", - " rehab_other_post_destination_prob=[0.12, 0.88]):\n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.run_length = run_length\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - " \n", - " \n", - " # New parameters for RehabilitationUnit treatment distributions and probabilities\n", - " self.rehab_stroke_iat = rehab_stroke_iat\n", - " self.rehab_neuro_iat = rehab_neuro_iat\n", - " self.rehab_other_iat = rehab_other_iat\n", - " \n", - " self.rehab_stroke_esd_mean = rehab_stroke_esd_mean\n", - " self.rehab_stroke_esd_std_dev = rehab_stroke_esd_std_dev\n", - " \n", - " self.rehab_stroke_other_mean = rehab_stroke_other_mean\n", - " self.rehab_stroke_other_std_dev = rehab_stroke_other_std_dev\n", - " \n", - " self.rehab_neuro_mean = rehab_neuro_mean\n", - " self.rehab_neuro_std_dev = rehab_neuro_std_dev\n", - " \n", - " self.rehab_other_mean = rehab_other_mean\n", - " self.rehab_other_std_dev = rehab_other_std_dev\n", - " \n", - " # Probabilities for post-rehab destination sampling for each patient type in RehabilitationUnit\n", - " self.rehab_stroke_post_destination_prob = rehab_stroke_post_destination_prob\n", - " self.rehab_neuro_post_destination_prob = rehab_neuro_post_destination_prob\n", - " self.rehab_other_post_destination_prob = rehab_other_post_destination_prob\n", - "```\n", - "\n", - "\n", - "Display only the `audit_rehab_occupancy` function and modified `Experiment` class. Show all code in `Experiment.__init__`\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/18_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/18_iteration.md\n", + ":::\n", + "::::" ] }, { - "cell_type": "code", - "execution_count": 3, - "id": "d6c96bfc-92ce-41e6-8e4a-041e88f2a611", + "cell_type": "markdown", + "id": "8ef37c70", "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Modify the script to run the model as follows:\n", - "\n", - "1. create an experiment\n", - "2. create an instance of a simpy environment\n", - "3. create an instance RehabilitationUnit\n", - "4. initialise the patient generators as simpy processes\n", - "5. initialise the audit of rehab occupancy as a simpy process. Use an interval of 1 day.\n", - "6. run the model for the default run length in the experiment * 10\n", - "7. use `calculate_occupancy_frequencies` to calculate occupancy frequencies of the rehab occupancy\n", - "8. use `occupancy_plot` to display an occupancy plot for the rehab unit. The x axis should be labelled \"No. of people in rehab\"\n", - "9. use `calculate_prob_delay` to calculate the probability of delay for rehab\n", - "10. use `prob_delay_plot` to display a prob of delay plot for rehab. The x label is \"No. rehab beds available\"\n", - "\n", - "```python\n", - "def calculate_occupancy_frequencies(data):\n", - " unique_values, counts = np.unique(data, return_counts=True)\n", - " relative_frequency = counts / len(data)\n", - " cumulative_frequency = np.cumsum(relative_frequency)\n", - " return relative_frequency, cumulative_frequency, unique_values\n", - "\n", - "\n", - "def occupancy_plot(relative_frequency, unique_values, x_label=\"No. people in ASU\", fig_size=(12, 5)):\n", - " fig, ax = plt.subplots(figsize=fig_size)\n", - " ax.bar(unique_values, relative_frequency, align='center', alpha=0.7)\n", - " ax.set_xticks(np.arange(0, 31, 1))\n", - " ax.set_xlabel(x_label)\n", - " ax.set_ylabel('Relative Frequency')\n", - " plt.grid(axis='y', linestyle='--', alpha=0.6)\n", - " plt.title('Occupancy Relative Frequency Distribution')\n", - " plt.show()\n", - " return fig, ax\n", - "\n", - "def calculate_prob_delay(relative_frequencies, cumulative_frequencies):\n", - " prob_delay = np.array(relative_frequencies) / np.array(cumulative_frequencies)\n", - " return prob_delay\n", - "\n", - "def prob_delay_plot(prob_delay, unique_values, x_label=\"No. acute beds available\", fig_size=(12, 5)):\n", - " fig, ax = plt.subplots(figsize=fig_size)\n", - " ax.step(unique_values, prob_delay, where='post')\n", - " ax.set_xticks(np.arange(0, 31, 1))\n", - " ax.set_xlabel(x_label)\n", - " ax.set_ylabel('Probability of Delay')\n", - " plt.grid(axis='y', linestyle='--', alpha=0.6)\n", - " plt.title('Probability of Delay Distribution')\n", - " plt.show()\n", - " return fig, ax\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], "source": [ - "display(Markdown(\"inputs/18a_iteration.md\"))" + "## LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/18a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/19_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/19_iteration.ipynb index 4cb9b5b..9ba3107 100644 --- a/notebooks/03_stroke/04_prompts_stage1/19_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/19_iteration.ipynb @@ -52,8 +52,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -69,141 +67,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `AcuteStrokeUnit` constructor to accept and store instance of `RehabilitationUnit` as a member variable called `rehab_unit`\n", - "\n", - "modify all methods in `AcuteStrokeUnit` postfixed with \"acute_treatment\" to accept `post_asu_destination` as a parameter. \n", - "Update all patient generator methods that call \"acute_treatment\" functions. \n", - "Rename `patient_type` in s`troke_acute_treatment` to `post_asu_destination`\n", - "\n", - "\n", - "\n", - "show all of the `AcuteStrokeUnit` code including all treatment and generator functions. \n", - "\n", - "```python\n", - "class AcuteStrokeUnit:\n", - " def __init__(self, env, experiment):\n", - " self.env = env\n", - " self.experiment = experiment\n", - " self.patient_count = 0\n", - " self.occupancy = 0\n", - "\n", - " def stroke_acute_treatment(self, patient_type):\n", - " if patient_type == \"Rehab\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_mean, self.experiment.rehab_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " elif patient_type == \"ESD\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.esd_mean, self.experiment.esd_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " else:\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean, self.experiment.other_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def tia_acute_treatment(self):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.tia_dest_mean, self.experiment.tia_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def neuro_acute_treatment(self):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.neuro_dest_mean, self.experiment.neuro_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def other_acute_treatment(self):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean_2, self.experiment.other_dest_std_dev_2)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def stroke_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.stroke_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.24, 0.13, 0.63])\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.stroke_acute_treatment(post_asu_destination))\n", - "\n", - " def tia_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.tia_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.01, 0.01, 0.98])\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.tia_acute_treatment())\n", - "\n", - " def neuro_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.neuro_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.11, 0.05, 0.84])\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.neuro_acute_treatment())\n", - "\n", - " def other_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.other_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.05, 0.10, 0.85])\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.other_acute_treatment())\n", - "```\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/19_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/19_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/20_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/20_iteration.ipynb index 47c136d..4f53472 100644 --- a/notebooks/03_stroke/04_prompts_stage1/20_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/20_iteration.ipynb @@ -52,8 +52,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -69,40 +67,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "append new code to the end of four methods in `AcuteStrokeUnit` postfixed with \"acute_treatment\": if `post_asu_destination` is \"Rehab\" then a.) incrememnt `rehab_unit.occupancy` and then b.) call the `rehab_unit` function with the same patient_type as a simpy process. For example, `stroke_patient_generator` called `rehab_unit.stroke_rehab_treatment`. Do not pass any parameters. The code should be located after \"self.occupancy -= 1\". Do not use the yield keyword. \n", - "\n", - "Display all code in the `AcuteStrokeUnit class including all treatment and patient generator methods.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/20_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/20_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -110,115 +80,12 @@ "id": "2bcf6d11-0f77-4b35-9e26-23c43d0204be", "metadata": {}, "source": [ - "## LLM Prompt 2 (for creating a script to run both models)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "06d9c5b2-5df5-4f7f-b899-66882b20aa70", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Combine the two scripts below create a new single script that follows these steps:\n", - "\n", - "1. create an instance of `Experiment`\n", - "2. create an instance of a simpy environment\n", - "3. create an instance RehabilitationUnit \n", - "4. create an instance of AcuteStrokeUnit. Pass the RehabilitationUnit as a parameter\n", - "5. initialise the four methods postfixed with \"generator\" in AcuteStrokeUnit as simpy processes\n", - "6. initialise the three methods postfixed with \"generator\" in RehabilitationUnit simpy processes\n", - "7. initialise the audit of rehab occupancy as a simpy process. Use an interval of 1 day. Pass in env\n", - "8. initialise the audit of the AcuteStrokeUnit occupancy as a simpy process. Use an interval of 1 day.\n", - "9. run the model for the default run length in the experiment * 50\n", - "10. use `calculate_occupancy_frequencies` to calculate occupancy frequencies of both the AcuteStrokeUnit and the rehab occupancy\n", - "11. use `calculate_prob_delay` to calculate the probability of delay for AcuteStrokeUnit and rehab \n", - "12. use `prob_delay_plot` to display a prob of delay plot for AcuteStrokeUnit and rehab. Use appropriate x_label values for the AcuteStrokeUnit and rehab unit\n", - "\n", - "Only show the code in the script. Do no modify the functions or classes used.\n", - "\n", - "```python\n", - "# Create an instance of the Experiment class with default parameters and trace set to False\n", - "default_experiment_params = Experiment()\n", - "\n", - "# Create the simulation environment and AcuteStrokeUnit instance with the Experiment parameters\n", - "env = simpy.Environment()\n", - "\n", - "## MODIFIED BY TESTER\n", - "# create instance of RU, but we do not run the model at this stage\n", - "rehab_unit = RehabilitationUnit(env, default_experiment_params)\n", - "##\n", - "\n", - "acu_experiment = AcuteStrokeUnit(env, default_experiment_params, rehab_unit)\n", - "\n", - "# Start the patient generators for each type of patient in the AcuteStrokeUnit instance\n", - "env.process(acu_experiment.stroke_patient_generator())\n", - "env.process(acu_experiment.tia_patient_generator())\n", - "env.process(acu_experiment.neuro_patient_generator())\n", - "env.process(acu_experiment.other_patient_generator())\n", - "\n", - "# Start the audit_acute_occupancy generator function to record ASU occupancy at intervals\n", - "env.process(audit_acute_occupancy(1, acu_experiment, default_experiment_params))\n", - "\n", - "# Run the simulation until the specified run length in the Experiment parameters\n", - "# modified by tester - run length * 10\n", - "env.run(until=default_experiment_params.run_length * 10)\n", - "\n", - "# Calculate occupancy frequencies and plot the relative frequency distribution\n", - "relative_freq, cumulative_freq, unique_vals = calculate_occupancy_frequencies(default_experiment_params.asu_occupancy)\n", - "\n", - "# Calculate probability of delay and plot the step chart\n", - "prob_delay = calculate_prob_delay(relative_freq, cumulative_freq)\n", - "prob_delay_plot(prob_delay, unique_vals)\n", - "```\n", - "\n", - "```python\n", - "# 1. Create an experiment\n", - "experiment = Experiment()\n", - "\n", - "# 2. Create an instance of a simpy environment\n", - "env = simpy.Environment()\n", - "\n", - "# 3. Create an instance of RehabilitationUnit\n", - "rehab_unit = RehabilitationUnit(env, experiment)\n", - "\n", - "# 4. Initialize the patient generators as simpy processes\n", - "env.process(rehab_unit.stroke_patient_generator())\n", - "env.process(rehab_unit.neuro_patient_generator())\n", - "env.process(rehab_unit.other_patient_generator())\n", - "\n", - "# 5. Initialize the audit of rehab occupancy as a simpy process with an interval of 1 day\n", - "env.process(audit_rehab_occupancy(env, 1, rehab_unit, experiment))\n", - "\n", - "# 6. Run the model for the default run length in the experiment * 10\n", - "env.run(until=experiment.run_length * 10)\n", - "\n", - "# 7. Calculate occupancy frequencies of the rehab occupancy\n", - "relative_frequency, cumulative_frequency, unique_values = calculate_occupancy_frequencies(experiment.rehab_occupancy)\n", - "\n", - "# 8. Display an occupancy plot for the rehab unit\n", - "occupancy_plot(relative_frequency, unique_values, x_label=\"No. of people in rehab\")\n", - "\n", - "# 9. Calculate the probability of delay for rehab\n", - "prob_delay = calculate_prob_delay(relative_frequency, cumulative_frequency)\n", - "\n", - "# 10. Display a probability of delay plot for rehab\n", - "prob_delay_plot(prob_delay, unique_values, x_label=\"No. rehab beds available\")\n", - "\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/20a_iteration.md\"))" + "## LLM Prompt 2 (for creating a script to run both models)\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/20a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/21_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/21_iteration.ipynb index 4c8fe24..e514916 100644 --- a/notebooks/03_stroke/04_prompts_stage1/21_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/21_iteration.ipynb @@ -48,8 +48,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -65,112 +63,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Create a new simpy generator function called `audit_rehab_occupancy` that accepts parameters: `env`, `first_interval`, `audit_interval`, an instance of the `RehabilitationUnit` called `rehab_unit`, and an instance `Experiment` called experiment. Function logic:\n", - "\n", - "1. Wait `first_interval` time units \n", - "2. The function repeatedly records the occupancy of `rehab_unit` and then waits `audit_interval` time units. The occupancy is appended `rehab_occupancy` in the experiment class. Do not append env.now\n", - "\n", - "Create a copy of the function called `audit_acute_occupancy`, but replace `rehab_unit` with `asu` and append to `asu_occupancy`\n", - "\n", - "Modify the `Experiment` class below:\n", - "Rename `run_length` to `results_collection_period` \n", - "Add a new parameter `warm_up` (default = 1095) and add a member variable of the same name underneath `results_collection_period` \n", - "\n", - "Display both the new functions and all of the modified `Experiment` class.\n", - "\n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " run_length=1825, trace=False,\n", - " rehab_stroke_iat=21.8, rehab_neuro_iat=31.7, rehab_other_iat=28.6,\n", - " rehab_stroke_esd_mean=30.3, rehab_stroke_esd_std_dev=23.1,\n", - " rehab_stroke_other_mean=28.4, rehab_stroke_other_std_dev=27.2,\n", - " rehab_neuro_mean=27.6, rehab_neuro_std_dev=28.4,\n", - " rehab_other_mean=16.1, rehab_other_std_dev=14.1,\n", - " rehab_stroke_post_destination_prob=[0.4, 0.6],\n", - " rehab_neuro_post_destination_prob=[0.09, 0.91],\n", - " rehab_other_post_destination_prob=[0.12, 0.88]):\n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.run_length = run_length\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - " self.rehab_occupancy = [] # List to store Rehabilitation Unit occupancy data\n", - "\n", - " \n", - " # New parameters for RehabilitationUnit treatment distributions and probabilities\n", - " self.rehab_stroke_iat = rehab_stroke_iat\n", - " self.rehab_neuro_iat = rehab_neuro_iat\n", - " self.rehab_other_iat = rehab_other_iat\n", - " \n", - " self.rehab_stroke_esd_mean = rehab_stroke_esd_mean\n", - " self.rehab_stroke_esd_std_dev = rehab_stroke_esd_std_dev\n", - " \n", - " self.rehab_stroke_other_mean = rehab_stroke_other_mean\n", - " self.rehab_stroke_other_std_dev = rehab_stroke_other_std_dev\n", - " \n", - " self.rehab_neuro_mean = rehab_neuro_mean\n", - " self.rehab_neuro_std_dev = rehab_neuro_std_dev\n", - " \n", - " self.rehab_other_mean = rehab_other_mean\n", - " self.rehab_other_std_dev = rehab_other_std_dev\n", - " \n", - " # Probabilities for post-rehab destination sampling for each patient type in RehabilitationUnit\n", - " self.rehab_stroke_post_destination_prob = rehab_stroke_post_destination_prob\n", - " self.rehab_neuro_post_destination_prob = rehab_neuro_post_destination_prob\n", - " self.rehab_other_post_destination_prob = rehab_other_post_destination_prob\n", - "\n", - "```\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/21_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/21_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -178,159 +76,12 @@ "id": "2bcf6d11-0f77-4b35-9e26-23c43d0204be", "metadata": {}, "source": [ - "## LLM Prompt 2 (for creating a script to run both models)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "06d9c5b2-5df5-4f7f-b899-66882b20aa70", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Correct the three python scripts below to use the correct versions of `audit_rehab_occupancy` and `audit_rehab_occupancy`. Always pass env. Set first_interval equal to warm_up.\n", - "Rename run_length to results_collection_period and run the model for the experiments results_collection_period + warm_up\n", - "\n", - "show the three edited scripts separately.\n", - "\n", - "### Script 1\n", - "\n", - "```python\n", - "# Create an instance of the Experiment class with default parameters and trace set to False\n", - "default_experiment_params = Experiment()\n", - "\n", - "# Create the simulation environment and AcuteStrokeUnit instance with the Experiment parameters\n", - "env = simpy.Environment()\n", - "\n", - "## MODIFIED BY TESTER\n", - "# create instance of RU, but we do not run the model at this stage\n", - "rehab_unit = RehabilitationUnit(env, default_experiment_params)\n", - "##\n", - "\n", - "acu_experiment = AcuteStrokeUnit(env, default_experiment_params, rehab_unit)\n", - "\n", - "# Start the patient generators for each type of patient in the AcuteStrokeUnit instance\n", - "env.process(acu_experiment.stroke_patient_generator())\n", - "env.process(acu_experiment.tia_patient_generator())\n", - "env.process(acu_experiment.neuro_patient_generator())\n", - "env.process(acu_experiment.other_patient_generator())\n", - "\n", - "# Start the audit_acute_occupancy generator function to record ASU occupancy at intervals\n", - "env.process(audit_acute_occupancy(1, acu_experiment, default_experiment_params))\n", - "\n", - "# Run the simulation until the specified run length in the Experiment parameters\n", - "# modified by tester - run length * 10\n", - "env.run(until=default_experiment_params.run_length * 10)\n", - "\n", - "# Calculate occupancy frequencies and plot the relative frequency distribution\n", - "relative_freq, cumulative_freq, unique_vals = calculate_occupancy_frequencies(default_experiment_params.asu_occupancy)\n", - "\n", - "# Calculate probability of delay and plot the step chart\n", - "prob_delay = calculate_prob_delay(relative_freq, cumulative_freq)\n", - "prob_delay_plot(prob_delay, unique_vals)\n", - "\n", - "```\n", - "\n", - "### Script 2\n", - "\n", - "```python\n", - "# 1. Create an experiment\n", - "experiment = Experiment()\n", - "\n", - "# 2. Create an instance of a simpy environment\n", - "env = simpy.Environment()\n", - "\n", - "# 3. Create an instance of RehabilitationUnit\n", - "rehab_unit = RehabilitationUnit(env, experiment)\n", - "\n", - "# 4. Initialize the patient generators as simpy processes\n", - "env.process(rehab_unit.stroke_patient_generator())\n", - "env.process(rehab_unit.neuro_patient_generator())\n", - "env.process(rehab_unit.other_patient_generator())\n", - "\n", - "# 5. Initialize the audit of rehab occupancy as a simpy process with an interval of 1 day\n", - "env.process(audit_rehab_occupancy(env, 1, rehab_unit, experiment))\n", - "\n", - "# 6. Run the model for the default run length in the experiment * 10\n", - "env.run(until=experiment.run_length * 10)\n", - "\n", - "# 7. Calculate occupancy frequencies of the rehab occupancy\n", - "relative_frequency, cumulative_frequency, unique_values = calculate_occupancy_frequencies(experiment.rehab_occupancy)\n", - "\n", - "# 8. Display an occupancy plot for the rehab unit\n", - "occupancy_plot(relative_frequency, unique_values, x_label=\"No. of people in rehab\")\n", - "\n", - "# 9. Calculate the probability of delay for rehab\n", - "prob_delay = calculate_prob_delay(relative_frequency, cumulative_frequency)\n", - "\n", - "# 10. Display a probability of delay plot for rehab\n", - "prob_delay_plot(prob_delay, unique_values, x_label=\"No. rehab beds available\")\n", - "```\n", - "\n", - "\n", - "### Script 3\n", - "\n", - "```python\n", - "# Combine the two scripts into a single script following the specified steps\n", - "\n", - "# Create an instance of the Experiment class with default parameters and trace set to False\n", - "default_experiment_params = Experiment()\n", - "\n", - "# Create the simulation environment\n", - "env = simpy.Environment()\n", - "\n", - "# Create an instance of RehabilitationUnit\n", - "rehab_unit = RehabilitationUnit(env, default_experiment_params)\n", - "\n", - "# Create an instance of AcuteStrokeUnit. Pass the RehabilitationUnit as a parameter\n", - "acu_experiment = AcuteStrokeUnit(env, default_experiment_params, rehab_unit)\n", - "\n", - "# Initialise the patient generators in AcuteStrokeUnit as simpy processes\n", - "env.process(acu_experiment.stroke_patient_generator())\n", - "env.process(acu_experiment.tia_patient_generator())\n", - "env.process(acu_experiment.neuro_patient_generator())\n", - "env.process(acu_experiment.other_patient_generator())\n", - "\n", - "# Initialise the patient generators in RehabilitationUnit as simpy processes\n", - "env.process(rehab_unit.stroke_patient_generator())\n", - "env.process(rehab_unit.neuro_patient_generator())\n", - "env.process(rehab_unit.other_patient_generator())\n", - "\n", - "# Initialise the audit of rehab occupancy as a simpy process. Use an interval of 1 day.\n", - "env.process(audit_rehab_occupancy(env, 1, rehab_unit, default_experiment_params))\n", - "\n", - "# Initialise the audit of AcuteStrokeUnit occupancy as a simpy process. Use an interval of 1 day.\n", - "env.process(audit_acute_occupancy(1, acu_experiment, default_experiment_params))\n", - "\n", - "# Run the model for the default run length in the experiment * 50\n", - "env.run(until=default_experiment_params.run_length * 50)\n", - "\n", - "# Calculate occupancy frequencies of both AcuteStrokeUnit and rehab occupancy\n", - "relative_freq_asu, cumulative_freq_asu, unique_vals_asu = calculate_occupancy_frequencies(default_experiment_params.asu_occupancy)\n", - "relative_freq_rehab, cumulative_freq_rehab, unique_vals_rehab = calculate_occupancy_frequencies(default_experiment_params.rehab_occupancy)\n", - "\n", - "# Calculate probability of delay for both AcuteStrokeUnit and rehab\n", - "prob_delay_asu = calculate_prob_delay(relative_freq_asu, cumulative_freq_asu)\n", - "prob_delay_rehab = calculate_prob_delay(relative_freq_rehab, cumulative_freq_rehab)\n", - "\n", - "# Display probability of delay plot for both AcuteStrokeUnit and rehab unit with appropriate x_label values\n", - "prob_delay_plot(prob_delay_asu, unique_vals_asu, x_label=\"No. of people in Acute Stroke Unit\")\n", - "prob_delay_plot(prob_delay_rehab, unique_vals_rehab, x_label=\"No. of people in Rehab Unit\")\n", - "\n", - "```\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/21a_iteration.md\"))" + "## LLM Prompt 2 (for creating a script to run both models)\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/21a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/22_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/22_iteration.ipynb index 57deff9..65d6e7f 100644 --- a/notebooks/03_stroke/04_prompts_stage1/22_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/22_iteration.ipynb @@ -50,8 +50,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -67,42 +65,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify `Experiment` to include a method `reset_kpi` that resets the occupancy lists to empty.\n", - "\n", - "modify edited script 3 into a function called `single_run(experiment)`. The first line of code should call experiment.reset_kpi(), In a dictionary, return the relative frequencies, prob of delay, and unique values for asu and rehab \n", - "\n", - "Using script 3 code a new script that creates an instance of `Experiment`, uses `single_run` and prints out a `prob_delay_plot` for both asu and rehab \n", - "\n", - "show all code in `Experiment`, `single_run`, the new script" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/22_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/22_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/23_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/23_iteration.ipynb index de30b02..ab78f2d 100644 --- a/notebooks/03_stroke/04_prompts_stage1/23_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/23_iteration.ipynb @@ -55,8 +55,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal\n", "import numpy as np\n", @@ -74,79 +73,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "create a function called `multiple_replications`. The function accepts an instance of `Experiment` and the number of replications (default=5) as parameters. The functions logic of each replication is as follows:\n", - "\n", - "1. call `single_run` \n", - "2. store the returned results of the replication for later use in a list called `rep_results`\n", - "\n", - "after all replications are complete return `rep_results`\n", - "\n", - "\n", - "create a function called `combine_pdelay_results(rep_results)` where `rep_results` is a python list where each item is a dictionary. The function logic is as follows:\n", - "\n", - "Loop through `rep_results`:\n", - "\n", - "1. select `prob_delay_asu` and `unique_vals_asu`.\n", - "2. find the minimum value in `unique_vals_asu` called `min_occupancy_asu`\n", - "3. Create an new array of length 30 of all zeros. Copy values from `prob_delay_asu` to the new array using `unique_vals_asu` as the index.\n", - "4. In the new array set all values whose array index is < `min_occupancy` to 1.0\n", - "5. store the results a new result list\n", - "\n", - "Repeat for `prob_delay_rehab`, `unique_vals_rehab` and `min_occupancy_rehab`\n", - "Return the result lists in a tuple of numpy arrays\n", - "\n", - "\n", - "create a function called `combine_occup_results(rep_results)` where `rep_results` is a python list where each item is a dictionary. The function logic is as follows:\n", - "\n", - "Loop through `rep_results`:\n", - "\n", - "1. select `relative_freq_asu` and `unique_vals_asu`.\n", - "2. Create an new array of length 30 of all zeros. Copy values from `relative_freq_asu` to the new array using `unique_vals_asu` as the index.\n", - "3. store the results a new result list\n", - "\n", - "Repeat for `relative_freq_rehab`,\n", - "Return the result lists in a tuple of numpy arrays\n", - "\n", - "\n", - "\n", - "create a function called `mean_results(rep_results)` where `rep_results` is a numpy array. The function should return the mean of the columns in rep_results.\n", - "\n", - "\n", - "create a function called `summary_table(mean_pdelay, min_beds, max_beds, bed_type)`. \n", - "1. Slice `mean_pdelay` between `min_beds` and `max_beds`.\n", - "2. Creates a pandas dataframe. The first column is the slice of `mean_pdelay` (2dp) the second column is 1 / the slice of `mean_pdelay` (to 2dp). Round the 2nd column down to nearest integer.\n", - "3. The column names are \"p(delay)\" and \"1 in every n patients delayed\".\n", - "4. The index should start at min_beds and end at max_beds. Its name is \"No. \" + `bed_type` + \" beds\"\n", - "5. Return the dataframe\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/23_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/23_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/24_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/24_iteration.ipynb index 69f72d9..ecf6869 100644 --- a/notebooks/03_stroke/04_prompts_stage1/24_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/24_iteration.ipynb @@ -54,8 +54,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -71,124 +69,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Modify the `Experiment` init method as follows:\n", - "\n", - "1. Add a new parameter called `random_number_set` with default value 0.\n", - "2. Add a call to a new method called `setup_streams(random_number_set)`\n", - "\n", - "Add a new method to `Experiment` called `setup_streams(random_number_set)` that accepts a parameter called `random_number_set`. It does not return any values.\n", - "`setup_streams` logic is as follows:\n", - "\n", - "1. create a member variable `streams` as an empty python list\n", - "2. create a numpy random default_rng generator object using `random_number_set` as a seed.\n", - "3. Using the generator object create a list of 25 random integer seeds sampled from a uniform distribution with lower bound 0 and an upper bound equal to the systems maximum 64bit integer size.\n", - "4. Loop through “seeds” and for each append a new numpy random default_rng object to `self.streams` passing in each seed as a parameter. \n", - "\n", - "Use correct indentation for all methods.\n", - "\n", - "Show the full Experiment class code and summarise code changes.\n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " results_collection_period=1825, trace=False,\n", - " rehab_stroke_iat=21.8, rehab_neuro_iat=31.7, rehab_other_iat=28.6,\n", - " rehab_stroke_esd_mean=30.3, rehab_stroke_esd_std_dev=23.1,\n", - " rehab_stroke_other_mean=28.4, rehab_stroke_other_std_dev=27.2,\n", - " rehab_neuro_mean=27.6, rehab_neuro_std_dev=28.4,\n", - " rehab_other_mean=16.1, rehab_other_std_dev=14.1,\n", - " rehab_stroke_post_destination_prob=[0.4, 0.6],\n", - " rehab_neuro_post_destination_prob=[0.09, 0.91],\n", - " rehab_other_post_destination_prob=[0.12, 0.88],\n", - " warm_up=1095):\n", - " \n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.results_collection_period = results_collection_period\n", - " self.warm_up = warm_up # New member variable for warm-up period\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - " self.rehab_occupancy = [] # List to store Rehabilitation Unit occupancy data\n", - "\n", - " \n", - " # New parameters for RehabilitationUnit treatment distributions and probabilities\n", - " self.rehab_stroke_iat = rehab_stroke_iat\n", - " self.rehab_neuro_iat = rehab_neuro_iat\n", - " self.rehab_other_iat = rehab_other_iat\n", - " \n", - " self.rehab_stroke_esd_mean = rehab_stroke_esd_mean\n", - " self.rehab_stroke_esd_std_dev = rehab_stroke_esd_std_dev\n", - " \n", - " self.rehab_stroke_other_mean = rehab_stroke_other_mean\n", - " self.rehab_stroke_other_std_dev = rehab_stroke_other_std_dev\n", - " \n", - " self.rehab_neuro_mean = rehab_neuro_mean\n", - " self.rehab_neuro_std_dev = rehab_neuro_std_dev\n", - " \n", - " self.rehab_other_mean = rehab_other_mean\n", - " self.rehab_other_std_dev = rehab_other_std_dev\n", - " \n", - " # Probabilities for post-rehab destination sampling for each patient type in RehabilitationUnit\n", - " self.rehab_stroke_post_destination_prob = rehab_stroke_post_destination_prob\n", - " self.rehab_neuro_post_destination_prob = rehab_neuro_post_destination_prob\n", - " self.rehab_other_post_destination_prob = rehab_other_post_destination_prob\n", - "\n", - " def reset_kpi(self):\n", - " \"\"\"Reset the occupancy lists to empty.\"\"\"\n", - " self.asu_occupancy.clear()\n", - " self.rehab_occupancy.clear()\n", - "```\n", - "\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/24_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/24_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/25_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/25_iteration.ipynb index 5b60890..2bc5c8a 100644 --- a/notebooks/03_stroke/04_prompts_stage1/25_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/25_iteration.ipynb @@ -54,8 +54,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -71,49 +70,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `multiple_replications` function\n", - "\n", - "before the model is run call the Experiment `setup_stream` method and pass in the current replication number as an argument.\n", - "\n", - "Show the full multiple_replications function code.\n", - "\n", - "```python\n", - "\n", - "def multiple_replications(experiment_instance, num_replications=5):\n", - " rep_results = []\n", - " for _ in range(num_replications):\n", - " rep_results.append(single_run(experiment_instance))\n", - " return rep_results\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/25_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/25_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/26_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/26_iteration.ipynb index ef304c5..0c10fa8 100644 --- a/notebooks/03_stroke/04_prompts_stage1/26_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/26_iteration.ipynb @@ -58,8 +58,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -75,151 +74,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the acute_treatment functions in `AcuteStrokeUnit` class\n", - "\n", - "code that uses `numpy.random`, must be replaced with a call to a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from zero and increment by 1 each time to allocate a unique number to each stream. E.g. in `stroke_acute_treatment` the first instance of `length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)` becomes `length_of_stay = self.experiment.streams[0](mean=mu, sigma=sigma)`; the second instance uses index 1 and the third uses index 2. Do not add new parameters to any methods. Do not modify the patient_generator functions at all.\n", - "\n", - "Show the full AcuteStrokeUnit including all patient generator and treatment functions. \n", - "\n", - "\n", - "\n", - "```python\n", - "class AcuteStrokeUnit:\n", - " def __init__(self, env, experiment, rehab_unit):\n", - " self.env = env\n", - " self.experiment = experiment\n", - " self.rehab_unit = rehab_unit\n", - " self.patient_count = 0\n", - " self.occupancy = 0\n", - "\n", - " def stroke_acute_treatment(self, post_asu_destination):\n", - " if post_asu_destination == \"Rehab\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_mean, self.experiment.rehab_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " elif post_asu_destination == \"ESD\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.esd_mean, self.experiment.esd_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " else:\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean, self.experiment.other_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.stroke_rehab_treatment())\n", - "\n", - " def tia_acute_treatment(self, post_asu_destination):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.tia_dest_mean, self.experiment.tia_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.tia_rehab_treatment())\n", - "\n", - " def neuro_acute_treatment(self, post_asu_destination):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.neuro_dest_mean, self.experiment.neuro_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.neuro_rehab_treatment())\n", - "\n", - " def other_acute_treatment(self, post_asu_destination):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean_2, self.experiment.other_dest_std_dev_2)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.other_rehab_treatment())\n", - "\n", - " def stroke_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.stroke_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.24, 0.13, 0.63])\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.stroke_acute_treatment(post_asu_destination))\n", - "\n", - " def tia_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.tia_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.01, 0.01, 0.98])\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.tia_acute_treatment(post_asu_destination))\n", - "\n", - " def neuro_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.neuro_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.11, 0.05, 0.84])\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.neuro_acute_treatment(post_asu_destination))\n", - "\n", - " def other_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.other_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.05, 0.10, 0.85])\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.other_acute_treatment(post_asu_destination))\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/26_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/26_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -227,35 +87,12 @@ "id": "844dda16-4038-49c4-85c1-a325bec88427", "metadata": {}, "source": [ - "### LLM Prompt 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "dd30bd4b-9978-4bb2-9f2d-67edd5a94c3a", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify all patient_generator functions in the `AcuteStrokeUnit` class. Do not modify the acute_treatment functions.\n", - "\n", - "code that uses `numpy.random`, must be replaced with a call to a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from 6 and increment by 1 each time to allocate a unique number to each stream. E.g. in `stroke_patient_generator` the first instance of `interarrival_time = np.random.exponential(self.experiment.stroke_interarrival_mean)` becomes `interarrival_time = self.experiment.streams[6](self.experiment.stroke_interarrival_mean)`; the call to choice will then use index 7. Do not add new parameters to any methods.\n", - "\n", - "Show the full AcuteStrokeUnit including all patient generator and treatment functions. \n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/26a_iteration.md\"))" + "### LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/26a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/27_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/27_iteration.ipynb index 1795ebf..6c456b5 100644 --- a/notebooks/03_stroke/04_prompts_stage1/27_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/27_iteration.ipynb @@ -60,8 +60,7 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", + "from IPython.display import display, HTML\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -77,140 +76,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the patient_generator functions in `RehabilitationUnit` class. Do not modify the rehab_treatment functions.\n", - "\n", - "code that uses `numpy.random` should be replaced. Call a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from 14 and increment by 1 each time to allocate a unique number to each stream. E.g. `stroke_patient_generator` uses 1 stream: 14. Do not add new parameters to any methods.\n", - "\n", - "Show the full RehabilitationUnit including all patient generator and treatment functions.\n", - "\n", - "```python\n", - "class RehabilitationUnit:\n", - " def __init__(self, env, experiment):\n", - " self.env = env\n", - " self.experiment = experiment\n", - " self.patient_count = 0\n", - " self.stroke_count = 0\n", - " self.neuro_count = 0\n", - " self.other_count = 0\n", - " self.occupancy = 0\n", - "\n", - " def stroke_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.rehab_stroke_iat)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " self.stroke_count += 1\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} arrived at Rehabilitation Unit at {self.env.now} days\")\n", - " self.occupancy += 1\n", - " self.env.process(self.stroke_rehab_treatment())\n", - "\n", - " def neuro_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.rehab_neuro_iat)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " self.neuro_count += 1\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neurological patient {self.patient_count} arrived at Rehabilitation Unit at {self.env.now} days\")\n", - " self.occupancy += 1\n", - " self.env.process(self.neuro_rehab_treatment())\n", - "\n", - " def other_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.rehab_other_iat)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " self.other_count += 1\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} arrived at Rehabilitation Unit at {self.env.now} days\")\n", - " self.occupancy += 1\n", - " self.env.process(self.other_rehab_treatment())\n", - "\n", - " def tia_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([0, 100])\n", - " mu, sigma = normal_moments_from_lognormal(18.7, 23.5)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "\n", - " def stroke_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([\"ESD\", \"Other\"], p=self.experiment.rehab_stroke_post_destination_prob)\n", - " if post_rehab_destination == \"ESD\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_stroke_esd_mean, self.experiment.rehab_stroke_esd_std_dev)\n", - " else:\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_stroke_other_mean, self.experiment.rehab_stroke_other_std_dev)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "\n", - " def neuro_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([\"ESD\", \"Other\"], p=self.experiment.rehab_neuro_post_destination_prob)\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_neuro_mean, self.experiment.rehab_neuro_std_dev)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"Complex Neurological patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "\n", - " def other_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([\"ESD\", \"Other\"], p=self.experiment.rehab_other_post_destination_prob)\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_other_mean, self.experiment.rehab_other_std_dev)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/27_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/27_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -218,34 +89,12 @@ "id": "844dda16-4038-49c4-85c1-a325bec88427", "metadata": {}, "source": [ - "### LLM Prompt 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "dd30bd4b-9978-4bb2-9f2d-67edd5a94c3a", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the rehab_treatment functions in `RehabilitationUnit` class. Do not modify the patient_generator functions.\n", - "\n", - "code that uses `numpy.random` should be replaced. Call a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from 17 and increment by 1 each time to allocate a unique number to each stream. \n", - "\n", - "Show the full RehabilitationUnit including all patient generator and treatment functions.#" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/27a_iteration.md\"))" + "### LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/27a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/28_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/28_iteration.ipynb index 492df41..79345e4 100644 --- a/notebooks/03_stroke/04_prompts_stage1/28_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/28_iteration.ipynb @@ -53,8 +53,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -70,78 +68,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 77, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "write python code that creates an interactive user interface using the package streamlit.\n", - "\n", - "The interface should include a main window.\n", - "\n", - "The main window contains a button labelled “Simulate”. After the button is pressed the following logic is implemented:\n", - "\n", - "1. display a spinner with the text “please wait for results”.\n", - "\n", - "2. run the python code included below\n", - "\n", - "3. display a streamlit table for df_acute and df_rehab results\n", - "\n", - "4. display all plots. Plotting functions return a tuple of figure, axis.\n", - "\n", - "All classes and functions should be imported from a module called `stroke_rehab_model`\n", - "\n", - "\n", - "```python\n", - "# Create an instance of Experiment (default params, default warm-up and rcp).\n", - "experiment = Experiment()\n", - "\n", - "# run multiple replications\n", - "rep_results = multiple_replications(experiment, 100)\n", - "\n", - "# combine results and take the mean \n", - "pd_asu, pd_rehab = combine_pdelay_results(rep_results)\n", - "rel_asu, rel_rehab = combine_occup_results(rep_results)\n", - "mean_pd_asu, mean_pd_rehab = mean_results(pd_asu), mean_results(pd_rehab)\n", - "mean_rel_asu, mean_rel_rehab = mean_results(rel_asu), mean_results(rel_rehab)\n", - "\n", - "# prob delay plots \n", - "prob_delay_plot(mean_pd_asu, np.arange(0, 30))\n", - "prob_delay_plot(mean_pd_rehab, np.arange(0, 30), \"No. rehab beds available\")\n", - "\n", - "# prob occupancy plots\n", - "occupancy_plot(mean_rel_asu, np.arange(0, 30))\n", - "occupancy_plot(mean_rel_rehab, np.arange(0, 30), \"No. people in rehab\")\n", - "\n", - "## tabular results\n", - "# acute\n", - "df_acute = summary_table(mean_pd_asu, 9, 14, \"acute\")\n", - "df_rehab = summary_table(mean_pd_rehab, 10, 16, \"rehab\")\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/28_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/28_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/29_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/29_iteration.ipynb index 9997600..9c57820 100644 --- a/notebooks/03_stroke/04_prompts_stage1/29_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/29_iteration.ipynb @@ -49,8 +49,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -66,55 +64,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Add a streamlit sidebar that contains a set of sliders, numeric text boxes, and check boxes that are used to set the parameters in an instance of Experiment. \n", - "\n", - "The following parameters that represent inter-arrival rates should be set. Labels are in brackets.\n", - "\n", - " stroke_mean (Stroke patients), \n", - " tia_mean (TIA patients), \n", - " neuro_mean (Complex Neurological patients)\n", - " other_mean (other patients)\n", - "\n", - "\n", - "Add a section on the sidebar model control including the following parameters:\n", - "\n", - " trace (Trace patients in simulation)\n", - " warm_up (Warm-up period)\n", - "\n", - "the default values of slider and text boxes should be the same as those in the Experiment class.\n", - "\n", - "In the main window add a numeric text box for the Number of replications used by multiple_replications.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/29_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/29_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/30_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/30_iteration.ipynb index 58897f4..2810782 100644 --- a/notebooks/03_stroke/04_prompts_stage1/30_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/30_iteration.ipynb @@ -47,8 +47,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,48 +62,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "add the following to the main window of the streamlit interface\n", - "\n", - " A title: “A modelling tool for capacity planning in acute and community stroke services”\n", - "\n", - " Text informing users that the model is a recreation of model reported in a published academic study.\n", - "\n", - " The following citation to the original study\n", - "\n", - "“Monks T, Worthington D, Allen M, Pitt M, Stein K, James MA. A modelling tool for capacity planning in acute and community stroke services. BMC Health Serv Res. 2016 Sep 29;16(1):530. doi: 10.1186/s12913-016-1789-4. PMID: 27688152; PMCID: PMC5043535.”\n", - "\n", - " A link of the original study using this url: https://doi.org/10.1186/s12913-016-1789-4\n", - "\n", - "Show the full streamlit code listing including modifications.\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/30_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/30_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/04_prompts_stage1/31_iteration.ipynb b/notebooks/03_stroke/04_prompts_stage1/31_iteration.ipynb index e519bfa..395c5ab 100644 --- a/notebooks/03_stroke/04_prompts_stage1/31_iteration.ipynb +++ b/notebooks/03_stroke/04_prompts_stage1/31_iteration.ipynb @@ -47,8 +47,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,101 +62,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "The functions `combine_pdelay_results` and `combine_occup_results` contain a bug when the number of unique values is greater than 30. Fix the bug so that the functions can handle more or less than 30 unique values, but still ensure that all arrays are of the same length.\n", - "\n", - "display all code in the modified functions.\n", - "\n", - "```python\n", - "def combine_pdelay_results(rep_results):\n", - " result_list_asu = []\n", - " result_list_rehab = []\n", - " \n", - " for rep_result in rep_results:\n", - " prob_delay_asu = rep_result['prob_delay_asu']\n", - " unique_vals_asu = rep_result['unique_vals_asu']\n", - " \n", - " min_occupancy_asu = min(unique_vals_asu)\n", - " \n", - " new_array_asu = np.zeros(30)\n", - " for i, val in zip(unique_vals_asu, prob_delay_asu):\n", - " new_array_asu[i] = val\n", - " \n", - " new_array_asu[:min_occupancy_asu] = 1.0\n", - " \n", - " result_list_asu.append(new_array_asu)\n", - " \n", - " prob_delay_rehab = rep_result['prob_delay_rehab']\n", - " unique_vals_rehab = rep_result['unique_vals_rehab']\n", - " \n", - " min_occupancy_rehab = min(unique_vals_rehab)\n", - " \n", - " new_array_rehab = np.zeros(30)\n", - " for i, val in zip(unique_vals_rehab, prob_delay_rehab):\n", - " new_array_rehab[i] = val\n", - " \n", - " new_array_rehab[:min_occupancy_rehab] = 1.0\n", - " \n", - " result_list_rehab.append(new_array_rehab)\n", - " \n", - " return np.array(result_list_asu), np.array(result_list_rehab)\n", - "\n", - "\n", - "\n", - "def combine_occup_results(rep_results):\n", - " result_list_asu = []\n", - " result_list_rehab = []\n", - " \n", - " for rep_result in rep_results:\n", - " relative_freq_asu = rep_result['relative_freq_asu']\n", - " unique_vals_asu = rep_result['unique_vals_asu']\n", - " \n", - " new_array_asu = np.zeros(30)\n", - " for i, val in zip(unique_vals_asu, relative_freq_asu):\n", - " new_array_asu[i] = val\n", - " \n", - " result_list_asu.append(new_array_asu)\n", - " \n", - " relative_freq_rehab = rep_result['relative_freq_rehab']\n", - " unique_vals_rehab = rep_result['unique_vals_rehab']\n", - " \n", - " new_array_rehab = np.zeros(30)\n", - " for i, val in zip(unique_vals_rehab, relative_freq_rehab):\n", - " new_array_rehab[i] = val\n", - " \n", - " result_list_rehab.append(new_array_rehab)\n", - " \n", - " return np.array(result_list_asu), np.array(result_list_rehab)\n", - "\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/31_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/31_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -166,57 +75,12 @@ "id": "c0d54f8a-e2f2-456a-8033-130b09f51fb0", "metadata": {}, "source": [ - "## LLM Prompt 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "9c691dd7-cbb9-4888-a109-7611dfb0b01f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "The functions `occupancy_plot` and `prob_delay_plot` contain a bug when the number of unique values is greater than 30. Fix the bug so that the functions can handle more or less than 30 unique values.\n", - "\n", - "display all code in the modified functions.\n", - "\n", - "\n", - "```python\n", - "def occupancy_plot(relative_frequency, unique_values, x_label=\"No. people in ASU\", fig_size=(12, 5)):\n", - " fig, ax = plt.subplots(figsize=fig_size)\n", - " ax.bar(unique_values, relative_frequency, align='center', alpha=0.7)\n", - " ax.set_xticks(np.arange(0, 31, 1))\n", - " ax.set_xlabel(x_label)\n", - " ax.set_ylabel('Relative Frequency')\n", - " plt.grid(axis='y', linestyle='--', alpha=0.6)\n", - " plt.title('Occupancy Relative Frequency Distribution')\n", - " plt.show()\n", - " return fig, ax\n", - "\n", - "def prob_delay_plot(prob_delay, unique_values, x_label=\"No. acute beds available\", fig_size=(12, 5)):\n", - " fig, ax = plt.subplots(figsize=fig_size)\n", - " ax.step(unique_values, prob_delay, where='post')\n", - " ax.set_xticks(np.arange(0, 31, 1))\n", - " ax.set_xlabel(x_label)\n", - " ax.set_ylabel('Probability of Delay')\n", - " plt.grid(axis='y', linestyle='--', alpha=0.6)\n", - " plt.title('Probability of Delay Distribution')\n", - " plt.show()\n", - " return fig, ax\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/31a_iteration.md\"))" + "## LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/31a_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -224,30 +88,12 @@ "id": "de04db1b-6593-4e7e-a6a1-1db387383f98", "metadata": {}, "source": [ - "## LLM Prompt 3" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "01a88aed-0a04-4ee4-958f-010166824358", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "The streamlit script contains a bug when the length of the results arrays passed to the plotting functions is more or less than 30. Fix the script so that the a dynamic size arange is passed. Show all code in the script." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/31b_iteration.md\"))" + "## LLM Prompt 3\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} inputs/31b_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/01_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/01_iteration_s2.ipynb index 9864bce..5190462 100644 --- a/notebooks/03_stroke/05_prompts_stage2/01_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/01_iteration_s2.ipynb @@ -19,88 +19,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Code a discrete-event simulation model of an Acute Stroke Unit (ACU) in python 3.10 and simpy 4. \n", - "\n", - "Please code the full model specified. Do not return a simplified version. Show all code.\n", - "\n", - "### General model logic\n", - "\n", - "All time units in the model are in days.\n", - "\n", - "The model should count the total number of patient arrivals. The first patient to arrive has an identifier of 0. For each subsequent patient increment the identifier by 1. The model should also maintain counts of the number of patients broken down by their type.\n", - "\n", - "Patients to arrive at the ACU from four different sources: Stroke, TIA, Complex Neurological, or Other. Each source had a different inter-arrival time distribution. After patients arrive they immediately leave the model.\n", - "\n", - "All patient types must have their own generator function.\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "The model should include a user settable run length. This defaults to 5 years.\n", - "\n", - "\n", - "### Simulation inputs\n", - "\n", - "the interarrival time distributions and parameters of patients are dependent on patient type. For each distribution time is measured in days.\n", - "\n", - "Stroke = Exponential: 1.2\n", - "TIA = Exponential: 9.3\n", - "Complex Neurological = Exponential: 3.6\n", - "Other = Exponential: 3.2\n", - "\n", - "\n", - "### simulation methodology\n", - "\n", - "numpy should be use for sampling.\n", - "\n", - "each interarrival distribution should have its own numpy.random.Generator object." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/01_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/01_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/02_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/02_iteration_s2.ipynb index eb646da..430fe3d 100644 --- a/notebooks/03_stroke/05_prompts_stage2/02_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/02_iteration_s2.ipynb @@ -13,78 +13,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to sample a patients destination after they have left the acute stroke unit (ASU).\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the ASU class.\n", - "\n", - "### General model logic\n", - "\n", - "After patients have arrived the model immediately samples their destination after the ASU. Destinations are:\n", - "\n", - "1. Rehab\n", - "2. ESD \n", - "3. Other\n", - "\n", - "Create a variable called \"post_asu_destination\". This variable is used to record the sampled destination of the patient.\n", - "\n", - "### Simulation inputs\n", - "\n", - "The sampling distribution are specific to the patient type.\n", - "\n", - "Stroke = Discrete Empirical: 24, 13, 63\n", - "TIA = Discrete Empirical: 1, 1, 98\n", - "Complex-neurological = Discrete Empirical: 11, 5, 84\n", - "Other = Discrete Empirical 5, 10, 85\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/02_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/02_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/03_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/03_iteration_s2.ipynb index 90b070b..41fabad 100644 --- a/notebooks/03_stroke/05_prompts_stage2/03_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/03_iteration_s2.ipynb @@ -13,88 +13,17 @@ "\n" ] }, - { - "cell_type": "markdown", - "id": "2e3176fc-587b-434d-a3d2-ee98f6501b7e", - "metadata": {}, - "source": [ - "## Notebook imports" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "c55ce33a-76d3-45a4-a286-3d3afd633dce", - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Markdown, display\n", - "import math" - ] - }, { "cell_type": "markdown", "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in four new `acute_treatment` methods to the ASU class each patient type i.e. Stroke, TIA, Complex Neurological, and other. Prefix the method names with the patient type e.g. `stroke_acute_treatment`\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the ASU class.\n", - "\n", - "### General model logic\n", - "\n", - "Add the following logic\n", - "\n", - "1. After a patient has been generated call `acute_treatment` as a simpy process. Pass the patient type to the method. Do not use the yield statement when calling this method.\n", - "2. sample a length of stay (measured in days) for treatment of patients\n", - "3. yield a simpy timeout equal to the length of stay for treatment\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "### Simulation inputs\n", - "\n", - "the length of stay (measured in days) for treatment of patients in the ASU follow source specific distributions\n", - "\n", - "if patient type = Stroke and post_asu_destination = Rehab then Lognormal: mean 7.4 and standard deviation 8.6\n", - "\n", - "if patient type = Stroke and post_asu_destination = ESD then Lognormal: mean 4.6 and standard deviation 4.8\n", - "\n", - "if patient type = Stroke and post_asu_destination = Other then Lognormal: mean 7.0 and standard deviation 8.7\n", - "\n", - "if patient type = TIA then Lognormal: mean 1.8 and standard deviation 5.0\n", - "\n", - "if patient type = Complex Neurological then Lognormal: mean 4.0 and standard deviation 5.0\n", - "\n", - "if patient type = Other then Lognormal: mean 3.8 and standard deviation 5.2\n", - "\n", - "The mean and standard deviation of the Lognormal distributions must be converted to the mean and standard deviation of the underlying normal distribution.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/03_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/03_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/04_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/04_iteration_s2.ipynb index 272e904..f2a25d8 100644 --- a/notebooks/03_stroke/05_prompts_stage2/04_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/04_iteration_s2.ipynb @@ -27,8 +27,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -37,35 +35,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "modify all `acute_treatment `functions to call a function external to the class called `normal_moments_from_lognormal`. The function should accept the mean and standard deviation of a Lognormal distribution and return the mu, sigma of the underlying Normal distribution. The returned values are the correct values to use when sampling from the Lognormal distributions. \n", - "\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the ASU class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/04_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/04_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/05_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/05_iteration_s2.ipynb index 238ba11..2233d0d 100644 --- a/notebooks/03_stroke/05_prompts_stage2/05_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/05_iteration_s2.ipynb @@ -29,8 +29,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -39,42 +37,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify the code so that all model parameters are stored within a class called Experiment that is separate from the model's logic. \n", - "\n", - "The list of parameters include:\n", - "\n", - "1. the means of the arrival distributions\n", - "2. the means and standard deviations of the lognormal distributions\n", - "3. simulation run length\n", - "\n", - "The parameters should be passed to the Experiment class constructor method when it is created. please provide default values\n", - "\n", - "Show all of the model code: this includes all patient generator functions in the AcuteStrokeUnit class." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/05_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/05_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/06_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/06_iteration_s2.ipynb index 4411051..2357fc9 100644 --- a/notebooks/03_stroke/05_prompts_stage2/06_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/06_iteration_s2.ipynb @@ -31,8 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -41,33 +39,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `AcuteStrokeUnit` class as follows: create a member variable called `occupancy`. Increment the `occupancy` member variable when a patient arrives to the ASU. Decrement the `occupancy` member variable at the end of the `acute_treatment` functions\n", - "\n", - "output only the AcuteStrokeUnit\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/06_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/06_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/07_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/07_iteration_s2.ipynb index 1f6f948..e9b7ac4 100644 --- a/notebooks/03_stroke/05_prompts_stage2/07_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/07_iteration_s2.ipynb @@ -31,8 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "from sim_tools.distributions import Lognormal" ] }, @@ -41,32 +39,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt a" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "add a new parameter to Experiment called \"trace\". The default value of \"trace\" is False. If the AcuteStrokeUnit has \"self.experiment.trace\" set to True the model will print out simulated events such as patient arrivals and discharges. \n", - "\n", - "output only the Experiment class for now. " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/07a_iteration.md\"))" + "## LLM Prompt a\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/07a_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -74,30 +52,12 @@ "id": "a970542d-0848-4cd4-896c-a974d31ab2ea", "metadata": {}, "source": [ - "## LLM Prompt b" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "46d6d48b-ba24-4cde-8abd-aca254485c65", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "now output the modified AcuteStrokeUnit Class" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/07b_iteration.md\"))" + "## LLM Prompt b\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/07b_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/08_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/08_iteration_s2.ipynb index cfb907a..b9d65bc 100644 --- a/notebooks/03_stroke/05_prompts_stage2/08_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/08_iteration_s2.ipynb @@ -29,8 +29,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -40,32 +38,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Create a new simpy generator function called `audit_acute_occupancy` that accepts parameters `acute_audit_interval`, an instance of the `AcuteStrokeUnit` called `asu`, and an instance `Experiment` called `experiment`. The function repeatedly records the occupancy of `asu` after `acute_audit_interval` time units. The occupancy is appended to a member variable `experiment` python list called `asu_occupancy` \n", - "\n", - "Output the `audit_acute_occupancy` function, modified `Experiment` class, and script to run the model and `audit_acute_occupancy`. `acute_audit_interval` should be set to 1 day." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/08_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/08_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/09_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/09_iteration_s2.ipynb index e385060..0f1b232 100644 --- a/notebooks/03_stroke/05_prompts_stage2/09_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/09_iteration_s2.ipynb @@ -34,8 +34,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -45,35 +43,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "create a function in python called `calculate_occupancy_frequencies` that accepts a python list of integer values. The function should use numpy to calculate the relative and cumulative frequencies of the numbers. The function should return a tuple containing the relative frequency, cumulative frequency, and the unique values. \n", - "\n", - "The relative frequency, unique values, a string called \"x_label\" (default value = \"No. people in ASU\"), and figure size (default = (12, 5)) should be passed to a function called `occupancy_plot` that creates a matplotlib bar chart of the relative frequency. the x axis values are taken from the unique values parameter. The x axis ticks should run from 0 to 30 and all values should be displayed. the x axis is label is set to the value of \"x_label\" The function `occupancy_plot` returns the matplotlib figure and axis objects to the calling code. \n", - "\n", - "The output should display the full script for creating a default `Experiment` and running the simulation model. Modify the script as follows: After the simulation model experiment is complete the code should call `calculate_occupancy_frequencies` and pass the \"asu_occupancy\" list as a parameter. The code should then use `occupancy_plot` and show the returned plot.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/09_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/09_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/10_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/10_iteration_s2.ipynb index 176f07a..c3d78de 100644 --- a/notebooks/03_stroke/05_prompts_stage2/10_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/10_iteration_s2.ipynb @@ -34,8 +34,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -45,17 +43,12 @@ "id": "a55c3ecc-617e-419e-8fb5-f4559bbc45c6", "metadata": {}, "source": [ - "## LLM Prompt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": {}, - "outputs": [], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/10_iteration.md\"))" + "## LLM Prompt\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/10_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/12_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/12_iteration_s2.ipynb index d4670f3..6058c7a 100644 --- a/notebooks/03_stroke/05_prompts_stage2/12_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/12_iteration_s2.ipynb @@ -43,8 +43,6 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -60,59 +58,12 @@ "tags": [] }, "source": [ - "(mylabel)=\n", - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Add a class representing the process at a Rehabilitation Unit (RU) called `RehabilitationUnit`\n", - "\n", - "### General model logic\n", - "\n", - "The RehabilitationUnit class should count the total number of patient arrivals. The first patient to arrive has an identifier of 0. For each subsequent patient increment the identifier by 1. The model should also maintain counts of the number of patients broken down by their type.\n", - "\n", - "Patients to arrive at the RU from three different sources: Stroke, Complex Neurological, or Other. Each source had a different inter-arrival time distribution. After patients arrive they immediately leave the model.\n", - "\n", - "All patient types must have their own generator function.\n", - "\n", - "The model should print out useful information after each event.\n", - "\n", - "### Simulation inputs\n", - "\n", - "the interarrival time distributions and parameters of patients are dependent on patient type. For each distribution time is measured in days.\n", - "\n", - "Stroke = Exponential: 21.8\n", - "Complex Neurological = Exponential: 31.7\n", - "Other = Exponential: 28.6\n", - "\n", - "Add three class member variables for the mean of each distribution. For example `self.stroke_iat_external`" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/12_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/12_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/13_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/13_iteration_s2.ipynb index 052d9ae..a28c95e 100644 --- a/notebooks/03_stroke/05_prompts_stage2/13_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/13_iteration_s2.ipynb @@ -49,8 +49,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -66,74 +64,12 @@ "tags": [] }, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 75, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify `Experiment` class below. Add three new inter-arrival means for stroke complex neurological and other patient types. These should be called `rehab_stroke_iat`, `rehab_neuro_iat`, `rehab_other_iat`. These inter-arrival means should be passed to the `Experiment` class constructor method when it is created. please provide default values using the values in `RehabilitationUnit`. Do not remove or overwrite any existing parameters.\n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " run_length=1825, trace=False):\n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.run_length = run_length\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - "```\n", - "\n", - "Modify the `RehabilitationUnit` class to accept an instance of `Experiment` and store as a member variable.\n", - "\n", - "\n", - "Display the modified `Experiment` and `RehabilitationUnit` classes.\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/13_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/13_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -141,34 +77,12 @@ "id": "7e50d1f2-db77-4822-85f1-f6c874470b1b", "metadata": {}, "source": [ - "> The prompt was modified for the Stage 2 `Experiment` class" - ] - }, - { - "cell_type": "code", - "execution_count": 76, - "id": "6f6e35f4-8ba0-4e38-a2c8-1cb85c385799", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Modify the script to run the model as follows:\n", - "\n", - "1. create an experiment,\n", - "2. create an instance RehabilitationUnit\n", - "3. run the model" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/13a_iteration.md\"))" + "> The prompt was modified for the Stage 2 `Experiment` class\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/13a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/14_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/14_iteration_s2.ipynb index ea4c318..b62c604 100644 --- a/notebooks/03_stroke/05_prompts_stage2/14_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/14_iteration_s2.ipynb @@ -47,8 +47,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,69 +62,12 @@ "tags": [] }, "source": [ - "## LLM Prompt " - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Modify the model to add in three new `rehab_treatment` methods to the `RehabilitationUnit` class each patient type i.e. Stroke, Complex Neurological, and other. Prefix the method names with the patient type e.g. `stroke_rehab_treatment`\n", - "\n", - "Show only the RehabilitationUnit class code: this includes all patient generator functions\n", - "\n", - "### General model logic\n", - "\n", - "Add the following logic\n", - "\n", - "1. After a patient has been generated call `rehab_treatment` as a simpy process. Pass the patient type. Do not use the yield statement when calling this method. \n", - "2. sample a post rehab destination. The options are ESD or Other. Store the result in `post_rehab_destination`\n", - "3. sample a length of stay (measured in days) for treatment of patients. store the result in `length_of_stay`\n", - "4. yield a simpy timeout equal to the length of stay for treatment\n", - "5. Print out information detailing the completion of a patient treatment.\n", - "\n", - "### Simulation inputs\n", - "\n", - "The sampling distribution for post_rehab_destination is specific to the patient type.\n", - "\n", - "Stroke = Discrete Empirical: 40, 60\n", - "Complex-neurological = Discrete Empirical: 9, 91\n", - "Other = Discrete Empirical 12, 88\n", - "\n", - "the length of stay (measured in days) for treatment of patients in the RehabilitationUnit follow source specific distributions\n", - "\n", - "if patient type = Stroke and post_rehab_destination = ESD then Lognormal: mean 30.3 and standard deviation 23.1\n", - "\n", - "if patient type = Stroke and post_rehab_destination = Other then Lognormal: mean 28.4 and standard deviation 27.2\n", - "\n", - "if patient type = Complex Neurological then Lognormal: mean 27.6 and standard deviation 28.4\n", - "\n", - "if patient type = Other then Lognormal: mean 16.1 and standard deviation 14.1\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/14_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/14_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/15_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/15_iteration_s2.ipynb index 01c2387..6ee9226 100644 --- a/notebooks/03_stroke/05_prompts_stage2/15_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/15_iteration_s2.ipynb @@ -49,8 +49,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -66,49 +64,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "## Main command\n", - "\n", - "Modify the `Experiment` class. Add new parameters that represent\n", - "\n", - "1. the means and standard deviations of the lognormal distributions used in `RehabilitationUnit` class.\n", - "2. the probabilities of the Empirical distributions (represented as python lists)\n", - "\n", - "pre fix all parameters with \"rehab_\"\n", - "\n", - "Do not remove or overwrite any existing parameters in `Experiment`\n", - "\n", - "Modify `RehabilitationUnit` to use the new parameters.\n", - "\n", - "Display only the modified `Experiment` class" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/15_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/15_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -116,30 +77,12 @@ "id": "e4efd9f0-e06a-4937-833b-ae73a69f0d31", "metadata": {}, "source": [ - "## LLM Prompt 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "21234327-9a4e-484d-b424-5916a2523ec2", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Display only the `RehabilitationUnit` class code" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/15a_iteration.md\"))" + "## LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/15a_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -147,15 +90,11 @@ "id": "be4fafa3-2ed3-484f-b21d-b693ba7d9cb5", "metadata": {}, "source": [ - "## LLM Prompt 3" - ] - }, - { - "cell_type": "markdown", - "id": "386e851b-767e-453f-b276-543f2fd0e12e", - "metadata": {}, - "source": [ - "Use the trace function in the RehabilitationUnit class for printing messages" + "## LLM Prompt 3\n", + "\n", + ":::{admonition} LLM Prompt\n", + "Use the trace function in the RehabilitationUnit class for printing messages\n", + ":::" ] }, { @@ -189,8 +128,7 @@ "\n", "* The `Experiment` class was appropriately modified. The LLM chose not to create a new rehab patient class or adapt the previous patient class\n", "* The `RehabilitationUnit` class was appropriately modified although the LLM removed the trace\n", - "* A third prompt was needed to use the trace function in the RehabilitationUnit class\n", - "```" + "* A third prompt was needed to use the trace function in the RehabilitationUnit class" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/16_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/16_iteration_s2.ipynb index b7d3d9f..6ea9d37 100644 --- a/notebooks/03_stroke/05_prompts_stage2/16_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/16_iteration_s2.ipynb @@ -47,8 +47,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,49 +62,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "### Main command\n", - "\n", - "Add a new method the `RehabilitationUnit` class to model TIA patient treatment called `tia_rehab_treatment`. The method should have the same code structure as the other treatment methods in `RehabilitationUnit` and include print statements for events.\n", - "\n", - "Do not add a new TIA patient generator method to the class.\n", - "\n", - "Show only the `RehabilitationUnit` class code.\n", - "\n", - "### Simulation inputs\n", - "\n", - "The sampling distribution for post_rehab_destination of TIA patients is Discrete Empirical: 0, 100\n", - "\n", - "the length of stay (measured in days) for treatment of TIA patients is Lognormal: mean 18.7 and standard deviation 23.5\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/16_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/16_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/17_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/17_iteration_s2.ipynb index 844aa42..69a6549 100644 --- a/notebooks/03_stroke/05_prompts_stage2/17_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/17_iteration_s2.ipynb @@ -48,8 +48,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -65,40 +63,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `RehabilitationUnit` class as follows: create a member variable called `occupancy`. Increment the `occupancy` member variable when a patient arrives to the `RehabilitationUnit`. Decrement the `occupancy` member variable at the end of the `rehab_treatment` functions\n", - "\n", - "modify the `RehabilitationUnit` class. Only print out events if `self.experiment.trace` is True.\n", - "\n", - "output only the `RehabilitationUnit` class code" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/17_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/17_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/18_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/18_iteration_s2.ipynb index 0392b4f..17740a3 100644 --- a/notebooks/03_stroke/05_prompts_stage2/18_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/18_iteration_s2.ipynb @@ -47,8 +47,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -64,172 +62,23 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Create a new simpy generator function called `audit_rehab_occupancy` that accepts parameters `env`, `rehab_audit_interval`, an instance of the `RehabilitationUnit` called `rehab_unit`, and an instance `Experiment` called experiment. The function repeatedly records the occupancy of `rehab_unit` after `rehab_audit_interval` time units. The occupancy is appended `rehab_occupancy` in the experiment class. Do not append env.now\n", - "\n", - "\n", - "Modify the `Experiment` class below. Add a new python list member variable to `__init__` called `rehab_occupancy` underneath `asu_occupancy`. \n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " run_length=1825, trace=False,\n", - " rehab_stroke_iat=21.8, rehab_neuro_iat=31.7, rehab_other_iat=28.6,\n", - " rehab_stroke_esd_mean=30.3, rehab_stroke_esd_std_dev=23.1,\n", - " rehab_stroke_other_mean=28.4, rehab_stroke_other_std_dev=27.2,\n", - " rehab_neuro_mean=27.6, rehab_neuro_std_dev=28.4,\n", - " rehab_other_mean=16.1, rehab_other_std_dev=14.1,\n", - " rehab_stroke_post_destination_prob=[0.4, 0.6],\n", - " rehab_neuro_post_destination_prob=[0.09, 0.91],\n", - " rehab_other_post_destination_prob=[0.12, 0.88]):\n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.run_length = run_length\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - " \n", - " \n", - " # New parameters for RehabilitationUnit treatment distributions and probabilities\n", - " self.rehab_stroke_iat = rehab_stroke_iat\n", - " self.rehab_neuro_iat = rehab_neuro_iat\n", - " self.rehab_other_iat = rehab_other_iat\n", - " \n", - " self.rehab_stroke_esd_mean = rehab_stroke_esd_mean\n", - " self.rehab_stroke_esd_std_dev = rehab_stroke_esd_std_dev\n", - " \n", - " self.rehab_stroke_other_mean = rehab_stroke_other_mean\n", - " self.rehab_stroke_other_std_dev = rehab_stroke_other_std_dev\n", - " \n", - " self.rehab_neuro_mean = rehab_neuro_mean\n", - " self.rehab_neuro_std_dev = rehab_neuro_std_dev\n", - " \n", - " self.rehab_other_mean = rehab_other_mean\n", - " self.rehab_other_std_dev = rehab_other_std_dev\n", - " \n", - " # Probabilities for post-rehab destination sampling for each patient type in RehabilitationUnit\n", - " self.rehab_stroke_post_destination_prob = rehab_stroke_post_destination_prob\n", - " self.rehab_neuro_post_destination_prob = rehab_neuro_post_destination_prob\n", - " self.rehab_other_post_destination_prob = rehab_other_post_destination_prob\n", - "```\n", - "\n", - "\n", - "Display only the `audit_rehab_occupancy` function and modified `Experiment` class. Show all code in `Experiment.__init__`\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/18_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/18_iteration.md\n", + ":::\n", + "::::" ] }, { - "cell_type": "code", - "execution_count": 2, - "id": "d6c96bfc-92ce-41e6-8e4a-041e88f2a611", + "cell_type": "markdown", + "id": "b809ccd4", "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Modify the script to run the model as follows:\n", - "\n", - "1. create an experiment\n", - "2. create an instance of a simpy environment\n", - "3. create an instance RehabilitationUnit\n", - "4. initialise the patient generators as simpy processes\n", - "5. initialise the audit of rehab occupancy as a simpy process. Use an interval of 1 day.\n", - "6. run the model for the default run length in the experiment * 10\n", - "7. use `calculate_occupancy_frequencies` to calculate occupancy frequencies of the rehab occupancy\n", - "8. use `occupancy_plot` to display an occupancy plot for the rehab unit. The x axis should be labelled \"No. of people in rehab\"\n", - "9. use `calculate_prob_delay` to calculate the probability of delay for rehab\n", - "10. use `prob_delay_plot` to display a prob of delay plot for rehab. The x label is \"No. rehab beds available\"\n", - "\n", - "```python\n", - "def calculate_occupancy_frequencies(data):\n", - " unique_values, counts = np.unique(data, return_counts=True)\n", - " relative_frequency = counts / len(data)\n", - " cumulative_frequency = np.cumsum(relative_frequency)\n", - " return relative_frequency, cumulative_frequency, unique_values\n", - "\n", - "\n", - "def occupancy_plot(relative_frequency, unique_values, x_label=\"No. people in ASU\", fig_size=(12, 5)):\n", - " fig, ax = plt.subplots(figsize=fig_size)\n", - " ax.bar(unique_values, relative_frequency, align='center', alpha=0.7)\n", - " ax.set_xticks(np.arange(0, 31, 1))\n", - " ax.set_xlabel(x_label)\n", - " ax.set_ylabel('Relative Frequency')\n", - " plt.grid(axis='y', linestyle='--', alpha=0.6)\n", - " plt.title('Occupancy Relative Frequency Distribution')\n", - " plt.show()\n", - " return fig, ax\n", - "\n", - "def calculate_prob_delay(relative_frequencies, cumulative_frequencies):\n", - " prob_delay = np.array(relative_frequencies) / np.array(cumulative_frequencies)\n", - " return prob_delay\n", - "\n", - "def prob_delay_plot(prob_delay, unique_values, x_label=\"No. acute beds available\", fig_size=(12, 5)):\n", - " fig, ax = plt.subplots(figsize=fig_size)\n", - " ax.step(unique_values, prob_delay, where='post')\n", - " ax.set_xticks(np.arange(0, 31, 1))\n", - " ax.set_xlabel(x_label)\n", - " ax.set_ylabel('Probability of Delay')\n", - " plt.grid(axis='y', linestyle='--', alpha=0.6)\n", - " plt.title('Probability of Delay Distribution')\n", - " plt.show()\n", - " return fig, ax\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], "source": [ - "display(Markdown(\"../01_perplexity/inputs/18a_iteration.md\"))" + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/18a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/19_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/19_iteration_s2.ipynb index a4ffd86..52a606d 100644 --- a/notebooks/03_stroke/05_prompts_stage2/19_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/19_iteration_s2.ipynb @@ -52,8 +52,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -69,141 +67,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `AcuteStrokeUnit` constructor to accept and store instance of `RehabilitationUnit` as a member variable called `rehab_unit`\n", - "\n", - "modify all methods in `AcuteStrokeUnit` postfixed with \"acute_treatment\" to accept `post_asu_destination` as a parameter. \n", - "Update all patient generator methods that call \"acute_treatment\" functions. \n", - "Rename `patient_type` in s`troke_acute_treatment` to `post_asu_destination`\n", - "\n", - "\n", - "\n", - "show all of the `AcuteStrokeUnit` code including all treatment and generator functions. \n", - "\n", - "```python\n", - "class AcuteStrokeUnit:\n", - " def __init__(self, env, experiment):\n", - " self.env = env\n", - " self.experiment = experiment\n", - " self.patient_count = 0\n", - " self.occupancy = 0\n", - "\n", - " def stroke_acute_treatment(self, patient_type):\n", - " if patient_type == \"Rehab\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_mean, self.experiment.rehab_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " elif patient_type == \"ESD\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.esd_mean, self.experiment.esd_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " else:\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean, self.experiment.other_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def tia_acute_treatment(self):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.tia_dest_mean, self.experiment.tia_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def neuro_acute_treatment(self):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.neuro_dest_mean, self.experiment.neuro_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def other_acute_treatment(self):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean_2, self.experiment.other_dest_std_dev_2)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - "\n", - " def stroke_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.stroke_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.24, 0.13, 0.63])\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.stroke_acute_treatment(post_asu_destination))\n", - "\n", - " def tia_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.tia_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.01, 0.01, 0.98])\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.tia_acute_treatment())\n", - "\n", - " def neuro_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.neuro_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.11, 0.05, 0.84])\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.neuro_acute_treatment())\n", - "\n", - " def other_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.other_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.05, 0.10, 0.85])\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.other_acute_treatment())\n", - "```\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/19_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/19_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/20_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/20_iteration_s2.ipynb index c63bd41..6d8e59c 100644 --- a/notebooks/03_stroke/05_prompts_stage2/20_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/20_iteration_s2.ipynb @@ -52,8 +52,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", - "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" ] @@ -69,40 +67,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "append new code to the end of four methods in `AcuteStrokeUnit` postfixed with \"acute_treatment\": if `post_asu_destination` is \"Rehab\" then a.) incrememnt `rehab_unit.occupancy` and then b.) call the `rehab_unit` function with the same patient_type as a simpy process. For example, `stroke_patient_generator` called `rehab_unit.stroke_rehab_treatment`. Do not pass any parameters. The code should be located after \"self.occupancy -= 1\". Do not use the yield keyword. \n", - "\n", - "Display all code in the `AcuteStrokeUnit class including all treatment and patient generator methods.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/20_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/20_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -110,115 +80,12 @@ "id": "2bcf6d11-0f77-4b35-9e26-23c43d0204be", "metadata": {}, "source": [ - "## LLM Prompt 2 (for creating a script to run both models)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "06d9c5b2-5df5-4f7f-b899-66882b20aa70", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Combine the two scripts below create a new single script that follows these steps:\n", - "\n", - "1. create an instance of `Experiment`\n", - "2. create an instance of a simpy environment\n", - "3. create an instance RehabilitationUnit \n", - "4. create an instance of AcuteStrokeUnit. Pass the RehabilitationUnit as a parameter\n", - "5. initialise the four methods postfixed with \"generator\" in AcuteStrokeUnit as simpy processes\n", - "6. initialise the three methods postfixed with \"generator\" in RehabilitationUnit simpy processes\n", - "7. initialise the audit of rehab occupancy as a simpy process. Use an interval of 1 day. Pass in env\n", - "8. initialise the audit of the AcuteStrokeUnit occupancy as a simpy process. Use an interval of 1 day.\n", - "9. run the model for the default run length in the experiment * 50\n", - "10. use `calculate_occupancy_frequencies` to calculate occupancy frequencies of both the AcuteStrokeUnit and the rehab occupancy\n", - "11. use `calculate_prob_delay` to calculate the probability of delay for AcuteStrokeUnit and rehab \n", - "12. use `prob_delay_plot` to display a prob of delay plot for AcuteStrokeUnit and rehab. Use appropriate x_label values for the AcuteStrokeUnit and rehab unit\n", - "\n", - "Only show the code in the script. Do no modify the functions or classes used.\n", - "\n", - "```python\n", - "# Create an instance of the Experiment class with default parameters and trace set to False\n", - "default_experiment_params = Experiment()\n", - "\n", - "# Create the simulation environment and AcuteStrokeUnit instance with the Experiment parameters\n", - "env = simpy.Environment()\n", - "\n", - "## MODIFIED BY TESTER\n", - "# create instance of RU, but we do not run the model at this stage\n", - "rehab_unit = RehabilitationUnit(env, default_experiment_params)\n", - "##\n", - "\n", - "acu_experiment = AcuteStrokeUnit(env, default_experiment_params, rehab_unit)\n", - "\n", - "# Start the patient generators for each type of patient in the AcuteStrokeUnit instance\n", - "env.process(acu_experiment.stroke_patient_generator())\n", - "env.process(acu_experiment.tia_patient_generator())\n", - "env.process(acu_experiment.neuro_patient_generator())\n", - "env.process(acu_experiment.other_patient_generator())\n", - "\n", - "# Start the audit_acute_occupancy generator function to record ASU occupancy at intervals\n", - "env.process(audit_acute_occupancy(1, acu_experiment, default_experiment_params))\n", - "\n", - "# Run the simulation until the specified run length in the Experiment parameters\n", - "# modified by tester - run length * 10\n", - "env.run(until=default_experiment_params.run_length * 10)\n", - "\n", - "# Calculate occupancy frequencies and plot the relative frequency distribution\n", - "relative_freq, cumulative_freq, unique_vals = calculate_occupancy_frequencies(default_experiment_params.asu_occupancy)\n", - "\n", - "# Calculate probability of delay and plot the step chart\n", - "prob_delay = calculate_prob_delay(relative_freq, cumulative_freq)\n", - "prob_delay_plot(prob_delay, unique_vals)\n", - "```\n", - "\n", - "```python\n", - "# 1. Create an experiment\n", - "experiment = Experiment()\n", - "\n", - "# 2. Create an instance of a simpy environment\n", - "env = simpy.Environment()\n", - "\n", - "# 3. Create an instance of RehabilitationUnit\n", - "rehab_unit = RehabilitationUnit(env, experiment)\n", - "\n", - "# 4. Initialize the patient generators as simpy processes\n", - "env.process(rehab_unit.stroke_patient_generator())\n", - "env.process(rehab_unit.neuro_patient_generator())\n", - "env.process(rehab_unit.other_patient_generator())\n", - "\n", - "# 5. Initialize the audit of rehab occupancy as a simpy process with an interval of 1 day\n", - "env.process(audit_rehab_occupancy(env, 1, rehab_unit, experiment))\n", - "\n", - "# 6. Run the model for the default run length in the experiment * 10\n", - "env.run(until=experiment.run_length * 10)\n", - "\n", - "# 7. Calculate occupancy frequencies of the rehab occupancy\n", - "relative_frequency, cumulative_frequency, unique_values = calculate_occupancy_frequencies(experiment.rehab_occupancy)\n", - "\n", - "# 8. Display an occupancy plot for the rehab unit\n", - "occupancy_plot(relative_frequency, unique_values, x_label=\"No. of people in rehab\")\n", - "\n", - "# 9. Calculate the probability of delay for rehab\n", - "prob_delay = calculate_prob_delay(relative_frequency, cumulative_frequency)\n", - "\n", - "# 10. Display a probability of delay plot for rehab\n", - "prob_delay_plot(prob_delay, unique_values, x_label=\"No. rehab beds available\")\n", - "\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/20a_iteration.md\"))" + "## LLM Prompt 2 (for creating a script to run both models)\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/20a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/21_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/21_iteration_s2.ipynb index 559c5fb..3908ac2 100644 --- a/notebooks/03_stroke/05_prompts_stage2/21_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/21_iteration_s2.ipynb @@ -48,7 +48,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -65,112 +64,12 @@ "tags": [] }, "source": [ - "## LLM Stage 1 Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Create a new simpy generator function called `audit_rehab_occupancy` that accepts parameters: `env`, `first_interval`, `audit_interval`, an instance of the `RehabilitationUnit` called `rehab_unit`, and an instance `Experiment` called experiment. Function logic:\n", - "\n", - "1. Wait `first_interval` time units \n", - "2. The function repeatedly records the occupancy of `rehab_unit` and then waits `audit_interval` time units. The occupancy is appended `rehab_occupancy` in the experiment class. Do not append env.now\n", - "\n", - "Create a copy of the function called `audit_acute_occupancy`, but replace `rehab_unit` with `asu` and append to `asu_occupancy`\n", - "\n", - "Modify the `Experiment` class below:\n", - "Rename `run_length` to `results_collection_period` \n", - "Add a new parameter `warm_up` (default = 1095) and add a member variable of the same name underneath `results_collection_period` \n", - "\n", - "Display both the new functions and all of the modified `Experiment` class.\n", - "\n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " run_length=1825, trace=False,\n", - " rehab_stroke_iat=21.8, rehab_neuro_iat=31.7, rehab_other_iat=28.6,\n", - " rehab_stroke_esd_mean=30.3, rehab_stroke_esd_std_dev=23.1,\n", - " rehab_stroke_other_mean=28.4, rehab_stroke_other_std_dev=27.2,\n", - " rehab_neuro_mean=27.6, rehab_neuro_std_dev=28.4,\n", - " rehab_other_mean=16.1, rehab_other_std_dev=14.1,\n", - " rehab_stroke_post_destination_prob=[0.4, 0.6],\n", - " rehab_neuro_post_destination_prob=[0.09, 0.91],\n", - " rehab_other_post_destination_prob=[0.12, 0.88]):\n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.run_length = run_length\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - " self.rehab_occupancy = [] # List to store Rehabilitation Unit occupancy data\n", - "\n", - " \n", - " # New parameters for RehabilitationUnit treatment distributions and probabilities\n", - " self.rehab_stroke_iat = rehab_stroke_iat\n", - " self.rehab_neuro_iat = rehab_neuro_iat\n", - " self.rehab_other_iat = rehab_other_iat\n", - " \n", - " self.rehab_stroke_esd_mean = rehab_stroke_esd_mean\n", - " self.rehab_stroke_esd_std_dev = rehab_stroke_esd_std_dev\n", - " \n", - " self.rehab_stroke_other_mean = rehab_stroke_other_mean\n", - " self.rehab_stroke_other_std_dev = rehab_stroke_other_std_dev\n", - " \n", - " self.rehab_neuro_mean = rehab_neuro_mean\n", - " self.rehab_neuro_std_dev = rehab_neuro_std_dev\n", - " \n", - " self.rehab_other_mean = rehab_other_mean\n", - " self.rehab_other_std_dev = rehab_other_std_dev\n", - " \n", - " # Probabilities for post-rehab destination sampling for each patient type in RehabilitationUnit\n", - " self.rehab_stroke_post_destination_prob = rehab_stroke_post_destination_prob\n", - " self.rehab_neuro_post_destination_prob = rehab_neuro_post_destination_prob\n", - " self.rehab_other_post_destination_prob = rehab_other_post_destination_prob\n", - "\n", - "```\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/21_iteration.md\"))" + "## LLM Stage 1 Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/21_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -178,159 +77,12 @@ "id": "2bcf6d11-0f77-4b35-9e26-23c43d0204be", "metadata": {}, "source": [ - "## LLM Prompt 2 (for creating a script to run both models)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "06d9c5b2-5df5-4f7f-b899-66882b20aa70", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "Correct the three python scripts below to use the correct versions of `audit_rehab_occupancy` and `audit_rehab_occupancy`. Always pass env. Set first_interval equal to warm_up.\n", - "Rename run_length to results_collection_period and run the model for the experiments results_collection_period + warm_up\n", - "\n", - "show the three edited scripts separately.\n", - "\n", - "### Script 1\n", - "\n", - "```python\n", - "# Create an instance of the Experiment class with default parameters and trace set to False\n", - "default_experiment_params = Experiment()\n", - "\n", - "# Create the simulation environment and AcuteStrokeUnit instance with the Experiment parameters\n", - "env = simpy.Environment()\n", - "\n", - "## MODIFIED BY TESTER\n", - "# create instance of RU, but we do not run the model at this stage\n", - "rehab_unit = RehabilitationUnit(env, default_experiment_params)\n", - "##\n", - "\n", - "acu_experiment = AcuteStrokeUnit(env, default_experiment_params, rehab_unit)\n", - "\n", - "# Start the patient generators for each type of patient in the AcuteStrokeUnit instance\n", - "env.process(acu_experiment.stroke_patient_generator())\n", - "env.process(acu_experiment.tia_patient_generator())\n", - "env.process(acu_experiment.neuro_patient_generator())\n", - "env.process(acu_experiment.other_patient_generator())\n", - "\n", - "# Start the audit_acute_occupancy generator function to record ASU occupancy at intervals\n", - "env.process(audit_acute_occupancy(1, acu_experiment, default_experiment_params))\n", - "\n", - "# Run the simulation until the specified run length in the Experiment parameters\n", - "# modified by tester - run length * 10\n", - "env.run(until=default_experiment_params.run_length * 10)\n", - "\n", - "# Calculate occupancy frequencies and plot the relative frequency distribution\n", - "relative_freq, cumulative_freq, unique_vals = calculate_occupancy_frequencies(default_experiment_params.asu_occupancy)\n", - "\n", - "# Calculate probability of delay and plot the step chart\n", - "prob_delay = calculate_prob_delay(relative_freq, cumulative_freq)\n", - "prob_delay_plot(prob_delay, unique_vals)\n", - "\n", - "```\n", - "\n", - "### Script 2\n", - "\n", - "```python\n", - "# 1. Create an experiment\n", - "experiment = Experiment()\n", - "\n", - "# 2. Create an instance of a simpy environment\n", - "env = simpy.Environment()\n", - "\n", - "# 3. Create an instance of RehabilitationUnit\n", - "rehab_unit = RehabilitationUnit(env, experiment)\n", - "\n", - "# 4. Initialize the patient generators as simpy processes\n", - "env.process(rehab_unit.stroke_patient_generator())\n", - "env.process(rehab_unit.neuro_patient_generator())\n", - "env.process(rehab_unit.other_patient_generator())\n", - "\n", - "# 5. Initialize the audit of rehab occupancy as a simpy process with an interval of 1 day\n", - "env.process(audit_rehab_occupancy(env, 1, rehab_unit, experiment))\n", - "\n", - "# 6. Run the model for the default run length in the experiment * 10\n", - "env.run(until=experiment.run_length * 10)\n", - "\n", - "# 7. Calculate occupancy frequencies of the rehab occupancy\n", - "relative_frequency, cumulative_frequency, unique_values = calculate_occupancy_frequencies(experiment.rehab_occupancy)\n", - "\n", - "# 8. Display an occupancy plot for the rehab unit\n", - "occupancy_plot(relative_frequency, unique_values, x_label=\"No. of people in rehab\")\n", - "\n", - "# 9. Calculate the probability of delay for rehab\n", - "prob_delay = calculate_prob_delay(relative_frequency, cumulative_frequency)\n", - "\n", - "# 10. Display a probability of delay plot for rehab\n", - "prob_delay_plot(prob_delay, unique_values, x_label=\"No. rehab beds available\")\n", - "```\n", - "\n", - "\n", - "### Script 3\n", - "\n", - "```python\n", - "# Combine the two scripts into a single script following the specified steps\n", - "\n", - "# Create an instance of the Experiment class with default parameters and trace set to False\n", - "default_experiment_params = Experiment()\n", - "\n", - "# Create the simulation environment\n", - "env = simpy.Environment()\n", - "\n", - "# Create an instance of RehabilitationUnit\n", - "rehab_unit = RehabilitationUnit(env, default_experiment_params)\n", - "\n", - "# Create an instance of AcuteStrokeUnit. Pass the RehabilitationUnit as a parameter\n", - "acu_experiment = AcuteStrokeUnit(env, default_experiment_params, rehab_unit)\n", - "\n", - "# Initialise the patient generators in AcuteStrokeUnit as simpy processes\n", - "env.process(acu_experiment.stroke_patient_generator())\n", - "env.process(acu_experiment.tia_patient_generator())\n", - "env.process(acu_experiment.neuro_patient_generator())\n", - "env.process(acu_experiment.other_patient_generator())\n", - "\n", - "# Initialise the patient generators in RehabilitationUnit as simpy processes\n", - "env.process(rehab_unit.stroke_patient_generator())\n", - "env.process(rehab_unit.neuro_patient_generator())\n", - "env.process(rehab_unit.other_patient_generator())\n", - "\n", - "# Initialise the audit of rehab occupancy as a simpy process. Use an interval of 1 day.\n", - "env.process(audit_rehab_occupancy(env, 1, rehab_unit, default_experiment_params))\n", - "\n", - "# Initialise the audit of AcuteStrokeUnit occupancy as a simpy process. Use an interval of 1 day.\n", - "env.process(audit_acute_occupancy(1, acu_experiment, default_experiment_params))\n", - "\n", - "# Run the model for the default run length in the experiment * 50\n", - "env.run(until=default_experiment_params.run_length * 50)\n", - "\n", - "# Calculate occupancy frequencies of both AcuteStrokeUnit and rehab occupancy\n", - "relative_freq_asu, cumulative_freq_asu, unique_vals_asu = calculate_occupancy_frequencies(default_experiment_params.asu_occupancy)\n", - "relative_freq_rehab, cumulative_freq_rehab, unique_vals_rehab = calculate_occupancy_frequencies(default_experiment_params.rehab_occupancy)\n", - "\n", - "# Calculate probability of delay for both AcuteStrokeUnit and rehab\n", - "prob_delay_asu = calculate_prob_delay(relative_freq_asu, cumulative_freq_asu)\n", - "prob_delay_rehab = calculate_prob_delay(relative_freq_rehab, cumulative_freq_rehab)\n", - "\n", - "# Display probability of delay plot for both AcuteStrokeUnit and rehab unit with appropriate x_label values\n", - "prob_delay_plot(prob_delay_asu, unique_vals_asu, x_label=\"No. of people in Acute Stroke Unit\")\n", - "prob_delay_plot(prob_delay_rehab, unique_vals_rehab, x_label=\"No. of people in Rehab Unit\")\n", - "\n", - "```\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/21a_iteration.md\"))" + "## LLM Prompt 2 (for creating a script to run both models)\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/21a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/22_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/22_iteration_s2.ipynb index 5917029..a2fb6b0 100644 --- a/notebooks/03_stroke/05_prompts_stage2/22_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/22_iteration_s2.ipynb @@ -50,7 +50,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -67,42 +66,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify `Experiment` to include a method `reset_kpi` that resets the occupancy lists to empty.\n", - "\n", - "modify edited script 3 into a function called `single_run(experiment)`. The first line of code should call experiment.reset_kpi(), In a dictionary, return the relative frequencies, prob of delay, and unique values for asu and rehab \n", - "\n", - "Using script 3 code a new script that creates an instance of `Experiment`, uses `single_run` and prints out a `prob_delay_plot` for both asu and rehab \n", - "\n", - "show all code in `Experiment`, `single_run`, the new script" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/22_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/22_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/23_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/23_iteration_s2.ipynb index b84b986..0206be0 100644 --- a/notebooks/03_stroke/05_prompts_stage2/23_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/23_iteration_s2.ipynb @@ -55,11 +55,9 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal\n", - "import numpy as np\n", "import pandas as pd" ] }, @@ -74,79 +72,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "create a function called `multiple_replications`. The function accepts an instance of `Experiment` and the number of replications (default=5) as parameters. The functions logic of each replication is as follows:\n", - "\n", - "1. call `single_run` \n", - "2. store the returned results of the replication for later use in a list called `rep_results`\n", - "\n", - "after all replications are complete return `rep_results`\n", - "\n", - "\n", - "create a function called `combine_pdelay_results(rep_results)` where `rep_results` is a python list where each item is a dictionary. The function logic is as follows:\n", - "\n", - "Loop through `rep_results`:\n", - "\n", - "1. select `prob_delay_asu` and `unique_vals_asu`.\n", - "2. find the minimum value in `unique_vals_asu` called `min_occupancy_asu`\n", - "3. Create an new array of length 30 of all zeros. Copy values from `prob_delay_asu` to the new array using `unique_vals_asu` as the index.\n", - "4. In the new array set all values whose array index is < `min_occupancy` to 1.0\n", - "5. store the results a new result list\n", - "\n", - "Repeat for `prob_delay_rehab`, `unique_vals_rehab` and `min_occupancy_rehab`\n", - "Return the result lists in a tuple of numpy arrays\n", - "\n", - "\n", - "create a function called `combine_occup_results(rep_results)` where `rep_results` is a python list where each item is a dictionary. The function logic is as follows:\n", - "\n", - "Loop through `rep_results`:\n", - "\n", - "1. select `relative_freq_asu` and `unique_vals_asu`.\n", - "2. Create an new array of length 30 of all zeros. Copy values from `relative_freq_asu` to the new array using `unique_vals_asu` as the index.\n", - "3. store the results a new result list\n", - "\n", - "Repeat for `relative_freq_rehab`,\n", - "Return the result lists in a tuple of numpy arrays\n", - "\n", - "\n", - "\n", - "create a function called `mean_results(rep_results)` where `rep_results` is a numpy array. The function should return the mean of the columns in rep_results.\n", - "\n", - "\n", - "create a function called `summary_table(mean_pdelay, min_beds, max_beds, bed_type)`. \n", - "1. Slice `mean_pdelay` between `min_beds` and `max_beds`.\n", - "2. Creates a pandas dataframe. The first column is the slice of `mean_pdelay` (2dp) the second column is 1 / the slice of `mean_pdelay` (to 2dp). Round the 2nd column down to nearest integer.\n", - "3. The column names are \"p(delay)\" and \"1 in every n patients delayed\".\n", - "4. The index should start at min_beds and end at max_beds. Its name is \"No. \" + `bed_type` + \" beds\"\n", - "5. Return the dataframe\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/23_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/23_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/24_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/24_iteration_s2.ipynb index 536d43a..deea30b 100644 --- a/notebooks/03_stroke/05_prompts_stage2/24_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/24_iteration_s2.ipynb @@ -54,7 +54,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -71,124 +70,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 78, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Modify the `Experiment` init method as follows:\n", - "\n", - "1. Add a new parameter called `random_number_set` with default value 0.\n", - "2. Add a call to a new method called `setup_streams(random_number_set)`\n", - "\n", - "Add a new method to `Experiment` called `setup_streams(random_number_set)` that accepts a parameter called `random_number_set`. It does not return any values.\n", - "`setup_streams` logic is as follows:\n", - "\n", - "1. create a member variable `streams` as an empty python list\n", - "2. create a numpy random default_rng generator object using `random_number_set` as a seed.\n", - "3. Using the generator object create a list of 25 random integer seeds sampled from a uniform distribution with lower bound 0 and an upper bound equal to the systems maximum 64bit integer size.\n", - "4. Loop through “seeds” and for each append a new numpy random default_rng object to `self.streams` passing in each seed as a parameter. \n", - "\n", - "Use correct indentation for all methods.\n", - "\n", - "Show the full Experiment class code and summarise code changes.\n", - "\n", - "```python\n", - "class Experiment:\n", - " def __init__(self, stroke_mean=1.2, tia_mean=9.3, neuro_mean=3.6, other_mean=3.2,\n", - " rehab_mean=7.4, rehab_std_dev=8.6, esd_mean=4.6, esd_std_dev=4.8,\n", - " other_dest_mean=7.0, other_dest_std_dev=8.7,\n", - " tia_dest_mean=1.8, tia_dest_std_dev=5.0,\n", - " neuro_dest_mean=4.0, neuro_dest_std_dev=5.0,\n", - " other_dest_mean_2=3.8, other_dest_std_dev_2=5.2,\n", - " results_collection_period=1825, trace=False,\n", - " rehab_stroke_iat=21.8, rehab_neuro_iat=31.7, rehab_other_iat=28.6,\n", - " rehab_stroke_esd_mean=30.3, rehab_stroke_esd_std_dev=23.1,\n", - " rehab_stroke_other_mean=28.4, rehab_stroke_other_std_dev=27.2,\n", - " rehab_neuro_mean=27.6, rehab_neuro_std_dev=28.4,\n", - " rehab_other_mean=16.1, rehab_other_std_dev=14.1,\n", - " rehab_stroke_post_destination_prob=[0.4, 0.6],\n", - " rehab_neuro_post_destination_prob=[0.09, 0.91],\n", - " rehab_other_post_destination_prob=[0.12, 0.88],\n", - " warm_up=1095):\n", - " \n", - " self.stroke_interarrival_mean = stroke_mean\n", - " self.tia_interarrival_mean = tia_mean\n", - " self.neuro_interarrival_mean = neuro_mean\n", - " self.other_interarrival_mean = other_mean\n", - " self.rehab_mean = rehab_mean\n", - " self.rehab_std_dev = rehab_std_dev\n", - " self.esd_mean = esd_mean\n", - " self.esd_std_dev = esd_std_dev\n", - " self.other_dest_mean = other_dest_mean\n", - " self.other_dest_std_dev = other_dest_std_dev\n", - " self.tia_dest_mean = tia_dest_mean\n", - " self.tia_dest_std_dev = tia_dest_std_dev\n", - " self.neuro_dest_mean = neuro_dest_mean\n", - " self.neuro_dest_std_dev = neuro_dest_std_dev\n", - " self.other_dest_mean_2 = other_dest_mean_2\n", - " self.other_dest_std_dev_2 = other_dest_std_dev_2\n", - " self.results_collection_period = results_collection_period\n", - " self.warm_up = warm_up # New member variable for warm-up period\n", - " self.trace = trace\n", - " self.asu_occupancy = [] # List to store ASU occupancy data\n", - " self.rehab_occupancy = [] # List to store Rehabilitation Unit occupancy data\n", - "\n", - " \n", - " # New parameters for RehabilitationUnit treatment distributions and probabilities\n", - " self.rehab_stroke_iat = rehab_stroke_iat\n", - " self.rehab_neuro_iat = rehab_neuro_iat\n", - " self.rehab_other_iat = rehab_other_iat\n", - " \n", - " self.rehab_stroke_esd_mean = rehab_stroke_esd_mean\n", - " self.rehab_stroke_esd_std_dev = rehab_stroke_esd_std_dev\n", - " \n", - " self.rehab_stroke_other_mean = rehab_stroke_other_mean\n", - " self.rehab_stroke_other_std_dev = rehab_stroke_other_std_dev\n", - " \n", - " self.rehab_neuro_mean = rehab_neuro_mean\n", - " self.rehab_neuro_std_dev = rehab_neuro_std_dev\n", - " \n", - " self.rehab_other_mean = rehab_other_mean\n", - " self.rehab_other_std_dev = rehab_other_std_dev\n", - " \n", - " # Probabilities for post-rehab destination sampling for each patient type in RehabilitationUnit\n", - " self.rehab_stroke_post_destination_prob = rehab_stroke_post_destination_prob\n", - " self.rehab_neuro_post_destination_prob = rehab_neuro_post_destination_prob\n", - " self.rehab_other_post_destination_prob = rehab_other_post_destination_prob\n", - "\n", - " def reset_kpi(self):\n", - " \"\"\"Reset the occupancy lists to empty.\"\"\"\n", - " self.asu_occupancy.clear()\n", - " self.rehab_occupancy.clear()\n", - "```\n", - "\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/24_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/24_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/25_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/25_iteration_s2.ipynb index b1be917..d8a94fc 100644 --- a/notebooks/03_stroke/05_prompts_stage2/25_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/25_iteration_s2.ipynb @@ -54,7 +54,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -71,49 +70,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the `multiple_replications` function\n", - "\n", - "before the model is run call the Experiment `setup_stream` method and pass in the current replication number as an argument.\n", - "\n", - "Show the full multiple_replications function code.\n", - "\n", - "```python\n", - "\n", - "def multiple_replications(experiment_instance, num_replications=5):\n", - " rep_results = []\n", - " for _ in range(num_replications):\n", - " rep_results.append(single_run(experiment_instance))\n", - " return rep_results\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/25_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/25_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/26_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/26_iteration_s2.ipynb index 534e107..8fd4f40 100644 --- a/notebooks/03_stroke/05_prompts_stage2/26_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/26_iteration_s2.ipynb @@ -58,7 +58,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -75,151 +74,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 stage 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 280, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the acute_treatment functions in `AcuteStrokeUnit` class. Do not modify the acute_treatment functions.\n", - "\n", - "code that uses `numpy.random`, must be replaced with a call to a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from zero and increment by 1 each time to allocate a unique number to each stream. E.g. in `stroke_acute_treatment` the first instance of `length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)` becomes `length_of_stay = self.experiment.streams[0](mean=mu, sigma=sigma)`; the second instance uses index 1 and the third uses index 2. Do not add new parameters to any methods. Do not modify the patient_generator functions at all.\n", - "\n", - "Show the full AcuteStrokeUnit including all patient generator and treatment functions. \n", - "\n", - "\n", - "\n", - "```python\n", - "class AcuteStrokeUnit:\n", - " def __init__(self, env, experiment, rehab_unit):\n", - " self.env = env\n", - " self.experiment = experiment\n", - " self.rehab_unit = rehab_unit\n", - " self.patient_count = 0\n", - " self.occupancy = 0\n", - "\n", - " def stroke_acute_treatment(self, post_asu_destination):\n", - " if post_asu_destination == \"Rehab\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_mean, self.experiment.rehab_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " elif post_asu_destination == \"ESD\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.esd_mean, self.experiment.esd_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " else:\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean, self.experiment.other_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.stroke_rehab_treatment())\n", - "\n", - " def tia_acute_treatment(self, post_asu_destination):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.tia_dest_mean, self.experiment.tia_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.tia_rehab_treatment())\n", - "\n", - " def neuro_acute_treatment(self, post_asu_destination):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.neuro_dest_mean, self.experiment.neuro_dest_std_dev)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.neuro_rehab_treatment())\n", - "\n", - " def other_acute_treatment(self, post_asu_destination):\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.other_dest_mean_2, self.experiment.other_dest_std_dev_2)\n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " self.occupancy += 1 # Increment occupancy when a patient arrives\n", - " yield self.env.timeout(length_of_stay)\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} finished treatment at {self.env.now} days\")\n", - " self.occupancy -= 1 # Decrement occupancy at the end of treatment\n", - " if post_asu_destination == \"Rehab\":\n", - " self.rehab_unit.occupancy += 1\n", - " self.env.process(self.rehab_unit.other_rehab_treatment())\n", - "\n", - " def stroke_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.stroke_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.24, 0.13, 0.63])\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.stroke_acute_treatment(post_asu_destination))\n", - "\n", - " def tia_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.tia_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.01, 0.01, 0.98])\n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.tia_acute_treatment(post_asu_destination))\n", - "\n", - " def neuro_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.neuro_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.11, 0.05, 0.84])\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neuro patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.neuro_acute_treatment(post_asu_destination))\n", - "\n", - " def other_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.other_interarrival_mean)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " post_asu_destination = np.random.choice([\"Rehab\", \"ESD\", \"Other\"], p=[0.05, 0.10, 0.85])\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} arrived at {self.env.now} days and will go to {post_asu_destination}\")\n", - " self.env.process(self.other_acute_treatment(post_asu_destination))\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/26_iteration.md\"))" + "## LLM Prompt 1 stage 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/26_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -227,35 +87,12 @@ "id": "844dda16-4038-49c4-85c1-a325bec88427", "metadata": {}, "source": [ - "### LLM Prompt 2 stage 1" - ] - }, - { - "cell_type": "code", - "execution_count": 281, - "id": "dd30bd4b-9978-4bb2-9f2d-67edd5a94c3a", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify all patient_generator functions in the `AcuteStrokeUnit` class. Do not modify the acute_treatment functions.\n", - "\n", - "code that uses `numpy.random`, must be replaced with a call to a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from 6 and increment by 1 each time to allocate a unique number to each stream. E.g. in `stroke_patient_generator` the first instance of `interarrival_time = np.random.exponential(self.experiment.stroke_interarrival_mean)` becomes `interarrival_time = self.experiment.streams[6](self.experiment.stroke_interarrival_mean)`; the call to choice will then use index 7. Do not add new parameters to any methods.\n", - "\n", - "Show the full AcuteStrokeUnit including all patient generator and treatment functions. \n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/26a_iteration.md\"))" + "### LLM Prompt 2 stage 1\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/26a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/27_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/27_iteration_s2.ipynb index dda5f97..826e7f3 100644 --- a/notebooks/03_stroke/05_prompts_stage2/27_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/27_iteration_s2.ipynb @@ -60,7 +60,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -77,141 +76,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "scrolled": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the patient_generator functions in `RehabilitationUnit` class. Do not modify the rehab_treatment functions.\n", - "\n", - "code that uses `numpy.random` should be replaced. Call a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from 14 and increment by 1 each time to allocate a unique number to each stream. E.g. `stroke_patient_generator` uses 1 stream: 14. Do not add new parameters to any methods.\n", - "\n", - "Show the full RehabilitationUnit including all patient generator and treatment functions.\n", - "\n", - "```python\n", - "class RehabilitationUnit:\n", - " def __init__(self, env, experiment):\n", - " self.env = env\n", - " self.experiment = experiment\n", - " self.patient_count = 0\n", - " self.stroke_count = 0\n", - " self.neuro_count = 0\n", - " self.other_count = 0\n", - " self.occupancy = 0\n", - "\n", - " def stroke_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.rehab_stroke_iat)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " self.stroke_count += 1\n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} arrived at Rehabilitation Unit at {self.env.now} days\")\n", - " self.occupancy += 1\n", - " self.env.process(self.stroke_rehab_treatment())\n", - "\n", - " def neuro_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.rehab_neuro_iat)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " self.neuro_count += 1\n", - " if self.experiment.trace:\n", - " print(f\"Complex Neurological patient {self.patient_count} arrived at Rehabilitation Unit at {self.env.now} days\")\n", - " self.occupancy += 1\n", - " self.env.process(self.neuro_rehab_treatment())\n", - "\n", - " def other_patient_generator(self):\n", - " while True:\n", - " interarrival_time = np.random.exponential(self.experiment.rehab_other_iat)\n", - " yield self.env.timeout(interarrival_time)\n", - " self.patient_count += 1\n", - " self.other_count += 1\n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} arrived at Rehabilitation Unit at {self.env.now} days\")\n", - " self.occupancy += 1\n", - " self.env.process(self.other_rehab_treatment())\n", - "\n", - " def tia_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([0, 100])\n", - " mu, sigma = normal_moments_from_lognormal(18.7, 23.5)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"TIA patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "\n", - " def stroke_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([\"ESD\", \"Other\"], p=self.experiment.rehab_stroke_post_destination_prob)\n", - " if post_rehab_destination == \"ESD\":\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_stroke_esd_mean, self.experiment.rehab_stroke_esd_std_dev)\n", - " else:\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_stroke_other_mean, self.experiment.rehab_stroke_other_std_dev)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"Stroke patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "\n", - " def neuro_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([\"ESD\", \"Other\"], p=self.experiment.rehab_neuro_post_destination_prob)\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_neuro_mean, self.experiment.rehab_neuro_std_dev)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"Complex Neurological patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "\n", - " def other_rehab_treatment(self):\n", - " post_rehab_destination = np.random.choice([\"ESD\", \"Other\"], p=self.experiment.rehab_other_post_destination_prob)\n", - " mu, sigma = normal_moments_from_lognormal(self.experiment.rehab_other_mean, self.experiment.rehab_other_std_dev)\n", - " \n", - " length_of_stay = np.random.lognormal(mean=mu, sigma=sigma)\n", - " \n", - " yield self.env.timeout(length_of_stay)\n", - " \n", - " if self.experiment.trace:\n", - " print(f\"Other patient {self.patient_count} finished treatment at Rehabilitation Unit at {self.env.now} days\")\n", - " \n", - " self.occupancy -= 1\n", - "```" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/27_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/27_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -219,34 +89,12 @@ "id": "844dda16-4038-49c4-85c1-a325bec88427", "metadata": {}, "source": [ - "### LLM Prompt 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "dd30bd4b-9978-4bb2-9f2d-67edd5a94c3a", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "modify the rehab_treatment functions in `RehabilitationUnit` class. Do not modify the patient_generator functions.\n", - "\n", - "code that uses `numpy.random` should be replaced. Call a unique stream in the `Experiment` list `streams`. Select the stream using a hard coded integer. Start from 17 and increment by 1 each time to allocate a unique number to each stream. \n", - "\n", - "Show the full RehabilitationUnit including all patient generator and treatment functions.#" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/27a_iteration.md\"))" + "### LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/27a_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/28_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/28_iteration_s2.ipynb index 2be6494..828858e 100644 --- a/notebooks/03_stroke/05_prompts_stage2/28_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/28_iteration_s2.ipynb @@ -53,7 +53,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -70,36 +69,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "inputs/28_iteration.md" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/28_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/28_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/29_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/29_iteration_s2.ipynb index a298418..cc281e5 100644 --- a/notebooks/03_stroke/05_prompts_stage2/29_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/29_iteration_s2.ipynb @@ -49,7 +49,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -66,55 +65,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "Add a streamlit sidebar that contains a set of sliders, numeric text boxes, and check boxes that are used to set the parameters in an instance of Experiment. \n", - "\n", - "The following parameters that represent inter-arrival rates should be set. Labels are in brackets.\n", - "\n", - " stroke_mean (Stroke patients), \n", - " tia_mean (TIA patients), \n", - " neuro_mean (Complex Neurological patients)\n", - " other_mean (other patients)\n", - "\n", - "\n", - "Add a section on the sidebar model control including the following parameters:\n", - "\n", - " trace (Trace patients in simulation)\n", - " warm_up (Warm-up period)\n", - "\n", - "the default values of slider and text boxes should be the same as those in the Experiment class.\n", - "\n", - "In the main window add a numeric text box for the Number of replications used by multiple_replications.\n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"../01_perplexity/inputs/29_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/29_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/30_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/30_iteration_s2.ipynb index 83b3d69..311c7e3 100644 --- a/notebooks/03_stroke/05_prompts_stage2/30_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/30_iteration_s2.ipynb @@ -47,7 +47,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -64,36 +63,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "inputs/30_iteration.md" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/30_iteration.md\"))" + "## LLM Prompt \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/30_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/03_stroke/05_prompts_stage2/31_iteration_s2.ipynb b/notebooks/03_stroke/05_prompts_stage2/31_iteration_s2.ipynb index 7481f3b..f4b727c 100644 --- a/notebooks/03_stroke/05_prompts_stage2/31_iteration_s2.ipynb +++ b/notebooks/03_stroke/05_prompts_stage2/31_iteration_s2.ipynb @@ -47,7 +47,6 @@ }, "outputs": [], "source": [ - "from IPython.display import Markdown, display, HTML\n", "import math\n", "import statistics\n", "from sim_tools.distributions import Lognormal" @@ -64,36 +63,12 @@ "tags": [] }, "source": [ - "## LLM Prompt 1 " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "b2ec31fa-8440-403e-b7e7-aa24eaf705f1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [ - { - "data": { - "text/markdown": [ - "inputs/31_iteration.md" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/31_iteration.md\"))" + "## LLM Prompt 1 \n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/31_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -101,30 +76,12 @@ "id": "c0d54f8a-e2f2-456a-8033-130b09f51fb0", "metadata": {}, "source": [ - "## LLM Prompt 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "9c691dd7-cbb9-4888-a109-7611dfb0b01f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "inputs/31a_iteration.md" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/31a_iteration.md\"))" + "## LLM Prompt 2\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/31a_iteration.md\n", + ":::\n", + "::::" ] }, { @@ -132,30 +89,12 @@ "id": "de04db1b-6593-4e7e-a6a1-1db387383f98", "metadata": {}, "source": [ - "## LLM Prompt 3" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "01a88aed-0a04-4ee4-958f-010166824358", - "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "inputs/31b_iteration.md" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(Markdown(\"inputs/31b_iteration.md\"))" + "## LLM Prompt 3\n", + "\n", + "::::{admonition} LLM Prompt\n", + ":::{include} ../04_prompts_stage1/inputs/31b_iteration.md\n", + ":::\n", + "::::" ] }, { diff --git a/notebooks/front_page.md b/notebooks/front_page.md index 1b05f74..171d43d 100644 --- a/notebooks/front_page.md +++ b/notebooks/front_page.md @@ -1,10 +1,10 @@ # Introduction -The publication of discrete-event simulation (DES) studies in healthcare has grown significantly, with over 100 studies published annually in academic journals. These studies employ DES to analyse critical aspects of healthcare delivery that impact patients internationally: spanning areas such as stroke, cancer, and dementia care. However, literature reviews have shown that 90% of these studies fail to provide access to the underlying computer simulation models used to generate their reported findings. This lack of transparency is particularly evident in older journal articles, where it is very rare to find computer model. In summary, the number of DES computer models that are accessible is a small fraction of the total number of DES models that have been developed and used in healthcare research studies. The majority of studies use commercial software, but Free and Open Source Software (FOSS) and simulation packages, such as Python's simpy, have emerged as valuable tools in promoting open publication of computer models. +The publication of discrete-event simulation (DES) studies in healthcare has grown significantly, with over 100 studies published annually in academic journals. These studies employ DES to analyse critical aspects of healthcare delivery that impact patients internationally: spanning areas such as stroke, cancer, and dementia care. However, literature reviews have shown that 90% of these studies fail to provide access to the underlying computer simulation models used to generate their reported findings. This lack of transparency is particularly evident in older journal articles, where it is very rare to find computer model. In summary, the number of DES computer models that are accessible is a small fraction of the total number of DES models that have been developed and used in healthcare research studies. The majority of studies use commercial software, but Free and Open Source Software (FOSS) and simulation packages, such as Python's SimPy, have emerged as valuable tools in promoting open publication of computer models. Traditionally, publishing a healthcare DES study has involved an academic journal article outlining the model's logic, performance metrics, aggregate input parameter data, assumptions, and simplifications, often accompanied by a logic or flow diagram depicting a patient's journey through the care pathway. A small subset of these publications adheres to reporting guidelines like the Strengthening the Reporting of Empirical Simulation Studies for DES (STRESS-DES). Replicating and constructing these models is a demanding task for specialized researchers and the NHS, often leading to duplication of research efforts and infrequent model reconstruction. -Large language models (LLMs) such as GPT3.5 or 4.0 are now widely accessible to the public via OpenAI’s ChatGPT, Google’s Bard and Perplexity.AI. LLMs, are trained on open data, such as Github, GitLab and the large number of code tutorials and code Q\&A sites online. LLMs offer general code generative capabilities to health researchers, but with some challenges. Users interact with LLMs using plain English, receiving sophisticated and detailed code outputs in response. The training data, likely containing code based models built in Python and simpy (and other packages and languages), as well as dashboarding/interface and web application tools like streamlit, may also include broken code, outdated packages, and hidden logic bugs. +Large language models (LLMs) such as GPT3.5 or 4.0 are now widely accessible to the public via OpenAI’s ChatGPT, Google’s Bard and Perplexity AI. LLMs, are trained on open data, such as Github, GitLab and the large number of code tutorials and code Q\&A sites online. LLMs offer general code generative capabilities to health researchers, but with some challenges. Users interact with LLMs using plain English, receiving sophisticated and detailed code outputs in response. The training data, likely containing code based models built in Python and SimPy (and other packages and languages), as well as dashboarding/interface and web application tools like Streamlit, may also include broken code, outdated packages, and hidden logic bugs. Large language models (LLMs) have opened up new avenues for the healthcare research and practitioner community: