Skip to content

Commit

Permalink
add test, fix tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Mar 1, 2024
1 parent 1ad61d6 commit 9a6f6d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/solvers/test_convex_bundle_method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ using Manopt: sectional_curvature, ζ_1, ζ_2, close_point
)
q = get_solver_result(cbm_s)
m = median(M, data)
@test distance(M, q, m) < 1e-2 #with default params this is not very precise
@test distance(M, q, m) < 1.5e-2 #with default params this is not very precise
# tst the other stopping criterion mode
q2 = convex_bundle_method(
M,
Expand Down
28 changes: 28 additions & 0 deletions test/solvers/test_quasi_Newton.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
using Manopt, Manifolds, Test
using LinearAlgebra: I, eigvecs, tr, Diagonal

struct QuasiNewtonGradientDirectionUpdate{VT<:AbstractVectorTransportMethod} <:
AbstractQuasiNewtonDirectionUpdate
vector_transport_method::VT
end
function (d::QuasiNewtonGradientDirectionUpdate)(mp, st)
return get_gradient(st)
end
function (d::QuasiNewtonGradientDirectionUpdate)(r, mp, st)
r .= get_gradient(st)
return r
end

@testset "Riemannian quasi-Newton Methods" begin
@testset "Show & Status" begin
M = Euclidean(4)
Expand Down Expand Up @@ -357,6 +369,22 @@ using LinearAlgebra: I, eigvecs, tr, Diagonal
@test contains(qns.direction_update.message, "gradient")
end

@testset "Broken direction update" begin
M = Euclidean(2)
p = [0.0, 1.0]
f(M, p) = sum(p .^ 2)
grad_f(M, p) = 2 * sum(p)
gmp = ManifoldGradientObjective(f, grad_f)
mp = DefaultManoptProblem(M, gmp)
qns = QuasiNewtonState(
M, p; direction_update=QuasiNewtonGradientDirectionUpdate(ParallelTransport())
)
@test_logs (
:warn,
"Computed direction is not a descent direction; resetting to negative gradient",
) match_mode = :any solve!(mp, qns)
end

@testset "A Circle example" begin
M = Circle()
data = [-π / 2, π / 4, 0.0, π / 4]
Expand Down

0 comments on commit 9a6f6d1

Please sign in to comment.