Skip to content

Commit 555cf5d

Browse files
feat: add proper remake for SDDEProblem
1 parent 1980fa6 commit 555cf5d

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

src/remake.jl

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,100 @@ function remake(func::DDEFunction;
498498
return DDEFunction{isinplace(func)}(f; props..., kwargs...)
499499
end
500500

501+
function remake(prob::SDDEProblem;
502+
f = missing,
503+
g = missing,
504+
h = missing,
505+
u0 = missing,
506+
tspan = missing,
507+
p = missing,
508+
constant_lags = missing,
509+
dependent_lags = missing,
510+
order_discontinuity_t0 = missing,
511+
neutral = missing,
512+
noise = missing,
513+
noise_rate_prototype = missing,
514+
interpret_symbolicmap = true,
515+
use_defaults = false,
516+
seed = missing,
517+
kwargs = missing,
518+
build_initializeprob = true,
519+
_kwargs...)
520+
if tspan === missing
521+
tspan = prob.tspan
522+
end
523+
524+
newu0, newp = updated_u0_p(prob, u0, p, tspan[1]; interpret_symbolicmap, use_defaults)
525+
526+
if build_initializeprob
527+
initialization_data = remake_initialization_data(
528+
prob.f.sys, prob.f, u0, tspan[1], p, newu0, newp)
529+
else
530+
initialization_data = nothing
531+
end
532+
533+
if noise === missing
534+
noise = prob.noise
535+
end
536+
537+
if noise_rate_prototype === missing
538+
noise_rate_prototype = prob.noise_rate_prototype
539+
end
540+
541+
if seed === missing
542+
seed = prob.seed
543+
end
544+
545+
if f === missing && g === missing
546+
f = prob.f
547+
g = prob.g
548+
elseif f !== missing && g === missing
549+
g = prob.g
550+
elseif f === missing && g !== missing
551+
if prob.f isa SDEFunction
552+
f = remake(prob.f; g = g)
553+
else
554+
f = SDEFunction(prob.f, g; sys = prob.f.sys)
555+
end
556+
else
557+
if f isa SDEFunction
558+
f = remake(f; g = g)
559+
else
560+
f = SDEFunction(f, g; sys = prob.f.sys)
561+
end
562+
end
563+
f = remake(f; initialization_data)
564+
iip = isinplace(prob)
565+
566+
h = coalesce(h, prob.h)
567+
constant_lags = coalesce(constant_lags, prob.constant_lags)
568+
dependent_lags = coalesce(dependent_lags, prob.dependent_lags)
569+
order_discontinuity_t0 = coalesce(order_discontinuity_t0, prob.order_discontinuity_t0)
570+
neutral = coalesce(neutral, prob.neutral)
571+
572+
if kwargs === missing
573+
SDDEProblem{iip}(f,
574+
g,
575+
newu0,
576+
h,
577+
tspan,
578+
newp;
579+
noise,
580+
noise_rate_prototype,
581+
seed,
582+
constant_lags,
583+
dependent_lags,
584+
order_discontinuity_t0,
585+
neutral,
586+
prob.kwargs...,
587+
_kwargs...)
588+
else
589+
SDDEProblem{iip}(
590+
f, newu0, tspan, newp; noise, noise_rate_prototype, seed, constant_lags,
591+
dependent_lags, order_discontinuity_t0, neutral, kwargs...)
592+
end
593+
end
594+
501595
"""
502596
remake(prob::OptimizationProblem; f = missing, u0 = missing, p = missing,
503597
lb = missing, ub = missing, int = missing, lcons = missing, ucons = missing,

0 commit comments

Comments
 (0)