Skip to content

Commit

Permalink
try fixing LM for banded jacobian
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Nov 2, 2023
1 parent b07360f commit 40a9ded
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolve"
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
authors = ["SciML"]
version = "2.6.0"
version = "2.6.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
12 changes: 6 additions & 6 deletions src/levenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function perform_step!(cache::LevenbergMarquardtCache{true, fastls}) where {fast
# Usual Levenberg-Marquardt step ("velocity").
# The following lines do: cache.v = -cache.mat_tmp \ cache.u_tmp
if fastls
cache.mat_tmp[1:length(fu1), :] .= cache.J
copyto!(@view(cache.mat_tmp[1:length(fu1), :]), cache.J)

Check warning on line 263 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L263

Added line #L263 was not covered by tests
cache.mat_tmp[(length(fu1) + 1):end, :] .= λ .* cache.DᵀD
cache.rhs_tmp[1:length(fu1)] .= _vec(fu1)
linres = dolinsolve(alg.precs, linsolve; A = cache.mat_tmp,
Expand Down Expand Up @@ -299,8 +299,8 @@ function perform_step!(cache::LevenbergMarquardtCache{true, fastls}) where {fast
cache.stats.nfactors += 2

# Require acceptable steps to satisfy the following condition.
norm_v = norm(v)
if 2 * norm(cache.a) α_geodesic * norm_v
norm_v = cache.internalnorm(v)
if 2 * cache.internalnorm(cache.a) α_geodesic * norm_v

Check warning on line 303 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L302-L303

Added lines #L302 - L303 were not covered by tests
_vec(cache.δ) .= _vec(v) .+ _vec(cache.a) ./ 2
@unpack δ, loss_old, norm_v_old, v_old, b_uphill = cache
f(cache.fu_tmp, u .+ δ, p)
Expand Down Expand Up @@ -356,7 +356,7 @@ function perform_step!(cache::LevenbergMarquardtCache{false, fastls}) where {fas

# Usual Levenberg-Marquardt step ("velocity").
if fastls
cache.mat_tmp = vcat(J, λ .* cache.DᵀD)
cache.mat_tmp = _vcat(J, λ .* cache.DᵀD)

Check warning on line 359 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L359

Added line #L359 was not covered by tests
cache.rhs_tmp[1:length(fu1)] .= -_vec(fu1)
linres = dolinsolve(alg.precs, linsolve; A = cache.mat_tmp,
b = cache.rhs_tmp, linu = _vec(cache.v), p = p, reltol = cache.abstol)
Expand Down Expand Up @@ -392,8 +392,8 @@ function perform_step!(cache::LevenbergMarquardtCache{false, fastls}) where {fas
cache.stats.nfactors += 1

# Require acceptable steps to satisfy the following condition.
norm_v = norm(v)
if 2 * norm(cache.a) α_geodesic * norm_v
norm_v = cache.internalnorm(v)
if 2 * cache.internalnorm(cache.a) α_geodesic * norm_v

Check warning on line 396 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L395-L396

Added lines #L395 - L396 were not covered by tests
cache.δ = _restructure(cache.δ, _vec(v) .+ _vec(cache.a) ./ 2)
@unpack δ, loss_old, norm_v_old, v_old, b_uphill = cache
fu_new = f(u .+ δ, p)
Expand Down

0 comments on commit 40a9ded

Please sign in to comment.