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

improved error message. #1412

Merged
merged 3 commits into from
May 30, 2024
Merged

Conversation

k1nshuk
Copy link
Contributor

@k1nshuk k1nshuk commented May 28, 2024

Fixes/Resolves:

Provides better instructions for debugging scaling problems, e.g., 0/0 calculations to identify which function the error is coming from.

Summary/Motivation:

Making the debugging process easier

Changes proposed in this PR:

  • Better error message. See file for changes

Legal Acknowledgement

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

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  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.

@k1nshuk k1nshuk requested review from adam-a-a and bknueven May 28, 2024 19:50
@k1nshuk k1nshuk self-assigned this May 28, 2024
@@ -158,7 +158,9 @@ def _scale_constraints(self, blk):
self._cleanup()
raise RuntimeError(
"Error in AMPL evaluation.\n"
"Run ipopt with halt_on_ampl_error=yes and symbolic_solver_labels=True to see the affected function."
"Re-run ipopt with:\n"
'1. solver options = {"halt_on_ampl_error" : "yes", "nlp_scaling_method" : "gradient-based"\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

I am forgetting- should nlp_scaling_method be what you have here or user-scaling? What happens if you don't specify gradient -based scaling?

Copy link
Contributor

Choose a reason for hiding this comment

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

This option ensures watertap's own scaling gets skipped and the model gets handed directly to Ipopt. This is what we want to see the problematic constraint / expression.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just thought I remembered this working regardless of that option so maybe I'm not recalling correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

It certainly does in IDAES or if you just use SolverFactory("ipopt").

Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.01%. Comparing base (8db93dd) to head (b30dd99).
Report is 54 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1412   +/-   ##
=======================================
  Coverage   94.01%   94.01%           
=======================================
  Files         335      335           
  Lines       35561    35561           
=======================================
  Hits        33431    33431           
  Misses       2130     2130           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@k1nshuk k1nshuk mentioned this pull request May 30, 2024
@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label May 30, 2024
@lbianchi-lbl lbianchi-lbl merged commit 77d096e into watertap-org:main May 30, 2024
26 checks passed
@k1nshuk k1nshuk deleted the better_err_msg branch May 31, 2024 20:50
lbianchi-lbl pushed a commit to watertap-org/watertap-solvers that referenced this pull request Dec 7, 2024
* improved error message.

* run black.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:Normal Normal Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants