-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Choose an SSA if no SSA is passed in JumpProblem
.
#351
Conversation
Pull Request Test Coverage Report for Build 7514454839Warning: This coverage report may be inaccurate.We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
💛 - Coveralls |
src/aggregators/aggregators.jl
Outdated
num_majumps(jumps) + num_crjs(jumps) < 10 && return Direct | ||
|
||
# if there are only massaction jumps, we can any build dependency graph, so return the fastest aggregator | ||
num_crjs(jumps) == 0 && num_vrjs(jumps) == 0 && return RSSACR | ||
|
||
# in the presence of constant rate jumps, we rely on the given dependency graphs | ||
if !isnothing(vartojumps_map) && !isnothing(jumptovars_map) | ||
return RSSACR | ||
elseif !isnothing(dep_graph) | ||
return DirectCR | ||
else | ||
return Direct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are missing a middle regime where SortingDirect
or RSSA
might be better. Have you played around with this at all / looked over the SciMLBenchmarks and the Catalyst paper results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I did the Catalyst tests, RSSA
was best for small systems. However, we didn't test very small systems, so not sure about these. But there definitely was a regime where RSSA
as the best choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This image suggests that RSSA is indeed better on small models but only marginally. I did not see a comparison with Direct and SortingDirect there. @TorkelE , do you have a table of times from when you did the benchmarking? I did not find such a table for SSA benchmarks in the paper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think the smallest model (Multistate) is 18 reactions. It is kind of hard to see the Direct and Sorting DIrect as RSSA (and RSSACR) is more or less on top of them (also suggesting that the choice of method is not that important).
There is not good table, but the results are in JSON files here: https://github.com/SciML/Catalyst_PLOS_COMPBIO_2023/tree/master/Benchmarks/Benchmarking_results/Threads_1
Look for e.g. RSSA_multistate and you find the multistate results. The data is saved in Dict
s with the benchmark median times and simulation lengs as separate entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that hold with static array states?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added RSSA
if the number of jumps is between 10 and 100. This schema is bound to be just a heuristic so I don't think we should spend a ton of time finding the exact threshold when e.g. RSSA is better than e.g. SortingDirect.
Perfect is always the enemy of good for this kind of thing. I can tell you that 90% of users just use Gillespie's method if we document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@TorkelE actually MTK and Catalyst need appropriate dispatches for JumpProblem to make this work, so not quite there yet for being usable in Catalyst. |
src/solve.jl
Outdated
function DiffEqBase.__solve(jump_prob::DiffEqBase.AbstractJumpProblem; kwargs...) | ||
DiffEqBase.__solve(jump_prob, SSAStepper(); kwargs...) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisRackauckas can you confirm this is an OK dispatch for me to add to enable
sol = solve(jprob; kwargs...) # equivalent to solve(jprob, SSAStepper(); kwargs...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess this ignores when the JumpProblem is over an ODEProblem or such. Is there a way I can explicitly select the default auto-solver for a given problem type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work currently either, so for now I'll just make this dispatch only work for JumpProblems over DiscreteProblems.
@ChrisRackauckas if you could give a quick look to ensure I haven't added a dispatch better handled elsewhere (or shadowing one elsewhere) that would be helpful. |
|
||
# if variable rate jumps are present, return one of the two SSAs that support them | ||
if num_vrjs(jumps) > 0 | ||
(num_bndvrjs(jumps) > 0) && return Coevolve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't they all need bounds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory we support mixing bounded and non-bounded vrjs (but if there are any non-bounded vrjs you need to use a JumpProblem over an ODEProblem or such). JumpProblem has code to check these cases, but I'm not sure how well this is actually tested currently.
@Vilin97 thanks for your work on this and sorry for the long long delay! |
Thank you for cleaning up and adding a default solver too. Now we need to update the docs, right? |
Yes, the docs need updates in places now. Using the defaults in the most introductory places, but explaining how to select solvers and such as they currently do in more advanced places. |
If
JumpProblem(prob, jumps)
is called, an SSA is selected via the function below. The assumption is thatDirect
is fastest for a small network, whileRSSACR
is fastest for other networks. IfRSSACR
cannot be used because no species-to-jumps graph is given, thenDirectCR
is used instead.