Skip to content

[BUG]: Model extraction cases #407

@liunelson

Description

@liunelson

I found some edge cases for template_model_from_sympy_odes.

Case 1

Fixed Birth (l) and proportionate death (m X) processes are interpreted correctly as natural production and natural degradation:

\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

However, I had expected the m S terms on d I/d t, d R/d t to be interpreted controlled degradation templates with rate laws m * S.

\frac{d S}{d t} = -b S I + l - m S
\frac{d I}{d t} = b S I - g I - m S
\frac{d R}{d t} = g I - m S

Doing it directly with template_model_from_sympy_odes gives a model that completely ignores all the m S terms:

odes = [
    sympy.Eq(S(t).diff(t), - b * S(t) * I(t) + l - m * S(t)),
    sympy.Eq(I(t).diff(t), b * S(t) * I(t) - g * I(t) - m * S(t)),
    sympy.Eq(R(t).diff(t), g * I(t) - m * S(t)),
]

Doing it within Terarium (which styles the above LaTeX and converts it to SymPy before sending to MIRA) gives a strange model wherein the rate laws are "-I*S*b + l", "I*S*b - I*g", "I*g" (possibly unrelated to MIRA):

Case 2

This is a case with "branching ratios":

\frac{d S}{d t} = -b S I
\frac{d I}{d t} = b S I - g I
\frac{d R}{d t} = k g I
\frac{d V}{d t} = (1 - k) g I

This gives a model where I has a natural degradation g I and two controlled productions of R, V, instead of two natural conversions from I into R, V.
Screenshot 2024-12-10 at 5 18 50 PM

If we were to rewrite the 2nd equation as \frac{d I}{d t} = b S I - k g I - (1 - k) g I, then MIRA returns the correct model (where I branches into R, V with ratio k).
Screenshot 2024-12-10 at 5 19 35 PM

Such a branching case was actually involved in a paper from which the UCSD team wanted to extract a model and it required careful reading of the text to realize a rewrite of the equations.

Do you have a forthcoming solution to this problem or do you expect users/Terarium to rewrite the equations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions