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&nbsp; present on Linux and Windows.<br><br>While doing optimization on the small following problem :<br><br>&nbsp; //// Interface de résolution COIN<br>&nbsp; boost::shared_ptr&lt;OsiSolverInterface&gt; bsi;
<br>&nbsp; bsi = boost::shared_ptr&lt;OsiSolverInterface&gt; ( new OsiClpSolverInterface );<br>&nbsp; <br>&nbsp; // nombre de dates d&#39;exercices<br>&nbsp; int N = exerc.size() ;<br><br>&nbsp; //&nbsp; nombre de colonnes<br>&nbsp; int n_cols = 2*N ;<br><br>
&nbsp; Array&lt;double,1&gt; bobjective(n_cols);<br>&nbsp; Array&lt;double,1&gt; bcol_lb(n_cols);<br>&nbsp; Array&lt;double,1&gt; bcol_ub(n_cols);<br><br>&nbsp; // fonction objectif<br>&nbsp; for (int i = 0 ; i &lt; N ; ++i)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bobjective(i) =&nbsp; - (future(i+1)- Cout_Tirage(i+1))*exp(-taux(i+1))*Duree(i+1) ;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bobjective(i+N) = (future(i+1) + Cout_Injection(i+1))*exp(-taux(i+1))*Duree(i+1);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; for (int i = 0 ; i &lt; N ; ++i)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bcol_lb(i) =&nbsp; 0.;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bcol_lb(i+N) = 0.;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bcol_ub(i) = Tirage(i+1);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bcol_ub(i+N) =&nbsp; Injection(i+1);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;<br>&nbsp; // pour la matrice des contraintes<br>&nbsp; int n_rows = N ;<br>&nbsp; <br>&nbsp; Array&lt;double,1&gt; brow_lb(n_rows);<br>&nbsp; Array&lt;double,1&gt; brow_ub(n_rows);
<br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; // création matrice contrainte<br>&nbsp; Array&lt;int,1&gt; bligne(N*(N+1));<br>&nbsp; Array&lt;int,1&gt; bcolonne(N*(N+1));<br>&nbsp; Array&lt;double,1&gt; belement(N*(N+1));<br>&nbsp; int ielement = 0;<br><br>&nbsp; for (int j = 0 ; j &lt; N ; ++j)
<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; brow_lb(j) = Stock_Min(j+2) -Stock_Init ;<br>&nbsp;&nbsp;&nbsp; brow_ub(j) = Stock_Max(j+2) -Stock_Init ;<br>&nbsp;&nbsp;&nbsp; for (int i = 0&nbsp; ;&nbsp;&nbsp; i &lt;= j&nbsp;&nbsp; ; ++i)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; double d = 1.;<br>&nbsp;&nbsp;&nbsp; bcolonne(ielement) = i;<br>&nbsp;&nbsp;&nbsp; bligne(ielement) = j;
<br>&nbsp;&nbsp;&nbsp; belement(ielement) = -d;<br>&nbsp;&nbsp;&nbsp; ielement++;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; <br>&nbsp;&nbsp;&nbsp; bcolonne(ielement) = i+N;<br>&nbsp;&nbsp;&nbsp; bligne(ielement) = j;<br>&nbsp;&nbsp;&nbsp; belement(ielement) = d;<br>&nbsp;&nbsp;&nbsp; ielement++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br><br><br>&nbsp; bsi-&gt;loadProblem(CoinPackedMatrix(false, 
bligne.data(), bcolonne.data(), belement.data(), ielement), <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; bcol_lb.data(), bcol_ub.data(), bobjective.data(), brow_lb.data(), brow_ub.data());<br>&nbsp; <br>&nbsp; bsi-&gt;initialSolve();<br><br>&nbsp; // Check the solution
<br>&nbsp; My_assert( bsi-&gt;isProvenOptimal() ) ;<br>#if defined(BZ_DEBUG)<br>&nbsp; std::cout &lt;&lt; &quot;Found optimal solution!&quot; &lt;&lt; std::endl; <br>&nbsp; std::cout &lt;&lt; &quot;Objective value bsi is &quot; &lt;&lt; bsi-&gt;getObjValue() &lt;&lt; std::endl;
<br>#endif<br><br><br>//&nbsp; const double *solution;<br>&nbsp; const double *bsolution;<br>&nbsp; bsolution = bsi-&gt;getColSolution();<br>&nbsp; // sortie Blitz des valeurs de tirages puis d&#39;injection en chaque date d&#39;exercice<br>
&nbsp; Array&lt;double,1&gt; sortie(n_cols, blitz::fortranArray);<br>&nbsp; for(int i = 1; i &lt;= n_cols; i++)<br>&nbsp;&nbsp;&nbsp; sortie(i) = bsolution[i-1] ;&nbsp;&nbsp;&nbsp; // 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==&nbsp;&nbsp;&nbsp; at 0x401DB31: operator new(unsigned) (vg_replace_malloc.c:163)<br>==29301==&nbsp;&nbsp;&nbsp; by 0x783B56B: ClpPlusMinusOneMatrix::getPackedMatrix() const (
ClpPlusMinusOneMatrix.cpp:1049)<br>==29301==&nbsp;&nbsp;&nbsp; by 0x77DBAF0: ClpModel::matrix() const (ClpModel.hpp:555)<br>==29301==&nbsp;&nbsp;&nbsp; by 0x786144A: ClpSimplex::tightenPrimalBounds(double, int) (ClpSimplex.cpp:3939)<br>==29301==&nbsp;&nbsp;&nbsp; by 0x78ADAD1: ClpSimplex::initialSolve(ClpSolve&amp;) (
ClpSolve.cpp:856)<br>==29301==&nbsp;&nbsp;&nbsp; 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&nbsp; ClpPLusMinusOneMatrix ::getPackedMatrix() with an allocation.
<br>When we slightly shift the value to 1. + epsilon&nbsp; the problem disappear because we don&#39;t construct this matrix anymore.<br><br>I hope it will help you.<br>Sincerely yours<br><br>Xavier Warin<br>