Skip to content

Commit 1dcbc83

Browse files
feat: add proper remake for SDDEProblem
1 parent 89c49c7 commit 1dcbc83

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
@@ -502,6 +502,100 @@ function remake(func::DDEFunction;
502502
return DDEFunction(f; mass_matrix, analytic, sys, kwargs...)
503503
end
504504

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

0 commit comments

Comments
 (0)