Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add TerminationCondition support to NewtonRaphson #162

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/solvers/NonlinearSystemSolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ is small, or the eigenvalues of the Jacobian are within a few orders of magnitud
then `NLSolveJL`'s `:anderson` can be a good choice.

!!! note

`TrustRegion` and `SimpleTrustRegion` are still in development.

## Full List of Methods

!!! note

For the full details on the capabilities and constructors of the different solvers,
see the Detailed Solver APIs section!

Expand Down Expand Up @@ -60,7 +60,7 @@ methods excel at small problems and problems defined with static arrays.
large-scale nonlinear systems of equations.

!!! note

When used with certain types for the states `u` such as a `Number` or `StaticArray`,
these solvers are very efficient and non-allocating. These implementations are thus
well-suited for small systems of equations.
Expand Down
31 changes: 17 additions & 14 deletions src/NonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,27 @@ include("ad.jl")

import PrecompileTools

PrecompileTools.@compile_workload begin for T in (Float32, Float64)
prob = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2))
PrecompileTools.@compile_workload begin
for T in (Float32, Float64)
prob = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2))

precompile_algs = if VERSION >= v"1.7"
(NewtonRaphson(), TrustRegion(), LevenbergMarquardt())
else
(NewtonRaphson(),)
end
precompile_algs = if VERSION >= v"1.7"
(NewtonRaphson(), TrustRegion(), LevenbergMarquardt())
else
(NewtonRaphson(),)
end

for alg in precompile_algs
solve(prob, alg, abstol = T(1e-2))
end
for alg in precompile_algs
solve(prob, alg, abstol = T(1e-2))
end

prob = NonlinearProblem{true}((du, u, p) -> du[1] = u[1] * u[1] - p[1], T[0.1], T[2])
for alg in precompile_algs
solve(prob, alg, abstol = T(1e-2))
prob = NonlinearProblem{true}((du, u, p) -> du[1] = u[1] * u[1] - p[1], T[0.1],
T[2])
for alg in precompile_algs
solve(prob, alg, abstol = T(1e-2))
end
end
end end
end

export RadiusUpdateSchemes

Expand Down
2 changes: 0 additions & 2 deletions src/jacobian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,3 @@ function jacobian_autodiff(f, x::AbstractArray, nonlinfun, alg)
jac_prototype = jac_prototype, chunksize = chunk_size),
num_of_chunks)
end


1 change: 1 addition & 0 deletions src/raphson.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ mutable struct NewtonRaphsonCache{iip, fType, algType, uType, duType, resType, p
jac_config::JC, iter::Int,
force_stop::Bool, maxiters::Int, internalnorm::INType,
retcode::SciMLBase.ReturnCode.T, abstol::tolType,
reltol::tolType, termination_condition::TC,
prob::probType) where {
iip, fType, algType, uType,
duType, resType, pType, INType,
Expand Down
Loading