Skip to content

Commit 5e48394

Browse files
feat: add proper remake for SDDEProblem
1 parent 94ed796 commit 5e48394

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

src/remake.jl

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,98 @@ function remake(func::DDEFunction;
479479
return DDEFunction(f; mass_matrix, analytic, sys, kwargs...)
480480
end
481481

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

0 commit comments

Comments
 (0)