Skip to content

Commit 1cc250d

Browse files
committed
Don't fail other solvers
1 parent 9b7ff46 commit 1cc250d

12 files changed

Lines changed: 23 additions & 13 deletions

File tree

lib/BoundaryValueDiffEqAscher/src/BoundaryValueDiffEqAscher.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using AlmostBlockDiagonals: AlmostBlockDiagonals, IntermediateAlmostBlockDiagona
66
using BoundaryValueDiffEqCore: AbstractBoundaryValueDiffEqAlgorithm,
77
AbstractBoundaryValueDiffEqCache, BVPJacobianAlgorithm,
88
__extract_problem_details, concrete_jacobian_algorithm,
9-
__Fix3, __concrete_nonlinearsolve_algorithm,
9+
__Fix3, __concrete_solve_algorithm,
1010
__internal_nlsolve_problem, __vec, __vec_f, __vec_f!,
1111
__vec_bc, __vec_bc!, __extract_mesh, get_dense_ad,
1212
__get_bcresid_prototype, __split_kwargs,

lib/BoundaryValueDiffEqAscher/src/ascher.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function __perform_ascher_iteration(
176176
cache::AscherCache{iip, T}, abstol, adaptive::Bool) where {iip, T}
177177
info::ReturnCode.T = ReturnCode.Success
178178
nlprob = __construct_nlproblem(cache)
179-
nlsolve_alg = __concrete_nonlinearsolve_algorithm(nlprob, cache.alg.nlsolve)
179+
nlsolve_alg = __concrete_solve_algorithm(nlprob, cache.alg.nlsolve)
180180
nlsol = __solve(nlprob, nlsolve_alg; cache.nlsolve_kwargs...)
181181
error_norm = 2 * abstol
182182
info = nlsol.retcode

lib/BoundaryValueDiffEqCore/src/default_internal_solve.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ If none of the solvers are specified, we use nonlinear solvers from NonlinearSol
5656
If both of the nonlinear solver and optimization solver are specified, we throw an error.
5757
If only one of the nonlinear solver and optimization solver is specified, we use that solver.
5858
"""
59+
@inline __concrete_solve_algorithm(prob, alg) = alg
5960
@inline __concrete_solve_algorithm(prob, alg, ::Nothing) = alg
6061
@inline __concrete_solve_algorithm(prob, ::Nothing, alg) = alg
6162
@inline __concrete_solve_algorithm(prob,
6263
alg1,
6364
alg2) = error("Both `nlsolve` and `optimize` are specified in the algorithm, but only one of them is allowed. Please specify only one of them.")
65+
@inline function __concrete_solve_algorithm(prob, ::Nothing)
66+
if prob isa NonlinearLeastSquaresProblem
67+
return __FastShortcutBVPCompatibleNLLSPolyalg(eltype(prob.u0))
68+
else
69+
return __FastShortcutBVPCompatibleNonlinearPolyalg(eltype(prob.u0))
70+
end
71+
end
6472
@inline function __concrete_solve_algorithm(prob, ::Nothing, ::Nothing)
6573
if prob isa NonlinearLeastSquaresProblem
6674
return __FastShortcutBVPCompatibleNLLSPolyalg(eltype(prob.u0))

lib/BoundaryValueDiffEqFIRK/src/BoundaryValueDiffEqFIRK.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using BandedMatrices: BandedMatrix, Ones
66
using BoundaryValueDiffEqCore: AbstractBoundaryValueDiffEqAlgorithm,
77
AbstractBoundaryValueDiffEqCache, BVPJacobianAlgorithm,
88
recursive_flatten, recursive_flatten!, recursive_unflatten!,
9-
__concrete_nonlinearsolve_algorithm, diff!, EvalSol,
9+
__concrete_solve_algorithm, diff!, EvalSol,
1010
concrete_jacobian_algorithm, eval_bc_residual, interval,
1111
eval_bc_residual!, get_tmp, __maybe_matmul!, __resize!,
1212
__extract_problem_details, __initial_guess, nodual_value,

lib/BoundaryValueDiffEqFIRK/src/firk.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ end
404404
function __perform_firk_iteration(
405405
cache::Union{FIRKCacheExpand, FIRKCacheNested}, abstol, adaptive::Bool)
406406
nlprob = __construct_nlproblem(cache, vec(cache.y₀), copy(cache.y₀))
407-
nlsolve_alg = __concrete_nonlinearsolve_algorithm(nlprob, cache.alg.nlsolve)
407+
nlsolve_alg = __concrete_solve_algorithm(nlprob, cache.alg.nlsolve)
408408
sol_nlprob = __solve(nlprob, nlsolve_alg; cache.nlsolve_kwargs..., alias_u0 = true)
409409
recursive_unflatten!(cache.y₀, sol_nlprob.u)
410410

lib/BoundaryValueDiffEqMIRK/Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
6767
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
6868
Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
6969
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
70+
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
7071
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
7172
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
7273
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
74+
OptimizationMOI = "fd9f6733-72f4-499f-8506-86b2bdd0dea1"
7375
OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce"
7476
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
7577
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
@@ -78,4 +80,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
7880
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7981

8082
[targets]
81-
test = ["Aqua", "DiffEqDevTools", "Enzyme", "Hwloc", "InteractiveUtils", "JET", "LinearSolve", "Mooncake", "OrdinaryDiffEqRosenbrock", "Random", "ReTestItems", "RecursiveArrayTools", "StaticArrays", "Test"]
83+
test = ["Aqua", "DiffEqDevTools", "Enzyme", "Hwloc", "InteractiveUtils", "Ipopt", "JET", "LinearSolve", "Mooncake", "OptimizationMOI", "OrdinaryDiffEqRosenbrock", "Random", "ReTestItems", "RecursiveArrayTools", "StaticArrays", "Test"]

lib/BoundaryValueDiffEqMIRK/test/mirk_basic_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ end
463463
@test sol.prob.p [17.09658] atol=1e-5
464464
end
465465

466-
@testset "Convergence with optimization based solver" setup=[MIRKConvergenceTests] begin
466+
@testitem "Convergence with optimization based solver" setup=[MIRKConvergenceTests] begin
467467
using LinearAlgebra, DiffEqDevTools, OptimizationMOI, Ipopt
468468

469469
@testset "Problem: $i" for i in (3, 4, 5, 6, 9, 10)

lib/BoundaryValueDiffEqMIRKN/src/BoundaryValueDiffEqMIRKN.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ using BandedMatrices: BandedMatrix, Ones
66
using BoundaryValueDiffEqCore: AbstractBoundaryValueDiffEqAlgorithm,
77
AbstractBoundaryValueDiffEqCache, BVPJacobianAlgorithm,
88
recursive_flatten, recursive_flatten!, recursive_unflatten!,
9-
__concrete_nonlinearsolve_algorithm, diff!, EvalSol,
10-
eval_bc_residual, eval_bc_residual!, get_tmp,
11-
__maybe_matmul!, __extract_problem_details, __initial_guess,
9+
__concrete_solve_algorithm, diff!, EvalSol, eval_bc_residual,
10+
eval_bc_residual!, get_tmp, __maybe_matmul!,
11+
__extract_problem_details, __initial_guess,
1212
__maybe_allocate_diffcache, __restructure_sol,
1313
__get_bcresid_prototype, safe_similar, __vec, __vec_f,
1414
__vec_f!, __vec_bc, __vec_bc!, __vec_so_bc!, __vec_so_bc,

lib/BoundaryValueDiffEqMIRKN/src/mirkn.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ end
113113

114114
function __perform_mirkn_iteration(cache::MIRKNCache)
115115
nlprob::NonlinearProblem = __construct_nlproblem(cache, vec(cache.y₀), copy(cache.y₀))
116-
nlsolve_alg = __concrete_nonlinearsolve_algorithm(nlprob, cache.alg.nlsolve)
116+
nlsolve_alg = __concrete_solve_algorithm(nlprob, cache.alg.nlsolve)
117117
sol_nlprob = __solve(nlprob, nlsolve_alg; cache.nlsolve_kwargs..., alias_u0 = true)
118118
recursive_unflatten!(cache.y₀, sol_nlprob.u)
119119

lib/BoundaryValueDiffEqShooting/src/BoundaryValueDiffEqShooting.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using ArrayInterface: fast_scalar_indexing
55
using BandedMatrices: BandedMatrix, Ones
66
using BoundaryValueDiffEqCore: AbstractBoundaryValueDiffEqAlgorithm, BVPJacobianAlgorithm,
77
recursive_flatten, recursive_flatten!, recursive_unflatten!,
8-
__concrete_nonlinearsolve_algorithm, diff!, __any_sparse_ad,
8+
__concrete_solve_algorithm, diff!, __any_sparse_ad,
99
__cache_trait, concrete_jacobian_algorithm, eval_bc_residual,
1010
eval_bc_residual!, get_tmp, __maybe_matmul!,
1111
__extract_problem_details, __initial_guess,

0 commit comments

Comments
 (0)