Skip to content

Commit 4b0c1a3

Browse files
committed
Merge remote-tracking branch 'origin/kellertuer/refactor-initial-guess' into kellertuer/refactor-initial-guess
2 parents 2f4c27f + ce7fa88 commit 4b0c1a3

2 files changed

Lines changed: 38 additions & 24 deletions

File tree

src/plans/stepsize/initial_guess.jl

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
1+
"""
2+
AbstractInitialLinesearchGuess
3+
4+
An abstract type for initial line search guess strategies. These are functors that map
5+
`(problem, state, k, last_stepsize, η) -> α_0`, where `α_0` is the initial step size,
6+
based on
7+
8+
* an [`AbstractManoptProblem`](@ref) `problem`
9+
* an [`AbstractManoptSolverState`](@ref) `state`
10+
* the current iterate `k`
11+
* the last step size `last_stepsize`
12+
* the search direction `η`
13+
"""
114
abstract type AbstractInitialLinesearchGuess end
215

16+
"""
17+
ConstantInitialGuess{TF} <: AbstractInitialLinesearchGuess
18+
19+
Implement a constant initial guess for line searches.
20+
21+
# Constructor
22+
23+
ConstantInitialGuess(α::TF)
24+
25+
where `α` is the constant initial step size.
26+
"""
327
struct ConstantInitialGuess{TF} <: AbstractInitialLinesearchGuess
428
α::TF
529
end
630
ConstantInitialGuess() = ConstantInitialGuess(1.0)
731

832
function (cig::ConstantInitialGuess)(
9-
mp::AbstractManoptProblem, s::AbstractManoptSolverState, ::Int, l::Real, η; kwargs...
33+
::AbstractManoptProblem, ::AbstractManoptSolverState, ::Int, ::Real, η; kwargs...
1034
)
1135
return cig.α
1236
end
1337

14-
15-
struct ArmijoInitialGuess <: AbstractInitialLinesearchGuess end
16-
1738
"""
18-
(::ArmijoInitialGuess)(mp::AbstractManoptProblem, s::AbstractManoptSolverState, k, l, η; kwargs...)
39+
ArmijoInitialGuess <: AbstractInitialLinesearchGuess
1940
20-
# Input
41+
Implement the initial guess for an Armijo line search.
2142
22-
* `mp`: the [`AbstractManoptProblem`](@ref) we are aiming to minimize
23-
* `s`: the [`AbstractManoptSolverState`](@ref) for the current solver
24-
* `k`: the current iteration
25-
* `l`: the last step size computed in the previous iteration.
26-
* `η`: the search direction
43+
The initial step size is chosen as `min(l, max_stepsize(M, p) / norm(M, p, η))`,
44+
where `l` is the last step size used, `p` the current point and `η` the search direction.
2745
28-
Return an initial guess for the [`ArmijoLinesearchStepsize`](@ref).
46+
The default provided is based on the [`max_stepsize`](@ref)`(M)`.
2947
30-
The default provided is based on the [`max_stepsize`](@ref)`(M)`, which we denote by ``m``.
31-
Let further ``X`` be the current descent direction with norm ``n=$(_tex(:norm, "X"; index = "p"))`` its length.
32-
Then this (default) initial guess returns
48+
# Constructor
3349
34-
* ``l`` if ``m`` is not finite
35-
* ``$(_tex(:min))(l, $(_tex(:frac, "m", "n")))`` otherwise
36-
37-
This ensures that the initial guess does not yield to large (initial) steps.
50+
ArmijoInitialGuess()
3851
"""
52+
struct ArmijoInitialGuess <: AbstractInitialLinesearchGuess end
53+
3954
function (::ArmijoInitialGuess)(
4055
mp::AbstractManoptProblem, s::AbstractManoptSolverState, ::Int, l::Real, η; kwargs...
4156
)
@@ -58,7 +73,6 @@ _doc_stepsize_initial_guess(default = "") = """
5873
and should at least accept the keywords
5974
* `lf0 = `[`get_cost`](@ref)`(problem, get_iterate(state))` the current cost at ^p` here interpreted as the initial point of `f` along the line search direction`
6075
* `Dlf0 = `[`get_differential`](@ref)`(problem, get_iterate(state), η)` the directional derivative at point `p` in direction `η`
61-
6276
"""
6377

6478
"""

src/plans/stepsize/stepsize.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ with the fields keyword arguments and the retraction is set to the default retra
4141
$(_var(:Keyword, :retraction_method))
4242
* `contraction_factor=0.95`
4343
* `sufficient_decrease=0.1`
44-
* `initial_stepsize = 1.0` the first step size to plug into the `initial_guess` function.
45-
* `initial_guess=`[`ArmijoInitialGuess`](@ref)
44+
* `last_stepsize=initialstepsize`
45+
* `initial_guess=`[`armijo_initial_guess`](@ref)
4646
* `stop_when_stepsize_less=0.0`: stop when the stepsize decreased below this version.
4747
* `stop_when_stepsize_exceeds=[`max_step`](@ref)`(M)`: provide an absolute maximal step size.
4848
* `stop_increasing_at_step=100`: for the initial increase test, stop after these many steps
4949
* `stop_decreasing_at_step=1000`: in the backtrack, stop after these many steps
5050
"""
51-
mutable struct ArmijoLinesearchStepsize{TRM <: AbstractRetractionMethod, P, I, F <: Real, IGF <: AbstractInitialLinesearchGuess, DF, IF, MSGS} <:
51+
mutable struct ArmijoLinesearchStepsize{TRM <: AbstractRetractionMethod, P, I, F <: Real, IGF, DF, IF, MSGS} <:
5252
Linesearch
5353
candidate_point::P
5454
contraction_factor::F
@@ -71,7 +71,7 @@ mutable struct ArmijoLinesearchStepsize{TRM <: AbstractRetractionMethod, P, I, F
7171
candidate_point::P = allocate_result(M, rand),
7272
contraction_factor::F = 0.95,
7373
initial_stepsize::F = 1.0,
74-
initial_guess::IGF = ArmijoInitialGuess(),
74+
initial_guess::IGF = armijo_initial_guess,
7575
retraction_method::TRM = default_retraction_method(M),
7676
stop_when_stepsize_less::F = 0.0,
7777
stop_when_stepsize_exceeds::Real = max_stepsize(M),

0 commit comments

Comments
 (0)