Skip to content

Commit a6d93ad

Browse files
feat: add proper remake for DDEProblem
1 parent ad5880c commit a6d93ad

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

0 commit comments

Comments
 (0)