<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Dirk,<br>
<br>
The -cpp was a nice idea - but impossible to keep current - so
something may be broken.<br>
<br>
Try using code from the Cbc/examples driver3.cpp or driver4.cpp
which should give you the same flexibility.<br>
<br>
John Forrest<br>
On 07/05/14 11:18, Dirk Eßer wrote:<br>
</div>
<blockquote cite="mid:536A0873.8030802@web.de" type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-15">
Hello,<br>
<br>
I have a little problem adding a preprocessing step to program
doing MIP solving using the CBC library. The problem is, that the
program fails with more or less random memory corruption (and in
the better cases: with a segfault) some of the time.<br>
<br>
The CbcModel instance is created programmatically<br>
<blockquote><small>OsiClpSolverInterface iface;<br>
CoinPackedMatrix pmx(false, num_columns, num_rows,
num_elements, matrix, columns, starts, lengths);<br>
<br>
iface.setObjSense(-1.0);<br>
iface.loadProblem(pmx, 0, 0, objective, senses, rights, 0);<br>
iface.passInMessageHandler(&printer);<br>
<br>
model_ptr LP(new CbcModel(iface));<br>
... adding stuff via LP->addObjects(...) to declare integer
constraints on variables and a few SOSes ...</small><br>
</blockquote>
Things work fine, if we directly compute a solution without
further preprocessing via<br>
<blockquote><small>LP->initialSolve();<br>
LP->branchAndBound();</small><br>
</blockquote>
We now try to add a pre-processing step to the solution process.
As a starting point, we used the driver code generated by the CBC
command line tool ("-cpp 0", which doesn't compile). <br>
<blockquote><small>OsiSolverInterface* original_solver =
LP->solver();<br>
OsiSolverInterface* cloned_solver =
original_solver->clone();<br>
OsiSolverInterface* configured_solver = 0;<br>
<br>
cloned_solver->passInMessageHandler(LP->messageHandler());<br>
cloned_solver->setHintParam(OsiDoInBranchAndCut, true,
OsiHintDo);<br>
<br>
CglPreProcess processor;<br>
<br>
{<br>
CglProbing prober;<br>
prober.setUsingObjective(1);<br>
prober.setMaxPass(3);<br>
prober.setMaxProbeRoot(cloned_solver->getNumCols());<br>
prober.setMaxElements(100);<br>
prober.setMaxLookRoot(50);<br>
prober.setRowCuts(3);<br>
processor.addCutGenerator(&prober);<br>
}<br>
<br>
configured_solver =
processor.preProcessNonDefault(*cloned_solver, 2, 10); <br>
<br>
cloned_solver->setHintParam(OsiDoInBranchAndCut, false,
OsiHintDo);<br>
<br>
if (!configured_solver)<br>
{<br>
delete cloned_solver;<br>
return status::infeasible;<br>
}<br>
<br>
configured_solver->setHintParam(OsiDoInBranchAndCut, false,
OsiHintDo);<br>
<br>
OsiSolverInterface* configured_clone =
configured_solver->clone();<br>
<br>
LP->assignSolver(configured_clone, true /* Kill previous
solver */); /*-- XXX --*/<br>
LP->initialSolve();<br>
LP->branchAndBound();<br>
<br>
int n_cols = cloned_solver->getNumCols();<br>
processor.postProcess(*LP->solver());<br>
<br>
LP->assignSolver(cloned_solver, true /* Kill previous
solver */);<br>
memcpy(LP->bestSolution(),
LP->solver()->getColSolution(), n_cols *
sizeof(double));</small><br>
</blockquote>
It seems, that we are violating one or two unwritten laws of
memory management with CBC, but I am at loss as what we are doing
wrong here. Any help, hints, pointer to documentation, etc. is
highly appreciated.<br>
<br>
Cheers,<br>
Dirk Eßer<br>
<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>
</body>
</html>