Skip to content

Commit 94ed796

Browse files
feat: add proper remake for DDEProblem
1 parent 0992a41 commit 94ed796

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

src/remake.jl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,77 @@ function remake(func::Union{SDEFunction, SDDEFunction};
408408
return T(f, g; mass_matrix, analytic, sys, kwargs...)
409409
end
410410

411+
function remake(prob::DDEProblem; f = missing, h = missing, u0 = missing, tspan = missing, p = missing, constant_lags = missing, dependent_lags = missing, order_discontinuity_t0 = missing, neutral = missing, kwargs = missing, interpret_symbolicmap = true, use_defaults = false, build_initializeprob = true, _kwargs...)
412+
if tspan === missing
413+
tspan = prob.tspan
414+
end
415+
416+
newu0, newp = updated_u0_p(prob, u0, p, tspan[1]; interpret_symbolicmap, use_defaults)
417+
418+
if build_initializeprob
419+
initialization_data = remake_initialization_data(
420+
prob.f.sys, prob.f, u0, tspan[1], p, newu0, newp)
421+
else
422+
initialization_data = nothing
423+
end
424+
425+
if f === missing
426+
f = prob.f
427+
elseif !(f isa DDEFunction)
428+
f = remake(prob.f; f = f)
429+
end
430+
f = remake(f; initialization_data)
431+
432+
h = coalesce(h, prob.h)
433+
constant_lags = coalesce(constant_lags, prob.constant_lags)
434+
dependent_lags = coalesce(dependent_lags, prob.dependent_lags)
435+
order_discontinuity_t0 = coalesce(order_discontinuity_t0, prob.order_discontinuity_t0)
436+
neutral = coalesce(neutral, prob.neutral)
437+
438+
iip = isinplace(prob)
439+
440+
if kwargs === missing
441+
DDEProblem{iip}(f,
442+
newu0,
443+
h,
444+
tspan,
445+
newp;
446+
constant_lags,
447+
dependent_lags,
448+
order_discontinuity_t0,
449+
neutral,
450+
prob.kwargs...,
451+
_kwargs...)
452+
else
453+
DDEProblem{iip}(f, newu0, h, tspan, newp; constant_lags, dependent_lags, order_discontinuity_t0, neutral, kwargs...)
454+
end
455+
end
456+
457+
function remake(func::DDEFunction;
458+
f = missing,
459+
mass_matrix = missing,
460+
analytic = missing,
461+
sys = missing,
462+
kwargs...)
463+
if f === missing
464+
f = func.f
465+
end
466+
467+
if mass_matrix === missing
468+
mass_matrix = func.mass_matrix
469+
end
470+
471+
if analytic === missing
472+
analytic = func.analytic
473+
end
474+
475+
if sys === missing
476+
sys = func.sys
477+
end
478+
479+
return DDEFunction(f; mass_matrix, analytic, sys, kwargs...)
480+
end
481+
411482
"""
412483
remake(prob::OptimizationProblem; f = missing, u0 = missing, p = missing,
413484
lb = missing, ub = missing, int = missing, lcons = missing, ucons = missing,

0 commit comments

Comments
 (0)