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

Improve calculate_variable_from_constraint error messages #2914

Merged
merged 6 commits into from
Jul 21, 2023

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Jul 19, 2023

Fixes # .

Summary/Motivation:

Debugging an IDAES model pointed out that the errors raised by calculate_variable_from_constraint are less informative than they could be. This improves those errors.

Changes proposed in this PR:

  • Add variable / constraint names to the exception messages raised by calculate_variable_from_constraint
  • Add IterationLimitError (subclass of RuntimeError) to provide more informative exceptions
  • Switch errors raised due to a poor initial guess (derivative too close to 0) from RuntimeError to ValueError

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

Copy link
Contributor

@mrmundt mrmundt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very small grammar issue; besides that, looks good.

pyomo/common/errors.py Outdated Show resolved Hide resolved
@jsiirola jsiirola requested a review from mrmundt July 20, 2023 13:31
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (abfedb9) 87.81% compared to head (48a545f) 87.81%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2914   +/-   ##
=======================================
  Coverage   87.81%   87.81%           
=======================================
  Files         770      770           
  Lines       89626    89628    +2     
=======================================
+ Hits        78701    78703    +2     
  Misses      10925    10925           
Flag Coverage Δ
linux 84.85% <100.00%> (+<0.01%) ⬆️
osx 74.57% <100.00%> (+<0.01%) ⬆️
other 85.02% <100.00%> (+<0.01%) ⬆️
win 82.10% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyomo/common/errors.py 100.00% <100.00%> (ø)
pyomo/util/calc_var_value.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jsiirola jsiirola merged commit 228f5eb into Pyomo:main Jul 21, 2023
30 checks passed
@jsiirola jsiirola deleted the calc-var-value-messages branch July 21, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants