Skip to content

Commit dd3c40e

Browse files
committed
Reenable some of the 23 test problems tests
1 parent 3bf5853 commit dd3c40e

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

src/lbroyden.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ An implementation of `LimitedMemoryBroyden` with reseting and line search.
2525
end
2626

2727
function LimitedMemoryBroyden(; max_resets::Int = 3, linesearch = LineSearch(),
28-
threshold::Int = 10, reset_tolerance = nothing)
28+
threshold::Int = 27, reset_tolerance = nothing)
2929
linesearch = linesearch isa LineSearch ? linesearch : LineSearch(; method = linesearch)
3030
return LimitedMemoryBroyden(max_resets, threshold, linesearch, reset_tolerance)
3131
end
@@ -134,6 +134,7 @@ function perform_step!(cache::LimitedMemoryBroydenCache{true})
134134
cache.resets += 1
135135
cache.du .= cache.fu
136136
else
137+
cache.du .*= -1
137138
idx = min(cache.iterations_since_reset, size(cache.U, 1))
138139
U_part = selectdim(cache.U, 1, 1:idx)
139140
Vᵀ_part = selectdim(cache.Vᵀ, 2, 1:idx)
@@ -193,6 +194,7 @@ function perform_step!(cache::LimitedMemoryBroydenCache{false})
193194
cache.resets += 1
194195
cache.du = cache.fu
195196
else
197+
cache.du = -cache.du
196198
idx = min(cache.iterations_since_reset, size(cache.U, 1))
197199
U_part = selectdim(cache.U, 1, 1:idx)
198200
Vᵀ_part = selectdim(cache.Vᵀ, 2, 1:idx)

src/linesearch.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ function perform_linesearch!(cache::LineSearchesJLCache, u, du)
162162

163163
ϕ₀, dϕ₀ = ϕdϕ(zero(eltype(u)))
164164

165-
# This case is sometimes possible for large optimization problems
166-
dϕ₀ 0 && return cache.α
167-
168-
return first(cache.ls.method(ϕ, cache.(u, du), cache.ϕdϕ(u, du), cache.α, ϕ₀, dϕ₀))
165+
return first(cache.ls.method(ϕ, dϕ, ϕdϕ, cache.α, ϕ₀, dϕ₀))
169166
end
170167

171168
"""
@@ -252,11 +249,11 @@ function perform_linesearch!(cache::LiFukushimaLineSearchCache{iip}, u, du) wher
252249
λ₁, λ₂ = λ₂, β * λ₂
253250

254251
if iip
255-
cache.u_cache .= u .- λ₂ .* du
252+
cache.u_cache .= u .+ λ₂ .* du
256253
cache.f(cache.fu_cache, cache.u_cache, cache.p)
257254
fxλp_norm = norm(cache.fu_cache, 2)
258255
else
259-
fxλp_norm = norm(cache.f(u .- λ₂ .* du, cache.p), 2)
256+
fxλp_norm = norm(cache.f(u .+ λ₂ .* du, cache.p), 2)
260257
end
261258

262259
nan_converged = isfinite(fxλp_norm)

test/23_test_problems.jl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,32 +83,20 @@ end
8383

8484
# Broyden and Klement Tests are quite flaky and failure seems to be platform dependent
8585
# needs additional investigation before we can enable them
86-
#=
8786
@testset "GeneralBroyden 23 Test Problems" begin
88-
alg_ops = (GeneralBroyden(),
89-
GeneralBroyden(; linesearch = LiFukushimaLineSearch(; beta = 0.1)),
90-
GeneralBroyden(; linesearch = BackTracking()))
87+
alg_ops = (GeneralBroyden(),)
9188

9289
broken_tests = Dict(alg => Int[] for alg in alg_ops)
93-
broken_tests[alg_ops[1]] = [1, 3, 4, 5, 6, 11, 12, 13, 14, 21]
94-
broken_tests[alg_ops[2]] = [1, 2, 3, 4, 5, 6, 9, 11, 13, 22]
95-
broken_tests[alg_ops[3]] = [1, 2, 4, 5, 6, 11, 12, 13, 14, 21]
90+
broken_tests[alg_ops[1]] = [1, 2, 4, 5, 6, 11, 12, 13, 14]
9691

9792
test_on_library(problems, dicts, alg_ops, broken_tests)
9893
end
9994

10095
@testset "GeneralKlement 23 Test Problems" begin
101-
alg_ops = (GeneralKlement(),
102-
GeneralKlement(; linesearch = BackTracking()),
103-
GeneralKlement(; linesearch = HagerZhang()))
96+
alg_ops = (GeneralKlement(),)
10497

10598
broken_tests = Dict(alg => Int[] for alg in alg_ops)
10699
broken_tests[alg_ops[1]] = [1, 2, 4, 5, 6, 7, 11, 13, 22]
107-
broken_tests[alg_ops[2]] = [1, 2, 4, 5, 6, 7, 11, 12, 13, 22]
108-
broken_tests[alg_ops[3]] = [1, 2, 4, 5, 6, 8, 11, 12, 13, 22]
109100

110101
test_on_library(problems, dicts, alg_ops, broken_tests)
111102
end
112-
=#
113-
114-
# NOTE: Not adding LimitedMemoryBroyden here since it fails on most of the preoblems

0 commit comments

Comments
 (0)