[Coin-discuss] Correct use of CglPreProcess with CbcModel?

James Gibbons James.Gibbons at nottingham.ac.uk
Wed Mar 29 09:14:49 EST 2006


Hi John,

I've tried the second way, i.e using:

//strategy and branching
    CbcStrategyDefault strategy(false,10);
    //Set up pre-processing to find sos if wanted
    if (preprocess_) strategy.setupPreProcessing(2);
    model.setStrategy(strategy);

Unfortunately, I still get a memory leak, at roughly the same rate as before. To check there isn't something wrong elsewhere in my code I've tried running with everything except the global solve function. Under this scenario there is no memory leak, which I guess confirms that the problem is in CbcModel somewhere.

Incidently, using this second approach am I right in thinking that to get the solution from the CbcModel object (model) back into my original solver0_  (OsiClpSolverInterface) I have to use:

solver0_->setColSolution(model.getColSolution());
solver0_->setRowPrice(model.getRowPrice());

i.e. it doesn't happen automatically as with CglPreProcess?

Thanks,
James

James,

Try the second way of using CglPreProcess as given in sample2.cpp.  This 
uses CbcStrategy and passes that in to Cbcmodel.  So CbcModel handles 
copies of solvers.  If that has a memory leak tell me and I will fix.

John Forrest



"James Gibbons" <James.Gibbons at nottingham.ac.uk> 
Sent by: coin-discuss-bounces at list.coin-or.org
03/28/2006 08:46 AM
Please respond to
Discussions about open source software for Operations Research 
<coin-discuss at list.coin-or.org>


To
<coin-discuss at list.coin-or.org>
cc

Subject
[Coin-discuss] Correct use of CglPreProcess with CbcModel?






Hi,

I'm having some problems using CglPreProcess and CbcModel together. My 
code involves modifying a matrix, solving and changing the many times. My 
code works but it leaks memory until eventually all memory is exhausted. 
The essentials of the code are at the end of this message (note though 
that in my application the LP solve and global solver are in different 
functions, and heuristics and cuts are used). To my naive eye it looks 
like I need to delete solver1 as preProcess returns a new solver instance, 
but this causes a crash. I'm happy to go about things in a different way 
if anyone can recommend an alternative. However, CglPreProcess does reduce 
the time to find a solution for me so I'd like to keep using it,

Thanks,
James

//code as follows

solver0_(new OsiClpSolverInterface());
solver0_->readLp(filename_.c_str(),1e-08);

for(int i=0;i<numRuns;++i) {

                 //LP solve function
                 solver0_->intitalSolve();
 
                 //Global solve function
                 CglPreProcess pinfo1;
                 OsiSolverInterface *solver1 = 
pinfo1.preProcess(*solver0_,false,15);
                 CbcModel model(*solver1);

                 //add cuts and heuristics to model

                 model.branchAndBound();
                 model.deleteObjects();          //is this necessary?
                 pinfo1.postProcess(*model.solver());
                 //delete solver1;               //causes crash   

                 //my update matrix function
                 updateMatrix();
}

delete solver0_;


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.





More information about the Coin-discuss mailing list