Skip to content

Commit

Permalink
Only return alpha in _hzI12 (#124)
Browse files Browse the repository at this point in the history
* Update mayterminate reference instead of returning the value

* Test infinite failure
  • Loading branch information
anriseth authored Jun 20, 2018
1 parent 0757cd2 commit 6d6339e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/initialguess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,16 @@ function _hzI12(alpha::T,

iterfinite = 1
while !isfinite(phitest)
alphatest = psi3 * alphatest
if iterfinite >= iterfinitemax
mayterminate[] = true
return T(0)
# TODO: Throw error / LineSearchException instead?
# error("Failed to achieve finite test value; alphatest = ", alphatest)
end

alphatest = psi3 * alphatest
phitest = ϕ(alphatest)

iterfinite += 1
if iterfinite >= iterfinitemax
return T(0), true
# error("Failed to achieve finite test value; alphatest = ", alphatest)
end
end
a = ((phitest-phi_0)/alphatest - dphi_0)/alphatest # quadratic fit

Expand Down
5 changes: 5 additions & 0 deletions test/initial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
is(ls, state, phi_0, dphi_0, df)
@test state.alpha == 0.4999999999999999
@test ls.mayterminate[] == true
dfinf = NLSolversBase.NonDifferentiable(x->Inf, x)
is = InitialHagerZhang(α0 = 1.0)
is(ls, state, phi_0, dphi_0, dfinf)
@test state.alpha == 0
@test ls.mayterminate[] == true

# Test Static unscaled
ls = HagerZhang()
Expand Down

0 comments on commit 6d6339e

Please sign in to comment.