From f19cc8a33c9fd8b07b1b3fd6a8f4995a23c209d4 Mon Sep 17 00:00:00 2001 From: Ronny Bergmann Date: Wed, 17 Jan 2024 18:48:36 +0100 Subject: [PATCH 1/5] Apply suggestions from code review Co-authored-by: Mateusz Baran --- src/plans/stopping_criterion.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plans/stopping_criterion.jl b/src/plans/stopping_criterion.jl index 60bf00341a..983b231228 100644 --- a/src/plans/stopping_criterion.jl +++ b/src/plans/stopping_criterion.jl @@ -506,7 +506,7 @@ A stopping criterion based on the current gradient norm. # Fields -* `norm` – a function `(M, p, X) -> R` that computes a norm of the gradient `X` in the tangent space at `p` on `M`` +* `norm` – a function `(M::AbstractManifold, p, X) -> ℝ` that computes a norm of the gradient `X` in the tangent space at `p` on `M`` * `threshold` – the threshold to indicate to stop when the distance is below this value # Internal fields @@ -529,7 +529,7 @@ mutable struct StopWhenGradientNormLess{F,TF} <: StoppingCriterion reason::String at_iteration::Int function StopWhenGradientNormLess( - ε::TF; norm::F=(M, p, X) -> norm(M, p, X) + ε::TF; norm::F=norm ) where {F,TF} return new{F,TF}(norm, ε, "", 0) end From caa87df2d47bf5ef110a249ec95255a1e8d56549 Mon Sep 17 00:00:00 2001 From: Ronny Bergmann Date: Wed, 17 Jan 2024 18:52:16 +0100 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/plans/stopping_criterion.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/plans/stopping_criterion.jl b/src/plans/stopping_criterion.jl index 983b231228..3687cea991 100644 --- a/src/plans/stopping_criterion.jl +++ b/src/plans/stopping_criterion.jl @@ -528,9 +528,7 @@ mutable struct StopWhenGradientNormLess{F,TF} <: StoppingCriterion threshold::Float64 reason::String at_iteration::Int - function StopWhenGradientNormLess( - ε::TF; norm::F=norm - ) where {F,TF} + function StopWhenGradientNormLess(ε::TF; norm::F=norm) where {F,TF} return new{F,TF}(norm, ε, "", 0) end end From 0d591eb859a11cc7c03f69c81bb2b846b01fa371 Mon Sep 17 00:00:00 2001 From: Ronny Bergmann Date: Thu, 18 Jan 2024 09:48:13 +0100 Subject: [PATCH 3/5] Update src/plans/stopping_criterion.jl Co-authored-by: Mateusz Baran --- src/plans/stopping_criterion.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plans/stopping_criterion.jl b/src/plans/stopping_criterion.jl index 3687cea991..adf2d41310 100644 --- a/src/plans/stopping_criterion.jl +++ b/src/plans/stopping_criterion.jl @@ -541,10 +541,13 @@ function (sc::StopWhenGradientNormLess)( sc.reason = "" sc.at_iteration = 0 end - if (i > 0) && (sc.norm(M, get_iterate(s), get_gradient(s)) < sc.threshold) - sc.reason = "The algorithm reached approximately critical point after $i iterations; the gradient norm ($(sc.norm(M,get_iterate(s),get_gradient(s)))) is less than $(sc.threshold).\n" - sc.at_iteration = i - return true + if (i > 0) + grad_norm = sc.norm(M, get_iterate(s), get_gradient(s)) + if grad_norm < sc.threshold) + sc.reason = "The algorithm reached approximately critical point after $i iterations; the gradient norm ($(grad_norm)) is less than $(sc.threshold).\n" + sc.at_iteration = i + return true + end end return false end From 687ecda7f617ade240400ec826930bda16a2846b Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Thu, 18 Jan 2024 11:20:05 +0100 Subject: [PATCH 4/5] Update src/plans/stopping_criterion.jl --- src/plans/stopping_criterion.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plans/stopping_criterion.jl b/src/plans/stopping_criterion.jl index adf2d41310..3c30b0a933 100644 --- a/src/plans/stopping_criterion.jl +++ b/src/plans/stopping_criterion.jl @@ -543,7 +543,7 @@ function (sc::StopWhenGradientNormLess)( end if (i > 0) grad_norm = sc.norm(M, get_iterate(s), get_gradient(s)) - if grad_norm < sc.threshold) + if grad_norm < sc.threshold sc.reason = "The algorithm reached approximately critical point after $i iterations; the gradient norm ($(grad_norm)) is less than $(sc.threshold).\n" sc.at_iteration = i return true From 747efe6a53002fd0e3e0d72b29f2fe1d8d9c384f Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Thu, 18 Jan 2024 11:21:58 +0100 Subject: [PATCH 5/5] Update src/plans/stopping_criterion.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/plans/stopping_criterion.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plans/stopping_criterion.jl b/src/plans/stopping_criterion.jl index 3c30b0a933..b53f29efd9 100644 --- a/src/plans/stopping_criterion.jl +++ b/src/plans/stopping_criterion.jl @@ -541,7 +541,7 @@ function (sc::StopWhenGradientNormLess)( sc.reason = "" sc.at_iteration = 0 end - if (i > 0) + if (i > 0) grad_norm = sc.norm(M, get_iterate(s), get_gradient(s)) if grad_norm < sc.threshold sc.reason = "The algorithm reached approximately critical point after $i iterations; the gradient norm ($(grad_norm)) is less than $(sc.threshold).\n"