diff --git a/notebook/Examples_for_TA2_Model_Representation/model1_missing_initial.json b/notebook/Examples_for_TA2_Model_Representation/model1_missing_initial.json
new file mode 100644
index 000000000..946dbcce5
--- /dev/null
+++ b/notebook/Examples_for_TA2_Model_Representation/model1_missing_initial.json
@@ -0,0 +1,419 @@
+{
+ "header": {
+ "name": "SEIRHD model with NPI Type 1 (for Timepoint 1)",
+ "schema": "https://raw.githubusercontent.com/DARPA-ASKEM/Model-Representations/petrinet_v0.5/petrinet/petrinet_schema.json",
+ "schema_name": "petrinet",
+ "description": "SEIRHD model with NPI type 1",
+ "model_version": "0.1",
+ "properties": {}
+ },
+ "model": {
+ "states": [
+ {
+ "id": "S",
+ "name": "S",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000514"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "I",
+ "name": "I",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "E",
+ "name": "E",
+ "grounding": {
+ "identifiers": {
+ "apollosv": "0000154"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "R",
+ "name": "R",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000592"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "H",
+ "name": "H",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {
+ "property": "ncit:C25179"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "D",
+ "name": "D",
+ "grounding": {
+ "identifiers": {
+ "ncit": "C28554"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ }
+ ],
+ "transitions": [
+ {
+ "id": "t1",
+ "input": [
+ "I",
+ "S"
+ ],
+ "output": [
+ "I",
+ "E"
+ ],
+ "properties": {
+ "name": "t1"
+ }
+ },
+ {
+ "id": "t2",
+ "input": [
+ "E"
+ ],
+ "output": [
+ "I"
+ ],
+ "properties": {
+ "name": "t2"
+ }
+ },
+ {
+ "id": "t3",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t3"
+ }
+ },
+ {
+ "id": "t4",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "H"
+ ],
+ "properties": {
+ "name": "t4"
+ }
+ },
+ {
+ "id": "t5",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t5"
+ }
+ },
+ {
+ "id": "t6",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "D"
+ ],
+ "properties": {
+ "name": "t6"
+ }
+ }
+ ]
+ },
+ "semantics": {
+ "ode": {
+ "rates": [
+ {
+ "target": "t1",
+ "expression": "I*S*kappa*(beta_c + (-beta_c + beta_s)/(1 + exp(-k*(-t + t_0))))/N",
+ "expression_mathml": "ISkappabeta_cbeta_cbeta_s1kt_0tN"
+ },
+ {
+ "target": "t2",
+ "expression": "E*delta",
+ "expression_mathml": "Edelta"
+ },
+ {
+ "target": "t3",
+ "expression": "I*gamma*(1 - eta)",
+ "expression_mathml": "Igamma1eta"
+ },
+ {
+ "target": "t4",
+ "expression": "I*eta*gamma",
+ "expression_mathml": "Ietagamma"
+ },
+ {
+ "target": "t5",
+ "expression": "H*(1 - mu)/los",
+ "expression_mathml": "H1mulos"
+ },
+ {
+ "target": "t6",
+ "expression": "H*mu/los",
+ "expression_mathml": "Hmulos"
+ }
+ ],
+ "initials": [
+ {
+ "target": "S",
+ "expression": "19339300.0",
+ "expression_mathml": "19339995.0"
+ },
+ {
+ "target": "I",
+ "expression": "175.00000000000000",
+ "expression_mathml": "4.0"
+ },
+ {
+ "target": "E",
+ "expression": "300.00000000000000",
+ "expression_mathml": "1.0"
+ },
+ {
+ "target": "H",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "D",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ }
+ ],
+ "parameters": [
+ {
+ "id": "N",
+ "value": 19340000.0,
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "beta_c",
+ "value": 0.09,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.05,
+ "maximum": 0.1
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "beta_s",
+ "value": 0.5,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.3,
+ "maximum": 0.6
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "k",
+ "value": 5.0,
+ "units": {
+ "expression": "1",
+ "expression_mathml": "1"
+ }
+ },
+ {
+ "id": "kappa",
+ "value": 1.0,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "t_0",
+ "value": 29.0,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 25.0,
+ "maximum": 35.0
+ }
+ },
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "delta",
+ "value": 0.25,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "eta",
+ "value": 0.1,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.005,
+ "maximum": 0.2
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "gamma",
+ "value": 0.2,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.1,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "los",
+ "value": 5.0,
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "mu",
+ "value": 0.4,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.18,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ }
+ ],
+ "observables": [
+ {
+ "id": "infected",
+ "name": "infected",
+ "expression": "I",
+ "expression_mathml": "I"
+ },
+ {
+ "id": "exposed",
+ "name": "exposed",
+ "expression": "E",
+ "expression_mathml": "E"
+ },
+ {
+ "id": "hospitalized",
+ "name": "hospitalized",
+ "expression": "H",
+ "expression_mathml": "H"
+ },
+ {
+ "id": "dead",
+ "name": "dead",
+ "expression": "D",
+ "expression_mathml": "D"
+ }
+ ],
+ "time": {
+ "id": "t",
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ }
+ }
+ },
+ "metadata": {
+ "annotations": {
+ "license": null,
+ "authors": [],
+ "references": [],
+ "time_scale": null,
+ "time_start": null,
+ "time_end": null,
+ "locations": [],
+ "pathogens": [],
+ "diseases": [],
+ "hosts": [],
+ "model_types": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/notebook/Examples_for_TA2_Model_Representation/model1_missing_rate_law.json b/notebook/Examples_for_TA2_Model_Representation/model1_missing_rate_law.json
new file mode 100644
index 000000000..f67498f18
--- /dev/null
+++ b/notebook/Examples_for_TA2_Model_Representation/model1_missing_rate_law.json
@@ -0,0 +1,419 @@
+{
+ "header": {
+ "name": "SEIRHD model with NPI Type 1 (for Timepoint 1)",
+ "schema": "https://raw.githubusercontent.com/DARPA-ASKEM/Model-Representations/petrinet_v0.5/petrinet/petrinet_schema.json",
+ "schema_name": "petrinet",
+ "description": "SEIRHD model with NPI type 1",
+ "model_version": "0.1",
+ "properties": {}
+ },
+ "model": {
+ "states": [
+ {
+ "id": "S",
+ "name": "S",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000514"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "I",
+ "name": "I",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "E",
+ "name": "E",
+ "grounding": {
+ "identifiers": {
+ "apollosv": "0000154"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "R",
+ "name": "R",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000592"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "H",
+ "name": "H",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {
+ "property": "ncit:C25179"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "D",
+ "name": "D",
+ "grounding": {
+ "identifiers": {
+ "ncit": "C28554"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ }
+ ],
+ "transitions": [
+ {
+ "id": "t1",
+ "input": [
+ "I",
+ "S"
+ ],
+ "output": [
+ "I",
+ "E"
+ ],
+ "properties": {
+ "name": "t1"
+ }
+ },
+ {
+ "id": "t2",
+ "input": [
+ "E"
+ ],
+ "output": [
+ "I"
+ ],
+ "properties": {
+ "name": "t2"
+ }
+ },
+ {
+ "id": "t3",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t3"
+ }
+ },
+ {
+ "id": "t4",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "H"
+ ],
+ "properties": {
+ "name": "t4"
+ }
+ },
+ {
+ "id": "t5",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t5"
+ }
+ },
+ {
+ "id": "t6",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "D"
+ ],
+ "properties": {
+ "name": "t6"
+ }
+ }
+ ]
+ },
+ "semantics": {
+ "ode": {
+ "rates": [
+ {
+ "target": "t1",
+ "expression": "I*S*kappa*(beta_c + (-beta_c + beta_s)/(1 + exp(-k*(-t + t_0))))/N",
+ "expression_mathml": "ISkappabeta_cbeta_cbeta_s1kt_0tN"
+ },
+ {
+ "target": "t2",
+ "expression": "E*delta",
+ "expression_mathml": "Edelta"
+ },
+ {
+ "target": "t4",
+ "expression": "I*eta*gamma",
+ "expression_mathml": "Ietagamma"
+ },
+ {
+ "target": "t5",
+ "expression": "H*(1 - mu)/los",
+ "expression_mathml": "H1mulos"
+ },
+ {
+ "target": "t6",
+ "expression": "H*mu/los",
+ "expression_mathml": "Hmulos"
+ }
+ ],
+ "initials": [
+ {
+ "target": "S",
+ "expression": "19339300.0",
+ "expression_mathml": "19339995.0"
+ },
+ {
+ "target": "I",
+ "expression": "175.00000000000000",
+ "expression_mathml": "4.0"
+ },
+ {
+ "target": "E",
+ "expression": "300.00000000000000",
+ "expression_mathml": "1.0"
+ },
+ {
+ "target": "R",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "H",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "D",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ }
+ ],
+ "parameters": [
+ {
+ "id": "N",
+ "value": 19340000.0,
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "beta_c",
+ "value": 0.09,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.05,
+ "maximum": 0.1
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "beta_s",
+ "value": 0.5,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.3,
+ "maximum": 0.6
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "k",
+ "value": 5.0,
+ "units": {
+ "expression": "1",
+ "expression_mathml": "1"
+ }
+ },
+ {
+ "id": "kappa",
+ "value": 1.0,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "t_0",
+ "value": 29.0,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 25.0,
+ "maximum": 35.0
+ }
+ },
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "delta",
+ "value": 0.25,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "eta",
+ "value": 0.1,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.005,
+ "maximum": 0.2
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "gamma",
+ "value": 0.2,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.1,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "los",
+ "value": 5.0,
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "mu",
+ "value": 0.4,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.18,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ }
+ ],
+ "observables": [
+ {
+ "id": "infected",
+ "name": "infected",
+ "expression": "I",
+ "expression_mathml": "I"
+ },
+ {
+ "id": "exposed",
+ "name": "exposed",
+ "expression": "E",
+ "expression_mathml": "E"
+ },
+ {
+ "id": "hospitalized",
+ "name": "hospitalized",
+ "expression": "H",
+ "expression_mathml": "H"
+ },
+ {
+ "id": "dead",
+ "name": "dead",
+ "expression": "D",
+ "expression_mathml": "D"
+ }
+ ],
+ "time": {
+ "id": "t",
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ }
+ }
+ },
+ "metadata": {
+ "annotations": {
+ "license": null,
+ "authors": [],
+ "references": [],
+ "time_scale": null,
+ "time_start": null,
+ "time_end": null,
+ "locations": [],
+ "pathogens": [],
+ "diseases": [],
+ "hosts": [],
+ "model_types": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/notebook/Examples_for_TA2_Model_Representation/model1_missing_transition.json b/notebook/Examples_for_TA2_Model_Representation/model1_missing_transition.json
new file mode 100644
index 000000000..17b937ea5
--- /dev/null
+++ b/notebook/Examples_for_TA2_Model_Representation/model1_missing_transition.json
@@ -0,0 +1,410 @@
+{
+ "header": {
+ "name": "SEIRHD model with NPI Type 1 (for Timepoint 1)",
+ "schema": "https://raw.githubusercontent.com/DARPA-ASKEM/Model-Representations/petrinet_v0.5/petrinet/petrinet_schema.json",
+ "schema_name": "petrinet",
+ "description": "SEIRHD model with NPI type 1",
+ "model_version": "0.1",
+ "properties": {}
+ },
+ "model": {
+ "states": [
+ {
+ "id": "S",
+ "name": "S",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000514"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "I",
+ "name": "I",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "E",
+ "name": "E",
+ "grounding": {
+ "identifiers": {
+ "apollosv": "0000154"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "R",
+ "name": "R",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000592"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "H",
+ "name": "H",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {
+ "property": "ncit:C25179"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "D",
+ "name": "D",
+ "grounding": {
+ "identifiers": {
+ "ncit": "C28554"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ }
+ ],
+ "transitions": [
+ {
+ "id": "t2",
+ "input": [
+ "E"
+ ],
+ "output": [
+ "I"
+ ],
+ "properties": {
+ "name": "t2"
+ }
+ },
+ {
+ "id": "t3",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t3"
+ }
+ },
+ {
+ "id": "t4",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "H"
+ ],
+ "properties": {
+ "name": "t4"
+ }
+ },
+ {
+ "id": "t5",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t5"
+ }
+ },
+ {
+ "id": "t6",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "D"
+ ],
+ "properties": {
+ "name": "t6"
+ }
+ }
+ ]
+ },
+ "semantics": {
+ "ode": {
+ "rates": [
+ {
+ "target": "t1",
+ "expression": "I*S*kappa*(beta_c + (-beta_c + beta_s)/(1 + exp(-k*(-t + t_0))))/N",
+ "expression_mathml": "ISkappabeta_cbeta_cbeta_s1kt_0tN"
+ },
+ {
+ "target": "t2",
+ "expression": "E*delta",
+ "expression_mathml": "Edelta"
+ },
+ {
+ "target": "t3",
+ "expression": "I*gamma*(1 - eta)",
+ "expression_mathml": "Igamma1eta"
+ },
+ {
+ "target": "t4",
+ "expression": "I*eta*gamma",
+ "expression_mathml": "Ietagamma"
+ },
+ {
+ "target": "t5",
+ "expression": "H*(1 - mu)/los",
+ "expression_mathml": "H1mulos"
+ },
+ {
+ "target": "t6",
+ "expression": "H*mu/los",
+ "expression_mathml": "Hmulos"
+ }
+ ],
+ "initials": [
+ {
+ "target": "S",
+ "expression": "19339300.0",
+ "expression_mathml": "19339995.0"
+ },
+ {
+ "target": "I",
+ "expression": "175.00000000000000",
+ "expression_mathml": "4.0"
+ },
+ {
+ "target": "E",
+ "expression": "300.00000000000000",
+ "expression_mathml": "1.0"
+ },
+ {
+ "target": "R",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "H",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "D",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ }
+ ],
+ "parameters": [
+ {
+ "id": "N",
+ "value": 19340000.0,
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "beta_c",
+ "value": 0.09,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.05,
+ "maximum": 0.1
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "beta_s",
+ "value": 0.5,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.3,
+ "maximum": 0.6
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "k",
+ "value": 5.0,
+ "units": {
+ "expression": "1",
+ "expression_mathml": "1"
+ }
+ },
+ {
+ "id": "kappa",
+ "value": 1.0,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "t_0",
+ "value": 29.0,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 25.0,
+ "maximum": 35.0
+ }
+ },
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "delta",
+ "value": 0.25,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "eta",
+ "value": 0.1,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.005,
+ "maximum": 0.2
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "gamma",
+ "value": 0.2,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.1,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "los",
+ "value": 5.0,
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "mu",
+ "value": 0.4,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.18,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ }
+ ],
+ "observables": [
+ {
+ "id": "infected",
+ "name": "infected",
+ "expression": "I",
+ "expression_mathml": "I"
+ },
+ {
+ "id": "exposed",
+ "name": "exposed",
+ "expression": "E",
+ "expression_mathml": "E"
+ },
+ {
+ "id": "hospitalized",
+ "name": "hospitalized",
+ "expression": "H",
+ "expression_mathml": "H"
+ },
+ {
+ "id": "dead",
+ "name": "dead",
+ "expression": "D",
+ "expression_mathml": "D"
+ }
+ ],
+ "time": {
+ "id": "t",
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ }
+ }
+ },
+ "metadata": {
+ "annotations": {
+ "license": null,
+ "authors": [],
+ "references": [],
+ "time_scale": null,
+ "time_start": null,
+ "time_end": null,
+ "locations": [],
+ "pathogens": [],
+ "diseases": [],
+ "hosts": [],
+ "model_types": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/notebook/Examples_for_TA2_Model_Representation/model1_no_header.json b/notebook/Examples_for_TA2_Model_Representation/model1_no_header.json
new file mode 100644
index 000000000..058ef1034
--- /dev/null
+++ b/notebook/Examples_for_TA2_Model_Representation/model1_no_header.json
@@ -0,0 +1,424 @@
+{
+ "heady": {
+ "name": "SEIRHD model with NPI Type 1 (for Timepoint 1)",
+ "schema": "https://raw.githubusercontent.com/DARPA-ASKEM/Model-Representations/petrinet_v0.5/petrinet/petrinet_schema.json",
+ "schema_name": "petrinet",
+ "description": "SEIRHD model with NPI type 1",
+ "model_version": "0.1",
+ "properties": {}
+ },
+ "model": {
+ "states": [
+ {
+ "id": "S",
+ "name": "S",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000514"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "I",
+ "name": "I",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "E",
+ "name": "E",
+ "grounding": {
+ "identifiers": {
+ "apollosv": "0000154"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "R",
+ "name": "R",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000592"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "H",
+ "name": "H",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {
+ "property": "ncit:C25179"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "D",
+ "name": "D",
+ "grounding": {
+ "identifiers": {
+ "ncit": "C28554"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ }
+ ],
+ "transitions": [
+ {
+ "id": "t1",
+ "input": [
+ "I",
+ "S"
+ ],
+ "output": [
+ "I",
+ "E"
+ ],
+ "properties": {
+ "name": "t1"
+ }
+ },
+ {
+ "id": "t2",
+ "input": [
+ "E"
+ ],
+ "output": [
+ "I"
+ ],
+ "properties": {
+ "name": "t2"
+ }
+ },
+ {
+ "id": "t3",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t3"
+ }
+ },
+ {
+ "id": "t4",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "H"
+ ],
+ "properties": {
+ "name": "t4"
+ }
+ },
+ {
+ "id": "t5",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t5"
+ }
+ },
+ {
+ "id": "t6",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "D"
+ ],
+ "properties": {
+ "name": "t6"
+ }
+ }
+ ]
+ },
+ "semantics": {
+ "ode": {
+ "rates": [
+ {
+ "target": "t1",
+ "expression": "I*S*kappa*(beta_c + (-beta_c + beta_s)/(1 + exp(-k*(-t + t_0))))/N",
+ "expression_mathml": "ISkappabeta_cbeta_cbeta_s1kt_0tN"
+ },
+ {
+ "target": "t2",
+ "expression": "E*delta",
+ "expression_mathml": "Edelta"
+ },
+ {
+ "target": "t3",
+ "expression": "I*gamma*(1 - eta)",
+ "expression_mathml": "Igamma1eta"
+ },
+ {
+ "target": "t4",
+ "expression": "I*eta*gamma",
+ "expression_mathml": "Ietagamma"
+ },
+ {
+ "target": "t5",
+ "expression": "H*(1 - mu)/los",
+ "expression_mathml": "H1mulos"
+ },
+ {
+ "target": "t6",
+ "expression": "H*mu/los",
+ "expression_mathml": "Hmulos"
+ }
+ ],
+ "initials": [
+ {
+ "target": "S",
+ "expression": "19339300.0",
+ "expression_mathml": "19339995.0"
+ },
+ {
+ "target": "I",
+ "expression": "175.00000000000000",
+ "expression_mathml": "4.0"
+ },
+ {
+ "target": "E",
+ "expression": "300.00000000000000",
+ "expression_mathml": "1.0"
+ },
+ {
+ "target": "R",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "H",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "D",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ }
+ ],
+ "parameters": [
+ {
+ "id": "N",
+ "value": 19340000.0,
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "beta_c",
+ "value": 0.09,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.05,
+ "maximum": 0.1
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "beta_s",
+ "value": 0.5,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.3,
+ "maximum": 0.6
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "k",
+ "value": 5.0,
+ "units": {
+ "expression": "1",
+ "expression_mathml": "1"
+ }
+ },
+ {
+ "id": "kappa",
+ "value": 1.0,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "t_0",
+ "value": 29.0,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 25.0,
+ "maximum": 35.0
+ }
+ },
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "delta",
+ "value": 0.25,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "eta",
+ "value": 0.1,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.005,
+ "maximum": 0.2
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "gamma",
+ "value": 0.2,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.1,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "los",
+ "value": 5.0,
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "mu",
+ "value": 0.4,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.18,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ }
+ ],
+ "observables": [
+ {
+ "id": "infected",
+ "name": "infected",
+ "expression": "I",
+ "expression_mathml": "I"
+ },
+ {
+ "id": "exposed",
+ "name": "exposed",
+ "expression": "E",
+ "expression_mathml": "E"
+ },
+ {
+ "id": "hospitalized",
+ "name": "hospitalized",
+ "expression": "H",
+ "expression_mathml": "H"
+ },
+ {
+ "id": "dead",
+ "name": "dead",
+ "expression": "D",
+ "expression_mathml": "D"
+ }
+ ],
+ "time": {
+ "id": "t",
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ }
+ }
+ },
+ "metadata": {
+ "annotations": {
+ "license": null,
+ "authors": [],
+ "references": [],
+ "time_scale": null,
+ "time_start": null,
+ "time_end": null,
+ "locations": [],
+ "pathogens": [],
+ "diseases": [],
+ "hosts": [],
+ "model_types": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/notebook/Examples_for_TA2_Model_Representation/model1_working.json b/notebook/Examples_for_TA2_Model_Representation/model1_working.json
new file mode 100644
index 000000000..38ed24951
--- /dev/null
+++ b/notebook/Examples_for_TA2_Model_Representation/model1_working.json
@@ -0,0 +1,424 @@
+{
+ "header": {
+ "name": "SEIRHD model with NPI Type 1 (for Timepoint 1)",
+ "schema": "https://raw.githubusercontent.com/DARPA-ASKEM/Model-Representations/petrinet_v0.5/petrinet/petrinet_schema.json",
+ "schema_name": "petrinet",
+ "description": "SEIRHD model with NPI type 1",
+ "model_version": "0.1",
+ "properties": {}
+ },
+ "model": {
+ "states": [
+ {
+ "id": "S",
+ "name": "S",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000514"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "I",
+ "name": "I",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "E",
+ "name": "E",
+ "grounding": {
+ "identifiers": {
+ "apollosv": "0000154"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "R",
+ "name": "R",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000592"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "H",
+ "name": "H",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ },
+ "modifiers": {
+ "property": "ncit:C25179"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "D",
+ "name": "D",
+ "grounding": {
+ "identifiers": {
+ "ncit": "C28554"
+ },
+ "modifiers": {}
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ }
+ ],
+ "transitions": [
+ {
+ "id": "t1",
+ "input": [
+ "I",
+ "S"
+ ],
+ "output": [
+ "I",
+ "E"
+ ],
+ "properties": {
+ "name": "t1"
+ }
+ },
+ {
+ "id": "t2",
+ "input": [
+ "E"
+ ],
+ "output": [
+ "I"
+ ],
+ "properties": {
+ "name": "t2"
+ }
+ },
+ {
+ "id": "t3",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t3"
+ }
+ },
+ {
+ "id": "t4",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "H"
+ ],
+ "properties": {
+ "name": "t4"
+ }
+ },
+ {
+ "id": "t5",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "t5"
+ }
+ },
+ {
+ "id": "t6",
+ "input": [
+ "H"
+ ],
+ "output": [
+ "D"
+ ],
+ "properties": {
+ "name": "t6"
+ }
+ }
+ ]
+ },
+ "semantics": {
+ "ode": {
+ "rates": [
+ {
+ "target": "t1",
+ "expression": "I*S*kappa*(beta_c + (-beta_c + beta_s)/(1 + exp(-k*(-t + t_0))))/N",
+ "expression_mathml": "ISkappabeta_cbeta_cbeta_s1kt_0tN"
+ },
+ {
+ "target": "t2",
+ "expression": "E*delta",
+ "expression_mathml": "Edelta"
+ },
+ {
+ "target": "t3",
+ "expression": "I*gamma*(1 - eta)",
+ "expression_mathml": "Igamma1eta"
+ },
+ {
+ "target": "t4",
+ "expression": "I*eta*gamma",
+ "expression_mathml": "Ietagamma"
+ },
+ {
+ "target": "t5",
+ "expression": "H*(1 - mu)/los",
+ "expression_mathml": "H1mulos"
+ },
+ {
+ "target": "t6",
+ "expression": "H*mu/los",
+ "expression_mathml": "Hmulos"
+ }
+ ],
+ "initials": [
+ {
+ "target": "S",
+ "expression": "19339300.0",
+ "expression_mathml": "19339995.0"
+ },
+ {
+ "target": "I",
+ "expression": "175.00000000000000",
+ "expression_mathml": "4.0"
+ },
+ {
+ "target": "E",
+ "expression": "300.00000000000000",
+ "expression_mathml": "1.0"
+ },
+ {
+ "target": "R",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "H",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ },
+ {
+ "target": "D",
+ "expression": "0.0",
+ "expression_mathml": "0.0"
+ }
+ ],
+ "parameters": [
+ {
+ "id": "N",
+ "value": 19340000.0,
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "beta_c",
+ "value": 0.09,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.05,
+ "maximum": 0.1
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "beta_s",
+ "value": 0.5,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.3,
+ "maximum": 0.6
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "k",
+ "value": 5.0,
+ "units": {
+ "expression": "1",
+ "expression_mathml": "1"
+ }
+ },
+ {
+ "id": "kappa",
+ "value": 1.0,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "t_0",
+ "value": 29.0,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 25.0,
+ "maximum": 35.0
+ }
+ },
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "delta",
+ "value": 0.25,
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "eta",
+ "value": 0.1,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.005,
+ "maximum": 0.2
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "gamma",
+ "value": 0.2,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.1,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ },
+ {
+ "id": "los",
+ "value": 5.0,
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ },
+ {
+ "id": "mu",
+ "value": 0.4,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.18,
+ "maximum": 0.5
+ }
+ },
+ "units": {
+ "expression": "1/day",
+ "expression_mathml": "day-1"
+ }
+ }
+ ],
+ "observables": [
+ {
+ "id": "infected",
+ "name": "infected",
+ "expression": "I",
+ "expression_mathml": "I"
+ },
+ {
+ "id": "exposed",
+ "name": "exposed",
+ "expression": "E",
+ "expression_mathml": "E"
+ },
+ {
+ "id": "hospitalized",
+ "name": "hospitalized",
+ "expression": "H",
+ "expression_mathml": "H"
+ },
+ {
+ "id": "dead",
+ "name": "dead",
+ "expression": "D",
+ "expression_mathml": "D"
+ }
+ ],
+ "time": {
+ "id": "t",
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ }
+ }
+ },
+ "metadata": {
+ "annotations": {
+ "license": null,
+ "authors": [],
+ "references": [],
+ "time_scale": null,
+ "time_start": null,
+ "time_end": null,
+ "locations": [],
+ "pathogens": [],
+ "diseases": [],
+ "hosts": [],
+ "model_types": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/notebook/Examples_for_TA2_Model_Representation/producing_model_and_AMR_error_messages.ipynb b/notebook/Examples_for_TA2_Model_Representation/producing_model_and_AMR_error_messages.ipynb
new file mode 100644
index 000000000..eff485e76
--- /dev/null
+++ b/notebook/Examples_for_TA2_Model_Representation/producing_model_and_AMR_error_messages.ipynb
@@ -0,0 +1,245 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "a029eec6",
+ "metadata": {},
+ "source": [
+ "This notebook is for improving error messages arising from issues with models and their AMRs."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "d227d9ff",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from pyciemss.PetriNetODE.interfaces import run_petri_model_checks, load_petri_model"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "14b03c98",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/Users/altu809/Projects/pyciemss/src/pyciemss/PetriNetODE/base.py:342: UserWarning: Parameter (('S', ('identity', 'ido:0000514')), ('E', ('identity', 'apollosv:0000154')), ('I', ('identity', 'ido:0000511')), 'ControlledConversion', 'rate') has value None and will be set to Uniform(0, 1). This is likely to be an error.\n",
+ " warnings.warn(warnings_string)\n",
+ "/Users/altu809/Projects/pyciemss/src/pyciemss/PetriNetODE/base.py:342: UserWarning: Parameter (('I', ('identity', 'ido:0000511')), ('R', ('identity', 'ido:0000592')), 'NaturalConversion', 'rate') has value None and will be set to Uniform(0, 1). This is likely to be an error.\n",
+ " warnings.warn(warnings_string)\n",
+ "/Users/altu809/Projects/pyciemss/src/pyciemss/PetriNetODE/base.py:342: UserWarning: Parameter (('I', ('identity', 'ido:0000511')), ('H', ('identity', 'ido:0000511'), ('property', 'ncit:C25179')), 'NaturalConversion', 'rate') has value None and will be set to Uniform(0, 1). This is likely to be an error.\n",
+ " warnings.warn(warnings_string)\n",
+ "/Users/altu809/Projects/pyciemss/src/pyciemss/PetriNetODE/base.py:342: UserWarning: Parameter (('H', ('identity', 'ido:0000511'), ('property', 'ncit:C25179')), ('R', ('identity', 'ido:0000592')), 'NaturalConversion', 'rate') has value None and will be set to Uniform(0, 1). This is likely to be an error.\n",
+ " warnings.warn(warnings_string)\n",
+ "/Users/altu809/Projects/pyciemss/src/pyciemss/PetriNetODE/base.py:342: UserWarning: Parameter (('H', ('identity', 'ido:0000511'), ('property', 'ncit:C25179')), ('D', ('identity', 'ncit:C28554')), 'NaturalConversion', 'rate') has value None and will be set to Uniform(0, 1). This is likely to be an error.\n",
+ " warnings.warn(warnings_string)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "ScaledNormalNoisePetriNetODESystem(\n",
+ "\tN = Uniform(low: 17406000.0, high: 21274000.0),\n",
+ "\tbeta_c = Uniform(low: 0.05000000074505806, high: 0.10000000149011612),\n",
+ "\tbeta_s = Uniform(low: 0.30000001192092896, high: 0.6000000238418579),\n",
+ "\tk = Uniform(low: 4.5, high: 5.5),\n",
+ "\tkappa = Uniform(low: 0.8999999761581421, high: 1.100000023841858),\n",
+ "\tt_0 = Uniform(low: 25.0, high: 35.0),\n",
+ "\t(('S', ('identity', 'ido:0000514')), ('E', ('identity', 'apollosv:0000154')), ('I', ('identity', 'ido:0000511')), 'ControlledConversion', 'rate') = Uniform(low: 0.0, high: 1.0),\n",
+ "\tdelta = Uniform(low: 0.22499999403953552, high: 0.2750000059604645),\n",
+ "\teta = Uniform(low: 0.004999999888241291, high: 0.20000000298023224),\n",
+ "\tgamma = Uniform(low: 0.10000000149011612, high: 0.5),\n",
+ "\t(('I', ('identity', 'ido:0000511')), ('R', ('identity', 'ido:0000592')), 'NaturalConversion', 'rate') = Uniform(low: 0.0, high: 1.0),\n",
+ "\t(('I', ('identity', 'ido:0000511')), ('H', ('identity', 'ido:0000511'), ('property', 'ncit:C25179')), 'NaturalConversion', 'rate') = Uniform(low: 0.0, high: 1.0),\n",
+ "\tlos = Uniform(low: 4.5, high: 5.5),\n",
+ "\tmu = Uniform(low: 0.18000000715255737, high: 0.5),\n",
+ "\t(('H', ('identity', 'ido:0000511'), ('property', 'ncit:C25179')), ('R', ('identity', 'ido:0000592')), 'NaturalConversion', 'rate') = Uniform(low: 0.0, high: 1.0),\n",
+ "\t(('H', ('identity', 'ido:0000511'), ('property', 'ncit:C25179')), ('D', ('identity', 'ncit:C28554')), 'NaturalConversion', 'rate') = Uniform(low: 0.0, high: 1.0),\n",
+ "\tnoise_scale = 0.10000000149011612\n",
+ ")"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# This model should load properly\n",
+ "model1 = \"../../notebook/Examples_for_TA2_Model_Representation/model1_working.json\"\n",
+ "load_petri_model(model1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "76abc77d",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "File not found. Make sure you have the correct model path.\n"
+ ]
+ },
+ {
+ "ename": "KeyError",
+ "evalue": "'model'",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[3], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Expect to get \"File not found.\"\u001b[39;00m\n\u001b[1;32m 2\u001b[0m model1 \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m../../notebook/Examples_for_TA2_Model_Representation/model1.json\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mload_petri_model\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel1\u001b[49m\u001b[43m)\u001b[49m\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:113\u001b[0m, in \u001b[0;36mload_petri_model\u001b[0;34m(petri_model_or_path, add_uncertainty, noise_model, noise_scale, compile_observables_p, compile_rate_law_p)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_beta\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m run_petri_model_checks(petri_model_or_path):\n\u001b[1;32m 110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledBetaNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 111\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 112\u001b[0m )\n\u001b[0;32m--> 113\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_normal\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m \u001b[43mrun_petri_model_checks\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpetri_model_or_path\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[1;32m 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledNormalNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 115\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 116\u001b[0m )\n\u001b[1;32m 117\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:76\u001b[0m, in \u001b[0;36mrun_petri_model_checks\u001b[0;34m(petri_model_or_path)\u001b[0m\n\u001b[1;32m 73\u001b[0m missing_keys \u001b[38;5;241m=\u001b[39m [key \u001b[38;5;28;01mfor\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m required_keys \u001b[38;5;28;01mif\u001b[39;00m key \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m amr_dict]\n\u001b[1;32m 75\u001b[0m \u001b[38;5;66;03m# Get the number of transitions and rate laws for comparison \u001b[39;00m\n\u001b[0;32m---> 76\u001b[0m num_transitions \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(\u001b[43mamr_dict\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmodel\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtransitions\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m 77\u001b[0m num_rate_laws \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(amr_dict[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msemantics\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mode\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrates\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m 79\u001b[0m \u001b[38;5;66;03m# Check that every state variable is assigned an initial condition\u001b[39;00m\n",
+ "\u001b[0;31mKeyError\u001b[0m: 'model'"
+ ]
+ }
+ ],
+ "source": [
+ "# Expect to get \"File not found.\"\n",
+ "model1 = \"../../notebook/Examples_for_TA2_Model_Representation/model1.json\"\n",
+ "load_petri_model(model1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "1b9d220a",
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "ValueError",
+ "evalue": "The AMR is missing: header",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[4], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Expect to be told the AMR has no \"header\"\u001b[39;00m\n\u001b[1;32m 2\u001b[0m model1 \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m../../notebook/Examples_for_TA2_Model_Representation/model1_no_header.json\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mload_petri_model\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel1\u001b[49m\u001b[43m)\u001b[49m\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:113\u001b[0m, in \u001b[0;36mload_petri_model\u001b[0;34m(petri_model_or_path, add_uncertainty, noise_model, noise_scale, compile_observables_p, compile_rate_law_p)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_beta\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m run_petri_model_checks(petri_model_or_path):\n\u001b[1;32m 110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledBetaNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 111\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 112\u001b[0m )\n\u001b[0;32m--> 113\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_normal\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m \u001b[43mrun_petri_model_checks\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpetri_model_or_path\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[1;32m 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledNormalNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 115\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 116\u001b[0m )\n\u001b[1;32m 117\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:85\u001b[0m, in \u001b[0;36mrun_petri_model_checks\u001b[0;34m(petri_model_or_path)\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m missing_keys:\n\u001b[1;32m 84\u001b[0m missing_keys_str \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(missing_keys)\n\u001b[0;32m---> 85\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThe AMR is missing: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmissing_keys_str\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 86\u001b[0m \u001b[38;5;66;03m# Check that the number of transitions matches the number of rate laws\u001b[39;00m\n\u001b[1;32m 87\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m num_transitions \u001b[38;5;241m<\u001b[39m num_rate_laws:\n",
+ "\u001b[0;31mValueError\u001b[0m: The AMR is missing: header"
+ ]
+ }
+ ],
+ "source": [
+ "# Expect to be told the AMR has no \"header\"\n",
+ "model1 = \"../../notebook/Examples_for_TA2_Model_Representation/model1_no_header.json\"\n",
+ "load_petri_model(model1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "236f1de3",
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "ValueError",
+ "evalue": "At least one transition is missing. The number of transitions must equal the number of rate laws.",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[5], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Expect to be told there are more rate laws than transitions\u001b[39;00m\n\u001b[1;32m 2\u001b[0m model1 \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m../../notebook/Examples_for_TA2_Model_Representation/model1_missing_transition.json\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mload_petri_model\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel1\u001b[49m\u001b[43m)\u001b[49m\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:113\u001b[0m, in \u001b[0;36mload_petri_model\u001b[0;34m(petri_model_or_path, add_uncertainty, noise_model, noise_scale, compile_observables_p, compile_rate_law_p)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_beta\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m run_petri_model_checks(petri_model_or_path):\n\u001b[1;32m 110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledBetaNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 111\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 112\u001b[0m )\n\u001b[0;32m--> 113\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_normal\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m \u001b[43mrun_petri_model_checks\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpetri_model_or_path\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[1;32m 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledNormalNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 115\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 116\u001b[0m )\n\u001b[1;32m 117\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:88\u001b[0m, in \u001b[0;36mrun_petri_model_checks\u001b[0;34m(petri_model_or_path)\u001b[0m\n\u001b[1;32m 86\u001b[0m \u001b[38;5;66;03m# Check that the number of transitions matches the number of rate laws\u001b[39;00m\n\u001b[1;32m 87\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m num_transitions \u001b[38;5;241m<\u001b[39m num_rate_laws:\n\u001b[0;32m---> 88\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAt least one transition is missing. The number of transitions must equal the number of rate laws.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 89\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m num_transitions \u001b[38;5;241m>\u001b[39m num_rate_laws:\n\u001b[1;32m 90\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThere are more transitions than rate laws. The number of transitions must equal the number of rate laws.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
+ "\u001b[0;31mValueError\u001b[0m: At least one transition is missing. The number of transitions must equal the number of rate laws."
+ ]
+ }
+ ],
+ "source": [
+ "# Expect to be told there are more rate laws than transitions\n",
+ "model1 = \"../../notebook/Examples_for_TA2_Model_Representation/model1_missing_transition.json\"\n",
+ "load_petri_model(model1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "9e2469ff",
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "ValueError",
+ "evalue": "There are more transitions than rate laws. The number of transitions must equal the number of rate laws.",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[6], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Expect to be told there are more transitions than rate laws\u001b[39;00m\n\u001b[1;32m 2\u001b[0m model1 \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m../../notebook/Examples_for_TA2_Model_Representation/model1_missing_rate_law.json\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mload_petri_model\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel1\u001b[49m\u001b[43m)\u001b[49m\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:113\u001b[0m, in \u001b[0;36mload_petri_model\u001b[0;34m(petri_model_or_path, add_uncertainty, noise_model, noise_scale, compile_observables_p, compile_rate_law_p)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_beta\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m run_petri_model_checks(petri_model_or_path):\n\u001b[1;32m 110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledBetaNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 111\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 112\u001b[0m )\n\u001b[0;32m--> 113\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_normal\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m \u001b[43mrun_petri_model_checks\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpetri_model_or_path\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[1;32m 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledNormalNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 115\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 116\u001b[0m )\n\u001b[1;32m 117\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:90\u001b[0m, in \u001b[0;36mrun_petri_model_checks\u001b[0;34m(petri_model_or_path)\u001b[0m\n\u001b[1;32m 88\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAt least one transition is missing. The number of transitions must equal the number of rate laws.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 89\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m num_transitions \u001b[38;5;241m>\u001b[39m num_rate_laws:\n\u001b[0;32m---> 90\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThere are more transitions than rate laws. The number of transitions must equal the number of rate laws.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 91\u001b[0m \u001b[38;5;66;03m# Check that every state variable is assigned an initial condition\u001b[39;00m\n\u001b[1;32m 92\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m missing_ids:\n",
+ "\u001b[0;31mValueError\u001b[0m: There are more transitions than rate laws. The number of transitions must equal the number of rate laws."
+ ]
+ }
+ ],
+ "source": [
+ "# Expect to be told there are more transitions than rate laws\n",
+ "model1 = \"../../notebook/Examples_for_TA2_Model_Representation/model1_missing_rate_law.json\"\n",
+ "load_petri_model(model1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "dca271e6",
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "ValueError",
+ "evalue": "The following state variables do not have corresponding initials: R",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[8], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Expect to be told there is no initial condition for \"R\"\u001b[39;00m\n\u001b[1;32m 2\u001b[0m model1 \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m../../notebook/Examples_for_TA2_Model_Representation/model1_missing_initial.json\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mload_petri_model\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel1\u001b[49m\u001b[43m)\u001b[49m\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:113\u001b[0m, in \u001b[0;36mload_petri_model\u001b[0;34m(petri_model_or_path, add_uncertainty, noise_model, noise_scale, compile_observables_p, compile_rate_law_p)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_beta\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m run_petri_model_checks(petri_model_or_path):\n\u001b[1;32m 110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledBetaNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 111\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 112\u001b[0m )\n\u001b[0;32m--> 113\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m (noise_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscaled_normal\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m \u001b[43mrun_petri_model_checks\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpetri_model_or_path\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[1;32m 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ScaledNormalNoisePetriNetODESystem\u001b[38;5;241m.\u001b[39mfrom_askenet(\n\u001b[1;32m 115\u001b[0m petri_model_or_path, noise_scale\u001b[38;5;241m=\u001b[39mnoise_scale, compile_rate_law_p\u001b[38;5;241m=\u001b[39mcompile_rate_law_p, compile_observables_p\u001b[38;5;241m=\u001b[39mcompile_observables_p, add_uncertainty\u001b[38;5;241m=\u001b[39madd_uncertainty\n\u001b[1;32m 116\u001b[0m )\n\u001b[1;32m 117\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/PetriNetODE/interfaces.py:94\u001b[0m, in \u001b[0;36mrun_petri_model_checks\u001b[0;34m(petri_model_or_path)\u001b[0m\n\u001b[1;32m 92\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m missing_ids:\n\u001b[1;32m 93\u001b[0m missing_ids_str \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(missing_ids)\n\u001b[0;32m---> 94\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThe following state variables do not have corresponding initials: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmissing_ids_str\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 95\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 96\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m\n",
+ "\u001b[0;31mValueError\u001b[0m: The following state variables do not have corresponding initials: R"
+ ]
+ }
+ ],
+ "source": [
+ "# Expect to be told there is no initial condition for \"R\"\n",
+ "model1 = \"../../notebook/Examples_for_TA2_Model_Representation/model1_missing_initial.json\"\n",
+ "load_petri_model(model1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4c7e643a",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/notebook/april_ensemble/syndata_generate_and_test.ipynb b/notebook/april_ensemble/syndata_generate_and_test.ipynb
index bcc9f7deb..c694018e9 100644
--- a/notebook/april_ensemble/syndata_generate_and_test.ipynb
+++ b/notebook/april_ensemble/syndata_generate_and_test.ipynb
@@ -19,9 +19,23 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "AttributeError",
+ "evalue": "module 'torch' has no attribute 'fx'",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpyciemss\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mutils\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpetri_utils\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m deterministic\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/utils/__init__.py:1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpetri_utils\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m (seq_id_suffix,\n\u001b[1;32m 2\u001b[0m reparameterize,\n\u001b[1;32m 3\u001b[0m load_sim_result,\n\u001b[1;32m 4\u001b[0m load,\n\u001b[1;32m 5\u001b[0m draw_petri,\n\u001b[1;32m 6\u001b[0m natural_order,\n\u001b[1;32m 7\u001b[0m add_state_indicies,\n\u001b[1;32m 8\u001b[0m register_template,\n\u001b[1;32m 9\u001b[0m natural_conversion,\n\u001b[1;32m 10\u001b[0m natural_degradation,\n\u001b[1;32m 11\u001b[0m natural_order,\n\u001b[1;32m 12\u001b[0m controlled_conversion,\n\u001b[1;32m 13\u001b[0m grouped_controlled_conversion,\n\u001b[1;32m 14\u001b[0m deterministic,\n\u001b[1;32m 15\u001b[0m petri_to_ode,\n\u001b[1;32m 16\u001b[0m order_state,\n\u001b[1;32m 17\u001b[0m reparameterize,\n\u001b[1;32m 18\u001b[0m unorder_state,\n\u001b[1;32m 19\u001b[0m duplicate_petri_net,\n\u001b[1;32m 20\u001b[0m intervene_petri_net)\n\u001b[1;32m 21\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01minference_utils\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m (get_tspan,\n\u001b[1;32m 22\u001b[0m state_flux_constraint,\n\u001b[1;32m 23\u001b[0m run_inference,\n\u001b[1;32m 24\u001b[0m is_density_equal,\n\u001b[1;32m 25\u001b[0m is_intervention_density_equal)\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mplot_utils\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m (setup_ax,\n\u001b[1;32m 27\u001b[0m plot_predictive,\n\u001b[1;32m 28\u001b[0m plot_trajectory,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 31\u001b[0m sideaxis,\n\u001b[1;32m 32\u001b[0m sideaxishist)\n",
+ "File \u001b[0;32m~/Projects/pyciemss/src/pyciemss/utils/petri_utils.py:264\u001b[0m\n\u001b[1;32m 259\u001b[0m \u001b[38;5;129m@register_template\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGroupedControlledConversion\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 260\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mgrouped_controlled_conversion\u001b[39m(params: Dict[\u001b[38;5;28mstr\u001b[39m, T], t: T, states: Tuple[T, \u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m]) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Tuple[T, \u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m]:\n\u001b[1;32m 261\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m \u001b[38;5;66;03m# TODO\u001b[39;00m\n\u001b[0;32m--> 264\u001b[0m \u001b[38;5;129m@torch\u001b[39m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfx\u001b[49m\u001b[38;5;241m.\u001b[39mwrap\n\u001b[1;32m 265\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdeterministic\u001b[39m(name, value, \u001b[38;5;241m*\u001b[39m, event_dim\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 266\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m pyro\u001b[38;5;241m.\u001b[39mdeterministic(name, value, event_dim\u001b[38;5;241m=\u001b[39mevent_dim)\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mpetri_to_ode\u001b[39m(\n\u001b[1;32m 270\u001b[0m G: nx\u001b[38;5;241m.\u001b[39mMultiDiGraph,\n\u001b[1;32m 271\u001b[0m funcs: Optional[Dict[\u001b[38;5;28mstr\u001b[39m, Callable[[Tuple[T, \u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m], T], Tuple[T, \u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m]]]] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 272\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Callable[[T, Tuple[T, \u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m]], Tuple[T, \u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m]]:\n",
+ "\u001b[0;31mAttributeError\u001b[0m: module 'torch' has no attribute 'fx'"
+ ]
+ }
+ ],
"source": [
"from pyciemss.utils.synth_data_utils import *"
]
diff --git a/notebook/april_ensemble/synthetic_data_with_custom_models.ipynb b/notebook/april_ensemble/synthetic_data_with_custom_models.ipynb
index feddd6aa9..b739058ab 100644
--- a/notebook/april_ensemble/synthetic_data_with_custom_models.ipynb
+++ b/notebook/april_ensemble/synthetic_data_with_custom_models.ipynb
@@ -26,7 +26,19 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "ModuleNotFoundError",
+ "evalue": "No module named 'pyro'",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[1], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mos\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtorch\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpyro\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpyro\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdistributions\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mdist\u001b[39;00m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpd\u001b[39;00m\n",
+ "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pyro'"
+ ]
+ }
+ ],
"source": [
"import os\n",
"import torch\n",
@@ -1787,7 +1799,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.3"
+ "version": "3.10.9"
}
},
"nbformat": 4,
diff --git a/src/pyciemss/PetriNetODE/interfaces.py b/src/pyciemss/PetriNetODE/interfaces.py
index 12c437644..f3c95d591 100644
--- a/src/pyciemss/PetriNetODE/interfaces.py
+++ b/src/pyciemss/PetriNetODE/interfaces.py
@@ -26,6 +26,7 @@
from pyciemss.visuals import plots
import mira
+import json
# Load base interfaces
from pyciemss.interfaces import (
@@ -53,6 +54,46 @@
PetriSolution = dict # NOTE: [str, torch.tensor] type argument removed because of issues with type-based dispatch.
PetriInferredParameters = pyro.nn.PyroModule
+def run_petri_model_checks(petri_model_or_path: Union[str, mira.metamodel.TemplateModel, mira.modeling.Model]) -> bool:
+ """
+ Check that the model AMR (a) is readable/formatted correctly, (b) that the number of transitions matches the number of rate laws, and (c) includes initial conditions for each state variable.
+ """
+ amr_dict = {}
+ # Read the AMR as a dictionary and alert the user if the model path is incorrect, or the AMR in not properly formatted
+ try:
+ with open(petri_model_or_path, 'r') as file:
+ amr_dict = json.load(file)
+ except FileNotFoundError:
+ print("File not found. Make sure you have the correct model path.")
+ except json.JSONDecodeError:
+ print("Error decoding JSON data. Check that the AMR is formatted correctly.")
+
+ # Check that the AMR contains the required header, model, semantics, and metadata keys:
+ required_keys = ['header', 'model', 'semantics', 'metadata']
+ missing_keys = [key for key in required_keys if key not in amr_dict]
+
+ # Get the number of transitions and rate laws for comparison
+ num_transitions = len(amr_dict["model"]["transitions"])
+ num_rate_laws = len(amr_dict["semantics"]["ode"]["rates"])
+
+ # Check that every state variable is assigned an initial condition
+ missing_ids = [state['id'] for state in amr_dict["model"]["states"] if state['id'] not in set(item['target'] for item in amr_dict["semantics"]["ode"]["initials"])]
+
+ # Check that the AMR contains the required header, model, semantics, and metadata keys:
+ if missing_keys:
+ missing_keys_str = ', '.join(missing_keys)
+ raise ValueError(f"The AMR is missing: {missing_keys_str}")
+ # Check that the number of transitions matches the number of rate laws
+ elif num_transitions < num_rate_laws:
+ raise ValueError("At least one transition is missing. The number of transitions must equal the number of rate laws.")
+ elif num_transitions > num_rate_laws:
+ raise ValueError("There are more transitions than rate laws. The number of transitions must equal the number of rate laws.")
+ # Check that every state variable is assigned an initial condition
+ elif missing_ids:
+ missing_ids_str = ', '.join(missing_ids)
+ raise ValueError(f"The following state variables do not have corresponding initials: {missing_ids_str}")
+ else:
+ return True
def load_petri_model(
petri_model_or_path: Union[str, mira.metamodel.TemplateModel, mira.modeling.Model],
@@ -65,11 +106,11 @@ def load_petri_model(
"""
Load a petri net from a file and compile it into a probabilistic program.
"""
- if noise_model == "scaled_beta":
+ if (noise_model == "scaled_beta") and run_petri_model_checks(petri_model_or_path):
return ScaledBetaNoisePetriNetODESystem.from_askenet(
petri_model_or_path, noise_scale=noise_scale, compile_rate_law_p=compile_rate_law_p, compile_observables_p=compile_observables_p, add_uncertainty=add_uncertainty
)
- elif noise_model == "scaled_normal":
+ elif (noise_model == "scaled_normal") and run_petri_model_checks(petri_model_or_path):
return ScaledNormalNoisePetriNetODESystem.from_askenet(
petri_model_or_path, noise_scale=noise_scale, compile_rate_law_p=compile_rate_law_p, compile_observables_p=compile_observables_p, add_uncertainty=add_uncertainty
)
diff --git a/src/pyciemss/utils/__init__.py b/src/pyciemss/utils/__init__.py
index 6789e6032..8abb3a917 100644
--- a/src/pyciemss/utils/__init__.py
+++ b/src/pyciemss/utils/__init__.py
@@ -11,7 +11,7 @@
natural_order,
controlled_conversion,
grouped_controlled_conversion,
- deterministic,
+# deterministic,
petri_to_ode,
order_state,
reparameterize,
diff --git a/src/pyciemss/utils/petri_utils.py b/src/pyciemss/utils/petri_utils.py
index f09125f15..adab743c0 100644
--- a/src/pyciemss/utils/petri_utils.py
+++ b/src/pyciemss/utils/petri_utils.py
@@ -261,9 +261,9 @@ def grouped_controlled_conversion(params: Dict[str, T], t: T, states: Tuple[T, .
raise NotImplementedError # TODO
-@torch.fx.wrap
-def deterministic(name, value, *, event_dim=None):
- return pyro.deterministic(name, value, event_dim=event_dim)
+# @torch.fx.wrap
+# def deterministic(name, value, *, event_dim=None):
+# return pyro.deterministic(name, value, event_dim=event_dim)
def petri_to_ode(