Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/backtracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ end
a = (a₁ - a₂) * div
b = (-α₁ * a₁ + α₂ * a₂) * div

return ifelse(iszero(a), dϕ₀ / 2b, (-b + sqrt(max(b^2 - 3a * dϕ₀, T(0)))) / 3a)
return ifelse(iszero(a), -dϕ₀ / 2b, (-b + sqrt(max(b^2 - 3a * dϕ₀, T(0)))) / 3a)
end

function SciMLBase.reinit!(
Expand Down
5 changes: 5 additions & 0 deletions test/root_finding_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ end
end
end

@testset "BackTracking cubic step on a quadratic merit" begin
# ϕ(α) = (1 - α)², sampled at α = 1 and 1/2: the cubic coefficient vanishes and the minimizer is α = 1.
@test LineSearch.compute_alpha_backtracking(Val(3), Float64, -2.0, 1.0, 0.0, 0.25, 1.0, 0.5) == 1.0
end

@testset "Static Strong Wolfe residual mode" begin
using CommonSolve: init, solve!
using SciMLBase: NonlinearProblem, ReturnCode
Expand Down