Skip to content

Detailed IPOPT Log in ipopt_v2 #3577

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Detailed IPOPT Log in ipopt_v2 #3577

wants to merge 15 commits into from

Conversation

mrmundt
Copy link
Contributor

@mrmundt mrmundt commented Apr 24, 2025

Fixes #548, #728 , IDAES/idaes-pse#92

Summary/Motivation:

There is a utility wrapper in parmest that gathers helpful data from the IPOPT log that has never been promoted to a "real world citizen." This PR replaces the need for that in ipopt_v2 by parsing the output and storing important data by default on the Results object.

NOTE: This PR contains #3576 so that one needs to be merged first.

Changes proposed in this PR:

  • Update IPOPT parsing logic to capture iterations, various final scaled/unscaled results, the full solver log, etc.
  • Update tests to ensure that we are actually capturing the output
  • Fix a really sneaky bug that only appeared on older Python versions in Windows that stopped output from being captured

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

@michaelbynum michaelbynum left a comment

Choose a reason for hiding this comment

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

A couple minor comments. Yay for improved type hints!

Comment on lines 468 to 470
results.extra_info.get("iteration_log")._visibility = (
ADVANCED_OPTION
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused. What type of object does results.extra_info.get("iteration_log") return? From below, I thought it would be a list.

Copy link
Contributor Author

@mrmundt mrmundt May 2, 2025

Choose a reason for hiding this comment

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

Correct - it's a list. (It can be a very long list, because it captures all of the iterations. See IDAES/idaes-pse#92 (comment))

EDIT: To be clear, the remainder of parsed_output_data by this point is a dictionary with complementarity, constraint_violation, final_scaled_results, iteration_log, etc. iteration_log is the only thing that I am setting to ADVANCED_OPTION because it can be a lot to print out when running *.display().

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just confused about how it has the _visibility attribute...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, because it's an implicitly declared ConfigValue.

@mrmundt mrmundt requested a review from michaelbynum May 2, 2025 13:36
@michaelbynum
Copy link
Contributor

Oh, is there a copy of the log parsing code in parmest that needs to be removed?

@mrmundt
Copy link
Contributor Author

mrmundt commented May 5, 2025

Oh, is there a copy of the log parsing code in parmest that needs to be removed?

I'm hesitant to remove anything from parmest because I don't know how it's being used outside of Pyomo (e.g., it might be "the thing" that people are using to parse IPOPT output in other places). I figure it's something we can either (a) leave because it does no harm or (b) remove in the future with a fair deprecation warning.

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.

return final Ipopt values in solution object
2 participants