1- function step! end
2- @doc """
3- step !(p::Problem, a::Algorithm, s::State)
1+ _doc_init_state = """
2+ s = initialize_state(p::Problem, a::Algorithm; kwargs...)
3+ initialize_state !(p::Problem, a::Algorithm, s::State; kwargs... )
44
5- Perform the current step of an [`Algorithm`](@ref) `a` solving [`Problem`](@ref) `p`
6- starting from [`State`](@ref) `s`.
5+ Initialize a [`State`](@ref) `s` base on a [`Problem`](@ref) `p` and an [`Algorithm`](@ref).
6+ The `kwargs...` should allow to initialize for example the initial point.
7+ This can be done in-place of `s`, then only values that did change have to be provided.
78"""
8- step! (p:: Problem , a:: Algorithm , s:: State )
99
10+ function initialize_state end
11+
12+ @doc " $(_doc_init_state) "
13+ initialize_state (:: Problem , :: Algorithm ; kwargs... )
14+
15+ function initialize_state! end
16+
17+ @doc " $(_doc_init_state) "
18+ initialize_state! (:: State , :: Problem , :: Algorithm ; kwargs... )
19+
20+ @doc """
21+ is_finished(p::Problem, a::Algorithm, s::State)
22+ """
23+ function is_finished (p:: Problem , a:: Algorithm , s:: State )
24+ sc = get_stopping_criterion (s)
25+ return sc (p, a, s)
26+ end
27+
28+ # has to be defined before used in solve but is documented alphabetically after
1029
1130@doc """
1231 solve(p::Problem, a::Algorithm; kwargs...)
@@ -19,14 +38,31 @@ returns a state.
1938By default this method continues to call [`solve!`](@ref).
2039"""
2140function solve (p:: Problem , a:: Algorithm ; kwargs... )
22- s = initialize_state (p, a)
23- return solve! (p, a, s)
41+ s = initialize_state (p, a; kwargs ... )
42+ return solve! (p, a, s; kwargs ... )
2443end
2544
2645@doc """
27- solve!(p::Problem, a::Algorithm, s::State)
46+ solve!(p::Problem, a::Algorithm, s::State; kwargs... )
2847
2948Solve the [`Problem`](@ref) `p` using the [`Algorithm`](@ref) `a`
3049working on the [`State`](@ref).
50+
51+ All keyword arguments are passed to the [`initialize_state!`](@ref) function.
52+ """
53+ function solve! (p:: Problem , a:: Algorithm , s:: State ; kwargs... )
54+ initialize_state! (p, a, s; kwargs... )
55+ while ! is_finished (p, a, s)
56+ increment! (s)
57+ step! (p, a, s)
58+ end
59+ end
60+
61+ function step! end
62+ @doc """
63+ step!(p::Problem, a::Algorithm, s::State)
64+
65+ Perform the current step of an [`Algorithm`](@ref) `a` solving [`Problem`](@ref) `p`
66+ starting from [`State`](@ref) `s`.
3167"""
32- solve ! (p:: Problem , a:: Algorithm , s:: State )
68+ step ! (p:: Problem , a:: Algorithm , s:: State )
0 commit comments