[Cbc] Cbc changes solver pointer after solving a problem [c++ API]

Tobias Stengel Tobias.Stengel at locom.de
Sun Jan 6 11:46:17 EST 2019


Sorry for hijacking this thread but is there any chance to use this opportunity to document some of possible defines of CBC?
I did a quick „grep | sort | unique“ search on trunk – see attachment.
Wendel will probably remember KEEP_ORIGINAL_SOLVER and I can remember the story behind GOMORY_LONG but I doubt many others do. Stuff like MORE_GOMORY_CUTS and #ifdef MAKE_SOS_CLIQUES sound interesting.
There are also some defines that look unnecessary and/or outdated:
·         #if 0
·         #if 1
·         #ifdef USELESS (sic!)
·         #ifdef XXXXXX
·         #ifdef COIN_PRESOLVE_BUG
·         #if defined (hp300)  - I doubt there is any compiler that supports hp300 and a sufficiently new version of c++ to build cbc.
·         …
Maybe we can kill some of them?
Some are self explaining and/or used by the build system – e.g. #ifdef COIN_HAS_LAPACK, #ifdef _Win32  that need no documentation.
Some look like typos:
·         #ifdef ALT_UPDATE_WEIGHTS vs #ifdef ALT_UPDATE_WEIGHTSz

Tobias





Von: Cbc <cbc-bounces at coin-or.org> Im Auftrag von John Forrest
Gesendet: Sonntag, 6. Januar 2019 16:19
An: cbc at list.coin-or.org
Betreff: Re: [Cbc] Cbc changes solver pointer after solving a problem [c++ API]

If you update Cbc stable and add

 -DKEEP_ORIGINAL_SOLVER

to CXXDEFS in configure then solver will stay same.

Remember that the bounds on integer variables will have been changed to give an integer solution.

John Forrest

On 05/01/2019 23:12, Wendel Melo wrote:
Dear friends

I am giving my first steps with CBC to Mixed Integer Linear Programming (MILP) by means of the C++ API. My current goal is to turn Cbc one of the MILP solvers supported in Muriqui Optimizer, a free MINLP solver (www.wendelmelo.net/software<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.wendelmelo.net_software&d=DwMDaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=zU1-bo4qay1GSxqnW8lKSuGZO4rtR2XKpD4FKabSFw8&m=Dlncezz6ZXqPDV70JRMj-7nMP89Z4J6ejU1siRSKD90&s=FcYkDDfmdBeP5OAt-9fgPycvrYTcrodyBArDYF92PqA&e=>).

Due to design questions, I have been constructing an object of the CbcModel class using an empty OsiSolverInterface object:

OsiClpSolverInterface   clp ;
CbcModel   *model = new (std::nothrow) CbcModel(clp);

After that, I have been set the coefficients of my MILP problem by means of the pointer returned by the method CbcModel::solver, for example:

OsiSolverInterface *solver = model->solver()

solver->addCol(0, NULL, NULL,   0.0,  1000.0,   1.0);

I am performing in this way to avoid delay copping the OsiSolverInterface object in the CbcModel constructor since I need to solve a sequence where the same MILP problem has to be solved several times just changing some parameters.

But I have been getting some problems. After calling method CbcModel::branchAndBound by the second time, the pointer returned by CbcModel::solver is getting a different value of the previous call, for example:

std::cout << "before BB solver pointer: " <<  model->solver() << std::endl;
model->branchAndBound()
std::cout << "after BB solver pointer: " <<  model->solver() << std::endl;

The code above prints:

before BB solver pointer:  0x1455a628
after BB solver pointer:  0x14887f88

So, we can see the solver pointer in CbcModel object was changed. Why is it happening? I believe creating new solver objects is bad because increase the computations. Is there a way to avoid the changing of solver object pointer? Are there other methods in CbcModel that can provoke the changing of the solver pointer?

Thanks in advanced

Best regards


Wendel Melo
www.wendeldelo.net<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.wendeldelo.net&d=DwMDaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=zU1-bo4qay1GSxqnW8lKSuGZO4rtR2XKpD4FKabSFw8&m=Dlncezz6ZXqPDV70JRMj-7nMP89Z4J6ejU1siRSKD90&s=JYh8Yxd78YR1psLERivTyWK7ucneElUkq1Z8lpuKBIw&e=>



_______________________________________________

Cbc mailing list

Cbc at list.coin-or.org<mailto:Cbc at list.coin-or.org>

https://list.coin-or.org/mailman/listinfo/cbc<https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cbc&d=DwMDaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=zU1-bo4qay1GSxqnW8lKSuGZO4rtR2XKpD4FKabSFw8&m=Dlncezz6ZXqPDV70JRMj-7nMP89Z4J6ejU1siRSKD90&s=RAbMHMb3ITS3FymBW1NhNKgJjpOwr-MTnXzqE7rsT2o&e=>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20190106/4425e64d/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cbc_defines.txt
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20190106/4425e64d/attachment-0001.txt>


More information about the Cbc mailing list