Skip to content

Commit 8974bca

Browse files
committed
Finish two further small states.
1 parent 491e7e6 commit 8974bca

3 files changed

Lines changed: 14 additions & 33 deletions

File tree

src/helpers/test.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ mutable struct DummyState <: AbstractManoptSolverState
5454
end
5555
DummyState() = DummyState([])
5656
Manopt.status_summary(ds::DummyState; context = :Default) = "A Manopt Test state with storage $(ds.storage)"
57+
Base.show(io::IO, ds::DummyState) = print(io, "Manopt.Test.DummyState($(ds.storage))")
5758
Manopt.get_iterate(::DummyState) = NaN
5859
Manopt.set_parameter!(s::DummyState, ::Val, v) = s
5960
Manopt.set_parameter!(s::DummyState, ::Val{:StoppingCriterion}, v) = s

src/plans/proximal_gradient_plan.jl

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -290,24 +290,16 @@ $(_kwargs(:sub_state; default = _glossary[:Variable][:evaluation][:default]))
290290
$(_kwargs(:X; add_properties = [:as_Memory]))
291291
"""
292292
mutable struct ProximalGradientMethodState{
293-
P,
294-
T,
295-
Pr <: Union{<:AbstractManoptProblem, F, Nothing} where {F},
296-
St <: Union{<:AbstractManoptSolverState, Nothing},
297-
A,
298-
S <: StoppingCriterion,
299-
TStepsize <: Stepsize,
300-
RM <: AbstractRetractionMethod,
301-
IRM <: AbstractInverseRetractionMethod,
302-
R,
293+
P, T, Pr <: Union{<:AbstractManoptProblem, F, Nothing} where {F}, St <: Union{<:AbstractManoptSolverState, Nothing},
294+
A, SC <: StoppingCriterion, S <: Stepsize, RM <: AbstractRetractionMethod, IRM <: AbstractInverseRetractionMethod, R,
303295
} <: AbstractManoptSolverState
304296
a::P
305297
acceleration::A
306-
stepsize::TStepsize
298+
stepsize::S
307299
last_stepsize::R
308300
p::P
309301
q::P
310-
stop::S
302+
stop::SC
311303
X::T
312304
retraction_method::RM
313305
inverse_retraction_method::IRM
@@ -322,35 +314,22 @@ function ProximalGradientMethodState(
322314
copyto!(get_manifold(pr), st.a, st.p)
323315
return st
324316
end,
325-
stepsize::TS = default_stepsize(M, ProximalGradientMethodState),
326-
stopping_criterion::S = StopWhenGradientMappingNormLess(1.0e-2) |
327-
StopAfterIteration(5000) |
328-
StopWhenChangeLess(M, 1.0e-9),
317+
stepsize::S = default_stepsize(M, ProximalGradientMethodState),
318+
stopping_criterion::SC = StopWhenGradientMappingNormLess(1.0e-2) | StopAfterIteration(5000) | StopWhenChangeLess(M, 1.0e-9),
329319
X::T = zero_vector(M, p),
330320
retraction_method::RM = default_retraction_method(M, typeof(p)),
331321
inverse_retraction_method::IRM = default_inverse_retraction_method(M, typeof(p)),
332322
sub_problem::Pr = nothing,
333323
sub_state::St = nothing, #AllocatingEvaluation(),
334324
) where {
335-
P,
336-
T,
337-
S <: StoppingCriterion,
338-
A,
339-
Pr <: Union{<:AbstractManoptProblem, F, Nothing} where {F},
340-
St <: Union{<:AbstractManoptSolverState, <:AbstractEvaluationType, Nothing},
341-
RM <: AbstractRetractionMethod,
342-
IRM <: AbstractInverseRetractionMethod,
343-
TS <: Stepsize,
325+
P, T, SC <: StoppingCriterion, A,
326+
Pr <: Union{<:AbstractManoptProblem, F, Nothing} where {F}, St <: Union{<:AbstractManoptSolverState, <:AbstractEvaluationType, Nothing},
327+
RM <: AbstractRetractionMethod, IRM <: AbstractInverseRetractionMethod, S <: Stepsize,
344328
}
345-
_sub_state = if sub_state isa AbstractEvaluationType
346-
ClosedFormSubSolverState(; evaluation = sub_state)
347-
else
348-
sub_state
349-
end
350-
329+
_sub_state = maybe_wrap_evaluation_type(sub_state)
351330
last_stepsize = zero(number_eltype(p))
352331
return ProximalGradientMethodState{
353-
P, T, Pr, typeof(_sub_state), A, S, TS, RM, IRM, typeof(last_stepsize),
332+
P, T, Pr, typeof(_sub_state), A, SC, S, RM, IRM, typeof(last_stepsize),
354333
}(
355334
copy(M, p),
356335
acceleration,

src/plans/record.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ function RecordSolverState(s::S, symbol::Symbol) where {S <: AbstractManoptSolve
7575
return RecordSolverState{S}(s; RecordFactory(get_state(s), symbol)...)
7676
end
7777
function status_summary(rst::RecordSolverState; context::Symbol = :default)
78-
_is_inline(context) && (return "a RecordSolverState for $(status_summary(rst.state; context = context))")
78+
(context === :short) && return repr(rst)
79+
(context === :inline) && (return "a RecordSolverState for $(status_summary(rst.state; context = context))")
7980
if length(rst.recordDictionary) > 0
8081
return """
8182
$(status_summary(rst.state; context = context))

0 commit comments

Comments
 (0)