Catalyst.jl
Catalyst.jl copied to clipboard
Special case of creating `ODEProblem` from `ODESystem` with conservation laws and default values takes *very* long time
I am going through the docs bit byt bit, trying to see which parts contribute to long build times. This bit in the FAQ one is a significant culprit (haven't bothered waiting to see how long it takes for it to finish/if it actually does):
using Catalyst, OrdinaryDiffEq, Plots
rn = @reaction_network ABtoC begin
(k₊,k₋), A + B <--> C
end
# initial condition and parameter values
setdefaults!(rn, [:A => 1.0, :B => 2.0, :C => 0.0, :k₊ => 1.0, :k₋ => 1.0])
osys = convert(ODESystem, rn; remove_conserved = true)
osys = complete(osys)
observed(osys)
oprob = ODEProblem(osys, [], (0.0, 10.0), []) # We get stuck at this step.
sol = solve(oprob, Tsit5())
Ensuring completeness only after defaults are set, and using symbolic representations, does not help:
using Catalyst, OrdinaryDiffEq, Plots
rn = @network_component ABtoC begin
(k₊,k₋), A + B <--> C
end
@unpack A, B, C, k₊, k₋ = rn
# initial condition and parameter values
setdefaults!(rn, [A => 1.0, B => 2.0, C => 0.0, k₊ => 1.0, k₋ => 1.0])
rn = complete(rn)
osys = convert(ODESystem, rn; remove_conserved = true)
osys = complete(osys)
observed(osys)
oprob = ODEProblem(osys, [], (0.0, 10.0), []) # We still get stuck at this step.
sol = solve(oprob, Tsit5())
A normal workflow, however, is fine:
using Catalyst, OrdinaryDiffEq, Plots
rn = @reaction_network ABtoC begin
(k₊,k₋), A + B <--> C
end
oprob = ODEProblem(rn, [:A => 1.0, :B => 2.0, :C => 0.0], (0.0, 10.0), [:k₊ => 1.0, :k₋ => 1.0]; remove_conserved = true)
sol = solve(oprob, Tsit5())
Is this a Catalyst issue or a general MTK issue with the new symbolic indexing interface changes? If the latter this should be an issue over there.
I already spent over an hour trying to figure out what was going on with the FAQ docs, so I raised the issue here for a starter. When I get the opportunity I will try to look into this in more detail. Likely it is a MTK issue, in which case I agree it should be moved over there.
What function is taking the time?
ODEProblem(osys, [], (0.0, 10.0), [])
No, inside of that function.
not sure, haven't gotten that far yet