You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in all these cases, the "Edited by AI" equations are all correct.
since the rate laws are wrong, it seems that the problem lies around the juncture between good LaTeX and MIRA's template_model_from_sympy_odes
the problem seems to be with sympy.parsing.latex.parse_latex(ode_latex_str) producing incorrect SymPy expressions; example
sympy.parsing.latex.parse_latex(r"\frac{d V(t)}{d t} = a b I(t) (1 - g)")
# produces Eq(Derivative(V(t), t), a*(I(t)*b(1 - g))) where parameter 'b' is treated as a function of (1-g)sympy.parsing.latex.parse_latex(r"\frac{d I(t)}{d t} = k E(t) - d I(t)")
# produces Eq(Derivative(I(t), t), -dI*t + k*E(t)) where parameter 'd' became 'dI'
thus, instructing the equation-styling agent to add or retain * in the edited LaTeX as indication of multiplication probably could fix Case 2; currently, the agent is instructed to remove all *
for Case 3, it seems that the source of the problem is again parse_latex where it adds unnecessary parentheses
sympy.parsing.latex.parse_latex(r"\frac{d I(t)}{d t} = b * S(t) * I(t) - k * g * I(t) - (1 - k) * g * I(t)")
# produces Eq(Derivative(I(t), t), -g*(1 - k)*I(t) + ((b*S(t))*I(t) - g*k*I(t))) where the second term is wrapped in parentheses that MIRA then interprets as a single template
the solution for Case 1, 3 may be to use a LLM to convert the LaTeX to SymPy with instructions to avoid this sort of parenthesis issue
Case 1
Basic SIR model with added birth and death processes (l birth rate and every state dies at a rate of m)
\frac{d S}{d t} = -b S I + l - m S
\frac{d I}{d t} = b S I - g I - m I
\frac{d R}{d t} = g I - m R
the d I(t) term got turned into a natural production with nonsensical rate law -dI * t
note that renaming the parameter d to f fixes the above point
the parameter b somehow interpreted as a state variable with d b(t) / d t = 0
the parameter g disappeared from the rate laws but is somehow still present in the parameter table
note that changing the equation from a b (1 - g) I(t) to a b I(t) (1 - g) avoids the two above points; this shouldn't matter since SymPy is aware of commutativity (i.e. a b (1 - g) I(t) == a b I(t) (1 - g))
liunelson
changed the title
[BUG]: "Create model from equations" produces wrong models (probably not caused by MIRA)
[BUG]: "Create model from equations" produces/shows wrong models (probably not caused by MIRA)
Dec 10, 2024
liunelson
changed the title
[BUG]: "Create model from equations" produces/shows wrong models (probably not caused by MIRA)
[BUG]: "Create model from equations" produces/shows wrong models
Dec 10, 2024
Now that I think of it, as in the "Note" above, we maybe forced to create a GoLLM task to convert the cleaned LaTeX to SymPy since most of the cases are due to extra () introduced by SymPy's parse_latex.
Describe the bug
Note:
template_model_from_sympy_odes
sympy.parsing.latex.parse_latex(ode_latex_str)
producing incorrect SymPy expressions; example*
in the edited LaTeX as indication of multiplication probably could fix Case 2; currently, the agent is instructed to remove all*
parse_latex
where it adds unnecessary parenthesesCase 1
Basic SIR model with added birth and death processes (
l
birth rate and every state dies at a rate ofm
)Incorrect model diagram and rate laws:
Correct model (with its own, unrelated bugs):
I*S*b, l, S*m, I*g, I*m, R*m
S
is converted toI
,I
is converted toR
, production ofS
, degradation/death ofS, I, R
individuallyCase 2 - Controlled production
Production of viral particles in wastewater (Phan et al. 2023 from last monthly demo)
Incorrect model:
d I(t)
term got turned into a natural production with nonsensical rate law-dI * t
d
tof
fixes the above pointb
somehow interpreted as a state variable withd b(t) / d t = 0
g
disappeared from the rate laws but is somehow still present in the parameter tablea b (1 - g) I(t)
toa b I(t) (1 - g)
avoids the two above points; this shouldn't matter since SymPy is aware of commutativity (i.e.a b (1 - g) I(t) == a b I(t) (1 - g)
)Correct model:
Case 3 - Branching ratio (2)
The
I
state splits into two streams, one intoV
and other intoR
.Incorrect model:
t1, t3
are completely wrong - should be a single controlled conversion fromS
toI
with rate lawI*S*b
t4
is supposed to be a natural conversion fromI
toR
with rate lawI*g*k
Correct model:
The text was updated successfully, but these errors were encountered: