Skip to content

Commit

Permalink
Soft bounds on x_abschange (#503)
Browse files Browse the repository at this point in the history
* Soft bounds on x_abschange

* Use right type in checked_dphi0
  • Loading branch information
anriseth authored and pkofod committed Jan 3, 2018
1 parent 5099dd4 commit 9b75e90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utilities/assess_convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end
function default_convergence_assessment(state::AbstractOptimizerState, d, options)
x_converged, f_converged, f_increased, g_converged = false, false, false, false

if x_abschange(state.x, state.x_previous) < options.x_tol
if x_abschange(state.x, state.x_previous) options.x_tol
x_converged = true
end

Expand Down
4 changes: 2 additions & 2 deletions src/utilities/perform_linesearch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ checked_dphi0!(state, d, method) = vecdot(gradient(d), state.s)
function checked_dphi0!(state, d, method::M) where M<:Union{BFGS, LBFGS}
# If invH is not positive definite, reset it
dphi0 = vecdot(gradient(d), state.s)
if dphi0 >= 0.0
if dphi0 >= zero(dphi0)
# "reset" Hessian approximation
if M <: BFGS
copy!(state.invH, method.initial_invH(state.x))
Expand All @@ -19,7 +19,7 @@ end
function checked_dphi0!(state, d, method::ConjugateGradient)
# Reset the search direction if it becomes corrupted
dphi0 = vecdot(gradient(d), state.s)
if dphi0 >= 0
if dphi0 >= zero(dphi0)
state.s .= .-state.pg
dphi0 = vecdot(gradient(d), state.s)
end
Expand Down

0 comments on commit 9b75e90

Please sign in to comment.