From bf859b70f5224a3456c23c003ea4d80206646a61 Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Wed, 12 Jul 2023 16:53:32 -0400 Subject: [PATCH] Fix units of N after norm --- mira/metamodel/ops.py | 2 + notebooks/hackathon_2023.07/scenario1.ipynb | 88 ++++++++---- .../scenario1_d_normalized.json | 130 +++++++++++++++++- 3 files changed, 189 insertions(+), 31 deletions(-) diff --git a/mira/metamodel/ops.py b/mira/metamodel/ops.py index 8e69ac3ca..f3cfa96ed 100644 --- a/mira/metamodel/ops.py +++ b/mira/metamodel/ops.py @@ -490,6 +490,8 @@ def counts_to_dimensionless(tm: TemplateModel, if p.units: (coeff, exponent) = \ p.units.expression.args[0].as_coeff_exponent(counts_unit_symbol) + if isinstance(exponent, sympy.core.numbers.One): + exponent = 1 if exponent: p.units.expression = \ SympyExprStr(p.units.expression.args[0] / diff --git a/notebooks/hackathon_2023.07/scenario1.ipynb b/notebooks/hackathon_2023.07/scenario1.ipynb index a32d045d1..93728520d 100644 --- a/notebooks/hackathon_2023.07/scenario1.ipynb +++ b/notebooks/hackathon_2023.07/scenario1.ipynb @@ -282,7 +282,7 @@ " 'delta': Parameter(name='delta', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=1/day), value=0.2, distribution=None),\n", " 'alpha': Parameter(name='alpha', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=1), value=6.4e-05, distribution=None),\n", " 'rho': Parameter(name='rho', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=1/day), value=0.1111111111111111, distribution=None),\n", - " 'N': Parameter(name='N', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=1), value=1.00000000000000, distribution=None),\n", + " 'N': Parameter(name='N', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=1), value=1.0, distribution=None),\n", " 'beta_s': Parameter(name='beta_s', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=1/day), value=1.0, distribution=None),\n", " 'beta_c': Parameter(name='beta_c', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=1/day), value=0.4, distribution=None),\n", " 't_0': Parameter(name='t_0', display_name=None, description=None, identifiers={}, context={}, units=Unit(expression=day), value=89.0, distribution=None),\n", @@ -332,30 +332,10 @@ "cell_type": "code", "execution_count": 15, "id": "831f2be9", - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "Object of type Float is not JSON serializable", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[15], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mAskeNetPetriNetModel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mModel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtm_norm\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_json_file\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mscenario1_d_normalized.json\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Dropbox/postdoc/askem/src/mira/mira/modeling/askenet/petrinet.py:262\u001b[0m, in \u001b[0;36mAskeNetPetriNetModel.to_json_file\u001b[0;34m(self, fname, name, description, model_version, **kwargs)\u001b[0m\n\u001b[1;32m 259\u001b[0m js \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mto_json(name\u001b[38;5;241m=\u001b[39mname, description\u001b[38;5;241m=\u001b[39mdescription,\n\u001b[1;32m 260\u001b[0m model_version\u001b[38;5;241m=\u001b[39mmodel_version)\n\u001b[1;32m 261\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(fname, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m fh:\n\u001b[0;32m--> 262\u001b[0m \u001b[43mjson\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdump\u001b[49m\u001b[43m(\u001b[49m\u001b[43mjs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfh\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindent\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindent\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/__init__.py:179\u001b[0m, in \u001b[0;36mdump\u001b[0;34m(obj, fp, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)\u001b[0m\n\u001b[1;32m 173\u001b[0m iterable \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mcls\u001b[39m(skipkeys\u001b[38;5;241m=\u001b[39mskipkeys, ensure_ascii\u001b[38;5;241m=\u001b[39mensure_ascii,\n\u001b[1;32m 174\u001b[0m check_circular\u001b[38;5;241m=\u001b[39mcheck_circular, allow_nan\u001b[38;5;241m=\u001b[39mallow_nan, indent\u001b[38;5;241m=\u001b[39mindent,\n\u001b[1;32m 175\u001b[0m separators\u001b[38;5;241m=\u001b[39mseparators,\n\u001b[1;32m 176\u001b[0m default\u001b[38;5;241m=\u001b[39mdefault, sort_keys\u001b[38;5;241m=\u001b[39msort_keys, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkw)\u001b[38;5;241m.\u001b[39miterencode(obj)\n\u001b[1;32m 177\u001b[0m \u001b[38;5;66;03m# could accelerate with writelines in some versions of Python, at\u001b[39;00m\n\u001b[1;32m 178\u001b[0m \u001b[38;5;66;03m# a debuggability cost\u001b[39;00m\n\u001b[0;32m--> 179\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m chunk \u001b[38;5;129;01min\u001b[39;00m iterable:\n\u001b[1;32m 180\u001b[0m fp\u001b[38;5;241m.\u001b[39mwrite(chunk)\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:431\u001b[0m, in \u001b[0;36m_make_iterencode.._iterencode\u001b[0;34m(o, _current_indent_level)\u001b[0m\n\u001b[1;32m 429\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m _iterencode_list(o, _current_indent_level)\n\u001b[1;32m 430\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(o, \u001b[38;5;28mdict\u001b[39m):\n\u001b[0;32m--> 431\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m _iterencode_dict(o, _current_indent_level)\n\u001b[1;32m 432\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 433\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m markers \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:405\u001b[0m, in \u001b[0;36m_make_iterencode.._iterencode_dict\u001b[0;34m(dct, _current_indent_level)\u001b[0m\n\u001b[1;32m 403\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 404\u001b[0m chunks \u001b[38;5;241m=\u001b[39m _iterencode(value, _current_indent_level)\n\u001b[0;32m--> 405\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m chunks\n\u001b[1;32m 406\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m newline_indent \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 407\u001b[0m _current_indent_level \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:405\u001b[0m, in \u001b[0;36m_make_iterencode.._iterencode_dict\u001b[0;34m(dct, _current_indent_level)\u001b[0m\n\u001b[1;32m 403\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 404\u001b[0m chunks \u001b[38;5;241m=\u001b[39m _iterencode(value, _current_indent_level)\n\u001b[0;32m--> 405\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m chunks\n\u001b[1;32m 406\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m newline_indent \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 407\u001b[0m _current_indent_level \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:405\u001b[0m, in \u001b[0;36m_make_iterencode.._iterencode_dict\u001b[0;34m(dct, _current_indent_level)\u001b[0m\n\u001b[1;32m 403\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 404\u001b[0m chunks \u001b[38;5;241m=\u001b[39m _iterencode(value, _current_indent_level)\n\u001b[0;32m--> 405\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m chunks\n\u001b[1;32m 406\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m newline_indent \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 407\u001b[0m _current_indent_level \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:325\u001b[0m, in \u001b[0;36m_make_iterencode.._iterencode_list\u001b[0;34m(lst, _current_indent_level)\u001b[0m\n\u001b[1;32m 323\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 324\u001b[0m chunks \u001b[38;5;241m=\u001b[39m _iterencode(value, _current_indent_level)\n\u001b[0;32m--> 325\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m chunks\n\u001b[1;32m 326\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m newline_indent \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 327\u001b[0m _current_indent_level \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:405\u001b[0m, in \u001b[0;36m_make_iterencode.._iterencode_dict\u001b[0;34m(dct, _current_indent_level)\u001b[0m\n\u001b[1;32m 403\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 404\u001b[0m chunks \u001b[38;5;241m=\u001b[39m _iterencode(value, _current_indent_level)\n\u001b[0;32m--> 405\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m chunks\n\u001b[1;32m 406\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m newline_indent \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 407\u001b[0m _current_indent_level \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:438\u001b[0m, in \u001b[0;36m_make_iterencode.._iterencode\u001b[0;34m(o, _current_indent_level)\u001b[0m\n\u001b[1;32m 436\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;124mCircular reference detected\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 437\u001b[0m markers[markerid] \u001b[38;5;241m=\u001b[39m o\n\u001b[0;32m--> 438\u001b[0m o \u001b[38;5;241m=\u001b[39m \u001b[43m_default\u001b[49m\u001b[43m(\u001b[49m\u001b[43mo\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 439\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m _iterencode(o, _current_indent_level)\n\u001b[1;32m 440\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m markers \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", - "File \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py:179\u001b[0m, in \u001b[0;36mJSONEncoder.default\u001b[0;34m(self, o)\u001b[0m\n\u001b[1;32m 160\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdefault\u001b[39m(\u001b[38;5;28mself\u001b[39m, o):\n\u001b[1;32m 161\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Implement this method in a subclass such that it returns\u001b[39;00m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;124;03m a serializable object for ``o``, or calls the base implementation\u001b[39;00m\n\u001b[1;32m 163\u001b[0m \u001b[38;5;124;03m (to raise a ``TypeError``).\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 177\u001b[0m \n\u001b[1;32m 178\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 179\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mObject of type \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mo\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 180\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mis not JSON serializable\u001b[39m\u001b[38;5;124m'\u001b[39m)\n", - "\u001b[0;31mTypeError\u001b[0m: Object of type Float is not JSON serializable" - ] - } - ], + "metadata": { + "scrolled": true + }, + "outputs": [], "source": [ "AskeNetPetriNetModel(Model(tm_norm)).to_json_file('scenario1_d_normalized.json')" ] @@ -371,7 +351,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "3c2a2909", "metadata": {}, "outputs": [], @@ -386,20 +366,68 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "8f7f4015", "metadata": { "scrolled": false }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[ControlledConversion(rate_law=I_u*S_u*kappa_0*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), subject=Concept(name='S_u', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_v1*S_u*kappa_1*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), subject=Concept(name='S_u', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_v2*S_u*kappa_2*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), subject=Concept(name='S_u', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_v1*S_v1*kappa_3*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), subject=Concept(name='S_v1', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='E_v1', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_u*S_v1*kappa_4*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), subject=Concept(name='S_v1', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='E_v1', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_v2*S_v1*kappa_5*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), subject=Concept(name='S_v1', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='E_v1', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_v2*S_v2*kappa_6*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), subject=Concept(name='S_v2', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='E_v2', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_u*S_v2*kappa_7*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), subject=Concept(name='S_v2', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='E_v2', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " ControlledConversion(rate_law=I_v1*S_v2*kappa_8*(beta_nc + (beta_c - beta_nc)/(1 + exp(-k_2*(-t + t_1))) + (-beta_c + beta_s)/(1 + exp(-k_1*(-t + t_0))))/N, type='ControlledConversion', controller=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), subject=Concept(name='S_v2', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='E_v2', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=E_u*delta, type='NaturalConversion', subject=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=E_v1*delta, type='NaturalConversion', subject=Concept(name='E_v1', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=E_v2*delta, type='NaturalConversion', subject=Concept(name='E_v2', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=I_u*gamma*(1 - alpha), type='NaturalConversion', subject=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='R_u', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=I_v1*gamma*(1 - alpha), type='NaturalConversion', subject=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='R_v1', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=I_v2*gamma*(1 - alpha), type='NaturalConversion', subject=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='R_v2', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=I_u*alpha*rho, type='NaturalConversion', subject=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='D_u', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=I_v1*alpha*rho, type='NaturalConversion', subject=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='D_v1', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=I_v2*alpha*rho, type='NaturalConversion', subject=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='D_v2', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='S_u', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='S_v1', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='S_v1', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='S_u', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='E_v1', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='E_v1', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='I_v1', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='R_u', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='R_v1', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='R_v1', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='R_u', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='D_u', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='D_v1', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'v1'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='D_v1', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'v1'}, units=Unit(expression=1)), outcome=Concept(name='D_u', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='S_u', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='S_v2', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='S_v2', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='S_u', display_name=None, description=None, identifiers={'ido': '0000514'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='E_v2', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='E_v2', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='E_u', display_name=None, description=None, identifiers={'apollosv': '0000154'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='I_v2', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='I_u', display_name=None, description=None, identifiers={'ido': '0000511'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='R_u', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='R_v2', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='R_v2', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='R_u', display_name=None, description=None, identifiers={'ido': '0000592'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='D_u', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'u'}, units=Unit(expression=1)), outcome=Concept(name='D_v2', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'v2'}, units=Unit(expression=1)), provenance=[]),\n", + " NaturalConversion(rate_law=None, type='NaturalConversion', subject=Concept(name='D_v2', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'v2'}, units=Unit(expression=1)), outcome=Concept(name='D_u', display_name=None, description=None, identifiers={'ncit': 'C28554'}, context={'vax': 'u'}, units=Unit(expression=1)), provenance=[])]" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "tm_age.templates" ] }, { "cell_type": "code", - "execution_count": null, - "id": "716390c4", + "execution_count": 18, + "id": "ead3698d", "metadata": {}, "outputs": [], "source": [ diff --git a/notebooks/hackathon_2023.07/scenario1_d_normalized.json b/notebooks/hackathon_2023.07/scenario1_d_normalized.json index c758d3763..f6852df82 100644 --- a/notebooks/hackathon_2023.07/scenario1_d_normalized.json +++ b/notebooks/hackathon_2023.07/scenario1_d_normalized.json @@ -185,4 +185,132 @@ "parameters": [ { "id": "N", - "value": \ No newline at end of file + "value": 1.0, + "units": { + "expression": "1", + "expression_mathml": "1" + } + }, + { + "id": "beta_c", + "value": 0.4, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, + { + "id": "beta_nc", + "value": 0.5, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, + { + "id": "beta_s", + "value": 1.0, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, + { + "id": "k_1", + "value": 5.0, + "units": { + "expression": "1", + "expression_mathml": "1" + } + }, + { + "id": "k_2", + "value": 1.0, + "units": { + "expression": "1", + "expression_mathml": "1" + } + }, + { + "id": "kappa", + "value": 0.45454545454545453, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, + { + "id": "t_0", + "value": 89.0, + "units": { + "expression": "day", + "expression_mathml": "day" + } + }, + { + "id": "t_1", + "value": 154.0, + "units": { + "expression": "day", + "expression_mathml": "day" + } + }, + { + "id": "delta", + "value": 0.2, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, + { + "id": "alpha", + "value": 6.4e-05, + "units": { + "expression": "1", + "expression_mathml": "1" + } + }, + { + "id": "gamma", + "value": 0.09090909090909091, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, + { + "id": "rho", + "value": 0.1111111111111111, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + } + ], + "observables": [], + "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