Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special case of creating ODEProblem from ODESystem with conservation laws and default values takes *very* long time #886

Open
TorkelE opened this issue May 29, 2024 · 6 comments
Labels

Comments

@TorkelE
Copy link
Member

TorkelE commented May 29, 2024

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())
@isaacsas
Copy link
Member

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.

@TorkelE
Copy link
Member Author

TorkelE commented May 29, 2024

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.

@ChrisRackauckas
Copy link
Member

What function is taking the time?

@TorkelE
Copy link
Member Author

TorkelE commented May 30, 2024

ODEProblem(osys, [], (0.0, 10.0), [])

@ChrisRackauckas
Copy link
Member

No, inside of that function.

@TorkelE
Copy link
Member Author

TorkelE commented May 30, 2024

not sure, haven't gotten that far yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants