[Cbc] multiple solutions with CbcMain
Matthew Galati
matthew.galati at gmail.com
Fri Feb 13 10:52:21 EST 2015
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?
>
>
>
>
> _______________________________________________
> Cbc mailing listCbc at list.coin-or.orghttp://list.coin-or.org/mailman/listinfo/cbc
>
>
> --
> ==================================================
> Haroldo Gambini Santos
> D.Sc, Computer Science
> Universidade Federal de Ouro Pretohttp://www.decom.ufop.br/haroldo/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20150213/df1baf78/attachment.html>
More information about the Cbc
mailing list