-
Notifications
You must be signed in to change notification settings - Fork 34
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 test cases, disable flatness check in HZ #180
base: master
Are you sure you want to change the base?
Conversation
The flatness check in HagerZhang was intended to prevent excessive iteration in cases where the objective function is flat to within numerical precision. This test is a poor attempt at capturing the issue. HZ takes more iterations than any other linesearch algorithm, but it's still a far cry from real-world cases I've seen where the linesearch exits from the iteration limit.
Aha, it looks like CI caught a case where the new flatness test (without the flatness check) spent 32 iterations in a flat basin. That's a little closer to the behavior I've seen. I'll leave this open and wait for some feedback. |
Oh interesting, it's also the diff --git a/test/issues.jl b/test/issues.jl
index 7b40677..b37a851 100644
--- a/test/issues.jl
+++ b/test/issues.jl
@@ -57,14 +57,15 @@ end
BackTracking(; cache=cache), BackTracking(; order=2, cache=cache) )
n = 0
- while n < 10
+ while n < 1000
ϕ, dϕ, ϕdϕ = makeϕdϕ(randn(2))
ϕ0, dϕ0 = ϕdϕ(0)
dϕ0 < -eps(abs(ϕ0)) || continue # any "slope" is just roundoff error, but we want roundoff that looks like descent
n += 1
for ls in lsalgs
res = ls(ϕ, dϕ, ϕdϕ, 1.0, ϕ(0.0), dϕ(0.0))
- @test length(cache.alphas) < 10 # really should be < 5
+ length(cache.alphas) >= 10 && println(typeof(ls), ": ", length(cache.alphas))
+ # @test length(cache.alphas) < 10 # really should be < 5
end
end
end I get the following printout:
|
In trying this locally, I got this many passes (out of 1000 attempts):
|
OK, this was more successful in capturing the purpose of the flatness check than I initially thought. Maybe best to wait to merge this for an actual fix. |
This follows the notation in the paper and is much more readable. It also introduces an external parameter, `epsilonk`, that "solves" the flatness problem (though it requires external specification).
Are there any ideas from here that @avikpal should consider for the newer LineSearch.jl? |
What's the status of this PR? I ran into #157 and it seems that issue would be fixed by the rewrite in this PR. |
This may cause problems of its own, but for the time being it's better
than the status quo.
Fixes #173
Closes #174
Fixes #175
I am pretty sure that without the flatness check, I've seen HZ iterate until the
linesearchmax
limit is hit, which is rather inefficient. This comes nowhere close to hitting that limit, though. So until we have a better test case we should probably disable the flatness check.Note: this PR should probably not be squash-merged, the three commits are crafted to be independent.