Skip to content

Commit 89c49c7

Browse files
feat: add proper remake for DDEProblem
1 parent 20ce512 commit 89c49c7

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

src/remake.jl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,82 @@ function remake(func::Union{SDEFunction, SDDEFunction};
426426
return T(f, g; mass_matrix, analytic, sys, kwargs...)
427427
end
428428

429+
function remake(prob::DDEProblem; f = missing, h = missing, u0 = missing,
430+
tspan = missing, p = missing, constant_lags = missing,
431+
dependent_lags = missing, order_discontinuity_t0 = missing,
432+
neutral = missing, kwargs = missing, interpret_symbolicmap = true,
433+
use_defaults = false, build_initializeprob = true, _kwargs...)
434+
if tspan === missing
435+
tspan = prob.tspan
436+
end
437+
438+
newu0, newp = updated_u0_p(prob, u0, p, tspan[1]; interpret_symbolicmap, use_defaults)
439+
440+
if build_initializeprob
441+
initialization_data = remake_initialization_data(
442+
prob.f.sys, prob.f, u0, tspan[1], p, newu0, newp)
443+
else
444+
initialization_data = nothing
445+
end
446+
447+
if f === missing
448+
f = prob.f
449+
elseif !(f isa DDEFunction)
450+
f = remake(prob.f; f = f)
451+
end
452+
f = remake(f; initialization_data)
453+
454+
h = coalesce(h, prob.h)
455+
constant_lags = coalesce(constant_lags, prob.constant_lags)
456+
dependent_lags = coalesce(dependent_lags, prob.dependent_lags)
457+
order_discontinuity_t0 = coalesce(order_discontinuity_t0, prob.order_discontinuity_t0)
458+
neutral = coalesce(neutral, prob.neutral)
459+
460+
iip = isinplace(prob)
461+
462+
if kwargs === missing
463+
DDEProblem{iip}(f,
464+
newu0,
465+
h,
466+
tspan,
467+
newp;
468+
constant_lags,
469+
dependent_lags,
470+
order_discontinuity_t0,
471+
neutral,
472+
prob.kwargs...,
473+
_kwargs...)
474+
else
475+
DDEProblem{iip}(f, newu0, h, tspan, newp; constant_lags, dependent_lags,
476+
order_discontinuity_t0, neutral, kwargs...)
477+
end
478+
end
479+
480+
function remake(func::DDEFunction;
481+
f = missing,
482+
mass_matrix = missing,
483+
analytic = missing,
484+
sys = missing,
485+
kwargs...)
486+
if f === missing
487+
f = func.f
488+
end
489+
490+
if mass_matrix === missing
491+
mass_matrix = func.mass_matrix
492+
end
493+
494+
if analytic === missing
495+
analytic = func.analytic
496+
end
497+
498+
if sys === missing
499+
sys = func.sys
500+
end
501+
502+
return DDEFunction(f; mass_matrix, analytic, sys, kwargs...)
503+
end
504+
429505
"""
430506
remake(prob::OptimizationProblem; f = missing, u0 = missing, p = missing,
431507
lb = missing, ub = missing, int = missing, lcons = missing, ucons = missing,

0 commit comments

Comments
 (0)