-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
120 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
using SciMLBase: NonlinearLeastSquaresProblem, NonlinearFunction | ||
|
||
nonlinear_functions = ( | ||
(NonlinearFunction{false}((u, p) -> (u .^ 2 .- p)[1:1]), [0.1, 0.0]), | ||
(NonlinearFunction{false}((u, p) -> vcat(u .* u .- p, u .* u .- p)), [0.1, 0.1]), | ||
( | ||
NonlinearFunction{true}( | ||
(du, u, p) -> du[1] = u[1] * u[1] - p, resid_prototype = zeros(1) | ||
), | ||
[0.1, 0.0] | ||
), | ||
( | ||
NonlinearFunction{true}( | ||
(du, u, p) -> du .= vcat(u .* u .- p, u .* u .- p), resid_prototype = zeros(4) | ||
), | ||
[0.1, 0.1] | ||
) | ||
) | ||
|
||
nlls_problems = NonlinearLeastSquaresProblem[] | ||
for (fn, u0) in nonlinear_functions | ||
push!(nlls_problems, NonlinearLeastSquaresProblem(fn, u0, 2.0)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
name = "BracketingNonlinearSolve" | ||
uuid = "70df07ce-3d50-431d-a3e7-ca6ddb60ac1e" | ||
authors = ["Avik Pal <[email protected]> and contributors"] | ||
version = "1.0.0" | ||
version = "1.1.0" | ||
|
||
[deps] | ||
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2" | ||
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471" | ||
NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0" | ||
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" | ||
Reexport = "189a3867-3050-52da-a836-e630ba90ab69" | ||
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" | ||
|
||
[weakdeps] | ||
|
@@ -25,6 +26,7 @@ ForwardDiff = "0.10.36" | |
InteractiveUtils = "<0.0.1, 1" | ||
NonlinearSolveBase = "1" | ||
PrecompileTools = "1.2" | ||
Reexport = "1.2" | ||
SciMLBase = "2.50" | ||
Test = "1.10" | ||
TestItemRunner = "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
""" | ||
TrustRegion(; | ||
concrete_jac = nothing, linsolve = nothing, precs = nothing, | ||
radius_update_scheme = RadiusUpdateSchemes.Simple, max_trust_radius::Real = 0 // 1, | ||
initial_trust_radius::Real = 0 // 1, step_threshold::Real = 1 // 10000, | ||
shrink_threshold::Real = 1 // 4, expand_threshold::Real = 3 // 4, | ||
shrink_factor::Real = 1 // 4, expand_factor::Real = 2 // 1, | ||
max_shrink_times::Int = 32, | ||
vjp_autodiff = nothing, autodiff = nothing, jvp_autodiff = nothing | ||
) | ||
An advanced TrustRegion implementation with support for efficient handling of sparse | ||
matrices via colored automatic differentiation and preconditioned linear solvers. Designed | ||
for large-scale and numerically-difficult nonlinear systems. | ||
### Keyword Arguments | ||
- `radius_update_scheme`: the scheme used to update the trust region radius. Defaults to | ||
`RadiusUpdateSchemes.Simple`. See [`RadiusUpdateSchemes`](@ref) for more details. For a | ||
review on trust region radius update schemes, see [yuan2015recent](@citet). | ||
For the remaining arguments, see [`NonlinearSolve.GenericTrustRegionScheme`](@ref) | ||
documentation. | ||
""" | ||
function TrustRegion(; | ||
concrete_jac = nothing, linsolve = nothing, precs = nothing, | ||
radius_update_scheme = RadiusUpdateSchemes.Simple, max_trust_radius::Real = 0 // 1, | ||
initial_trust_radius::Real = 0 // 1, step_threshold::Real = 1 // 10000, | ||
shrink_threshold::Real = 1 // 4, expand_threshold::Real = 3 // 4, | ||
shrink_factor::Real = 1 // 4, expand_factor::Real = 2 // 1, | ||
max_shrink_times::Int = 32, | ||
autodiff = nothing, vjp_autodiff = nothing, jvp_autodiff = nothing | ||
) | ||
descent = Dogleg(; linsolve, precs) | ||
trustregion = GenericTrustRegionScheme(; | ||
method = radius_update_scheme, step_threshold, shrink_threshold, expand_threshold, | ||
shrink_factor, expand_factor, initial_trust_radius, max_trust_radius) | ||
return GeneralizedFirstOrderAlgorithm{concrete_jac, :TrustRegion}(; | ||
trustregion, descent, autodiff, vjp_autodiff, jvp_autodiff, max_shrink_times) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters