From 0cc84ab6f167f967808ec76f67c9c149ead2186c Mon Sep 17 00:00:00 2001 From: FHoltorf Date: Wed, 22 Nov 2023 11:51:38 -0500 Subject: [PATCH] compute Newton step as opposed to Gauss-Newton step when J is square and full rank --- lib/SimpleNonlinearSolve/src/trustRegion.jl | 2 +- lib/SimpleNonlinearSolve/src/utils.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/SimpleNonlinearSolve/src/trustRegion.jl b/lib/SimpleNonlinearSolve/src/trustRegion.jl index 72d8efa88..011ececd8 100644 --- a/lib/SimpleNonlinearSolve/src/trustRegion.jl +++ b/lib/SimpleNonlinearSolve/src/trustRegion.jl @@ -140,7 +140,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, for k in 1:maxiters # Solve the trust region subproblem. - δ = dogleg_method(H, g, Δ) + δ = dogleg_method(∇f, F, g, Δ) xₖ₊₁ = x + δ Fₖ₊₁ = f(xₖ₊₁) fₖ₊₁ = 0.5 * norm(Fₖ₊₁)^2 diff --git a/lib/SimpleNonlinearSolve/src/utils.jl b/lib/SimpleNonlinearSolve/src/utils.jl index 45df96410..af66f63f8 100644 --- a/lib/SimpleNonlinearSolve/src/utils.jl +++ b/lib/SimpleNonlinearSolve/src/utils.jl @@ -58,9 +58,9 @@ function init_J(x) return J end -function dogleg_method(H, g, Δ) +function dogleg_method(J, f, g, Δ) # Compute the Newton step. - δN = -H \ g + δN = J \ (-f) # Test if the full step is within the trust region. if norm(δN) ≤ Δ return δN