-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
BUG: optimize.minimize: set trust-constr
success=False
when constraints are not satisfied
#21407
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
Conversation
…aints are not satisfied Reference issue Fixes scipy#18882. What does this implement/fix? Previously trust-constr returned success=True (i.e. status equal to 1 or 2) even when the constraints were not satisfied. Now trust-constr returns success=False and status=4 with message="Constraints are not satisfied." A test is implemented in test_minimized_constrained.py to check success=False when constr_violation>gtol. Additional information This fix is based in part on the PR created by @ellieLitwack at scipy#18890 (comment), but approaches the solution to the bug in a way that does not require a modification to the stop criteria. The feedback from @andyfaff to this previous PR was also considered in the creation of this new fix.
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.
This looks pretty good to me, apologies for the long wait for a review. @andyfaff perhaps you would be able to follow up on your previous comments from the linked PR?
trust-constr
success=False
when constraints are not satisfied
trust-constr
success=False
when constraints are not satisfiedtrust-constr
success=False
when constraints are not satisfied
@@ -18,7 +18,8 @@ | |||
0: "The maximum number of function evaluations is exceeded.", | |||
1: "`gtol` termination condition is satisfied.", | |||
2: "`xtol` termination condition is satisfied.", | |||
3: "`callback` function requested termination." | |||
3: "`callback` function requested termination.", | |||
4: "Constraints are not satisfied." |
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.
I think the status message can be improved here, currently it doesn't give enough information as to why the status was set to 4.
How about Constraint violation exceeds 'gtol'
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.
I think you are right. Your status message is more clear. I'll go ahead and update it.
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.
Quick question. Should I rebase before attempting another commit? This is my first PR and am not familiar with the process to update an existing commit.
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.
Feel free to just commit the change on top of your current branch - a reviewer can always 'squash' commits down before merge.
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.
Thanks, I just added a new commit with the updated status message.
Thank you for your contribution @CarrascoCesar |
Reference issue
Fixes #18882.
What does this implement/fix?
Previously trust-constr returned success=True (i.e. status equal to 1 or 2) even when the constraints were not satisfied. Now trust-constr returns success=False and status=4 with message="Constraints are not satisfied." A test is implemented in test_minimized_constrained.py to check success=False when constr_violation>gtol.
Additional information
This fix is based in part on the PR created by @ellieLitwack at #18890 (comment), but approaches the solution to the bug in a way that does not require a modification to the stop criteria. The feedback from @andyfaff to this previous PR was also considered in the creation of this new fix.