Skip to content

Commit 936c3d9

Browse files
fix: handle u0 and p in kwargs of get_concrete_problem
1 parent d70c406 commit 936c3d9

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/solve.jl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,11 @@ keyword arguments.
524524
525525
Should be called before the problem is solved, after performing type-promotion on the
526526
problem.
527+
528+
# Keyword Arguments
529+
530+
- `u0`, `p`: Override values for `state_values(prob)` and `parameter_values(prob)` which
531+
should be used instead of the ones in `prob`.
527532
"""
528533
function get_updated_symbolic_problem(indp, prob; kw...)
529534
return prob
@@ -1239,27 +1244,30 @@ function checkkwargs(kwargshandle; kwargs...)
12391244
end
12401245

12411246
function get_concrete_problem(prob::AbstractJumpProblem, isadapt; kwargs...)
1242-
get_updated_symbolic_problem(_get_root_indp(prob), prob)
1247+
get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
12431248
end
12441249

12451250
function get_concrete_problem(prob::SteadyStateProblem, isadapt; kwargs...)
1246-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob)
1251+
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1252+
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
12471253
p = get_concrete_p(prob, kwargs)
12481254
u0 = get_concrete_u0(prob, isadapt, Inf, kwargs)
12491255
u0 = promote_u0(u0, p, nothing)
12501256
remake(prob; u0 = u0, p = p)
12511257
end
12521258

12531259
function get_concrete_problem(prob::NonlinearProblem, isadapt; kwargs...)
1254-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob)
1260+
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1261+
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
12551262
p = get_concrete_p(prob, kwargs)
12561263
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
12571264
u0 = promote_u0(u0, p, nothing)
12581265
remake(prob; u0 = u0, p = p)
12591266
end
12601267

12611268
function get_concrete_problem(prob::NonlinearLeastSquaresProblem, isadapt; kwargs...)
1262-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob)
1269+
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1270+
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
12631271
p = get_concrete_p(prob, kwargs)
12641272
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
12651273
u0 = promote_u0(u0, p, nothing)
@@ -1281,7 +1289,8 @@ function init(prob::PDEProblem, alg::AbstractDEAlgorithm, args...;
12811289
end
12821290

12831291
function get_concrete_problem(prob, isadapt; kwargs...)
1284-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob)
1292+
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1293+
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
12851294
p = get_concrete_p(prob, kwargs)
12861295
tspan = get_concrete_tspan(prob, isadapt, kwargs, p)
12871296
u0 = get_concrete_u0(prob, isadapt, tspan[1], kwargs)
@@ -1300,7 +1309,8 @@ function get_concrete_problem(prob, isadapt; kwargs...)
13001309
end
13011310

13021311
function get_concrete_problem(prob::DAEProblem, isadapt; kwargs...)
1303-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob)
1312+
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1313+
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
13041314
p = get_concrete_p(prob, kwargs)
13051315
tspan = get_concrete_tspan(prob, isadapt, kwargs, p)
13061316
u0 = get_concrete_u0(prob, isadapt, tspan[1], kwargs)
@@ -1324,7 +1334,8 @@ function get_concrete_problem(prob::DAEProblem, isadapt; kwargs...)
13241334
end
13251335

13261336
function get_concrete_problem(prob::DDEProblem, isadapt; kwargs...)
1327-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob)
1337+
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1338+
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
13281339
p = get_concrete_p(prob, kwargs)
13291340
tspan = get_concrete_tspan(prob, isadapt, kwargs, p)
13301341
u0 = get_concrete_u0(prob, isadapt, tspan[1], kwargs)

0 commit comments

Comments
 (0)