Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Negative Curvature Status Overriding in CR.jl #970

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
npcurv && (status = "nonpositive curvature")
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)
Expand Down
10 changes: 9 additions & 1 deletion test/test_cr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +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
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)
Expand All @@ -90,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
Expand Down
Loading