diff --git a/HISTORY.md b/HISTORY.md index 4ebaff1ea..88e1fe9de 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,16 +1,26 @@ # Breaking updates and feature summaries across releases -## Unreleased +## 10.2.0 - New `isolated_copy(jprob)` returns a `JumpProblem` with its own jump state, for concurrent solves and for integrators that are alive at the same time. It copies only the jump aggregator's working data and rebuilds the jump callbacks around it, sharing everything else, including the wrapped problem, the jumps and the stored callbacks, so it is much cheaper than `deepcopy`, especially for problems built with ModelingToolkit or Catalyst. StochasticDiffEq's copies of the jump state (`alias_jumps = false`, the - default off thread 1) now use it. The docs no longer recommend `deepcopy`, which - copies `p`, `u0` and the stored callbacks too, but with `FunctionWrapper`-based - aggregators can call the original problem's rate and affect functions and needs the - original kept alive. + default off thread 1) now use it, so these copies share `p`, the stored callbacks and a + noise process passed to the `SDEProblem` with the original problem, where they used to + be deep copies. Ensembles are unaffected, since they copy the problem for each task + first. To solve one problem from several threads, give each thread its own + `isolated_copy`, with its own `p` (through `remake`) if callbacks modify it, and pass + `alias_noise = false` to `solve` if the `SDEProblem` has a noise process: + StochasticDiffEq otherwise writes each solve's noise path back into it, as it does for + any `SDEProblem`. The docs no longer recommend `deepcopy`, which copies `p`, `u0` and + the stored callbacks too, but with `FunctionWrapper`-based aggregators can call the + original problem's rate and affect functions and needs the original kept alive. + - `SpatialMassActionJump`s with site-dependent rates (a matrix) and `scale_rates = true`, + the default, now divide the rates of every reaction by the factorials of its reactant + stoichiometry. Only the last reaction was scaled, so the others with a stoichiometric + coefficient above one fired too often, for example `2A → ∅` twice as often. - `VR_Direct` and `VR_DirectFW` no longer also simulate the bounded `VariableRateJump`s that `Coevolve` handles. In problems with both bounded and general `VariableRateJump`s, those bounded jumps fired twice as often. diff --git a/Project.toml b/Project.toml index 29da40edc..019c0088d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JumpProcesses" uuid = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5" authors = ["Chris Rackauckas "] -version = "10.1.1" +version = "10.2.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/src/isolated_copy.jl b/src/isolated_copy.jl index 7307da620..55ef3cb9e 100644 --- a/src/isolated_copy.jl +++ b/src/isolated_copy.jl @@ -90,8 +90,9 @@ not take one while another thread is solving `jprob`. - State captured by rate, affect or callback functions. Pass callbacks with such state to `init` or `solve` instead of storing them in the problem. - A noise process passed to an `SDEProblem` with `noise`. StochasticDiffEq copies each - solve's noise back into `prob.noise`, so copies that share it must not be solved - concurrently. Give a copy its own with + solve's noise back into `prob.noise` unless `solve` is given `alias_noise = false`, so + without that keyword, copies that share it must not be solved concurrently. A copy can + also be given its own with `remake(isolated_copy(jprob); prob = remake(jprob.prob; noise = new_noise))`. `deepcopy(jprob)` also copies `p`, `u0`, the stored callbacks and the wrapped problem, at a