Skip to content
Merged
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
5 changes: 2 additions & 3 deletions src/hagerzhang.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,9 @@ function (ls::HagerZhang)(ϕ, ϕdϕ,
iter += 1
end

best_alpha = alphas[argmin(values)]
throw(LineSearchException("Linesearch failed to converge, reached maximum iterations $(linesearchmax).",
alphas[ia]))


best_alpha))
end

# Check Wolfe & approximate Wolfe
Expand Down
13 changes: 13 additions & 0 deletions test/captured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ end
α, val = hz(fdf.f, fdf.fdf, 1.0, fdf.fdf(0.0)...)
@test val <= minimum(tc)
end

@testset "PR#185" begin
ϕ(α) = 1/(α+1)
dϕ(α) = -1/(α+1)^2
ϕdϕ(α) = ϕ(α), dϕ(α)

α0 = 1.0
ϕ0 = ϕ(0.0)
dϕ0 = dϕ(0.0)

_error_msg = @test_throws LineSearchException (HagerZhang())(ϕ, dϕ, ϕdϕ, α0, ϕ0, dϕ0)
@test _error_msg.value.alpha > α0 # Should be something gigantic like 1e34
end
Loading