[Scip] Message Handler

Tobias Achterberg achterberg at zib.de
Thu Mar 9 13:15:06 MET 2006


Martin,

> I need to redirect the messages of SCIP and would therefore like to
> employ my own message handler. However, I don’t quite understand, why
> the message handler's output routines are passed a "FILE *" parameter. A
> cursory inspection of the source seems to indicate that SCIP passes only
> "stdout" and "stderr" there. Can my implementation rely on that? If not,
> what's the point of this parameter?

Messages can be displayed with the SCIP methods SCIPdialogMessage(),
SCIPinfoMessage(), SCIPverbMessage() from "scip.h", and
SCIPerrorMessage() and SCIPwarningMessage() from "pub_message.h".

The first three have a FILE* parameter that can be used by the user to
print the message into a file. If this is a NULL pointer, the message
is printed to stdout. Error and warning messages go to stderr in any case.

In the current external plugins and in the internal SCIP code,
messages are always (as far as I can remember) printed to NULL, i.e.,
stdout. However, a user might implement a message output that goes to
a file, so you can--in principle--not assume "file == stdout || file
== stderr".

Anyways, since it is your message handler, you can do whatever you
want with the messages, in particular you can just ignore them if you
want to suppress all output. A user who is using your message handler
should know what the message handler does, and if you reveal the
behaviour in the documentation of the message handler, it should be okay.

A message handler cannot break crucial code. Is is purely for messages
that are intended to inform the user, e.g., about progress. For
example, the functionality to write the current problem to a file is
NOT routed through a message handler, but written directly to a file.
I implemented a message handler for a project, where we wanted to have
prefixes "-I- ", "-E- ", "-W- " and the like for each output line,
such that one can distinct these messages from other messages like
result messages produced by the underlying application in the log
files. Thus, if a method like the "write problem" command would use
this message handler, the produced file wouldn't correspond to the
output format anymore because of these additional "-I- "'s at the
beginning of each line.


Best regards,   Tobias



-- 
Tobias Achterberg          Konrad-Zuse-Zentrum fuer
                           Informationstechnik Berlin
Tel: +49 (0)30 84185-301   Takustr. 7
Email: achterberg at zib.de   D-14195 Berlin, Germany


More information about the Scip mailing list