<br><font size=2 face="sans-serif">Xavier,</font>
<br>
<br><font size=2 face="sans-serif">With your new example, I eventually
managed to get it to give me a memory leak with Clp/stable. The putative
leak is in Clp/trunk but is very unlikely to occur as the +-1 matrix is
switched off by default and can not easily be switched on using OsiClpSolverInterface.</font>
<br>
<br><font size=2 face="sans-serif">So I would switch to trunk. I
will fix leak anyway - but that will only be in trunk. If you need
a +-1 matrix for speed (and are not doing branch and cut) then you will
have to wait a day or two.</font>
<br>
<br><font size=2 face="sans-serif">John Forrest</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>"xavier warin"
<xavier.warin@gmail.com></b> </font>
<br><font size=1 face="sans-serif">Sent by: coin-lpsolver-bounces@list.coin-or.org</font>
<p><font size=1 face="sans-serif">09/13/2007 07:24 AM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">coin-lpsolver@list.coin-or.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">Olivier CORMIER <olivier.cormier@edf.fr></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">[Coin-lpsolver] Re: Re: Memory leaks
(John J Forrest)</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=3>Dear John<br>
<br>
I agree on the small example i gave you. In fact i noticed yesterday that
i was perhaps linking against an old coin version.<br>
I crashed my whole installation and i installed Coin again.<br>
On the small example i gave you, no problem if you add the good delete.
<br>
On our own problem the problem is present on Linux and Windows.<br>
<br>
While doing optimization on the small following problem :<br>
<br>
//// Interface de résolution COIN<br>
boost::shared_ptr<OsiSolverInterface> bsi; <br>
bsi = boost::shared_ptr<OsiSolverInterface> ( new OsiClpSolverInterface
);<br>
<br>
// nombre de dates d'exercices<br>
int N = exerc.size() ;<br>
<br>
// nombre de colonnes<br>
int n_cols = 2*N ;<br>
<br>
Array<double,1> bobjective(n_cols);<br>
Array<double,1> bcol_lb(n_cols);<br>
Array<double,1> bcol_ub(n_cols);<br>
<br>
// fonction objectif<br>
for (int i = 0 ; i < N ; ++i)<br>
{<br>
bobjective(i) = - (future(i+1)- Cout_Tirage(i+1))*exp(-taux(i+1))*Duree(i+1)
; <br>
bobjective(i+N) = (future(i+1) + Cout_Injection(i+1))*exp(-taux(i+1))*Duree(i+1);<br>
}<br>
for (int i = 0 ; i < N ; ++i)<br>
{<br>
bcol_lb(i) = 0.;<br>
bcol_lb(i+N) = 0.;<br>
bcol_ub(i) = Tirage(i+1); <br>
bcol_ub(i+N) = Injection(i+1);<br>
}<br>
<br>
<br>
// pour la matrice des contraintes<br>
int n_rows = N ;<br>
<br>
Array<double,1> brow_lb(n_rows);<br>
Array<double,1> brow_ub(n_rows); <br>
<br>
// création matrice contrainte<br>
Array<int,1> bligne(N*(N+1));<br>
Array<int,1> bcolonne(N*(N+1));<br>
Array<double,1> belement(N*(N+1));<br>
int ielement = 0;<br>
<br>
for (int j = 0 ; j < N ; ++j) <br>
{<br>
brow_lb(j) = Stock_Min(j+2) -Stock_Init ;<br>
brow_ub(j) = Stock_Max(j+2) -Stock_Init ;<br>
for (int i = 0 ; i <= j ; ++i)<br>
{<br>
double d = 1.;<br>
bcolonne(ielement) = i;<br>
bligne(ielement) = j; <br>
belement(ielement) = -d;<br>
ielement++;<br>
<br>
bcolonne(ielement) = i+N;<br>
bligne(ielement) = j;<br>
belement(ielement) = d;<br>
ielement++;<br>
}<br>
}<br>
<br>
<br>
bsi->loadProblem(CoinPackedMatrix(false, bligne.data(), bcolonne.data(),
belement.data(), ielement), <br>
bcol_lb.data(), bcol_ub.data(), bobjective.data(),
brow_lb.data(), brow_ub.data());<br>
<br>
bsi->initialSolve();<br>
<br>
// Check the solution <br>
My_assert( bsi->isProvenOptimal() ) ;<br>
#if defined(BZ_DEBUG)<br>
std::cout << "Found optimal solution!" <<
std::endl; <br>
std::cout << "Objective value bsi is " <<
bsi->getObjValue() << std::endl; <br>
#endif<br>
<br>
<br>
// const double *solution;<br>
const double *bsolution;<br>
bsolution = bsi->getColSolution();<br>
// sortie Blitz des valeurs de tirages puis d'injection en chaque
date d'exercice<br>
Array<double,1> sortie(n_cols, blitz::fortranArray);<br>
for(int i = 1; i <= n_cols; i++)<br>
sortie(i) = bsolution[i-1] ; // stockage du
resultat<br>
<br>
There are leaks.<br>
Using valgrind we found that it is due to an allocation of a CoinPackedMatrix
in <br>
<br>
==29301== 1,560 bytes in 26 blocks are definitely lost in loss record 657
of 723<br>
==29301== at 0x401DB31: operator new(unsigned) (vg_replace_malloc.c:163)<br>
==29301== by 0x783B56B: ClpPlusMinusOneMatrix::getPackedMatrix()
const ( ClpPlusMinusOneMatrix.cpp:1049)<br>
==29301== by 0x77DBAF0: ClpModel::matrix() const (ClpModel.hpp:555)<br>
==29301== by 0x786144A: ClpSimplex::tightenPrimalBounds(double,
int) (ClpSimplex.cpp:3939)<br>
==29301== by 0x78ADAD1: ClpSimplex::initialSolve(ClpSolve&)
( ClpSolve.cpp:856)<br>
==29301== by 0x77DB54F: OsiClpSolverInterface::initialSolve()
(OsiClpSolverInterface.cpp:274)<br>
<br>
This is due to the fact that there are 1. in the constraint matrix. In
this case we use ClpPLusMinusOneMatrix ::getPackedMatrix() with an
allocation. <br>
When we slightly shift the value to 1. + epsilon the problem disappear
because we don't construct this matrix anymore.<br>
<br>
I hope it will help you.<br>
Sincerely yours<br>
<br>
Xavier Warin</font><tt><font size=2>_______________________________________________<br>
Coin-lpsolver mailing list<br>
Coin-lpsolver@list.coin-or.org<br>
http://list.coin-or.org/mailman/listinfo/coin-lpsolver<br>
</font></tt>
<br>