StochasticDiffEq.jl
StochasticDiffEq.jl copied to clipboard
CaoTauLeaping Implementation
using StochasticDiffEq, JumpProcesses, DiffEqBase, Statistics, Plots
using Test, LinearAlgebra
function regular_rate(out,u,p,t)
out[1] = (0.1/1000.0)*u[1]*u[2]
out[2] = 0.01u[2]
end
const dc = zeros(3, 2)
dc[1,1] = -1
dc[2,1] = 1
dc[2,2] = -1
dc[3,2] = 1
function regular_c(du,u,p,t,counts,mark)
mul!(du,dc,counts)
end
rj = RegularJump(regular_rate,regular_c,2)
jumps = JumpSet(rj)
iip_prob = DiscreteProblem([999.0,1,0],(0.0,250.0))
jump_iipprob = JumpProblem(iip_prob,Direct(),rj)
N = 100
sol = solve(EnsembleProblem(jump_iipprob),CaoTauLeaping();dt=1.0,trajectories = N)
plot(sol)
Checklist
- [X] Appropriate tests were added
- [X] Any code changes were done in a way that does not break public API
- [ ] All documentation related to code changes were updated
- [X] The new code follows the contributor guidelines, in particular the SciML Style Guide and COLPRAC.
- [X] Any new documentation only uses public API
Additional context
Add any other context about the problem here.