Skip to content

Commit

Permalink
Add observables to models
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Jul 13, 2023
1 parent 8c7207e commit e1a4eba
Show file tree
Hide file tree
Showing 10 changed files with 5,923 additions and 29 deletions.
4 changes: 2 additions & 2 deletions mira/metamodel/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def stratify(

observables = {}
for observable_key, observable in template_model.observables.items():
syms = set(observable.expression.args[0].free_symbols)
syms = {s.name for s in observable.expression.args[0].free_symbols}
expr = deepcopy(observable.expression.args[0])
for sym in (syms & concept_names) - exclude_concepts:
new_symbols = []
Expand All @@ -217,7 +217,7 @@ def stratify(
do_rename=modify_names, **{key: stratum},
)
new_symbols.append(sympy.Symbol(new_concept.name))
expr = expr.args[0].subs(sym, sympy.Add(*new_symbols))
expr = expr.subs(sympy.Symbol(sym), sympy.Add(*new_symbols))
observables[observable_key] = deepcopy(observable)
observables[observable_key].expression = SympyExprStr(expr)

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 @@ -75,7 +75,8 @@ def __init__(self, model: Model):
states_dict['units'] = {
'expression': str(var.concept.units.expression),
'expression_mathml': expression_to_mathml(
var.concept.units.expression.args[0]),
var.concept.units.expression.args[0]
),
}

self.states.append(states_dict)
Expand Down
250 changes: 228 additions & 22 deletions notebooks/hackathon_2023.07/scenario1.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit e1a4eba

Please sign in to comment.