<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#FFFFFF" text="#000000">
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><font face="Courier New, Courier, monospace">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 ...</font></small><br>
</blockquote>
Things work fine, if we directly compute a solution without further
preprocessing via<br>
<blockquote><font face="Courier New, Courier, monospace"><small>LP->initialSolve();<br>
LP->branchAndBound();</small></font><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><font face="Courier New, Courier, monospace">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));</font></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>
</body>
</html>