Skip to content

Commit 7a1da23

Browse files
Remove BoundaryValueDiffEqShooting blanket reexports
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 219b502 commit 7a1da23

7 files changed

Lines changed: 110 additions & 55 deletions

File tree

lib/BoundaryValueDiffEqShooting/Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
1717
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
1818
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1919
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
20-
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2120
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2221
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
2322
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
@@ -35,6 +34,7 @@ DifferentiationInterface = "0.7.15"
3534
FastClosures = "0.3.2"
3635
ForwardDiff = "0.10.38, 1"
3736
LinearAlgebra = "1.10"
37+
NonlinearSolveFirstOrder = "1.2, 2"
3838
OrdinaryDiffEqLowOrderRK = "1, 2"
3939
OrdinaryDiffEqRosenbrock = "1, 2"
4040
OrdinaryDiffEqTsit5 = "1, 2"
@@ -44,7 +44,6 @@ Preferences = "1.5"
4444
PreallocationTools = "1.2"
4545
Random = "1.10"
4646
RecursiveArrayTools = "3.27.0, 4"
47-
Reexport = "1.2"
4847
SciMLBase = "3.30"
4948
SciMLLogging = "1.10.1, 2"
5049
SciMLTesting = "2.4"
@@ -57,6 +56,7 @@ julia = "1.10"
5756
[extras]
5857
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
5958
DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
59+
NonlinearSolveFirstOrder = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d"
6060
OrdinaryDiffEqLowOrderRK = "1344f307-1e59-4825-a18e-ace9aa3fa4c6"
6161
OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce"
6262
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
@@ -68,4 +68,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
6868
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6969

7070
[targets]
71-
test = ["DiffEqDevTools", "OrdinaryDiffEqLowOrderRK", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqTsit5", "OrdinaryDiffEqVerner", "Random", "RecursiveArrayTools", "SciMLTesting", "StaticArrays", "Test", "SafeTestsets"]
71+
test = ["DiffEqDevTools", "NonlinearSolveFirstOrder", "OrdinaryDiffEqLowOrderRK", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqTsit5", "OrdinaryDiffEqVerner", "Random", "RecursiveArrayTools", "SciMLTesting", "StaticArrays", "Test", "SafeTestsets"]

lib/BoundaryValueDiffEqShooting/src/BoundaryValueDiffEqShooting.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ using BoundaryValueDiffEqCore: BoundaryValueDiffEqCore,
1919
__extract_u0,
2020
__initial_guess_on_mesh,
2121
__get_non_sparse_ad, __build_solution, get_dense_ad,
22-
__internal_solve, _process_verbose_param, BVPVerbosity, _unwrap_val
22+
__internal_solve, _process_verbose_param, _unwrap_val
2323

2424
using ConcreteStructs: @concrete
2525
using DifferentiationInterface: DifferentiationInterface,
2626
overloaded_input_type
2727
using FastClosures: @closure
2828
using ForwardDiff: ForwardDiff, pickchunksize
2929
using LinearAlgebra: LinearAlgebra
30-
using Reexport: @reexport
3130
using SciMLBase: SciMLBase, BVProblem, EnsembleSerial, EnsembleThreads,
3231
NonlinearFunction, ODEProblem, StandardBVProblem, TwoPointBVProblem,
3332
__solve, isinplace, remake, solve, solve!
@@ -40,8 +39,6 @@ using Preferences: Preferences
4039

4140
const DI = DifferentiationInterface
4241

43-
@reexport using ADTypes, BoundaryValueDiffEqCore, SciMLBase
44-
4542
include("algorithms.jl")
4643
include("single_shooting.jl")
4744
include("multiple_shooting.jl")

lib/BoundaryValueDiffEqShooting/src/algorithms.jl

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,49 @@ abstract type AbstractShooting <: AbstractBoundaryValueDiffEqAlgorithm end
44
"""
55
Shooting(ode_alg; kwargs...)
66
Shooting(ode_alg, nlsolve; kwargs...)
7-
Shooting(; ode_alg = nothing, nlsolve = nothing, optimize = nothing, jac_alg = nothing)
7+
Shooting(; ode_alg = nothing, nlsolve = nothing, optimize = nothing, jac_alg = nothing) -> Shooting
88
9-
Single shooting method, reduces BVP to an initial value problem and solves the IVP.
9+
Configures the single-shooting algorithm for a boundary value problem. Single shooting
10+
integrates one initial value problem and solves for the initial condition that satisfies the
11+
boundary conditions.
1012
1113
## Arguments
1214
13-
- `ode_alg`: ODE algorithm to use for solving the IVP. Any solver which conforms to the
14-
SciML `ODEProblem` interface can be used! (Defaults to `nothing` which will use
15-
poly-algorithm if `DifferentialEquations.jl` is loaded else this must be supplied)
16-
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
17-
`NonlinearProblem` interface can be used. Note that any autodiff argument for the solver
18-
will be ignored and a custom jacobian algorithm will be used.
19-
- `optimize`: Internal Optimization solver. Any solver which conforms to the SciML
20-
`OptimizationProblem` interface can be used. Note that any autodiff argument for the solver
21-
will be ignored and a custom jacobian algorithm will be used.
22-
- `jac_alg`: Jacobian Algorithm used for the Nonlinear Solver. If this is not set, we
23-
check if `nlsolve.ad` exists and is not nothing. If it is, we use that to construct
24-
the jacobian. If not, we try to use the best algorithm based on the input types
25-
and problem type. If `BVPJacobianAlgorithm` is provided, only `diffmode` is used
26-
(defaults to `AutoForwardDiff` if possible else `AutoFiniteDiff`).
15+
- `ode_alg`: algorithm used to solve the internal `SciMLBase.ODEProblem`. Pass this as the
16+
first positional argument or keyword argument. `nothing` selects a loaded polyalgorithm;
17+
otherwise an ODE algorithm must be supplied.
18+
- `nlsolve`: nonlinear-solver algorithm for the shooting residual. Its autodiff setting is
19+
superseded by `jac_alg` when a Jacobian algorithm is materialized.
20+
21+
## Keywords
22+
23+
- `ode_alg = nothing`: ODE algorithm, as described above.
24+
- `nlsolve = nothing`: nonlinear-solver algorithm, as described above.
25+
- `optimize = nothing`: optimization-solver algorithm used when the selected BVP solve path
26+
formulates the residual as an optimization problem.
27+
- `jac_alg = nothing`: `BVPJacobianAlgorithm` configuration. When omitted, the constructor
28+
derives it from `nlsolve` and the problem during solve initialization. For single shooting,
29+
only its `diffmode` setting is used; the default is `AutoForwardDiff` when applicable and
30+
otherwise `AutoFiniteDiff`.
31+
32+
## Fields
33+
34+
- `ode_alg`: configured ODE algorithm or `nothing`.
35+
- `nlsolve`: configured nonlinear-solver algorithm or `nothing`.
36+
- `optimize`: configured optimization-solver algorithm or `nothing`.
37+
- `jac_alg::BVPJacobianAlgorithm`: materialized Jacobian-algorithm configuration.
38+
39+
## Returns
40+
41+
- `Shooting`: an algorithm object accepted by `SciMLBase.solve` for a boundary value problem.
42+
43+
## Examples
44+
45+
```julia
46+
using BoundaryValueDiffEqShooting, OrdinaryDiffEqTsit5
47+
48+
alg = Shooting(Tsit5())
49+
```
2750
"""
2851
@concrete struct Shooting{J <: BVPJacobianAlgorithm} <: AbstractShooting
2952
ode_alg
@@ -46,37 +69,40 @@ end
4669

4770
"""
4871
MultipleShooting(; nshoots::Int, ode_alg = nothing, nlsolve = nothing,
49-
optimize = nothing, grid_coarsening = true, jac_alg = nothing)
72+
optimize = nothing, grid_coarsening = true, jac_alg = nothing) -> MultipleShooting
5073
MultipleShooting(nshoots::Int; kwargs...)
5174
MultipleShooting(nshoots::Int, ode_alg; kwargs...)
5275
MultipleShooting(nshoots::Int, ode_alg, nlsolve; kwargs...)
5376
54-
Multiple Shooting method, reduces BVP to an initial value problem and solves the IVP.
55-
Significantly more stable than Single Shooting.
77+
Configures the multiple-shooting algorithm for a boundary value problem. Multiple shooting
78+
integrates an IVP on `nshoots` subintervals and solves for their matching initial conditions;
79+
it is generally more stable than [`Shooting`](@ref).
5680
5781
## Arguments
5882
59-
- `nshoots`: Number of shooting points.
83+
- `nshoots::Int`: number of shooting subintervals.
84+
- `ode_alg`: algorithm used to solve each internal `SciMLBase.ODEProblem`. Pass this as the
85+
second positional argument or keyword argument. `nothing` selects a loaded polyalgorithm;
86+
otherwise an ODE algorithm must be supplied.
87+
- `nlsolve`: nonlinear-solver algorithm for the multiple-shooting residual.
6088
61-
- `ode_alg`: ODE algorithm to use for solving the IVP. Any solver which conforms to the
62-
SciML `ODEProblem` interface can be used! (Defaults to `nothing` which will use
63-
poly-algorithm if `DifferentialEquations.jl` is loaded else this must be supplied)
64-
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
65-
`NonlinearProblem` interface can be used.
66-
- `optimize`: Internal Optimization solver. Any solver which conforms to the SciML
67-
`OptimizationProblem` interface can be used.
68-
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
69-
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to use based
70-
on the input types and problem type.
89+
## Keywords
90+
91+
- `ode_alg = nothing`: ODE algorithm, as described above.
92+
- `nlsolve = nothing`: nonlinear-solver algorithm, as described above.
93+
- `optimize = nothing`: optimization-solver algorithm used when the selected BVP solve path
94+
formulates the residual as an optimization problem.
95+
- `jac_alg = nothing`: `BVPJacobianAlgorithm` configuration. When omitted, the constructor
96+
derives it from `nlsolve` and the problem during solve initialization.
7197
7298
+ For `TwoPointBVProblem`, only `diffmode` is used (defaults to
7399
`AutoSparse(AutoForwardDiff())` if possible else `AutoSparse(AutoFiniteDiff())`).
74100
+ For `BVProblem`, `bc_diffmode` and `nonbc_diffmode` are used. For `nonbc_diffmode`
75101
we default to `AutoSparse(AutoForwardDiff())` if possible else
76102
`AutoSparse(AutoFiniteDiff())`. For `bc_diffmode`, we default to `AutoForwardDiff`
77103
if possible else `AutoFiniteDiff`.
78-
- `grid_coarsening`: Coarsening the multiple-shooting grid to generate a stable IVP
79-
solution. Possible Choices:
104+
- `grid_coarsening = true`: coarsens the multiple-shooting grid while generating a stable
105+
IVP solution. Supported values are:
80106
81107
+ `true`: Halve the grid size, till we reach a grid size of 1.
82108
+ `false`: Do not coarsen the grid. Solve a Multiple Shooting Problem and finally
@@ -87,6 +113,28 @@ Significantly more stable than Single Shooting.
87113
+ `Function`: Takes the current number of shooting points and returns the next number
88114
of shooting points. For example, if `nshoots = 10` and
89115
`grid_coarsening = n -> n ÷ 2`, then the grid will be coarsened to `[5, 2]`.
116+
117+
## Fields
118+
119+
- `ode_alg`: configured ODE algorithm or `nothing`.
120+
- `nlsolve`: configured nonlinear-solver algorithm or `nothing`.
121+
- `optimize`: configured optimization-solver algorithm or `nothing`.
122+
- `jac_alg::BVPJacobianAlgorithm`: materialized Jacobian-algorithm configuration.
123+
- `nshoots::Int`: configured number of shooting subintervals.
124+
- `grid_coarsening`: configured grid-coarsening strategy.
125+
126+
## Returns
127+
128+
- `MultipleShooting`: an algorithm object accepted by `SciMLBase.solve` for a boundary value
129+
problem.
130+
131+
## Examples
132+
133+
```julia
134+
using BoundaryValueDiffEqShooting, OrdinaryDiffEqTsit5
135+
136+
alg = MultipleShooting(8, Tsit5(); grid_coarsening = true)
137+
```
90138
"""
91139
@concrete struct MultipleShooting{J <: BVPJacobianAlgorithm} <: AbstractShooting
92140
ode_alg

lib/BoundaryValueDiffEqShooting/test/Core/basic_problems_tests.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
using BoundaryValueDiffEqShooting
2+
using ADTypes: AutoFiniteDiff, AutoForwardDiff, AutoSparse
3+
using BoundaryValueDiffEqCore: BVPJacobianAlgorithm
4+
using NonlinearSolveFirstOrder: NewtonRaphson, TrustRegion
5+
using SciMLBase: BVPFunction, BVProblem, TwoPointBVProblem, solve
26
using Test
37

8+
import SciMLBase
9+
410
@testset "Basic Shooting" begin
5-
using BoundaryValueDiffEqShooting, LinearAlgebra, OrdinaryDiffEqTsit5
11+
using LinearAlgebra, OrdinaryDiffEqTsit5
612

713
# JET tests have been moved to the separate QA test group (test/qa/)
814

@@ -111,7 +117,7 @@ using Test
111117
end
112118

113119
@testset "Shooting with Complex Values" begin
114-
using BoundaryValueDiffEqShooting, OrdinaryDiffEqVerner, LinearAlgebra
120+
using OrdinaryDiffEqVerner, LinearAlgebra
115121

116122
SOLVERS = [
117123
Shooting(Vern7(), NewtonRaphson(; autodiff = AutoFiniteDiff())), Shooting(Vern7()),
@@ -148,7 +154,7 @@ end
148154
end
149155

150156
@testset "Flow in a Channel" begin
151-
using BoundaryValueDiffEqShooting, OrdinaryDiffEqTsit5, OrdinaryDiffEqRosenbrock,
157+
using OrdinaryDiffEqTsit5, OrdinaryDiffEqRosenbrock,
152158
LinearAlgebra
153159

154160
function flow_in_a_channel!(du, u, p, t)
@@ -206,7 +212,7 @@ end
206212
end
207213
#FIXME: MultipleShooting fails for large out-of-place BVP systems
208214
@testset "Ray Tracing" begin
209-
using BoundaryValueDiffEqShooting, OrdinaryDiffEqVerner, OrdinaryDiffEqRosenbrock,
215+
using OrdinaryDiffEqVerner, OrdinaryDiffEqRosenbrock,
210216
LinearAlgebra
211217

212218
@inline v(x, y, z, p) = 1 / (4 + cos(p[1] * x) + sin(p[2] * y) - cos(p[3] * z))
@@ -380,7 +386,7 @@ end
380386
end
381387

382388
@testset "Shooting with heterogeneous initial guess" begin
383-
using BoundaryValueDiffEqShooting, OrdinaryDiffEqVerner, LinearAlgebra
389+
using OrdinaryDiffEqVerner, LinearAlgebra
384390
g = 9.81
385391
L = 1.0
386392
tspan = (0.0, pi / 2.0)

lib/BoundaryValueDiffEqShooting/test/Core/nlls_tests.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
using BoundaryValueDiffEqShooting
2+
using ADTypes: AutoFiniteDiff, AutoForwardDiff
3+
using BoundaryValueDiffEqCore: BVPJacobianAlgorithm
4+
using NonlinearSolveFirstOrder: GaussNewton, LevenbergMarquardt, NewtonRaphson, TrustRegion
5+
using SciMLBase: BVPFunction, BVProblem, solve
26
using Test
37

8+
import SciMLBase
9+
410
@testset "Overconstrained BVP" begin
5-
using BoundaryValueDiffEqShooting, OrdinaryDiffEqTsit5, LinearAlgebra
11+
using OrdinaryDiffEqTsit5, LinearAlgebra
612

713
# JET tests have been moved to the separate QA test group (test/qa/)
814

lib/BoundaryValueDiffEqShooting/test/Core/orbital_tests.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
using BoundaryValueDiffEqShooting
2+
using ADTypes: ADTypes, AutoFiniteDiff, AutoForwardDiff, AutoSparse
3+
using BoundaryValueDiffEqCore: BVPJacobianAlgorithm
4+
using NonlinearSolveFirstOrder: TrustRegion
5+
using SciMLBase: BVProblem, TwoPointBVProblem, solve
26
using Test
37

8+
import SciMLBase
9+
410
@testset "Lambert's Problem" begin
5-
using BoundaryValueDiffEqShooting, OrdinaryDiffEqLowOrderRK, LinearAlgebra
11+
using OrdinaryDiffEqLowOrderRK, LinearAlgebra
612

713
y0 = [
814
-4.7763169762853989e+6, -3.838639870444152e+5, -5.3500183933132319e+6,
@@ -68,7 +74,7 @@ using Test
6874

6975
jac_alg = BVPJacobianAlgorithm(;
7076
nonbc_diffmode = autodiff,
71-
bc_diffmode = BoundaryValueDiffEqShooting.__get_non_sparse_ad(autodiff)
77+
bc_diffmode = ADTypes.dense_ad(autodiff)
7278
)
7379

7480
sol = solve(

lib/BoundaryValueDiffEqShooting/test/qa/qa.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ using SciMLTesting
22
using BoundaryValueDiffEqShooting
33
using Test
44

5-
const DOCS_SRC = normpath(joinpath(@__DIR__, "..", "..", "..", "..", "docs", "src"))
6-
include(joinpath(@__DIR__, "..", "..", "..", "..", "test", "qa", "reexports.jl"))
7-
85
run_qa(
96
BoundaryValueDiffEqShooting;
107
aqua_kwargs = (; persistent_tasks = false),
@@ -17,9 +14,4 @@ run_qa(
1714
ignore = (:StandardBVProblem, :overloaded_input_type, :pickchunksize),
1815
),
1916
),
20-
reexports_allow = SHOOTING_REEXPORTS,
21-
api_docs_kwargs = (;
22-
docs_src = DOCS_SRC, ignore = SHOOTING_REEXPORTS,
23-
rendered_ignore = SHOOTING_REEXPORTS,
24-
),
2517
)

0 commit comments

Comments
 (0)