Skip to content

Commit 6dc3237

Browse files
Fix alg definition in adjoints
1 parent d452726 commit 6dc3237

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/solve.jl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,17 +1424,19 @@ end
14241424

14251425
function _solve_adjoint(prob, sensealg, u0, p, originator, args...; merge_callbacks = true,
14261426
kwargs...)
1427-
_prob = if haskey(kwargs, :alg) && (isempty(args) || args[1] === nothing)
1427+
alg, _prob = if haskey(kwargs, :alg) && (isempty(args) || args[1] === nothing)
14281428
alg = kwargs[:alg]
1429-
get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
1429+
alg, get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
14301430
elseif !isempty(args) && typeof(args[1]) <: DEAlgorithm
14311431
alg = args[1]
1432-
get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
1432+
alg, get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
14331433
elseif isempty(args) # Default algorithm handling
1434-
get_concrete_problem(prob, !(typeof(prob) <: DiscreteProblem); u0 = u0, p = p,
1434+
alg = !(typeof(prob) <: DiscreteProblem)
1435+
alg, get_concrete_problem(prob, alg; u0 = u0, p = p,
14351436
kwargs...)
14361437
else
1437-
get_concrete_problem(prob, !(typeof(prob) <: DiscreteProblem); u0 = u0, p = p,
1438+
alg = !(typeof(prob) <: DiscreteProblem)
1439+
alg, get_concrete_problem(prob, alg; u0 = u0, p = p,
14381440
kwargs...)
14391441
end
14401442

@@ -1460,17 +1462,19 @@ end
14601462

14611463
function _solve_forward(prob, sensealg, u0, p, originator, args...; merge_callbacks = true,
14621464
kwargs...)
1463-
_prob = if haskey(kwargs, :alg) && (isempty(args) || args[1] === nothing)
1465+
alg, _prob = if haskey(kwargs, :alg) && (isempty(args) || args[1] === nothing)
14641466
alg = kwargs[:alg]
1465-
get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
1467+
alg, get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
14661468
elseif !isempty(args) && typeof(args[1]) <: DEAlgorithm
14671469
alg = args[1]
1468-
get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
1470+
alg, get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
14691471
elseif isempty(args) # Default algorithm handling
1470-
get_concrete_problem(prob, !(typeof(prob) <: DiscreteProblem); u0 = u0, p = p,
1472+
alg = !(typeof(prob) <: DiscreteProblem)
1473+
alg, get_concrete_problem(prob, alg; u0 = u0, p = p,
14711474
kwargs...)
14721475
else
1473-
get_concrete_problem(prob, !(typeof(prob) <: DiscreteProblem); u0 = u0, p = p,
1476+
alg = !(typeof(prob) <: DiscreteProblem)
1477+
alg, get_concrete_problem(prob, alg; u0 = u0, p = p,
14741478
kwargs...)
14751479
end
14761480

@@ -1487,10 +1491,10 @@ function _solve_forward(prob, sensealg, u0, p, originator, args...; merge_callba
14871491
end
14881492

14891493
if isempty(args)
1490-
_concrete_solve_forward(prob, nothing, sensealg, u0, p; kwargs...)
1494+
_concrete_solve_forward(_prob, alg, sensealg, u0, p, originator; kwargs...)
14911495
else
1492-
_concrete_solve_forward(prob, args[1], sensealg, u0, p, Base.tail(args)...;
1493-
kwargs...)
1496+
_concrete_solve_forward(_prob, alg, sensealg, u0, p, originator,
1497+
Base.tail(args)...; kwargs...)
14941498
end
14951499
end
14961500

0 commit comments

Comments
 (0)