-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathincrease_decrease.jl
More file actions
66 lines (51 loc) · 1.66 KB
/
increase_decrease.jl
File metadata and controls
66 lines (51 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
decrease(X::TPData, α::T, TR::ARTrustRegion)
Return a decreased `α`.
"""
function decrease(X::TPData, α::T, TR::ARTrustRegion) where {T}
return α * TR.decrease_factor
end
"""
increase(X::TPData, α::T, TR::ARTrustRegion)
Return an increased `α`.
"""
function increase(::TPData, α::T, TR::ARTrustRegion) where {T}
return min(α * TR.increase_factor, TR.max_α)
end
# X.indmin is between 1 and nshifts
function decrease(X::PDataKARC, α::T, TR::ARTrustRegion) where {T}
X.indmin += 1 # the step wasn't successful so we need to change something
α2 = max(X.norm_dirs[X.indmin] / X.shifts[X.indmin], eps(T))
targetα = α * TR.decrease_factor
# fix α to its "ideal" value to satisfy αλ=||d||
# while ensuring α decreases enough
last = findlast(X.positives)
while !isnothing(last) && α2 > targetα && X.indmin < last
X.indmin += 1
α2 = max(X.norm_dirs[X.indmin] / X.shifts[X.indmin], eps(T))
end
if (isnothing(X.indmin) | isnothing(last) | X.indmin == last) & (α2 > targetα)
@warn "PreProcessKARC failure: α2=$α2"
end
X.d .= X.xShift[X.indmin]
X.λ = X.shifts[X.indmin]
return α2
end
function decrease(X::PDataTRK, α::T, TR::ARTrustRegion) where {T}
X.indmin += 1
α2 = X.norm_dirs[X.indmin]
# fix α to its "ideal" value to satisfy α=||d||
# while ensuring α decreases enough
targetα = α * TR.decrease_factor
last = findlast(X.positives)
while !isnothing(last) && α2 > targetα && X.indmin < last
X.indmin += 1
α2 = X.norm_dirs[X.indmin]
end
if X.indmin == last
@warn "PreProcessTRK failure: α2=$α2"
end
X.d .= X.xShift[X.indmin]
X.λ = X.shifts[X.indmin]
return α2
end