Skip to content

Commit

Permalink
📈 Part 5
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Jun 12, 2024
1 parent 2d6ff3a commit e346a53
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plans/bundle_plan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ mutable struct StopWhenLagrangeMultiplierLess{
end
function get_reason(sc::StopWhenLagrangeMultiplierLess)
if (sc.at_iteration >= 0)
if isnothing(sc.sumbols)
if isnothing(sc.symbols)
tol_str = join(
["$ai < $bi" for (ai, bi) in zip(sc.values, sc.tolerances)], ", "
)
Expand All @@ -134,7 +134,7 @@ function get_reason(sc::StopWhenLagrangeMultiplierLess)
", ",
)
end
return "After $(c.at_iteration) iterations the algorithm reached an approximate critical point with tolerances $tol_str.\n"
return "After $(sc.at_iteration) iterations the algorithm reached an approximate critical point with tolerances $tol_str.\n"
end
return ""
end
Expand Down
4 changes: 4 additions & 0 deletions test/plans/test_stopping_criteria.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ struct DummyStoppingCriterion <: StoppingCriterion end
@test s3.κ == 0.5
update_stopping_criterion!(s3, :ResidualPower, 0.5)
@test s3.θ == 0.5
@test get_reason(s3) == ""
# Trigger manually
s3.at_iteration = 1
@test length(get_reason(s3)) > 0
end

@testset "Stop with step size" begin
Expand Down
5 changes: 5 additions & 0 deletions test/solvers/test_particle_swarm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,10 @@ using Random
@testset "Specific Stopping criteria" begin
sc = StopWhenSwarmVelocityLess(1.0)
@test startswith(repr(sc), "StopWhenSwarmVelocityLess")
@test get_reason(sc) == ""
# Trigger manually
sc.at_iteration = 2
sc.velocity_norms = [0.001, 0.001]
@test length(get_reason(sc)) > 0
end
end
8 changes: 8 additions & 0 deletions test/solvers/test_proximal_bundle_method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ import Manopt: proximal_bundle_method_subsolver, proximal_bundle_method_subsolve
@test startswith(
repr(sc1), "StopWhenLagrangeMultiplierLess([1.0e-8]; mode=:estimate)\n"
)
@test get_reason(sc1) == ""
# Trigger manually
sc1.at_iteration = 2
@test length(get_reason(sc1)) > 0
sc2 = StopWhenLagrangeMultiplierLess([1e-8, 1e-8]; mode=:both)
@test startswith(
repr(sc2), "StopWhenLagrangeMultiplierLess([1.0e-8, 1.0e-8]; mode=:both)\n"
)
@test get_reason(sc2) == ""
# Trigger manually
sc2.at_iteration = 2
@test length(get_reason(sc2)) > 0
end
@testset "Allocating Subgradient" begin
f(M, q) = distance(M, q, p)
Expand Down
4 changes: 4 additions & 0 deletions test/solvers/test_truncated_cg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ using Manifolds, Manopt, ManifoldsBase, Test
str1 = Manopt.status_summary(str)
@test str1 == "Trust region exceeded:\tnot reached"
@test repr(str) == "StopWhenTrustRegionIsExceeded()\n $(str1)"
@test get_reason(str) == ""
# Trigger manually
str.at_iteration = 1
@test length(get_reason(str)) > 0
scn = StopWhenCurvatureIsNegative()
scn1 = Manopt.status_summary(scn)
@test scn1 == "Curvature is negative:\tnot reached"
Expand Down

0 comments on commit e346a53

Please sign in to comment.