Skip to content

Commit 34dd450

Browse files
refactor: call get_updated_symbolic_problem in get_concrete_problem instead of init_call
1 parent 4f28525 commit 34dd450

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/solve.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ function init_call(_prob, args...; merge_callbacks = true, kwargshandle = nothin
547547
kwargshandle = has_kwargs(_prob) && haskey(_prob.kwargs, :kwargshandle) ?
548548
_prob.kwargs[:kwargshandle] : kwargshandle
549549

550-
_prob = get_updated_symbolic_problem(_get_root_indp(_prob), _prob)
551550
if has_kwargs(_prob)
552551
if merge_callbacks && haskey(_prob.kwargs, :callback) && haskey(kwargs, :callback)
553552
kwargs_temp = NamedTuple{
@@ -1240,28 +1239,32 @@ function checkkwargs(kwargshandle; kwargs...)
12401239
end
12411240

12421241
function get_concrete_problem(prob::AbstractJumpProblem, isadapt; kwargs...)
1242+
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob)
12431243
prob
12441244
end
12451245

12461246
function get_concrete_problem(prob::SteadyStateProblem, isadapt; kwargs...)
12471247
p = get_concrete_p(prob, kwargs)
12481248
u0 = get_concrete_u0(prob, isadapt, Inf, kwargs)
12491249
u0 = promote_u0(u0, p, nothing)
1250-
remake(prob; u0 = u0, p = p)
1250+
prob = remake(prob; u0 = u0, p = p)
1251+
get_updated_symbolic_problem(_get_root_indp(prob), prob)
12511252
end
12521253

12531254
function get_concrete_problem(prob::NonlinearProblem, isadapt; kwargs...)
12541255
p = get_concrete_p(prob, kwargs)
12551256
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
12561257
u0 = promote_u0(u0, p, nothing)
1257-
remake(prob; u0 = u0, p = p)
1258+
prob = remake(prob; u0 = u0, p = p)
1259+
get_updated_symbolic_problem(_get_root_indp(prob), prob)
12581260
end
12591261

12601262
function get_concrete_problem(prob::NonlinearLeastSquaresProblem, isadapt; kwargs...)
12611263
p = get_concrete_p(prob, kwargs)
12621264
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
12631265
u0 = promote_u0(u0, p, nothing)
1264-
remake(prob; u0 = u0, p = p)
1266+
prob = remake(prob; u0 = u0, p = p)
1267+
get_updated_symbolic_problem(_get_root_indp(prob), prob)
12651268
end
12661269

12671270
function get_concrete_problem(prob::AbstractEnsembleProblem, isadapt; kwargs...)
@@ -1286,14 +1289,13 @@ function get_concrete_problem(prob, isadapt; kwargs...)
12861289
tspan_promote = promote_tspan(u0_promote, p, tspan, prob, kwargs)
12871290
f_promote = promote_f(prob.f, Val(SciMLBase.specialization(prob.f)), u0_promote, p,
12881291
tspan_promote[1])
1289-
if isconcreteu0(prob, tspan[1], kwargs) && prob.u0 === u0 &&
1292+
if !(isconcreteu0(prob, tspan[1], kwargs) && prob.u0 === u0 &&
12901293
typeof(u0_promote) === typeof(prob.u0) &&
12911294
prob.tspan == tspan && typeof(prob.tspan) === typeof(tspan_promote) &&
1292-
p === prob.p && f_promote === prob.f
1293-
return prob
1294-
else
1295-
return remake(prob; f = f_promote, u0 = u0_promote, p = p, tspan = tspan_promote)
1295+
p === prob.p && f_promote === prob.f)
1296+
prob = remake(prob; f = f_promote, u0 = u0_promote, p = p, tspan = tspan_promote)
12961297
end
1298+
get_updated_symbolic_problem(_get_root_indp(prob), prob)
12971299
end
12981300

12991301
function get_concrete_problem(prob::DAEProblem, isadapt; kwargs...)
@@ -1308,15 +1310,14 @@ function get_concrete_problem(prob::DAEProblem, isadapt; kwargs...)
13081310

13091311
f_promote = promote_f(prob.f, Val(SciMLBase.specialization(prob.f)), u0_promote, p,
13101312
tspan_promote[1])
1311-
if isconcreteu0(prob, tspan[1], kwargs) && typeof(u0_promote) === typeof(prob.u0) &&
1313+
if !(isconcreteu0(prob, tspan[1], kwargs) && typeof(u0_promote) === typeof(prob.u0) &&
13121314
isconcretedu0(prob, tspan[1], kwargs) && typeof(du0_promote) === typeof(prob.du0) &&
13131315
prob.tspan == tspan && typeof(prob.tspan) === typeof(tspan_promote) &&
1314-
p === prob.p && f_promote === prob.f
1315-
return prob
1316-
else
1317-
return remake(prob; f = f_promote, du0 = du0_promote, u0 = u0_promote, p = p,
1316+
p === prob.p && f_promote === prob.f)
1317+
prob = remake(prob; f = f_promote, du0 = du0_promote, u0 = u0_promote, p = p,
13181318
tspan = tspan_promote)
13191319
end
1320+
get_updated_symbolic_problem(_get_root_indp(prob), prob)
13201321
end
13211322

13221323
function get_concrete_problem(prob::DDEProblem, isadapt; kwargs...)
@@ -1333,7 +1334,8 @@ function get_concrete_problem(prob::DDEProblem, isadapt; kwargs...)
13331334
u0 = promote_u0(u0, p, tspan[1])
13341335
tspan = promote_tspan(u0, p, tspan, prob, kwargs)
13351336

1336-
remake(prob; u0 = u0, tspan = tspan, p = p, constant_lags = constant_lags)
1337+
prob = remake(prob; u0 = u0, tspan = tspan, p = p, constant_lags = constant_lags)
1338+
get_updated_symbolic_problem(_get_root_indp(prob), prob)
13371339
end
13381340

13391341
# Most are extensions

0 commit comments

Comments
 (0)