Skip to content

Commit

Permalink
Implement display name and update scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Jul 6, 2023
1 parent 84cd710 commit 21d1911
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 46 deletions.
4 changes: 4 additions & 0 deletions mira/metamodel/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion mira/modeling/askenet/petrinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion mira/sources/askenet/petrinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', {})
Expand All @@ -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)
Expand Down
32 changes: 16 additions & 16 deletions notebooks/hackathon_2023.07/scenario1_a.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@
}
],
"parameters": [
{
"id": "beta_s",
"value": 1.0
},
{
"id": "N",
"value": 5600000.0,
Expand All @@ -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",
Expand All @@ -205,14 +205,6 @@
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "gamma",
"value": 0.09090909090909091,
"units": {
"expression": "1/day",
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "alpha",
"value": 6.4e-05,
Expand All @@ -221,6 +213,14 @@
"expression_mathml": "<cn>1</cn>"
}
},
{
"id": "gamma",
"value": 0.09090909090909091,
"units": {
"expression": "1/day",
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "rho",
"value": 0.1111111111111111,
Expand Down
28 changes: 14 additions & 14 deletions notebooks/hackathon_2023.07/scenario1_c.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -197,14 +197,6 @@
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "gamma",
"value": 0.09090909090909091,
"units": {
"expression": "1/day",
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "alpha",
"value": 6.4e-05,
Expand All @@ -213,6 +205,14 @@
"expression_mathml": "<cn>1</cn>"
}
},
{
"id": "gamma",
"value": 0.09090909090909091,
"units": {
"expression": "1/day",
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "rho",
"value": 0.1111111111111111,
Expand Down
28 changes: 14 additions & 14 deletions notebooks/hackathon_2023.07/scenario1_d.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -197,14 +197,6 @@
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "gamma",
"value": 0.09090909090909091,
"units": {
"expression": "1/day",
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "alpha",
"value": 6.4e-05,
Expand All @@ -213,6 +205,14 @@
"expression_mathml": "<cn>1</cn>"
}
},
{
"id": "gamma",
"value": 0.09090909090909091,
"units": {
"expression": "1/day",
"expression_mathml": "<apply><power/><ci>day</ci><cn>-1</cn></apply>"
}
},
{
"id": "rho",
"value": 0.1111111111111111,
Expand Down

0 comments on commit 21d1911

Please sign in to comment.