Skip to content

Default solver selection very slow (x20) compared to Rodas5P on a given problem #2708

Open
@TorkelE

Description

@TorkelE

The system is a bit unusual (has a large number of similar variables). I am also not sure how interesting cases like this is, and how feasible they are to deal with. However, since the performance difference is large, I figured it could be interesting to know.

# Fetch packages.
using Catalyst, OrdinaryDiffEqDefault, OrdinaryDiffEqRosenbrock, FiniteStateProjection, BenchmarkTools

# Create the model.
rs = @reaction_network begin
    (p,d), 0 <--> X
    (kB,kD), 2X <--> X2
end

# Create the ODEProblem.
ps = [:p => 1.0, :d => 0.2, :kB => 2.0, :kD => 5.0]
u0 = zeros(25,25)
u0[1,1] = 1.0
fsp_sys = FSPSystem(rs, [:X, :X2])
oprob = ODEProblem(fsp_sys, u0, 50.0, ps)

# Simulate using default solver and Rodas5P.
@btime sol1 = solve($oprob, Rodas5P()) #   126.148 ms (3719 allocations: 6.96 MiB)
@btime sol2 = solve($oprob) #   2.689 s (309050 allocations: 138.95 MiB)

Here, the state is a 25x25 matrix (so 625 variables in total).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions