Open ZedongPeng opened 1 year ago
@ZedongPeng, Can you pinpoint exactly when HiGHS outputs this? I don't think it is during run
. Maybe when the HiGHS model is constructed?
Yes. HiGHS outputs this when HiGHS model is constructed, more exactly this line https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/appsi/solvers/highs.py#L354.
Any thoughts on this? @michaelbynum @mrmundt
Any suggestions to stop the default log? @michaelbynum
Can you try wrapping with capture_output()
(either by wrapping the call to set_instance()
, or by putting it into that method)?
I am thinking something like
def set_instance(self, model):
if self._last_results_object is not None:
self._last_results_object.solution_loader.invalidate()
if not self.available():
c = self.__class__
raise PyomoException(
f'Solver {c.__module__}.{c.__qualname__} is not available '
f'({self.available()}).'
)
self._reinit()
self._model = model
if self.use_extensions and cmodel_available:
self._expr_types = cmodel.PyomoExprTypes()
- self._solver_model = highspy.Highs()
- self.add_block(model)
+ with capture_output(capture_output=True):
+ self._solver_model = highspy.Highs()
+ self.add_block(model)
if self._objective is None:
self.set_objective(None)
I only think we should hide the output after it is displayed at least once.
I only think we should hide the output after it is displayed at least once.
Why would the APPSI interface be different from the Ipopt, Gurobi, Cplex, CBC interfaces? We don't display any output from any of them unless tee=True
. Maybe the better implementation here would be to duplicate the logic from _solve()
and check the tee
value / redirect the output to the solver log.
It would be nice if that problem could be resolved.
I would like to use the HiGHS solver but with this bug i'm reluctant to switch.
I used to have output like this:
time 0 sample 0
time 5 sample 1
time 7 sample 2
time 9 sample 3
time 11 sample 4
...
But with the HiGHS solver it becomes this:
time 0 sample 0
Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d]
Copyright (c) 2023 HiGHS under MIT licence terms
time 5 sample 1
Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d]
Copyright (c) 2023 HiGHS under MIT licence terms
time 7 sample 2
Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d]
Copyright (c) 2023 HiGHS under MIT licence terms
time 9 sample 3
Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d]
Copyright (c) 2023 HiGHS under MIT licence terms
time 11 sample 4
...
Which is obviously quite annoying.
I've tried to suppress the output in a number of ways (including stuff related to sys.stdout) but it seems to be quite presistent.
Summary
I am using
appsi_highs
inMindtPy
. However, there are two lines of default logs when callingappsi_highs
. I think it is inherent fromhighs
itself, notappsi_highs
interface. How can we stop the default logs?