Skip to content

Commit ba8f893

Browse files
committed
refactor: move stuff around a bit
1 parent 4e1098f commit ba8f893

23 files changed

+1566
-1654
lines changed

Project.toml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,25 @@ ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
99
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
1010
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
1111
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
12-
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
1312
FastClosures = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a"
1413
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
1514
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1615
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
1716
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1817
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
19-
MaybeInplace = "bb5d69b7-63fc-4a16-80bd-7e42200c7bdb"
2018
NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
2119
NonlinearSolveFirstOrder = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d"
2220
NonlinearSolveQuasiNewton = "9a2c21bd-3a47-402d-9113-8faf9a0ee114"
2321
NonlinearSolveSpectralMethods = "26075421-4e9a-44e1-8bd1-420ed7ad02b2"
2422
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2523
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
26-
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
2724
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2825
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
29-
SciMLJacobianOperators = "19f34311-ddf3-4b8b-af20-060888a46c0e"
30-
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
3126
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
3227
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
3328
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
3429
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
3530
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
36-
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
3731

3832
[weakdeps]
3933
FastLevenbergMarquardt = "7a0df574-e128-4d35-8cbd-3d84502bf7ce"
@@ -71,7 +65,6 @@ CUDA = "5.5"
7165
CommonSolve = "0.2.4"
7266
ConcreteStructs = "0.2.3"
7367
DiffEqBase = "6.155.3"
74-
DifferentiationInterface = "0.6.16"
7568
Enzyme = "0.13.11"
7669
ExplicitImports = "1.5"
7770
FastClosures = "0.3.2"
@@ -84,11 +77,10 @@ InteractiveUtils = "<0.0.1, 1"
8477
LeastSquaresOptim = "0.8.5"
8578
LineSearch = "0.1.4"
8679
LineSearches = "7.3"
87-
LinearAlgebra = "1.10"
88-
LinearSolve = "2.35"
80+
LinearAlgebra = "1.11.0"
81+
LinearSolve = "2.36.1"
8982
MINPACK = "1.2"
9083
MPI = "0.20.22"
91-
MaybeInplace = "0.1.4"
9284
NLSolvers = "0.5"
9385
NLsolve = "4.5"
9486
NaNMath = "1"
@@ -101,12 +93,9 @@ PrecompileTools = "1.2"
10193
Preferences = "1.4"
10294
Random = "1.10"
10395
ReTestItems = "1.24"
104-
RecursiveArrayTools = "3.27"
10596
Reexport = "1.2"
10697
SIAMFANLEquations = "1.0.1"
10798
SciMLBase = "2.54.0"
108-
SciMLJacobianOperators = "0.1"
109-
SciMLOperators = "0.3.10"
11099
SimpleNonlinearSolve = "2"
111100
SparseArrays = "1.10"
112101
SparseConnectivityTracer = "0.6.5"
@@ -118,7 +107,6 @@ StaticArraysCore = "1.4"
118107
Sundials = "4.23.1"
119108
SymbolicIndexingInterface = "0.3.31"
120109
Test = "1.10"
121-
TimerOutputs = "0.5.23"
122110
Zygote = "0.6.69"
123111
julia = "1.10"
124112

lib/NonlinearSolveBase/src/abstract_types.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function reinit_self!(x::Any; kwargs...)
1818
return
1919
end
2020

21-
function reinit_self!(stats::NLStats)
21+
function reinit!(stats::NLStats)
2222
stats.nf = 0
2323
stats.nsteps = 0
2424
stats.nfactors = 0
@@ -257,8 +257,8 @@ Abstract Type for all NonlinearSolveBase Caches.
257257
- `SciMLBase.set_u!(cache, u)`: set the current state.
258258
- `SciMLBase.reinit!(cache, u0; kwargs...)`: reinitialize the cache with the initial state
259259
`u0` and any additional keyword arguments.
260-
- `SciMLBase.step!(cache; kwargs...)`: See [`SciMLBase.step!`](@ref) for more details.
261260
- `SciMLBase.isinplace(cache)`: whether or not the solver is inplace.
261+
- `CommonSolve.step!(cache; kwargs...)`: See [`CommonSolve.step!`](@ref) for more details.
262262
263263
Additionally implements `SymbolicIndexingInterface` interface Functions.
264264
@@ -577,7 +577,8 @@ macro internal_caches(cType, internal_cache_names...)
577577
return
578578
end
579579
function NonlinearSolveBase.InternalAPI.reinit!(
580-
cache::$(cType), args...; kwargs...)
580+
cache::$(cType), args...; kwargs...
581+
)
581582
$(reinit_caches...)
582583
$(InternalAPI.reinit_self!)(cache, args...; kwargs...)
583584
return

lib/NonlinearSolveBase/src/descent/damped_newton.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ supports_trust_region(::DampedNewtonDescent) = true
4242
mode <: Union{Val{:normal_form}, Val{:least_squares}, Val{:simple}}
4343
end
4444

45-
NonlinearSolveBase.@internal_caches DampedNewtonDescentCache :lincache :damping_fn_cache
45+
@internal_caches DampedNewtonDescentCache :lincache :damping_fn_cache
4646

4747
function InternalAPI.init(
4848
prob::AbstractNonlinearProblem, alg::DampedNewtonDescent, J, fu, u; stats,

lib/NonlinearSolveBase/src/descent/dogleg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ end
4444
normal_form <: Union{Val{false}, Val{true}}
4545
end
4646

47-
NonlinearSolveBase.@internal_caches DoglegCache :newton_cache :cauchy_cache
47+
@internal_caches DoglegCache :newton_cache :cauchy_cache
4848

4949
function InternalAPI.init(
5050
prob::AbstractNonlinearProblem, alg::Dogleg, J, fu, u;
@@ -111,15 +111,15 @@ function InternalAPI.solve!(
111111

112112
l_grad = cache.internalnorm(δu_cauchy)
113113
@bb cache.δu_cache_mul = JᵀJ × vec(δu_cauchy)
114-
δuJᵀJδu = Utils.dot(cache.δu_cache_mul, cache.δu_cache_mul)
114+
δuJᵀJδu = Utils.safe_dot(cache.δu_cache_mul, cache.δu_cache_mul)
115115
else
116116
δu_cauchy = InternalAPI.solve!(
117117
cache.cauchy_cache, J, fu, u, idx; skip_solve, kwargs...
118118
).δu
119119
J_ = preinverted_jacobian(cache) ? inv(J) : J
120120
l_grad = cache.internalnorm(δu_cauchy)
121121
@bb cache.Jᵀδu_cache = J_ × vec(δu_cauchy)
122-
δuJᵀJδu = Utils.dot(cache.Jᵀδu_cache, cache.Jᵀδu_cache)
122+
δuJᵀJδu = Utils.safe_dot(cache.Jᵀδu_cache, cache.Jᵀδu_cache)
123123
end
124124
d_cauchy = (l_grad^3) / δuJᵀJδu
125125

lib/NonlinearSolveBase/src/descent/geodesic_acceleration.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function InternalAPI.reinit_self!(cache::GeodesicAccelerationCache; p = cache.p,
5454
cache.last_step_accepted = false
5555
end
5656

57-
NonlinearSolveBase.@internal_caches GeodesicAccelerationCache :descent_cache
57+
@internal_caches GeodesicAccelerationCache :descent_cache
5858

5959
function get_velocity(cache::GeodesicAccelerationCache)
6060
return SciMLBase.get_du(cache.descent_cache, Val(1))

lib/NonlinearSolveBase/src/descent/newton.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ supports_line_search(::NewtonDescent) = true
2424
normal_form <: Union{Val{false}, Val{true}}
2525
end
2626

27-
NonlinearSolveBase.@internal_caches NewtonDescentCache :lincache
27+
@internal_caches NewtonDescentCache :lincache
2828

2929
function InternalAPI.init(
3030
prob::AbstractNonlinearProblem, alg::NewtonDescent, J, fu, u; stats,

lib/NonlinearSolveBase/src/descent/steepest.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ supports_line_search(::SteepestDescent) = true
2121
preinverted_jacobian <: Union{Val{false}, Val{true}}
2222
end
2323

24-
NonlinearSolveBase.@internal_caches SteepestDescentCache :lincache
24+
@internal_caches SteepestDescentCache :lincache
2525

2626
function InternalAPI.init(
2727
prob::AbstractNonlinearProblem, alg::SteepestDescent, J, fu, u;

lib/NonlinearSolveBase/src/solve.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ function SciMLBase.__solve(
22
prob::AbstractNonlinearProblem, alg::AbstractNonlinearSolveAlgorithm, args...;
33
kwargs...
44
)
5-
cache = SciMLBase.init(prob, alg, args...; kwargs...)
6-
return SciMLBase.solve!(cache)
5+
cache = SciMLBase.__init(prob, alg, args...; kwargs...)
6+
return CommonSolve.solve!(cache)
77
end
88

99
function CommonSolve.solve!(cache::AbstractNonlinearSolveCache)
1010
while not_terminated(cache)
11-
SciMLBase.step!(cache)
11+
CommonSolve.step!(cache)
1212
end
1313

1414
# The solver might have set a different `retcode`
@@ -47,7 +47,7 @@ Performs one step of the nonlinear solver.
4747
respectively. For algorithms that don't use jacobian information, this keyword is
4848
ignored with a one-time warning.
4949
"""
50-
function SciMLBase.step!(cache::AbstractNonlinearSolveCache, args...; kwargs...)
50+
function CommonSolve.step!(cache::AbstractNonlinearSolveCache, args...; kwargs...)
5151
not_terminated(cache) || return
5252

5353
has_time_limit(cache) && (time_start = time())

lib/NonlinearSolveBase/src/utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Utils
22

33
using ArrayInterface: ArrayInterface
44
using FastClosures: @closure
5-
using LinearAlgebra: LinearAlgebra, Diagonal, Symmetric, norm, dot, cond, diagind, pinv, inv
5+
using LinearAlgebra: LinearAlgebra, Diagonal, Symmetric, norm, dot, cond, diagind, pinv
66
using MaybeInplace: @bb
77
using RecursiveArrayTools: AbstractVectorOfArray, ArrayPartition
88
using SciMLOperators: AbstractSciMLOperator
@@ -117,6 +117,7 @@ is_default_value(::Any, ::Symbol, ::Nothing) = true
117117
is_default_value(::Any, ::Symbol, ::Missing) = true
118118
is_default_value(::Any, ::Symbol, val::Int) = val == typemax(typeof(val))
119119
is_default_value(::Any, ::Symbol, ::Any) = false
120+
is_default_value(::Any, ::Any, ::Any) = false
120121

121122
maybe_symmetric(x) = Symmetric(x)
122123
maybe_symmetric(x::Number) = x

lib/NonlinearSolveFirstOrder/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
1919
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2020
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2121
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
22+
SciMLJacobianOperators = "19f34311-ddf3-4b8b-af20-060888a46c0e"
2223
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2324
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
2425

lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm,
2222
NewtonDescent, DampedNewtonDescent, GeodesicAcceleration,
2323
Dogleg
2424
using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode, NonlinearFunction
25+
using SciMLJacobianOperators: VecJacOperator, JacVecOperator, StatefulJacobianOperator
2526
using Setfield: @set!
2627
using StaticArraysCore: SArray
2728

@@ -41,9 +42,8 @@ include("solve.jl")
4142
@__DIR__, "..", "..", "..", "common", "nlls_problem_workloads.jl"
4243
))
4344

44-
# XXX: TrustRegion
45-
nlp_algs = [NewtonRaphson(), LevenbergMarquardt()]
46-
nlls_algs = [GaussNewton(), LevenbergMarquardt()]
45+
nlp_algs = [NewtonRaphson(), TrustRegion(), LevenbergMarquardt()]
46+
nlls_algs = [GaussNewton(), TrustRegion(), LevenbergMarquardt()]
4747

4848
@compile_workload begin
4949
for prob in nonlinear_problems, alg in nlp_algs
@@ -61,6 +61,8 @@ end
6161
export NewtonRaphson, PseudoTransient
6262
export GaussNewton, LevenbergMarquardt, TrustRegion
6363

64+
export RadiusUpdateSchemes
65+
6466
export GeneralizedFirstOrderAlgorithm
6567

6668
end

0 commit comments

Comments
 (0)