Skip to content

Ipopt_v2: update options processing #3693

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 16 commits into
base: main
Choose a base branch
from

Conversation

jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

@eslickj pointed out two problems with the new contrib.solver Ipopt interface:

  • naming your model anything with a space in it would cause ipopt to fail to parse any options from the option file
  • The LegacySolver wrapper failed to process the OF_ options that the original ipopt interface supported.

This PR resolves both of those issues:

  • Update how we generate the base file name to avoid the quotes that can be added when retrieving the model's local name. In addition, we process the model name to ensure that it is a valid (allowable by the OS) file name. Finally, we ensure that all string options passed to the solver on the command line are properly quoted.
  • Create a custom Legacy wrapper for Ipopt that will correctly handle the old OF_* options
  • Define a new utility for ensuring strings are valid file names
  • Ensure that temporary filenames are more likely to be unique (by including the PID and thread id)
  • Check to make sure the interface doesn't overwrite any existing files
  • The standard Pyomo time_limit option overrides the ipopt-specific max_cpu_time option

Changes proposed in this PR:

  • (see above)

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.

for ext in ('.nl', '.row', '.col', '.sol', '.opt'):
if os.path.exists(basename + ext):
raise RuntimeError(
f"Solver interface file {basename + ext} already exists!"
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the funny/snarky message about cowardly abandoning all hope?!

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's more "cowardly refusing to proceed" than "abandoning all hope".

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that one ;)

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.

I think this is perfectly fine as-is but had some comments that Tuesday-morning-brain needed to get out.

@github-project-automation github-project-automation bot moved this from Todo to Reviewer Approved in Pyomo 6.9.4 Release Aug 12, 2025
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 96.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.22%. Comparing base (35b2802) to head (d94366c).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
pyomo/contrib/solver/solvers/ipopt.py 95.55% 2 Missing ⚠️
pyomo/common/envvar.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3693      +/-   ##
==========================================
+ Coverage   89.19%   89.22%   +0.02%     
==========================================
  Files         892      892              
  Lines      103015   103256     +241     
==========================================
+ Hits        91888    92127     +239     
- Misses      11127    11129       +2     
Flag Coverage Δ
builders 26.74% <32.00%> (+0.01%) ⬆️
default 85.77% <96.00%> (?)
expensive 34.08% <32.00%> (?)
linux 86.96% <96.00%> (-1.97%) ⬇️
linux_other 86.96% <96.00%> (+0.01%) ⬆️
osx 83.28% <96.00%> (+0.03%) ⬆️
win 85.16% <92.00%> (+<0.01%) ⬆️
win_other 85.16% <92.00%> (+<0.01%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Reviewer Approved
Development

Successfully merging this pull request may close these issues.

2 participants