@@ -32,17 +32,28 @@ function (ls::DeprecatedStatic)(df::AbstractObjective, x, s, α, x_new = similar
32
32
ls (ϕ, x, s, α)
33
33
end
34
34
35
- function (ls:: DeprecatedStatic )(ϕ, x, s, alpha)
36
- @unpack alpha , scaled = ls
37
- @assert alpha > zero ( typeof (alpha) ) # This should really be done at the constructor level
35
+ function (ls:: DeprecatedStatic )(ϕ, x, s, α :: T α) where Tα
36
+ @unpack α , scaled = ls
37
+ @assert α > Tα ( 0 ) # This should really be done at the constructor level
38
38
39
- if scaled == true && (ns = vecnorm (s)) > zero ( typeof (alpha) )
40
- alpha = min (alpha , ns) / ns
39
+ if scaled == true && (ns = vecnorm (s)) > Tα ( 0 )
40
+ α = min (α , ns) / ns
41
41
end
42
42
43
- ϕα = ϕ (alpha )
43
+ ϕα = ϕ (α )
44
44
45
- return alpha, ϕα
45
+ # Hard-coded backtrack until we find a finite function value
46
+ iterfinite = 0
47
+ iterfinitemax = - log2 (eps (real (Tα)))
48
+ while ! isfinite (ϕα) && iterfinite < iterfinitemax
49
+ iterfinite += 1
50
+ αold = α
51
+ α = αold/ 2
52
+
53
+ ϕα = ϕ (α)
54
+ end
55
+
56
+ return α, ϕα
46
57
end
47
58
# #########################
48
59
# # DELETE UNTIL THIS LINE
55
66
"""
56
67
immutable NewStatic end
57
68
58
- function (ls:: NewStatic )(df:: AbstractObjective , x, s, α, x_new = similar (x), phi0 = nothing , dphi0 = nothing )
69
+ function (ls:: NewStatic )(df:: AbstractObjective , x, s, α, x_new = similar (x), ϕ_0 = nothing , dϕ_0 = nothing )
59
70
ϕ = make_ϕ (df, x_new, x, s)
60
71
ls (ϕ, x, s, α)
61
72
end
62
73
63
- function (ls:: NewStatic )(ϕ, x, s, alpha)
64
- ϕα = ϕ (alpha)
74
+ function (ls:: NewStatic )(ϕ, x, s, α:: T α) where Tα
75
+ @assert α > real (Tα (0 ))
76
+ ϕα = ϕ (α)
77
+
78
+ # Hard-coded backtrack until we find a finite function value
79
+ iterfinite = 0
80
+ iterfinitemax = - log2 (eps (real (Tα)))
81
+ while ! isfinite (ϕα) && iterfinite < iterfinitemax
82
+ iterfinite += 1
83
+ αold = α
84
+ α = αold/ 2
85
+
86
+ ϕα = ϕ (α)
87
+ end
65
88
66
- return alpha , ϕα
89
+ return α , ϕα
67
90
end
0 commit comments