Skip to content

Commit 59d915e

Browse files
committed
Sync tests and current code state.
1 parent f50a3ee commit 59d915e

15 files changed

Lines changed: 46 additions & 39 deletions

src/plans/stopping_criterion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ function status_summary(c::StopWhenStepsizeLess; context = :default)
825825
(context == :short) && return repr(c)
826826
has_stopped = (c.at_iteration >= 0)
827827
s = has_stopped ? "reached" : "not reached"
828-
return (_is_inline(context) ? "stepsize s < $(c.threshold):$(_MANOPT_INDENT)" : "A stopping criterion to stop when the step size is less than $(c.threshold)\n$(_MANOPT_INDENT)") * "$s"
828+
return (_is_inline(context) ? "Stepsize s < $(c.threshold):$(_MANOPT_INDENT)" : "A stopping criterion to stop when the step size is less than $(c.threshold)\n$(_MANOPT_INDENT)") * "$s"
829829
end
830830
function Base.show(io::IO, c::StopWhenStepsizeLess)
831831
return print(io, "StopWhenStepsizeLess($(c.threshold))")

src/solvers/Lanczos.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ function set_parameter!(ls::LanczosState, ::Val{:σ}, σ)
8383
ls.σ = σ
8484
return ls
8585
end
86-
87-
function show(io::IO, ls::LanczosState)
86+
function status_summary(ls::LanczosState; context = default)
87+
_is_inline(context) && return repr(ls)
8888
i = get_count(ls, :Iterations)
8989
Iter = (i > 0) ? "After $i iterations\n" : ""
9090
Conv = indicates_convergence(ls.stop) ? "Yes" : "No"
9191
vectors = length(ls.Lanczos_vectors)
92-
s = """
92+
return """
9393
# Solver state for `Manopt.jl`s Lanczos Iteration
9494
$Iter
9595
## Parameters
@@ -102,7 +102,6 @@ function show(io::IO, ls::LanczosState)
102102
(b) For the Newton sub solver
103103
$(status_summary(ls.stop_newton))
104104
This indicates convergence: $Conv"""
105-
return print(io, s)
106105
end
107106

108107
#

src/solvers/NelderMead.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,10 @@ function get_reason(c::StopWhenPopulationConcentrated)
421421
return ""
422422
end
423423
function status_summary(c::StopWhenPopulationConcentrated; context = :default)
424+
(context === :short) && (return repr(c))
424425
has_stopped = (c.at_iteration >= 0)
425426
s = has_stopped ? "reached" : "not reached"
426-
head = (!inline ? "Stop when the population of a swarm is concentrated in eher function values (tolerance: $(c.tol_f)) or points (tolerance: $(c.tol_p))\n$(_MANOPT_INDENT)" : "")
427+
head = (!_is_inline(context) ? "Stop when the population of a swarm is concentrated in eher function values (tolerance: $(c.tol_f)) or points (tolerance: $(c.tol_p))\n$(_MANOPT_INDENT)" : "")
427428
return head * "Population concentration: in f < $(c.tol_f) and in p < $(c.tol_p):$(_MANOPT_INDENT)$s"
428429
end
429430
function show(io::IO, c::StopWhenPopulationConcentrated)

src/solvers/cma_es.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,8 @@ function (c::StopWhenPopulationStronglyConcentrated)(
789789
end
790790
return false
791791
end
792-
function status_summary(c::StopWhenPopulationStronglyConcentrated)
792+
function status_summary(c::StopWhenPopulationStronglyConcentrated; context = :default)
793+
context === :short && return repr(c)
793794
has_stopped = is_active_stopping_criterion(c)
794795
s = has_stopped ? "reached" : "not reached"
795796
return "norm(s.deviations, Inf) < $(c.tol) && norm(s.σ * s.p_c, Inf) < $(c.tol) :$(_MANOPT_INDENT)$s"
@@ -801,9 +802,7 @@ function get_reason(c::StopWhenPopulationStronglyConcentrated)
801802
return ""
802803
end
803804
function show(io::IO, c::StopWhenPopulationStronglyConcentrated)
804-
return print(
805-
io, "StopWhenPopulationStronglyConcentrated($(c.tol))\n $(status_summary(c))"
806-
)
805+
return print(io, "StopWhenPopulationStronglyConcentrated($(c.tol))")
807806
end
808807

809808
"""
@@ -838,7 +837,8 @@ function (c::StopWhenPopulationDiverges)(::AbstractManoptProblem, s::CMAESState,
838837
end
839838
return false
840839
end
841-
function status_summary(c::StopWhenPopulationDiverges)
840+
function status_summary(c::StopWhenPopulationDiverges; context = :default)
841+
context === :short && return repr(c)
842842
has_stopped = is_active_stopping_criterion(c)
843843
s = has_stopped ? "reached" : "not reached"
844844
return "cur_σ_times_maxstddev / c.last_σ_times_maxstddev > $(c.tol) :$(_MANOPT_INDENT)$s"
@@ -850,7 +850,7 @@ function get_reason(c::StopWhenPopulationDiverges)
850850
return ""
851851
end
852852
function show(io::IO, c::StopWhenPopulationDiverges)
853-
return print(io, "StopWhenPopulationDiverges($(c.tol))\n $(status_summary(c))")
853+
return print(io, "StopWhenPopulationDiverges($(c.tol))")
854854
end
855855

856856
"""
@@ -898,7 +898,8 @@ function (c::StopWhenPopulationCostConcentrated)(
898898
end
899899
return false
900900
end
901-
function status_summary(c::StopWhenPopulationCostConcentrated)
901+
function status_summary(c::StopWhenPopulationCostConcentrated; context = :default)
902+
context === :short && return repr(c)
902903
has_stopped = is_active_stopping_criterion(c)
903904
s = has_stopped ? "reached" : "not reached"
904905
return "range of best objective values in the last $(length(c.best_value_history)) generations and all objective values in the current one < $(c.tol) :$(_MANOPT_INDENT)$s"
@@ -911,6 +912,6 @@ function get_reason(c::StopWhenPopulationCostConcentrated)
911912
end
912913
function show(io::IO, c::StopWhenPopulationCostConcentrated)
913914
return print(
914-
io, "StopWhenPopulationCostConcentrated($(c.tol))\n $(status_summary(c))"
915+
io, "StopWhenPopulationCostConcentrated($(c.tol))"
915916
)
916917
end

src/solvers/conjugate_gradient_descent.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function default_stepsize(
88
M; retraction_method = retraction_method, initial_stepsize = 1.0
99
)
1010
end
11-
function status_summary(cgds::ConjugateGradientDescentState)
11+
function status_summary(cgds::ConjugateGradientDescentState; context = :default)
12+
_is_inline(context) && repr(cgds)
1213
i = get_count(cgds, :Iterations)
1314
Iter = (i > 0) ? "After $i iterations\n" : ""
1415
Conv = indicates_convergence(cgds.stop) ? "Yes" : "No"

src/solvers/particle_swarm.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,11 @@ function get_reason(c::StopWhenSwarmVelocityLess)
408408
end
409409
return ""
410410
end
411-
function status_summary(c::StopWhenSwarmVelocityLess)
411+
function status_summary(c::StopWhenSwarmVelocityLess; context = :default)
412412
has_stopped = (c.at_iteration >= 0) && (norm(c.velocity_norms) < c.threshold)
413413
s = has_stopped ? "reached" : "not reached"
414414
return "swarm velocity norm < $(c.threshold):$(_MANOPT_INDENT)$s"
415415
end
416416
function show(io::IO, c::StopWhenSwarmVelocityLess)
417-
return print(io, "StopWhenSwarmVelocityLess($(c.threshold))\n $(status_summary(c))")
417+
return print(io, "StopWhenSwarmVelocityLess($(c.threshold))")
418418
end

src/solvers/proximal_point.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function status_summary(pps::ProximalPointState; context = :default)
4848
i = get_count(pps, :Iterations)
4949
Iter = (i > 0) ? "After $i iterations\n" : ""
5050
Conv = indicates_convergence(pps.stop) ? "Yes" : "No"
51-
inline && (return "$(repr(pps))$(Iter) $(has_converged(pps) ? "(converged)" : "")")
51+
_is_inline(context) && (return "$(repr(pps))$(Iter) $(has_converged(pps) ? "(converged)" : "")")
5252
s = """
5353
# Solver state for `Manopt.jl`s Proximal Point Method
5454
$Iter

src/solvers/truncated_conjugate_gradient_descent.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ function get_reason(c::StopWhenResidualIsReducedByFactorOrPower)
191191
return ""
192192
end
193193
function status_summary(c::StopWhenResidualIsReducedByFactorOrPower; context = :default)
194+
context === :short && return repr(c)
194195
has_stopped = (c.at_iteration >= 0)
195196
s = has_stopped ? "reached" : "not reached"
196197
return (_is_inline(context) ? "Residual reduced by factor $(c.κ) or power $(c.θ):$(_MANOPT_INDENT)" : "A stopping criterion used within tCG to check whether the residual is reduced by factor $(c.κ) or power 1+$(c.θ)\n$(_MANOPT_INDENT)") * "$s"
@@ -275,13 +276,13 @@ function get_reason(c::StopWhenTrustRegionIsExceeded)
275276
return ""
276277
end
277278
function status_summary(c::StopWhenTrustRegionIsExceeded; context = :default)
278-
(context == :short) && return repr(sc)
279+
(context == :short) && return repr(c)
279280
has_stopped = (c.at_iteration >= 0)
280281
s = has_stopped ? "reached" : "not reached"
281282
return (_is_inline(context) ? "Trust region exceeded:$(_MANOPT_INDENT)" : "A stopping criterion to stop when the trust region radius ($(c.trr)) is exceeded.\n$(_MANOPT_INDENT)") * "$s"
282283
end
283284
function show(io::IO, c::StopWhenTrustRegionIsExceeded)
284-
return print(io, "StopWhenTrustRegionIsExceeded()\n $(status_summary(c))")
285+
return print(io, "StopWhenTrustRegionIsExceeded()")
285286
end
286287

287288
@doc """
@@ -333,12 +334,12 @@ function get_reason(c::StopWhenCurvatureIsNegative)
333334
return ""
334335
end
335336
function status_summary(c::StopWhenCurvatureIsNegative; context = :default)
336-
(context == :short) && return repr(sc)
337+
(context == :short) && return repr(c)
337338
has_stopped = (c.at_iteration >= 0)
338339
s = has_stopped ? "reached" : "not reached"
339340
return (_is_inline(context) ? "Curvature is negative:$(_MANOPT_INDENT)" : "A stopping criterion to stop when the is negative\n$(_MANOPT_INDENT)") * "$s"
340341
end
341-
function show(io::IO, c::StopWhenCurvatureIsNegative)
342+
function show(io::IO, ::StopWhenCurvatureIsNegative)
342343
return print(io, "StopWhenCurvatureIsNegative()")
343344
end
344345

@@ -389,13 +390,14 @@ function get_reason(c::StopWhenModelIncreased)
389390
end
390391
return ""
391392
end
392-
function status_summary(c::StopWhenModelIncreased)
393+
function status_summary(c::StopWhenModelIncreased; context = :default)
394+
context === :short && return repr(c)
393395
has_stopped = (c.at_iteration >= 0)
394396
s = has_stopped ? "reached" : "not reached"
395397
return "Model Increased:$(_MANOPT_INDENT)$s"
396398
end
397-
function show(io::IO, c::StopWhenModelIncreased)
398-
return print(io, "StopWhenModelIncreased()\n $(status_summary(c))")
399+
function show(io::IO, ::StopWhenModelIncreased)
400+
return print(io, "StopWhenModelIncreased()")
399401
end
400402

401403
_doc_TCG_subproblem = raw"""

test/plans/test_debug.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ Manopt.get_parameter(d::TestDebugParameterState, ::Val{:value}) = d.value
404404

405405
@test repr(DebugGradient()) == "DebugGradient(; format=\"grad f(p):%s\", at_init=false)"
406406
dg_s = "(:Gradient, \"grad f(p):%s\")"
407-
@test Manopt.status_summary(DebugGradient()) == dg_s
407+
@test Manopt.status_summary(DebugGradient(); context = :short) == dg_s
408408
end
409409
@testset "Debug Messages" begin
410410
s = TestMessageState()

test/plans/test_record.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Manopt.get_parameter(d::TestRecordParameterState, ::Val{:value}) = d.value
188188
@testset "RecordStoppingReason" begin
189189
g = RecordStoppingReason()
190190
@test repr(g) == "RecordStoppingReason()"
191-
@test Manopt.status_summary(g) == ":Stop"
191+
@test Manopt.status_summary(g; context = :short) == ":Stop"
192192
@test length(get_record(g)) == 0
193193
stop_solver!(dmp, gds, 21) # trigger stop
194194
g(dmp, gds, 21) # record

0 commit comments

Comments
 (0)