linear_solver: implement logcallback for HiGHS#5023
Open
kiijeonghoo wants to merge 1 commit intogoogle:mainfrom
Open
linear_solver: implement logcallback for HiGHS#5023kiijeonghoo wants to merge 1 commit intogoogle:mainfrom
kiijeonghoo wants to merge 1 commit intogoogle:mainfrom
Conversation
Mizux
reviewed
Feb 4, 2026
| if (request->enable_internal_solver_output()) { | ||
| highs.setOptionValue("log_to_console", true); | ||
| highs.setOptionValue("output_flag", true); | ||
| if (logging_callback != nullptr && *logging_callback) { |
Collaborator
There was a problem hiding this comment.
why setup the logging callback only when the solver.enable_output(True) aka inside the if ?
I mean user may want to enable logging callback and still have no trace on the stdout/stderr i.e. both features (console output and logging callback) are orthogonals imho...
Collaborator
There was a problem hiding this comment.
note: for the sat solver we have:
or-tools/ortools/linear_solver/proto_solver/sat_proto_solver.cc
Lines 454 to 459 in 6e52c52
Author
There was a problem hiding this comment.
I read the HiGHS IO design
- it seems only when the
solver.enable_output(True), the log can be print; - and only logging callback OR stdout is chosen;
void highsLogUser(const HighsLogOptions& log_options_, const HighsLogType type,
const char* format, ...) {
if (!*log_options_.output_flag ||
(log_options_.log_stream == NULL && !*log_options_.log_to_console))
return;
//...
const bool use_log_callback =
log_options_.user_log_callback ||
(log_options_.user_callback && log_options_.user_callback_active);
if (!use_log_callback) {
// Write to log file stream unless it is NULL
if (log_options_.log_stream) {
// ... fprintf(log_options_.log_stream ...
}
// Write to stdout unless log file stream is stdout
if (*log_options_.log_to_console && log_options_.log_stream != stdout) {
// ... fprintf(stdout ...
}
} else {
// callback
// ...
if (log_options_.user_log_callback) {
log_options_.user_log_callback(...);
}
// ...
}So, do you have any suggestion? @Mizux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
implement logcallback for HiGHS solver by calling
setLogCalllbackin Java/Python