From 9a0fecaae9f1bd6f269ed69bd4dfe74ce761ccb8 Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Tue, 28 Jun 2022 17:54:46 -0400 Subject: [PATCH 1/4] fix doc dependencies --- docs/Project.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/Project.toml b/docs/Project.toml index 12ba95dd..747764f6 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -3,4 +3,6 @@ Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83" DiffEqJump = "c894b116-72e5-5b58-be3c-e6d8d4ac2b12" DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0" From 3ad2c4b39d5ac9cda30d5786352556881f60debc Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Tue, 28 Jun 2022 17:57:46 -0400 Subject: [PATCH 2/4] more I initially to avoid trivial plots --- docs/src/tutorials/discrete_stochastic_example.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/tutorials/discrete_stochastic_example.md b/docs/src/tutorials/discrete_stochastic_example.md index 32e90fde..ee950f52 100644 --- a/docs/src/tutorials/discrete_stochastic_example.md +++ b/docs/src/tutorials/discrete_stochastic_example.md @@ -184,7 +184,7 @@ people, and solve the problem from `t=0.0` to `t=250.0`. We use the parameters ```@example tut2 p = (:β => 0.1/1000, :ν => 0.01) -u₀ = [:S => 999, :I => 1, :R => 0] +u₀ = [:S => 999, :I => 10, :R => 0] tspan = (0.0, 250.0) prob = DiscreteProblem(sir_model, u₀, tspan, p) ``` @@ -301,7 +301,7 @@ jump2 = ConstantRateJump(rate2,affect2!) We will start with `999` susceptible people, `1` infected person, and `0` recovered people, and solve the problem from `t=0.0` to `t=250.0` so that ```@example tut2 -u₀ = [999, 1, 0] +u₀ = [999, 10, 0] tspan = (0.0, 250.0) ``` *Notice, the initial populations are integers since we want the exact number of @@ -538,7 +538,7 @@ function f(du, u, p, t) du[4] = u[2]*u[3]/100000 - u[1]*u[4]/100000 nothing end -u₀ = [999.0, 1.0, 0.0, 100.0] +u₀ = [999.0, 10.0, 0.0, 100.0] prob = ODEProblem(f, u₀, tspan, p) ``` Notice we gave the 4th component a starting value of 100.0, and used floating @@ -570,7 +570,7 @@ is not constant between jumps, *we must use a `VariableRateJump`*. Solving the equation is exactly the same: ```@example tut2 -u₀ = [999.0, 1.0, 0.0, 1.0] +u₀ = [999.0, 10.0, 0.0, 1.0] prob = ODEProblem(f, u₀, tspan, p) jump_prob = JumpProblem(prob, Direct(), jump, jump2, jump3) sol = solve(jump_prob, Tsit5()) From 6c8dbf3453b39a16dcae781b9c4d8971d50c7daf Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Tue, 28 Jun 2022 18:00:47 -0400 Subject: [PATCH 3/4] add reset_aggregated_jumps! to API --- docs/src/api.md | 1 + docs/src/faq.md | 6 +++--- src/aggregators/aggregated_api.jl | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/src/api.md b/docs/src/api.md index a1ed90f5..ce00c4e2 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -29,6 +29,7 @@ RDirect RSSA RSSACR SortingDirect +reset_aggregated_jumps! ``` # Private API Functions diff --git a/docs/src/faq.md b/docs/src/faq.md index fe99196c..6ef9e453 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -110,9 +110,9 @@ used (otherwise a different time stepper is needed). When using an ODE or SDE time stepper any callback should work. *Note, when modifying `u` or `p` within a callback, you must call -`reset_aggregated_jumps!(integrator)` after making updates.* This ensures that -the underlying jump simulation algorithms know to reinitialize their internal -data structures. Leaving out this call will lead to incorrect behavior! +[`reset_aggregated_jumps!`](@ref) after making updates.* This ensures that the +underlying jump simulation algorithms know to reinitialize their internal data +structures. Leaving out this call will lead to incorrect behavior! A simple example that uses a `MassActionJump` and changes the parameters at a specified time in the simulation using a `DiscreteCallback` is diff --git a/src/aggregators/aggregated_api.jl b/src/aggregators/aggregated_api.jl index 9719b129..54ef3677 100644 --- a/src/aggregators/aggregated_api.jl +++ b/src/aggregators/aggregated_api.jl @@ -1,11 +1,11 @@ """ - reset_aggregated_jumps!(integrator,uprev = nothing; update_jump_params=true) + reset_aggregated_jumps!(integrator, uprev = nothing; update_jump_params=true) Reset the state of jump processes and associated solvers following a change in parameters or such. Notes - - `update_jump_params=true` will recalculate the rates stored within any + - `update_jump_params=true` will recalculate the rates stored within any MassActionJump that was built from the parameter vector. If the parameter vector is unchanged this can safely be set to false to improve performance. """ From 44a5c3f836642dbd0287ff60b8fddbd77db85879 Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Tue, 28 Jun 2022 18:45:11 -0400 Subject: [PATCH 4/4] get reset_aggregated_jumps! to appear --- docs/src/api.md | 2 +- src/aggregators/aggregated_api.jl | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/src/api.md b/docs/src/api.md index ce00c4e2..286192fd 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -7,6 +7,7 @@ CurrentModule = DiffEqJump ```@docs JumpProblem SSAStepper +reset_aggregated_jumps! ``` ## Types of Jumps @@ -29,7 +30,6 @@ RDirect RSSA RSSACR SortingDirect -reset_aggregated_jumps! ``` # Private API Functions diff --git a/src/aggregators/aggregated_api.jl b/src/aggregators/aggregated_api.jl index 54ef3677..8fa80730 100644 --- a/src/aggregators/aggregated_api.jl +++ b/src/aggregators/aggregated_api.jl @@ -9,7 +9,6 @@ Notes MassActionJump that was built from the parameter vector. If the parameter vector is unchanged this can safely be set to false to improve performance. """ - function reset_aggregated_jumps!(integrator, uprev = nothing; update_jump_params = true, kwargs...) reset_aggregated_jumps!(integrator, uprev, integrator.opts.callback,