[Cbc] Message printing with CbcSolver

John Forrest john.forrest at fastercoin.com
Sun Mar 13 06:24:45 EDT 2011


Add

mipMessageHandler->setLogLevel(0,1);

On Sun, 2011-03-13 at 03:43 +0000, Kish Shen wrote:
> Hi,
> 
> I have looked at this a little more, and it seems that the messages are 
> not printing because of the passing in of the message handler:
> 
>  > DerivedHandler* mipMessageHandler = new DerivedHandler;
>  > // model->passInMessageHandler(mipMessageHandler);
> 
> If I comment out the line that pass the message handler in as above, the 
> messages from Cbc are printed. This happens in both the Trunk branch and 
> stable 2.4 branch I am using.
> 
> My DerivedHanlder is defined as:
> 
> class DerivedHandler : public CoinMessageHandler
> {
> public:
>      virtual int print();
> };
> 
> int DerivedHandler::print()
> {
>    printf("@@@@@HELLO@@@@\n");
>      int id = currentMessage().externalNumber();
>      int mtype = (id<3000 ? LogType : (id<6000 ? WrnType : ErrType));
>      eclipse_out(mtype, messageBuffer());
> 
>      return 0;
> }
> 
> I added the printf line so that I know when the handler is called.
> With the handler passed in, all I get printed is:
> 
> @@@@@HELLO@@@@
> Coin Cbc and Clp Solver version 2.4, build Mar 12 2011
> @@@@@HELLO@@@@
> command line - eplexcbcclpsolver -preprocess on -solve -quit (default 
> strategy 1)
> @@@@@HELLO@@@@
> Option for preprocess changed from sos to on
> @@@@@HELLO@@@@
> 0 fixed, 0 tightened bounds, 4 strengthened rows, 0 substitutions
> @@@@@HELLO@@@@
> 0 fixed, 0 tightened bounds, 3 strengthened rows, 0 substitutions
> @@@@@HELLO@@@@
> 0 fixed, 0 tightened bounds, 2 strengthened rows, 0 substitutions
> @@@@@HELLO@@@@
> 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> @@@@@HELLO@@@@
> 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> @@@@@HELLO@@@@
> 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> @@@@@HELLO@@@@
> 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> @@@@@HELLO@@@@
> processed model has 290 rows, 1055 columns (1055 integer) and 2465 elements
> 
> When I *don't* pass the handler in, I get a lot more output:
> 
> Coin Cbc and Clp Solver version 2.4, build Mar 12 2011
> command line - eplexcbcclpsolver -preprocess on -solve -quit (default 
> strategy 1)
> Option for preprocess changed from sos to on
> Continuous objective value is 156083 - 0.00 seconds
> Cgl0003I 0 fixed, 0 tightened bounds, 4 strengthened rows, 0 substitutions
> Cgl0003I 0 fixed, 0 tightened bounds, 3 strengthened rows, 0 substitutions
> Cgl0003I 0 fixed, 0 tightened bounds, 2 strengthened rows, 0 substitutions
> Cgl0003I 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> Cgl0003I 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> Cgl0003I 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> Cgl0003I 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
> Cgl0004I processed model has 290 rows, 1055 columns (1055 integer) and 
> 2465 elements
> Cbc0038I Pass   1: suminf.    0.66204 (6) obj. 228065 iterations 86
> Cbc0038I Pass   2: suminf.    0.66204 (6) obj. 228065 iterations 0
> ....
> Cbc0035I Maximum depth 12, 3374 variables fixed on reduced cost
> Cuts at root node changed objective from 196138 to 394807
> Probing was tried 184 times and created 309 cuts of which 44 were active 
> after adding rounds of cuts (0.220 seconds)
> Gomory was tried 182 times and created 993 cuts of which 48 were active 
> after adding rounds of cuts (0.315 seconds)
> Knapsack was tried 182 times and created 372 cuts of which 51 were 
> active after adding rounds of cuts (0.320 seconds)
> Clique was tried 69 times and created 0 cuts of which 0 were active 
> after adding rounds of cuts (0.004 seconds)
> MixedIntegerRounding2 was tried 182 times and created 193 cuts of which 
> 6 were active after adding rounds of cuts (0.022 seconds)
> FlowCover was tried 69 times and created 0 cuts of which 0 were active 
> after adding rounds of cuts (0.005 seconds)
> TwoMirCuts was tried 69 times and created 354 cuts of which 0 were 
> active after adding rounds of cuts (0.089 seconds)
> Result - Finished objective 405935.1799999999 after 78 nodes and 5281 
> iterations - took 2.11 seconds (total time 2.11)
> Total time 2.12
> Segmentation fault
> 
> I have cut out most of the printing in the middle, but it looks like 
> none of the output from Cbc are sent to the handler, only the messages 
> from Cgl at the start are printed (though without the "Cgl*" identifier 
> at the start, I do get this identifier when the handler prints messages 
> from Clp when a linear problem is solved.
> 
> There is also a segmentation fault at the end when I don't pass in the 
> handler. Besides commenting out the line as I show, the rest of the code 
> should be the same.
> 
> Any idea why this is happening, and if there is anyway to work around 
> this? I need to use the print handler to redirect the messages to my own 
> output stream, so not using a print handler is not really an option.
> 
> Thanks and cheers,
> 
> Kish
> 
> On 11/03/2011 17:55, Kish Shen wrote:
> > Hi,
> >
> > Currently, during the solving of a MIP problem in my code, where CBC is
> > called using the CbcMain0/CbcMain1 interface (which invokes CbcSolver, I
> > believe), I get no printing of the messages from Cbc.
> >
> > This is the behaviour I want normally, but recently some of our users
> > have asked if they can see solver messages to get some idea of what the
> > solver is doing. I have been unable to see any of Cbc's messages.
> >
> > As far as I can tell, Cbc is not calling my messageHandler -- I don't
> > know if this is because I have not passed the handler to the right place.
> >
> > Here is an outline of the code I use, and if anyone can see what I need
> > to do to get the Cbc messages, I would be very grateful:
> >
> > CbcModel* model = new(...);
> >
> > CbcMain0(*model);
> >
> > DerivedHandler* mipMessageHandler = new DerivedHandler;
> > model->passInMessageHandler(mipMessageHandler);
> >
> > model->solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry);
> >
> > const char* cbc_args[5];
> >
> >
> > cbc_args[0] = "eplexcbcclpsolver";
> > cbc_args[1] ="-preprocess"
> > cbc_args[2] = "on";
> > cbc_args[3] = "-solve";
> > cbc_args[4] = "-quit";
> > CbcMain1(5, cbc_args,*model,callBack);
> >
> > [I hope there are no typos in the above; I was not able to cut and paste
> > from my VNC window with the code listing to my Windows mailer]
> >
> > DerivcedHandler is a derived class of CoinMessageHandler that sends the
> > message to different streams depending on the externalNumber() of the
> > message, and does seem to work (I can see Clp messages when solving a
> > linear problem).
> >
> > An aside: I remember John (Forrest) suggesting the use of
> > CbcMain0/CbcMain1 to use the CbcSolver. I just tried to look up the
> > documentation for them in Cbc's Doxygen documentation, but was not able
> > to find them at all. Does anyone know where I can find the doucmentation?
> >
> > Thanks in advance for any help!
> >
> > --Kish Shen
> >
> 
> 




More information about the Cbc mailing list