Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyomo/solvers/plugins/solvers/gurobi_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def _apply_solver(self):
StaleFlagManager.mark_all_as_stale()

if self._tee:
self._solver_model.setParam('OutputFlag', 1)
self._solver_model.setParam('LogToConsole', 1)
else:
self._solver_model.setParam('OutputFlag', 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should this be the new default ? It seems that what you want can be achieved by adding LogToConsole=1 to the params you pass in the inputs

Copy link
Contributor Author

@rschwarz rschwarz Sep 3, 2025

Choose a reason for hiding this comment

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

No, I actually want (in this case) LogToConsole=0, which is implied by OutputFlag=0, but the latter also disables writing to log files.

But I want to be able to have all 4 combinations of console and log files for different use cases.

My understand was that the tee option refers to what is shown on the console, so it should not interfere with log files, which OutputFlag does.

self._solver_model.setParam('LogToConsole', 0)

if self._keepfiles:
# Only save log file when the user wants to keep it.
Expand Down
4 changes: 2 additions & 2 deletions pyomo/solvers/tests/checks/test_gurobi_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def setParam(self, param, value):
opt.solve(self.model, options={"MIPFocus": 2})

# Method should not be set again, but MIPFocus was changed.
# OutputFlag is explicitly set on the model.
# LogToConsole is explicitly set on the model.
assert envparams == {"Method": 2, "MIPFocus": 1}
assert modelparams == {"MIPFocus": 2, "OutputFlag": 0}
assert modelparams == {"MIPFocus": 2, "LogToConsole": 0}

# Try an erroneous parameter setting to ensure parameters go through in all
# cases. Expect an error to indicate pyomo tried to set the parameter.
Expand Down
Loading