[Cbc] CbcModel::takeOffCuts() for globalCuts_

Kibaek Kim kibaek.k at gmail.com
Mon Nov 24 08:38:26 EST 2014


Dear John,

Thanks for you suggestion. I have found a solution (or workaround?) for the issue, after having a better understanding of Cbc design.

Just to share my experience:

During CbcModel::branchAndBound(), I particularly needed to be careful for using user-defined cut generators when it’s called "at solution", because the code seems to let the cut generators do what is needed (e.g. adding cuts and re-optimizing problem). So I have modified generateCuts() function in my cut generators to add cuts to globalCuts_ and re-optimize model, when the cut generators are called at solution (atSolution()). Doing that, solver_ now has cuts applied and the correct number of rows before getting into takeOffCuts(). And no more error.

Thanks again,
Kibaek

On Nov 21, 2014, at 5:00 AM, John Forrest <john.forrest at fastercoin.com> wrote:

> Kibaek,
> 
> If you can give me something to reproduce the problem - using either the latest Cbc stable or trunk, then I can debug it.
> 
> I have added
> 
>     assert (numberRowsAtContinuous_+totalNumberCuts==solver_->getNumRows());
> 
> near top of CbcModel::takeOffCuts
> 
> If you add that, does it trigger an assert?
> 
> John Forrest
> 
> On 20/11/14 17:24, Kibaek Kim wrote:
>> Hello,
>> 
>> I am testing my global cut generator for outer approximation of piece-wise linear convex function. My implementation uses OsiBabSolver::solverType_ = 3 and manually sets up mipBound_ and bestObjectiveValue_, while generating global cuts.
>> 
>> Here is my issue. After running many iterations, Cbc complains the following:
>>   Assertion failed: (clpMatrix->getNumRows()==modelPtr_->getNumRows()), function freeCachedResults, file ../../../../Clp/src/OsiClp/OsiClpSolverInterface.cpp, line 4491.
>> and backtrace reports
>>   * frame #0: 0x00007fff9a5c8866 libsystem_kernel.dylib`__pthread_kill + 10
>>     frame #1: 0x00007fff9948035c libsystem_pthread.dylib`pthread_kill + 92
>>     frame #2: 0x00007fff947fbb1a libsystem_c.dylib`abort + 125
>>     frame #3: 0x00007fff947c59bf libsystem_c.dylib`__assert_rtn + 321
>>     frame #4: 0x00000001003e3187 MyTest`OsiClpSolverInterface::freeCachedResults(this=0x000000010afb1320) const + 623 at OsiClpSolverInterface.cpp:4491
>>     frame #5: 0x00000001003dcd27 MyTest`OsiClpSolverInterface::deleteRows(this=0x000000010afb1320, num=1, rowIndices=0x000000010afc8380) + 729 at OsiClpSolverInterface.cpp:3491
>>     frame #6: 0x00000001000b50af MyTest`CbcModel::takeOffCuts(this=0x000000010172d000, newCuts=0x00007fff5fbfd120, allowResolve=true, saveCuts=0x0000000000000000, numberNewCuts=0, addedCuts=0x0000000000000000) + 2029 at CbcModel.cpp:9792
>>     frame #7: 0x00000001000b080f MyTest`CbcModel::solveWithCuts(this=0x000000010172d000, cuts=0x00007fff5fbfd120, numberTries=0, node=0x000000010b31a6c0) + 16359 at CbcModel.cpp:8563
>>     frame #8: 0x00000001000c9765 MyTest`CbcModel::doOneNode(this=0x000000010172d000, baseModel=0x000000010172d000, node=0x00007fff5fbfd880, newNode=0x00007fff5fbfd938) + 2745 at CbcModel.cpp:14944
>>     frame #9: 0x000000010009b8d8 MyTest`CbcModel::branchAndBound(this=0x000000010172d000, doStatistics=0) + 49158 at CbcModel.cpp:4500
>> 
>> The issue is because OsiClpSolverInterface::deleteRows() tries deleting rows that are out of range. This results in that the row counter of clpMatrix is reduced whereas the         model row counter is not. The reason that solverCutIndices in CbcModel::takeOffCuts() contained out-of-range indices is that CbcMode::globalCuts_ were counted in solverCutIndices (in CbcModel::takeOffCuts), but the global cuts were not applied to solver_ yet.
>> 
>> Then, my question is
>> 1. Should I have added the global cuts manually to solver_ before getting into takeOffCuts()?
>> 2. or should this be handled in OsiClpSolverInterface side?
>> 
>> Thanks all for your helps in advance,
>> 
>> Best,
>> 
>> Kibaek
>> 
>> 
>> _______________________________________________
>> Cbc mailing list
>> Cbc at list.coin-or.org
>> http://list.coin-or.org/mailman/listinfo/cbc
> 
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cbc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20141124/e7f83bbe/attachment.html>


More information about the Cbc mailing list