-
Notifications
You must be signed in to change notification settings - Fork 0
/
monotonous_step.jl
42 lines (38 loc) · 966 Bytes
/
monotonous_step.jl
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
using FrankWolfe
"""
MonotonousStepSize{F}
Represents a monotonous open-loop step size.
Contains a halving factor increased at each iteration until there is primal progress
`gamma = 2 / (t + 2) * 2^(-N)`
"""
mutable struct MonotonousStepSize{F} <: FrankWolfe.LineSearchMethod
domain_oracle::F
factor::Int
end
MonotonousStepSize(f::F) where {F <: Function} = MonotonousStepSize{F}(f, 0)
MonotonousStepSize() = MonotonousStepSize(x -> true)
function FrankWolfe.line_search_wrapper(
line_search::MonotonousStepSize,
t,
f,
grad!,
x,
d,
gradient,
dual_gap,
L,
gamma0,
linesearch_tol,
step_lim,
gamma_max,
)
gamma = 2.0^(1-line_search.factor) / (2 + t)
xnew = x - gamma * d
f0 = f(x)
while !line_search.domain_oracle(xnew) || f(xnew) > f0
line_search.factor += 1
gamma = 2.0^(1-line_search.factor) / (2 + t)
@. xnew = x - gamma * d
end
return gamma, L
end