solvers: silence version output of highs#479
Conversation
How is it that selecting cbc leads to HiGHS logging? I can only think that m.solve() is using the HiGHS presolve.
Without seeing how m.solve calls HiGHS to silence the logging, I can't say what can be done to silence this header logging. Indeed, since m.solve(solver_name="cbc") yields HiGHS logging, it suggests that HiGHS is not being silenced correctly. Note that in C and C++ HiGHS can be made to run entirely silently, so it's not an inherent issue in HiGHS. |
91f8e09 to
91101ce
Compare
|
@jajhall One just has to set the options early enough for highs to take them up. Otherwise the header is already printed. |
Interesting, I never knew this about Cbc! |
aa476ce to
6adaadf
Compare
|
@jajhall just for clarification - this has nothing to do with the CBC solver itself, just how the problem is translated in linopy for CBC to read. regarding the failing test: there is no |
# Pull Request The `suppress_output` method redirects the output buffers. This is generally not a good idea, instead, the underlying source of unwanted output should be tackled. This PR fixes the output from highs in the redispatch market. ## Related Issue This fixes #619 as this produced errors in Colab. ## Description There is still a line `Running HiGHS 1.11.0 (git hash: 364c83a): Copyright (c) 2025 HiGHS under MIT licence terms` which is printed for every solving. This is going to be fixed in linopy with PyPSA/linopy#479 ## Changes Proposed - correctly pass the silence args to the highs solver - delete now unused suppress_output function - improve package installation in colab by calling pip less often ## Testing [Describe the testing you've done, including any specific test cases or scenarios] ## Checklist Please check all applicable items: - [ ] Code changes are sufficiently documented (docstrings, inline comments, `doc` folder updates) - [ ] New unit tests added for new features or bug fixes - [ ] Existing tests pass with the changes - [ ] Reinforcement learning examples are operational (for DRL-related changes) - [ ] Code tested with both local and Docker databases - [ ] Code follows project style guidelines and best practices - [ ] Changes are backwards compatible, or deprecation notices added - [ ] New dependencies added to `pyproject.toml` - [ ] A note for the release notes `doc/release_notes.rst` of the upcoming release is included - [x] Consent to release this PR's code under the GNU Affero General Public License v3.0 ## Additional Notes (if applicable) [Any additional information, concerns, or areas you want reviewers to focus on] ## Screenshots (if applicable) [Add screenshots to demonstrate visual changes]
# Pull Request The `suppress_output` method redirects the output buffers. This is generally not a good idea, instead, the underlying source of unwanted output should be tackled. This PR fixes the output from highs in the redispatch market. ## Related Issue This fixes assume-framework#619 as this produced errors in Colab. ## Description There is still a line `Running HiGHS 1.11.0 (git hash: 364c83a): Copyright (c) 2025 HiGHS under MIT licence terms` which is printed for every solving. This is going to be fixed in linopy with PyPSA/linopy#479 ## Changes Proposed - correctly pass the silence args to the highs solver - delete now unused suppress_output function - improve package installation in colab by calling pip less often ## Testing [Describe the testing you've done, including any specific test cases or scenarios] ## Checklist Please check all applicable items: - [ ] Code changes are sufficiently documented (docstrings, inline comments, `doc` folder updates) - [ ] New unit tests added for new features or bug fixes - [ ] Existing tests pass with the changes - [ ] Reinforcement learning examples are operational (for DRL-related changes) - [ ] Code tested with both local and Docker databases - [ ] Code follows project style guidelines and best practices - [ ] Changes are backwards compatible, or deprecation notices added - [ ] New dependencies added to `pyproject.toml` - [ ] A note for the release notes `doc/release_notes.rst` of the upcoming release is included - [x] Consent to release this PR's code under the GNU Affero General Public License v3.0 ## Additional Notes (if applicable) [Any additional information, concerns, or areas you want reviewers to focus on] ## Screenshots (if applicable) [Add screenshots to demonstrate visual changes]
Closes # (if applicable).
Changes proposed in this Pull Request
m.solve(solver_name="cbc")-> is now silent instead of writing the
Running HiGHS 1.11.0header.This was especially cumbersome, as
highswas not selected but did print.m.solve(solver_name="highs", log_to_console=False)-> solves silently as well.
This did print the header before
m.solve(solver_name="highs", log_fn="/tmp/linopy.xt", output_flag=False)-> creates empty file (as expected)
m.solve(solver_name="highs", log_fn="/tmp/linopy.xt", log_to_console=False)-> verbose, writes to file but not to console
m.solve(solver_name="highs", log_fn="/tmp/linopy.txt")-> verbose, writes to file and to console
related comment:
ERGO-Code/HiGHS#2161 (comment)
Checklist
doc.doc/release_notes.rstof the upcoming release is included.