-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
VariableRateJump Problems #636
Comments
I posted it on Discourse, but just for tracking purposes here is the simplest approach that works at the moment: using Catalyst, DifferentialEquations
sir_model = @reaction_network begin
β*t, S + I --> 2I
ν, I --> R
end
setdefaults!(sir_model, [:β => 1e-4, :ν => .01, :S => 999.0, :I => 1.0, :R => 0.0])
defs = ModelingToolkit.defaults(sir_model)
@named osys = ODESystem(Equation[], ModelingToolkit.get_iv(sir_model),
states(sir_model),
parameters(sir_model);
defaults = defs)
oprob = ODEProblem(osys, [], (0.0, 200.0), check_length = false)
jprob = JumpProblem(sir_model, oprob, Direct())
sol = solve(jprob, Tsit5()) There are two issues to resolve for a nicer interface.
The first is the issue linked by @arnold-c, and I'm still not sure how to handle it. The second could be handled by having some |
I'm having the same problem at the moment. Just to check, this solution does not contemplate the |
This should work for |
I updated my earlier comment to an example that has an explicit time dependence in the rate. Hopefully that makes it more clear that this should work for |
It worked! Thanks a lot! |
I think this can be closed (but correct me if wrong). |
It can be closed in the sense that there is a work around, but there isn’t yet a nice interface for this case. |
Ok, let's keep it open with that as the aim then. |
Some comments on it. The output of the solution, even if the jumps are on discrete state space, are being stored as floats, along with, at least I think to be the integration of the rates in time. Is there any option to overcome this? If I do an ensemble of trajectories , the memory allocation may grow really fast. |
The generic https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/ Likewise with https://docs.sciml.ai/DiffEqDocs/stable/features/ensemble/#Performing-an-Ensemble-Simulation |
@TorkelE getting into the various saving options and controls would probably make a nice tutorial too, especially combining with |
Yeah, it would. I plan to focus extra on Catalyst docs and functionality up until the ICSB workshop (October 8th), hopefully I can get to this as well. |
We have an interface for VariableRateJumps finally so I'm going to close this now. |
Copying this question/feature request from the discourse discussion here.
I'm trying to code up a JumpProcess of an SIR-style model that includes a VariableRateJump e.g. the transmission parameter varies throughout the year in a sinusoidal fashion. I have what I think is working code manually defining the rates and affects in JumpProcesses.jl directly, but I'm struggling to translate this to Catalyst.jl. Is this something that can be done in Catalyst.jl?
I am aware of this issue on the GitHub repo for MTK.jl, but couldn't translate this to my problem in either MTK or Catalyst.
JumpProcesses.jl Code
Core Catalyst.jl Code
Trying to use a
DiscreteProblem
with Integer species produces the following error.Using
ODEProblem
with theCoevolve()
andTsit5()
with Integer/Float species (Int gets converted to Float byODEProblem
)Using
ODEProblem
withDirect()
andTsit5()
with Integer/Float species (Int gets converted to Float byODEProblem
)Any advice would be appreciated, as I like the simplicity of the Catalyst interface, particularly as my actual model will be much more complex, and the idea of not needing to manually create the dependency graph is appealing!
The text was updated successfully, but these errors were encountered: