diff --git a/mira/metamodel/templates.py b/mira/metamodel/templates.py index cb80e3cf4..c2961e571 100644 --- a/mira/metamodel/templates.py +++ b/mira/metamodel/templates.py @@ -124,6 +124,10 @@ class Concept(BaseModel): """ name: str = Field(..., description="The name of the concept.") + display_name: str = \ + Field(None, description="An optional display name for the concept. " + "If not provided, the name can be used for " + "display purposes.") description: Optional[str] = \ Field(None, description="An optional description of the concept.") identifiers: Mapping[str, str] = Field( diff --git a/mira/modeling/askenet/petrinet.py b/mira/modeling/askenet/petrinet.py index 1a3674817..dc93a35ba 100644 --- a/mira/modeling/askenet/petrinet.py +++ b/mira/modeling/askenet/petrinet.py @@ -55,6 +55,7 @@ def __init__(self, model: Model): # Use the variable's concept name if possible but fall back # on the key otherwise vmap[key] = name = var.concept.name or str(key) + display_name = var.concept.display_name or name # State structure # { # 'id': str, @@ -63,7 +64,7 @@ def __init__(self, model: Model): # } states_dict = { 'id': name, - 'name': name, + 'name': display_name, 'grounding': { 'identifiers': {k: v for k, v in var.concept.identifiers.items() diff --git a/mira/sources/askenet/petrinet.py b/mira/sources/askenet/petrinet.py index 67e812851..7cb71ed6f 100644 --- a/mira/sources/askenet/petrinet.py +++ b/mira/sources/askenet/petrinet.py @@ -226,7 +226,11 @@ def state_to_concept(state): # } # } # } - name = state.get('name') or state['id'] + # Note that in the shared representation we have id and name + # whereas for Concepts in MIRA we have names and display + # names + name = state['id'] + display_name = state.get('name') grounding = state.get('grounding', {}) identifiers = grounding.get('identifiers', {}) context = grounding.get('modifiers', {}) @@ -239,6 +243,7 @@ def state_to_concept(state): units_expr = sympy.parse_expr(expr, local_dict=UNIT_SYMBOLS) units_obj = Unit(expression=units_expr) return Concept(name=name, + display_name=display_name, identifiers=identifiers, context=context, units=units_obj) diff --git a/notebooks/hackathon_2023.07/scenario1_a.json b/notebooks/hackathon_2023.07/scenario1_a.json index 517cc7d18..2ce954672 100644 --- a/notebooks/hackathon_2023.07/scenario1_a.json +++ b/notebooks/hackathon_2023.07/scenario1_a.json @@ -173,10 +173,6 @@ } ], "parameters": [ - { - "id": "beta_s", - "value": 1.0 - }, { "id": "N", "value": 5600000.0, @@ -186,16 +182,20 @@ } }, { - "id": "t_0", - "value": 89.0 + "id": "beta_c", + "value": 0.4 + }, + { + "id": "beta_s", + "value": 1.0 }, { "id": "kappa", "value": 0.45454545454545453 }, { - "id": "beta_c", - "value": 0.4 + "id": "t_0", + "value": 89.0 }, { "id": "delta", @@ -205,14 +205,6 @@ "expression_mathml": "day-1" } }, - { - "id": "gamma", - "value": 0.09090909090909091, - "units": { - "expression": "1/day", - "expression_mathml": "day-1" - } - }, { "id": "alpha", "value": 6.4e-05, @@ -221,6 +213,14 @@ "expression_mathml": "1" } }, + { + "id": "gamma", + "value": 0.09090909090909091, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, { "id": "rho", "value": 0.1111111111111111, diff --git a/notebooks/hackathon_2023.07/scenario1_c.json b/notebooks/hackathon_2023.07/scenario1_c.json index 1da50e5f0..0511f2622 100644 --- a/notebooks/hackathon_2023.07/scenario1_c.json +++ b/notebooks/hackathon_2023.07/scenario1_c.json @@ -174,20 +174,20 @@ ], "parameters": [ { - "id": "beta_s", - "value": 1.0 + "id": "beta_c", + "value": 0.4 }, { - "id": "t_0", - "value": 89.0 + "id": "beta_s", + "value": 1.0 }, { "id": "kappa", "value": 0.45454545454545453 }, { - "id": "beta_c", - "value": 0.4 + "id": "t_0", + "value": 89.0 }, { "id": "delta", @@ -197,14 +197,6 @@ "expression_mathml": "day-1" } }, - { - "id": "gamma", - "value": 0.09090909090909091, - "units": { - "expression": "1/day", - "expression_mathml": "day-1" - } - }, { "id": "alpha", "value": 6.4e-05, @@ -213,6 +205,14 @@ "expression_mathml": "1" } }, + { + "id": "gamma", + "value": 0.09090909090909091, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, { "id": "rho", "value": 0.1111111111111111, diff --git a/notebooks/hackathon_2023.07/scenario1_d.json b/notebooks/hackathon_2023.07/scenario1_d.json index 1da50e5f0..0511f2622 100644 --- a/notebooks/hackathon_2023.07/scenario1_d.json +++ b/notebooks/hackathon_2023.07/scenario1_d.json @@ -174,20 +174,20 @@ ], "parameters": [ { - "id": "beta_s", - "value": 1.0 + "id": "beta_c", + "value": 0.4 }, { - "id": "t_0", - "value": 89.0 + "id": "beta_s", + "value": 1.0 }, { "id": "kappa", "value": 0.45454545454545453 }, { - "id": "beta_c", - "value": 0.4 + "id": "t_0", + "value": 89.0 }, { "id": "delta", @@ -197,14 +197,6 @@ "expression_mathml": "day-1" } }, - { - "id": "gamma", - "value": 0.09090909090909091, - "units": { - "expression": "1/day", - "expression_mathml": "day-1" - } - }, { "id": "alpha", "value": 6.4e-05, @@ -213,6 +205,14 @@ "expression_mathml": "1" } }, + { + "id": "gamma", + "value": 0.09090909090909091, + "units": { + "expression": "1/day", + "expression_mathml": "day-1" + } + }, { "id": "rho", "value": 0.1111111111111111,