From a7ffb8ef5fa29223f895b004363832b3e7a1cbdf Mon Sep 17 00:00:00 2001 From: farhadrclass <31899325+farhadrclass@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:26:39 -0500 Subject: [PATCH 1/4] Update cr.jl --- src/cr.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cr.jl b/src/cr.jl index 65e43c63e..359601cfd 100644 --- a/src/cr.jl +++ b/src/cr.jl @@ -402,8 +402,8 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema # Termination status tired && (status = "maximum number of iterations exceeded") on_boundary && (status = "on trust-region boundary") - npcurv && (status = "nonpositive curvature") solved && (status = "solution good enough given atol and rtol") + npcurv && (status = "nonpositive curvature") user_requested_exit && (status = "user-requested exit") overtimed && (status = "time limit exceeded") From 396c180724de69d80973ce639e169f3b25b7f19f Mon Sep 17 00:00:00 2001 From: farhadrclass <31899325+farhadrclass@users.noreply.github.com> Date: Tue, 25 Feb 2025 15:03:54 -0500 Subject: [PATCH 2/4] added the test to check the status --- src/cr.jl | 2 +- test/test_cr.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cr.jl b/src/cr.jl index 359601cfd..83cdf926c 100644 --- a/src/cr.jl +++ b/src/cr.jl @@ -403,9 +403,9 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema tired && (status = "maximum number of iterations exceeded") on_boundary && (status = "on trust-region boundary") solved && (status = "solution good enough given atol and rtol") - npcurv && (status = "nonpositive curvature") user_requested_exit && (status = "user-requested exit") overtimed && (status = "time limit exceeded") + npcurv && (status = "nonpositive curvature") # Update x warm_start && kaxpy!(n, one(FC), Δx, x) diff --git a/test/test_cr.jl b/test/test_cr.jl index 52da6c013..2b7d0b1cb 100644 --- a/test/test_cr.jl +++ b/test/test_cr.jl @@ -67,6 +67,11 @@ x, stats = cr(A, b, linesearch=true) @test stats.status == "nonpositive curvature" + #test nonpositive curvature when radius > 0 + A, b = symmetric_indefinite(FC=FC, shift = 5) + x, stats = cr(A, b, radius = one(Float64)) + @test stats.status == "nonpositive curvature" + # Test Linesearch which would stop on the first call since A is negative definite A, b = symmetric_indefinite(FC=FC; shift = 5) x, stats = cr(A, b, linesearch=true) From f41e0e369431c3a923cd1c3706c21272898117e5 Mon Sep 17 00:00:00 2001 From: farhadrclass <31899325+farhadrclass@users.noreply.github.com> Date: Wed, 26 Feb 2025 12:40:01 -0500 Subject: [PATCH 3/4] updated the pm the trust-region boundary flag --- src/cr.jl | 4 ++-- test/test_cr.jl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cr.jl b/src/cr.jl index 83cdf926c..fe51955b7 100644 --- a/src/cr.jl +++ b/src/cr.jl @@ -335,7 +335,7 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema kaxpy!(n, α, p, x) xNorm = knorm(n, x) - xNorm ≈ radius && (on_boundary = true) + xNorm ≈ radius > 0 && (on_boundary = true) kaxpy!(n, -α, Mq, r) # residual if MisI rNorm² = kdotr(n, r, r) @@ -401,11 +401,11 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema # Termination status tired && (status = "maximum number of iterations exceeded") - on_boundary && (status = "on trust-region boundary") solved && (status = "solution good enough given atol and rtol") user_requested_exit && (status = "user-requested exit") overtimed && (status = "time limit exceeded") npcurv && (status = "nonpositive curvature") + on_boundary && (status = "on trust-region boundary") # Update x warm_start && kaxpy!(n, one(FC), Δx, x) diff --git a/test/test_cr.jl b/test/test_cr.jl index 2b7d0b1cb..c4b03b1f4 100644 --- a/test/test_cr.jl +++ b/test/test_cr.jl @@ -67,10 +67,10 @@ x, stats = cr(A, b, linesearch=true) @test stats.status == "nonpositive curvature" - #test nonpositive curvature when radius > 0 + #test on trust-region boundary when radius > 0 A, b = symmetric_indefinite(FC=FC, shift = 5) x, stats = cr(A, b, radius = one(Float64)) - @test stats.status == "nonpositive curvature" + @test stats.status == "on trust-region boundary" # Test Linesearch which would stop on the first call since A is negative definite A, b = symmetric_indefinite(FC=FC; shift = 5) From 71aa227f6feafb4ba397e2a11ccd59c174bdf29b Mon Sep 17 00:00:00 2001 From: farhadrclass <31899325+farhadrclass@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:55:11 -0500 Subject: [PATCH 4/4] Update test_cr.jl --- test/test_cr.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_cr.jl b/test/test_cr.jl index c4b03b1f4..6ea9de7d2 100644 --- a/test/test_cr.jl +++ b/test/test_cr.jl @@ -66,11 +66,14 @@ A, b = symmetric_indefinite(FC=FC) x, stats = cr(A, b, linesearch=true) @test stats.status == "nonpositive curvature" + # @test real(dot(x, A * x)) ≤ 0 - #test on trust-region boundary when radius > 0 + # Test on trust-region boundary when radius > 0 A, b = symmetric_indefinite(FC=FC, shift = 5) x, stats = cr(A, b, radius = one(Float64)) @test stats.status == "on trust-region boundary" + @test real(dot(x, A * x)) ≤ 0 + @test norm(x) ≈ 1.0 # Test Linesearch which would stop on the first call since A is negative definite A, b = symmetric_indefinite(FC=FC; shift = 5) @@ -95,7 +98,7 @@ @test stats.solved == true - # test callback function + # Test callback function A, b = symmetric_definite(FC=FC) solver = CrSolver(A, b) tol = 1.0e-1