Skip to content

BUGFIX: Validator for tee in contrib.solver#3482

Merged
mrmundt merged 6 commits intoPyomo:mainfrom
mrmundt:ipopt-bugfix
Feb 20, 2025
Merged

BUGFIX: Validator for tee in contrib.solver#3482
mrmundt merged 6 commits intoPyomo:mainfrom
mrmundt:ipopt-bugfix

Conversation

@mrmundt
Copy link
Copy Markdown
Contributor

@mrmundt mrmundt commented Feb 19, 2025

Fixes N/A

Summary/Motivation:

There is repeatable bug in the interaction between capture_output and any of the *_v2 solvers in contrib.solver due to the way the TextIO_or_Logger domain validator was working. A minimal reproducible example of the bug:

import pyomo.environ as pyo
from pyomo.common.tee import capture_output

m = pyo.ConcreteModel()
m.x = pyo.Var([1,2],initialize=1, bounds=(0, None))
m.eq = pyo.Constraint(expr=m.x[1]*m.x[2]**1.5 == 3)
m.obj = pyo.Objective(expr=m.x[1]**2 + m.x[2]**2)

solver = pyo.SolverFactory("ipopt_v2")
with capture_output():
    solver.solve(m, tee=True)

Changes proposed in this PR:

  • Slightly change the logic in TextIO_or_Logger
  • Add tests to ensure correct behavior, both alone and under capture_output

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.

@blnicho blnicho requested a review from jsiirola February 20, 2025 01:00
Copy link
Copy Markdown
Member

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

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

I have a couple nits that I would like addressed / documented. I am not officially "requesting changes" so that the release will not be held up by my re-review.

@mrmundt mrmundt merged commit 4acdb69 into Pyomo:main Feb 20, 2025
28 of 30 checks passed
@mrmundt mrmundt deleted the ipopt-bugfix branch March 19, 2025 17:39
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.

3 participants