<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Dear John,<div><br></div><div>Thanks for you suggestion. I have found a solution (or workaround?) for the issue, after having a better understanding of Cbc design.</div><div><br></div><div>Just to share my experience:</div><div><br></div><div>During <i>CbcModel::branchAndBound()</i>, 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 <i>generateCuts()</i> function in my cut generators to add cuts to <i>globalCuts_</i> and re-optimize model, when the cut generators are called at solution (<i>atSolution()</i>). Doing that, solver_ now has cuts applied and the correct number of rows before getting into <i>takeOffCuts()</i>. And no more error.</div><div><br></div><div>Thanks again,</div><div>Kibaek</div><div><br><div><div>On Nov 21, 2014, at 5:00 AM, John Forrest <<a href="mailto:john.forrest@fastercoin.com">john.forrest@fastercoin.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<div bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Kibaek,<br>
<br>
If you can give me something to reproduce the problem - using
either the latest Cbc stable or trunk, then I can debug it.<br>
<br>
I have added<br>
<br>
assert
(numberRowsAtContinuous_+totalNumberCuts==solver_->getNumRows());<br>
<br>
near top of CbcModel::takeOffCuts<br>
<br>
If you add that, does it trigger an assert?<br>
<br>
John Forrest<br>
<br>
On 20/11/14 17:24, Kibaek Kim wrote:<br>
</div>
<blockquote cite="mid:6DE8D694-9FF7-4B0A-857D-96F5AB7162AB@gmail.com" type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=us-ascii">
Hello,
<div><br>
</div>
<div>I am testing my global cut generator for outer approximation
of piece-wise linear convex function. My implementation uses <i>OsiBabSolver::solverType_
= 3</i> and manually sets up <i>mipBound_ </i>and <i>bestObjectiveValue_</i>,
while generating global cuts.</div>
<div><br>
</div>
<div>Here is my issue. After running many iterations, Cbc
complains the following:</div>
<div><i> Assertion failed:
(clpMatrix->getNumRows()==modelPtr_->getNumRows()),
function freeCachedResults, file
../../../../Clp/src/OsiClp/OsiClpSolverInterface.cpp, line
4491.</i></div>
<div>and backtrace reports</div>
<div>
<div><i> * frame #0: 0x00007fff9a5c8866
libsystem_kernel.dylib`__pthread_kill + 10</i></div>
<div><i> frame #1: 0x00007fff9948035c
libsystem_pthread.dylib`pthread_kill + 92</i></div>
<div><i> frame #2: 0x00007fff947fbb1a libsystem_c.dylib`abort
+ 125</i></div>
<div><i> frame #3: 0x00007fff947c59bf
libsystem_c.dylib`__assert_rtn + 321</i></div>
<div><i> frame #4: 0x00000001003e3187
MyTest`OsiClpSolverInterface::freeCachedResults(this=0x000000010afb1320)
const + 623 at OsiClpSolverInterface.cpp:4491</i></div>
<div><i> frame #5: 0x00000001003dcd27
MyTest`OsiClpSolverInterface::deleteRows(this=0x000000010afb1320,
num=1, rowIndices=0x000000010afc8380) + 729 at
OsiClpSolverInterface.cpp:3491</i></div>
<div><i> frame #6: 0x00000001000b50af
MyTest`CbcModel::takeOffCuts(this=0x000000010172d000,
newCuts=0x00007fff5fbfd120, allowResolve=true,
saveCuts=0x0000000000000000, numberNewCuts=0,
addedCuts=0x0000000000000000) + 2029 at CbcModel.cpp:9792</i></div>
<div><i> frame #7: 0x00000001000b080f
MyTest`CbcModel::solveWithCuts(this=0x000000010172d000,
cuts=0x00007fff5fbfd120, numberTries=0,
node=0x000000010b31a6c0) + 16359 at CbcModel.cpp:8563</i></div>
<div><i> frame #8: 0x00000001000c9765
MyTest`CbcModel::doOneNode(this=0x000000010172d000,
baseModel=0x000000010172d000, node=0x00007fff5fbfd880,
newNode=0x00007fff5fbfd938) + 2745 at CbcModel.cpp:14944</i></div>
<div><i> frame #9: 0x000000010009b8d8
MyTest`CbcModel::branchAndBound(this=0x000000010172d000,
doStatistics=0) + 49158 at CbcModel.cpp:4500</i></div>
</div>
<div><br>
</div>
<div>The issue is because <i>OsiClpSolverInterface::deleteRows()</i>
tries deleting rows that are out of range. This results in that
the row counter of <i>clpMatrix</i> is reduced whereas the
model row counter is not. The reason that <i>solverCutIndices</i>
in <i>CbcModel::takeOffCuts()</i> contained out-of-range
indices is that <i>CbcMode::globalCuts_</i> were counted in <i>solverCutIndices</i>
(in <i>CbcModel::takeOffCuts</i>), but the global cuts were not
applied to solver_ yet.</div>
<div><br>
</div>
<div>Then, my question is</div>
<div>1. Should I have added the global cuts manually to <i>solver_</i>
before getting into <i>takeOffCuts()</i>?</div>
<div>2. or should this be handled in <i>OsiClpSolverInterface</i>
side?</div>
<div><br>
</div>
<div>Thanks all for your helps in advance,</div>
<div><br>
</div>
<div>Best,</div>
<div><br>
</div>
<div>Kibaek</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Cbc mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Cbc@list.coin-or.org">Cbc@list.coin-or.org</a>
<a class="moz-txt-link-freetext" href="http://list.coin-or.org/mailman/listinfo/cbc">http://list.coin-or.org/mailman/listinfo/cbc</a>
</pre>
</blockquote>
<br>
</div>
_______________________________________________<br>Cbc mailing list<br><a href="mailto:Cbc@list.coin-or.org">Cbc@list.coin-or.org</a><br>http://list.coin-or.org/mailman/listinfo/cbc<br></blockquote></div><br></div></body></html>