-
Notifications
You must be signed in to change notification settings - Fork 56
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
base: main
Are you sure you want to change the base?
Fix Negative Curvature Status Overriding in CR.jl #970
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #970 +/- ##
==========================================
- Coverage 94.68% 93.66% -1.02%
==========================================
Files 45 47 +2
Lines 8027 9205 +1178
==========================================
+ Hits 7600 8622 +1022
- Misses 427 583 +156 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
One side note I noticed, is that we never test CR with radius > 0, I think we need a bug for that? |
test/test_cr.jl
Outdated
#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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but in trust-region methods, we would want “on trust-region boundary” to be the final status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpo so the issue here is that we want “on trust-region boundary” be the status?
In CR the flag is only set once
elseif pAp > 0 && ρ > 0 # no negative curvature
(verbose > 0) && @printf(iostream, "positive curvatures along p and r. pᴴAp = %8.1e and rᴴAr = %8.1e\n", pAp, ρ)
α = ρ / kdotr(n, q, Mq)
if α ≥ t1
α = t1
on_boundary = true
end
which is not the case in this test, since A is a diagonal with very -ve values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpo ?
@dpo # Test linesearch
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 # <-- this test fails
# 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 The first test is failing while the second one passes. I suspect this is because when Once the PR for MINRES is accepted, I plan to return |
Description:
This PR addresses an issue in
CR.jl
where the "nonpositive curvature" status was never set as intended. The problem arose from the current evaluation order:Because
solved
is defined asresid_decrease || npcurv || on_boundary
, even whennpcurv
istrue
,solved
also becomestrue
, leading to the"solution good enough given atol and rtol"
status being assigned afterward. This inadvertently overrides the negative curvature status, meaning the"nonpositive curvature"
status would never actually be set.Changes Made:
Modified the logic so that the negative curvature condition (
npcurv
) is checked and assigned before the generalsolved
condition. This ensures that if negative curvature is detected, the"nonpositive curvature"
status takes precedence.