Message Handling

Strictly speaking, message handling is a general COIN topic, but it won't hurt to repeat a few important things here.

A simple user you may wish to turn off some output. This is done with model.setLogLevel(int value) where 0 gives nothing and each increase in value switches on more messages. See ClpMessage.cpp, CoinMessage.cpp and Chapter 6, Messages to see which messages are at which level. A more sophisticated user may wish to handle messages in a different way. This is done using passInMessageHandler with a pointer to a handler of the user's own design. The simplest case would be to use the default handler but use a constructor which writes to file. The code would be:

  FILE * fp; // assumed open
  CoinMessageHandler handler(fp);
  model.passInMessageHandler(&handler);
  

A still more sophisticated use would be to write a class derived from CoinMessageHandler and then override the print method. Below follows an example which would print only a message for optimality (or infeasibility):

Example 3.1. Sophisticated message handling

  class DerivedHandler :
   public CoinMessageHandler {
   public:
     virtual int print() ;
   };


   int DerivedHandler::print()
   {
     if (currentSource()=="Clp") {
       if (currentMessage().externalNumber()>=0
       && currentMessage().externalNumber()<4) { 
         // finished
         return CoinMessageHandler::print(); // print
       }
     }
     return 0;
   }