[Cbc] multiple solutions with CbcMain

Matthew Galati matthew.galati at gmail.com
Sat Feb 14 19:18:31 EST 2015


Hi --

I did find some MILPs where I do get back multiple solutions using the
following:
   CbcMain0(cbc);
   cbc.setMaximumSavedSolutions(100);
   CbcMain1(argc, argv, cbc);

The original one only returned 1, despite the log saying:
Cbc0012I Integer solution of -264.97 found by rounding after 1 iterations
and 0 nodes (0.01 seconds)
Cbc0016I Integer solution of -282.4 found by strong branching after 11
iterations and 6 nodes (0.02 seconds)
Cbc0012I Integer solution of -282.4 found by feasibility pump after 0
iterations and 0 nodes (0.03 seconds)

So, I guess it is not storing everything that is mentioned in the log.
Which is what had me confused.



On Fri, Feb 13, 2015 at 10:52 AM, Matthew Galati <matthew.galati at gmail.com>
wrote:

> Hmm.
>
> That didn't seem to help.
>
>   const char * argv[20];
>    int   argc      = 0;
>    string cbcExe   = "cbc";
>    string cbcSolve = "-solve";
>    string cbcQuit  = "-quit";
>    string cbcLog   = "-log";
>    string cbcLogSet= UtilIntToStr(debugLevel);
>    string cbcMaxSave= "-maxSaved";
>    string cbcMaxSaveSet= "100";
>
>    argv[argc++] = cbcExe.c_str();
>    argv[argc++] = cbcLog.c_str();
>    argv[argc++] = cbcLogSet.c_str();
>    argv[argc++] = cbcMaxSave.c_str();
>    argv[argc++] = cbcMaxSaveSet.c_str();
>    argv[argc++] = cbcSolve.c_str();
>    argv[argc++] = cbcQuit.c_str();
>    CbcModel cbc(*osiClp);
>    CbcMain0(cbc);
>    CbcMain1(argc, argv, cbc);
>
> Then, in the log I see:
> Cbc0012I Integer solution of -264.97 found by rounding after 1 iterations
> and 0 nodes (0.01 seconds)
> Cbc0016I Integer solution of -282.4 found by strong branching after 11
> iterations and 6 nodes (0.02 seconds)
> Cbc0012I Integer solution of -282.4 found by feasibility pump after 0
> iterations and 0 nodes (0.03
> seconds)
>
>
> But, in the end:
>  int nSolutions = cbc.numberSavedSolutions();
>  printf("nSolutions=%d\n", nSolutions);
>
> nSolutions=1
>
>
>
>
> On Fri, Feb 13, 2015 at 10:36 AM, Haroldo Gambini Santos <
> haroldo.santos at gmail.com> wrote:
>
>>  Hi Matthew,
>>
>> To call CbcMain I think that the recommended way is:
>>
>> CbcMain0(cbcModel);
>> CbcMain1( nArgs, args, cbcModel);
>>
>> Using this way I got multiple solutions at the end using
>>
>> cbcModel.numberSavedSolutions()  and contents   cbcModel.savedSolution(i);
>>
>>
>>
>>
>> On 13-02-2015 11:53, Matthew Galati wrote:
>>
>> I switched to CbcMain from CbcModel.branchAndBound() based on comments
>> about performance.
>>
>>  I want to get multiple solutions from Cbc.
>>
>>  I am doing this:
>>
>>     const char * argv[20];
>>    int   argc      = 0;
>>    string cbcExe   = "cbc";
>>    string cbcSolve = "-solve";
>>    string cbcQuit  = "-quit";
>>    string cbcLog   = "-log";
>>    string cbcLogSet= UtilIntToStr(debugLevel);
>>    string cbcMaxSave= "-maxSaved";
>>     string cbcMaxSaveSet= "100";
>>
>>     argv[argc++] = cbcExe.c_str();
>>    argv[argc++] = cbcLog.c_str();
>>    argv[argc++] = cbcLogSet.c_str();
>>    argv[argc++] = cbcMaxSave.c_str();
>>    argv[argc++] = cbcMaxSaveSet.c_str();
>>    argv[argc++] = cbcSolve.c_str();
>>    argv[argc++] = cbcQuit.c_str();
>>    CbcModel cbc(*osiClp);
>>
>>
>>     CbcMain(argc, argv, cbc);
>>
>>
>>  And from the log, I can tell there are multiple solutions.
>>
>>  Then, I tried to get them with:
>> int nSolutions = cbc.numberSavedSolutions();
>>
>>  But, it says there is only 1.
>>
>>  When I was using cbc.branchAndBound(), this access method worked fine.
>>
>>  How do I get the multiple solutions back when using CbcMain?
>>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20150214/0e35f34a/attachment.html>


More information about the Cbc mailing list