Skip to content

Commit 3a2c48b

Browse files
committed
adapt one new StoppingCriterion to the new show/repr/status_summary style and fix one further bug.
1 parent 7bc7eb3 commit 3a2c48b

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/plans/stopping_criterion.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,14 +903,18 @@ function get_reason(c::StopWhenProjectedNegativeGradientNormLess)
903903
end
904904
return ""
905905
end
906-
function status_summary(c::StopWhenProjectedNegativeGradientNormLess)
906+
function status_summary(c::StopWhenProjectedNegativeGradientNormLess; context::Symbol = :default)
907+
(context === :short) && return repr(c)
907908
has_stopped = (c.at_iteration >= 0)
908909
s = has_stopped ? "reached" : "not reached"
909-
return "|proj (-grad f)| < $(c.threshold): $s"
910+
(context === :inline) && return "|proj (-grad f)| < $(c.threshold): $s"
911+
return "A StoppingCriterion to stop when the negative projected gradient norm is less than a threshold of $(c.threshold):\n$(_MANOPT_INDENT)$s"
910912
end
911913
indicates_convergence(c::StopWhenProjectedNegativeGradientNormLess) = true
912914
function show(io::IO, c::StopWhenProjectedNegativeGradientNormLess)
913-
return print(io, "StopWhenProjectedNegativeGradientNormLess($(c.threshold))\n $(status_summary(c))")
915+
print(io, "StopWhenProjectedNegativeGradientNormLess(", c.threshold, "; norm = ", c.norm)
916+
!ismissing(c.outer_norm) && print(io, ", outer_norm = ", c.outer_norm)
917+
return print(io, ")")
914918
end
915919

916920
"""

test/plans/test_stopping_criteria.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ end
424424

425425
@test startswith(
426426
to_display_string(sc),
427-
"StopWhenProjectedNegativeGradientNormLess(1.0e-10)\n",
427+
"A StoppingCriterion to stop when the negative projected gradient norm is less than",
428428
)
429-
@test startswith(Manopt.status_summary(sc), "|proj (-grad f)| < 1.0e-10")
429+
@test startswith(Manopt.status_summary(sc; context = :inline), "|proj (-grad f)| < 1.0e-10")
430430

431431
Manopt.set_parameter!(sc, Val(:MinGradNorm), 1.0e-5)
432432
@test sc.threshold == 1.0e-5

test/solvers/test_quasi_Newton.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ end
248248

249249
x = [0.7011245948687502, -0.1726003159556036, 0.38798265967671103, -0.5728026616491424]
250250
x_lrbfgs = quasi_Newton(
251-
M, F, grad_f, x; memory_size = -1,
251+
M, F, grad_f, x;
252252
basis = get_basis(M, x, DefaultOrthonormalBasis()),
253253
memory_size = -1,
254254
stopping_criterion = StopWhenGradientNormLess(1.0e-9) | StopAfterIteration(1000),

0 commit comments

Comments
 (0)