-
Notifications
You must be signed in to change notification settings - Fork 44
add tests for singularity #689
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
add tests for singularity #689
Conversation
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.
Pull Request Overview
This PR enhances the nonlinear solver's robustness by adding explicit detection and handling of singular and ill-conditioned Jacobian matrices during optimization. The solver now identifies when mathematical singularity prevents reliable convergence and provides clear diagnostic messages to users.
Key changes:
- Introduced condition number threshold checking and new termination codes (4 and 5) to distinguish singular system failures from normal convergence
- Updated solver logic to compute and track Jacobian condition numbers, preventing final adjustments when singularity is detected
- Added three test cases validating solver behavior with singular systems, ill-posed problems, and ill-conditioned Jacobians
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| burnman/optimize/nonlinear_solvers.py | Added max_condition_number threshold, condition number parameter to _termination_info, singularity detection logic, and new termination codes 4 and 5 with descriptive messages |
| tests/test_equilibration.py | Added three tests verifying correct termination codes for singular convergence (code 5), infeasible region exit (code 2), and singular system failure (code 4) |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
d0ef05d to
d1c3abb
Compare
7ec64c3 to
30024cd
Compare
30024cd to
c45108a
Compare
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@bjheinen some of the logic we discussed on Tuesday is implemented here. Thanks! |
|
@bobmyhill Looks good! With these extra tests and the check for is_singular at the start of the solve() loop I would be tempted again to see if moving the conditional regularisation to this stage would help convergence in near-singular cases (i.e. before computing luJ) |
This pull request improves the robustness of the nonlinear solver in
burnman/optimize/nonlinear_solvers.pyby adding explicit handling and reporting for singular and ill-conditioned Jacobian matrices during optimization. It introduces new termination codes and messages for these cases, updates the solver logic to detect and respond to singularities, and adds tests to verify correct behaviour in edge cases.Solver robustness and singularity handling:
max_condition_numberthreshold and logic to detect when the Jacobian is effectively singular, triggering new termination codes and descriptive messages for both failure (code 4) and successful convergence under singular conditions (code 5). (burnman/optimize/nonlinear_solvers.py) [1] [2] [3] [4] [5] [6] [7]_termination_infoto receive the Jacobian condition number and differentiate between normal convergence, singular convergence, and failure due to singularity while violating constraints. (burnman/optimize/nonlinear_solvers.py) [1] [2]burnman/optimize/nonlinear_solvers.py)Testing and validation:
tests/test_equilibration.pyto verify solver behaviour for: (1) convergence with a singular system, (2) ill-posed problems that leave the feasible region, and (3) detection of an ill-conditioned Jacobian. (tests/test_equilibration.py)Minor code cleanup:
namedtupleimport fromburnman/optimize/nonlinear_solvers.py