From 102ddf563facfef22832ee73a702a4e5a5358e97 Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Tue, 9 Apr 2024 14:25:04 -0400 Subject: [PATCH] Update and streamline notebook --- .../SEIR_scenario3_petrinet.json | 6 +- .../epi_scenario3/epi_eval_sc3_seir.ipynb | 83 ++++++++----------- 2 files changed, 36 insertions(+), 53 deletions(-) diff --git a/notebooks/evaluation_2024.03/epi_scenario3/SEIR_scenario3_petrinet.json b/notebooks/evaluation_2024.03/epi_scenario3/SEIR_scenario3_petrinet.json index 4f521ac78..9dab06a8f 100644 --- a/notebooks/evaluation_2024.03/epi_scenario3/SEIR_scenario3_petrinet.json +++ b/notebooks/evaluation_2024.03/epi_scenario3/SEIR_scenario3_petrinet.json @@ -129,7 +129,7 @@ "ido": "0000514" }, "modifiers": { - "status": "young" + "status": "old" } }, "units": { @@ -557,8 +557,8 @@ "id": "N", "value": 37742307.0, "units": { - "expression": "1/day", - "expression_mathml": "day-1" + "expression": "person", + "expression_mathml": "person" } }, { diff --git a/notebooks/evaluation_2024.03/epi_scenario3/epi_eval_sc3_seir.ipynb b/notebooks/evaluation_2024.03/epi_scenario3/epi_eval_sc3_seir.ipynb index c3d8df61a..c4717d93b 100644 --- a/notebooks/evaluation_2024.03/epi_scenario3/epi_eval_sc3_seir.ipynb +++ b/notebooks/evaluation_2024.03/epi_scenario3/epi_eval_sc3_seir.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 16, "id": "efd146e7-0742-4e39-a374-39fe931df029", "metadata": {}, "outputs": [], @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 17, "id": "f8d81322-226a-4676-a0b8-923e7220e10d", "metadata": {}, "outputs": [], @@ -75,7 +75,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 18, "id": "5e2c1d9f-51a9-46a4-aa06-5aa862b8b081", "metadata": {}, "outputs": [], @@ -88,7 +88,7 @@ "c = {\n", " 'S_y': _susceptible.with_context(status=\"young\"),\n", " 'S_m': _susceptible.with_context(status=\"middle\"),\n", - " 'S_o': _susceptible.with_context(status=\"young\"),\n", + " 'S_o': _susceptible.with_context(status=\"old\"),\n", " 'E_y': _exposed.with_context(status=\"young\"),\n", " 'E_m': _exposed.with_context(status=\"middle\"),\n", " 'E_o': _exposed.with_context(status=\"old\"),\n", @@ -99,18 +99,9 @@ " 'R_m': _recovered.with_context(status=\"middle\"),\n", " 'R_o': _recovered.with_context(status=\"old\"),\n", "}\n", - "c['S_y'].name = 'S_y'\n", - "c['S_m'].name = 'S_m'\n", - "c['S_o'].name = 'S_o'\n", - "c['E_y'].name = 'E_y'\n", - "c['E_m'].name = 'E_m'\n", - "c['E_o'].name = 'E_o'\n", - "c['I_y'].name = 'I_y'\n", - "c['I_m'].name = 'I_m'\n", - "c['I_o'].name = 'I_o'\n", - "c['R_y'].name = 'R_y'\n", - "c['R_m'].name = 'R_m'\n", - "c['R_o'].name = 'R_o'" + "\n", + "for concept in c:\n", + " c[concept].name = concept" ] }, { @@ -123,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 19, "id": "b4774d31-1ad4-4027-a82b-6bee06907e03", "metadata": {}, "outputs": [], @@ -138,7 +129,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 20, "id": "a902e806-0dad-4bf6-a264-0172324257b0", "metadata": {}, "outputs": [], @@ -148,7 +139,7 @@ " distribution=Distribution(type='StandardUniform1',\n", " parameters={'minimum': 0.05,\n", " 'maximum': 0.8})), # Infection rate\n", - " 'N': Parameter(name='total_population', value=sympy.Float(37742307.0), units=per_day_units()), # Total population\n", + " 'N': Parameter(name='total_population', value=sympy.Float(37742307.0), units=person_units()), # Total population\n", " 'mew': Parameter(name='mew', value=sympy.Float(0.0), units=per_day_units()), # Mask efficacy\n", " 'mcw': Parameter(name='mcw', value=sympy.Float(0.0), units=per_day_units()), # Mask compliance\n", " 'r_EI': Parameter(name='r_EI', value=sympy.Float(0.08), units=per_day_units()), # Rate of progressing E -> I\n", @@ -175,7 +166,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 21, "id": "802ce5dd-9f50-43c3-8d0b-f1e7a692d7b0", "metadata": {}, "outputs": [], @@ -196,24 +187,24 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 22, "id": "f892e033-55da-44c6-b309-459dee0cae1a", "metadata": {}, "outputs": [], "source": [ "initials = {\n", - " \"S_y\": Initial(concept=Concept(name=\"S_y\"), expression=sympy.Float(10305660.0)),\n", - " \"S_m\": Initial(concept=Concept(name=\"S_m\"), expression=sympy.Float(15281905.0)),\n", - " \"S_o\": Initial(concept=Concept(name=\"S_o\"), expression=sympy.Float(12154442.0)),\n", - " \"E_y\": Initial(concept=Concept(name=\"E_y\"), expression=sympy.Float(50.0)),\n", - " \"E_m\": Initial(concept=Concept(name=\"E_m\"), expression=sympy.Float(50.0)),\n", - " \"E_o\": Initial(concept=Concept(name=\"E_o\"), expression=sympy.Float(50.0)),\n", - " \"I_y\": Initial(concept=Concept(name=\"I_y\"), expression=sympy.Float(50.0)),\n", - " \"I_m\": Initial(concept=Concept(name=\"I_m\"), expression=sympy.Float(50.0)),\n", - " \"I_o\": Initial(concept=Concept(name=\"I_o\"), expression=sympy.Float(50.0)),\n", - " \"R_y\": Initial(concept=Concept(name=\"R_y\"), expression=sympy.Float(0.0)),\n", - " \"R_m\": Initial(concept=Concept(name=\"R_m\"), expression=sympy.Float(0.0)),\n", - " \"R_o\": Initial(concept=Concept(name=\"R_o\"), expression=sympy.Float(0.0)),\n", + " \"S_y\": Initial(concept=c[\"S_y\"], expression=10305660.0),\n", + " \"S_m\": Initial(concept=c[\"S_m\"], expression=15281905.0),\n", + " \"S_o\": Initial(concept=c[\"S_o\"], expression=12154442.0),\n", + " \"E_y\": Initial(concept=c[\"E_y\"], expression=50.0),\n", + " \"E_m\": Initial(concept=c[\"E_m\"], expression=50.0),\n", + " \"E_o\": Initial(concept=c[\"E_o\"], expression=50.0),\n", + " \"I_y\": Initial(concept=c[\"I_y\"], expression=50.0),\n", + " \"I_m\": Initial(concept=c[\"I_m\"], expression=50.0),\n", + " \"I_o\": Initial(concept=c[\"I_o\"], expression=50.0),\n", + " \"R_y\": Initial(concept=c[\"R_y\"], expression=0.0),\n", + " \"R_m\": Initial(concept=c[\"R_m\"], expression=0.0),\n", + " \"R_o\": Initial(concept=c[\"R_o\"], expression=0.0),\n", "}" ] }, @@ -227,7 +218,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 23, "id": "5f186c10-7b95-4678-8737-ebca86c1f856", "metadata": {}, "outputs": [], @@ -350,16 +341,16 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 24, "id": "38e21c50-8b53-4288-a8ef-73f6e02ac63a", "metadata": {}, "outputs": [], "source": [ "observables_seir = {\n", - " 'susceptible': Observable(name='susceptible', expression=SympyExprStr(S_y+S_m+S_o)),\n", - " 'exposed': Observable(name='exposed', expression=SympyExprStr(E_y+E_m+E_o)),\n", - " 'infected': Observable(name='infected', expression=SympyExprStr(I_y+I_m+I_o)),\n", - " 'recovered': Observable(name='recovered', expression=SympyExprStr(R_y+R_m+R_o)),\n", + " 'susceptible': Observable(name='susceptible', expression=S_y+S_m+S_o),\n", + " 'exposed': Observable(name='exposed', expression=E_y+E_m+E_o),\n", + " 'infected': Observable(name='infected', expression=I_y+I_m+I_o),\n", + " 'recovered': Observable(name='recovered', expression=R_y+R_m+R_o),\n", "}" ] }, @@ -373,7 +364,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 25, "id": "4c523830-dfc3-4b8a-b584-5dad7f95c729", "metadata": {}, "outputs": [], @@ -418,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 26, "id": "12219f8d-566f-466d-b35e-6bb70af5cea7", "metadata": {}, "outputs": [], @@ -438,14 +429,6 @@ "with open('update_parameters_example.json', 'w') as fh:\n", " json.dump(template_model_to_petrinet_json(tm), fh, indent=1)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c0f18783-7a00-4484-a1ac-8e5e1697f921", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -464,7 +447,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.10.13" } }, "nbformat": 4,