SciML/SBMLToolkit.jl

Warning: SBMLToolkit currently fires events regardless of uppass or downpass trigger.

Closed this issue · 10 comments

Hi All,

I am receiving this warning message when I import my model from SBMLToolkit. Is it something worrisome?

Thank you!

It might be. Are you using version 0.1.19?

What is your use case?

When simulating the SBML, you would have to manually check the places where the events were triggered, and if they should have been triggered. For instance, this can be done by visually comparing the simulation results with Copasi. Note that this validity check only works for the chosen set of initial conditions and parameters.

@isaacsas : we currently use Equations as trigger (e.g. A ~ 3 * k). Is there a way to replace the ~ with a < or similar to introduce directionality in the trigger? I think I darkly recall talking to sb (probably you) about this a while ago.

@paulflang I was using version 0.1.18. I updated it to 0.1.19 and still getting the same warning. I am modeling a pathway, using the BioNetGen, and trying to perform global sensitivity analysis, using the Global Sensitivity Analysis package. The issues come when I import the .NET or SBML files (I opened a different issue section in ReactionNetworkImporters).

Since I am relatively new, what do you mean by the terms "events" and "trigger"?

Thank you!

Yeah, in that case the warning is to be taken seriously. Terminology depends on the format used, but essentially your model contains something like

if X < 1  # The trigger condition
    X = 2*X  # The assignment (of course, you could also assign to another species than X)
end

where X is a chemical species that changes over time. In SBML this is called an event. Idk how it is called in BNGL. In Julia this is implemented via callback functions that are passed to the solver.

@paulflang are you asking for discrete or continuous callbacks? For discrete you can use inequalities, see this example:

https://docs.sciml.ai/ModelingToolkit/stable/basics/Events/#Example:-Injecting-cells-into-a-population

Thanks! Continuous would be more precise.
And the problem with discontinuous is that when I do injection = (tinject >= t) => [N ~ N + M] it fires all the time after t >= 10, when what I need is just at the crossing from false to true.

If you just want it to fire at tinject use equality comparison and add a tstop at the time you want the solver to stop.

Or just use a preset time callback (see the same tutorial page).

Oh, yes, that was a bad example. So typically it is not time that triggers, but a certain species reaching a given concentration. So Idk when that happens and thus when to set tstop. I tried sth like

@variables t N(t)=1 flag(t)=0
Dₜ = Differential(t)
eqs = [Dₜ(N) ~ -0.1N]

injection = (N <= 0.5 & flag <= 0.5) => [N ~ N + M, flag ~ 1.0]

but got errors like ERROR: MethodError: no method matching &(::Float64, ::Num).

I think some form of continuous callback that can be formulated with an Equation and accepts directionality would be best. But let's continue the discussion under SciML/ModelingToolkit.jl#1715