From 050c3e3b084f9bef504f29323b474cb18bad08a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Nilsen=20Riseth?= Date: Sun, 5 Nov 2017 14:01:29 +0000 Subject: [PATCH 1/2] Use NaNMath --- REQUIRE | 1 + src/backtracking.jl | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/REQUIRE b/REQUIRE index 63a2917..849aa41 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,3 +1,4 @@ julia 0.6 NLSolversBase 3.0 Parameters +NaNMath diff --git a/src/backtracking.jl b/src/backtracking.jl index f4bb6c3..8ac02f9 100644 --- a/src/backtracking.jl +++ b/src/backtracking.jl @@ -73,7 +73,7 @@ function _backtracking!(df, # Shrink proposed step-size: if order == 2 || iteration == 1 - # backtracking via interpolation: + # backtracking via quadratic interpolation: # This interpolates the available data # f(0), f'(0), f(α) # with a quadractic which is then minimised; this comes with a @@ -82,6 +82,7 @@ function _backtracking!(df, # of the function guarantees at least a backtracking factor rho. alphatmp = - (gxp * alpha^2) / ( 2.0 * (f_x_scratch - f_x - gxp*alpha) ) else + # Backtracking via cubic interpolation alpha0 = lsr.alpha[end-1] alpha1 = lsr.alpha[end] phi0 = lsr.value[end-1] @@ -98,8 +99,8 @@ function _backtracking!(df, alphatmp = (-b + sqrt(discr)) / (3.0*a) end end - alphatmp = min(alphatmp, alpha*rhohi) # avoid too small reductions - alphatmp = max(alphatmp, alpha*rholo) # avoid too big reductions + alphatmp = NaNMath.min(alphatmp, alpha*rhohi) # avoid too small reductions + alphatmp = NaNMath.max(alphatmp, alpha*rholo) # avoid too big reductions # enforce a maximum step alpha * s (application specific, default is Inf) alpha = min(alphatmp, maxstep / vecnorm(s, Inf)) From ca9216070536bbf3d35eb2690659578534b5bdca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Nilsen=20Riseth?= Date: Sun, 5 Nov 2017 15:59:57 +0000 Subject: [PATCH 2/2] using NaNMath --- src/LineSearches.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LineSearches.jl b/src/LineSearches.jl index d8dd7c0..2bbed2b 100644 --- a/src/LineSearches.jl +++ b/src/LineSearches.jl @@ -2,7 +2,7 @@ isdefined(Base, :__precompile__) && __precompile__() module LineSearches -using Parameters +using Parameters, NaNMath import NLSolversBase import Base.clear!