From cf9ded47be0b4cae53540e7fcbc145dbab9b125b Mon Sep 17 00:00:00 2001 From: ErikQQY <2283984853@qq.com> Date: Wed, 27 Sep 2023 22:18:39 +0800 Subject: [PATCH] Fix remake for SDEProblem constructor issues Signed-off-by: ErikQQY <2283984853@qq.com> --- Project.toml | 2 +- src/remake.jl | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1a787c897..592cee0f3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SciMLBase" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" authors = ["Chris Rackauckas and contributors"] -version = "2.0.3" +version = "2.0.4" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/src/remake.jl b/src/remake.jl index 9d310f07a..7bbc6de6a 100644 --- a/src/remake.jl +++ b/src/remake.jl @@ -120,6 +120,68 @@ function remake(prob::ODEProblem; f = missing, end end +""" + remake(prob::SDEProblem; f = missing, u0 = missing, tspan = missing, + p = missing, noise = missing, noise_rate_prototype = missing, + seed = missing, kwargs = missing, _kwargs...) + +Remake the given `SDEProblem`. +""" +function remake(prob::SDEProblem; + f = missing, + u0 = missing, + tspan = missing, + p = missing, + noise = missing, + noise_rate_prototype = missing, + seed = missing, + kwargs = missing, + _kwargs...) + if tspan === missing + tspan = prob.tspan + end + + if p === missing + p = prob.p + end + + if u0 === missing + u0 = prob.u0 + end + + if noise === missing + noise = prob.noise + end + + if noise_rate_prototype === missing + noise_rate_prototype = prob.noise_rate_prototype + end + + if seed === missing + seed = prob.seed + end + + if f === missing #TODO: Need more features, e.g. remake `g` + f = prob.f + end + + iip = isinplace(prob) + + if kwargs === missing + SDEProblem{iip}(f, + u0, + tspan, + p; + noise, + noise_rate_prototype, + seed, + prob.kwargs..., + _kwargs...) + else + SDEProblem{iip}(f, u0, tspan, p; noise, noise_rate_prototype, seed, kwargs...) + end +end + """ remake(prob::OptimizationProblem; f = missing, u0 = missing, p = missing, lb = missing, ub = missing, int = missing, lcons = missing, ucons = missing,