Skip to content

Commit fca7872

Browse files
feat: add proper remake for SDDEProblem
1 parent a6d93ad commit fca7872

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
@@ -484,6 +484,100 @@ function remake(func::DDEFunction;
484484
return DDEFunction(f; mass_matrix, analytic, sys, kwargs...)
485485
end
486486

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

0 commit comments

Comments
 (0)