Changeset 931 for trunk


Ignore:
Timestamp:
Dec 24, 2012 11:22:09 AM (7 years ago)
Author:
pbelotti
Message:

fixed leaks in sdpcuts. updated dependencies

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:externals
      •  

        old new  
        1 BuildTools  https://projects.coin-or.org/svn/BuildTools/releases/0.7.3/
         1BuildTools  https://projects.coin-or.org/svn/BuildTools/releases/0.7.4/
        22ThirdParty/ASL  https://projects.coin-or.org/svn/BuildTools/ThirdParty/ASL/releases/1.2.3/
        33ThirdParty/Blas  https://projects.coin-or.org/svn/BuildTools/ThirdParty/Blas/releases/1.2.2/
        44ThirdParty/HSL  https://projects.coin-or.org/svn/BuildTools/ThirdParty/HSL/releases/1.3.3/
        55ThirdParty/Lapack  https://projects.coin-or.org/svn/BuildTools/ThirdParty/Lapack/releases/1.3.3/
        6 ThirdParty/Mumps  https://projects.coin-or.org/svn/BuildTools/ThirdParty/Mumps/releases/1.4.3/
         6ThirdParty/Mumps  https://projects.coin-or.org/svn/BuildTools/ThirdParty/Mumps/releases/1.4.4/
        77ThirdParty/Metis  https://projects.coin-or.org/svn/BuildTools/ThirdParty/Metis/releases/1.2.3/
        8 ThirdParty/SoPlex  https://projects.coin-or.org/svn/BuildTools/ThirdParty/SoPlex/trunk
        9 ThirdParty/SCIP  https://projects.coin-or.org/svn/BuildTools/ThirdParty/SCIP/trunk
        10 CoinUtils  https://projects.coin-or.org/svn/CoinUtils/releases/2.8.7/CoinUtils
        11 Cbc  https://projects.coin-or.org/svn/Cbc/releases/2.7.7/Cbc
        12 Cgl  https://projects.coin-or.org/svn/Cgl/releases/0.57.3/Cgl
        13 Clp  https://projects.coin-or.org/svn/Clp/releases/1.14.7/Clp
        14 Osi  https://projects.coin-or.org/svn/Osi/releases/0.105.4/Osi
        15 Ipopt  https://projects.coin-or.org/svn/Ipopt/releases/3.10.2/Ipopt
         8ThirdParty/SoPlex  https://projects.coin-or.org/svn/BuildTools/ThirdParty/SoPlex/stable/1.2
         9ThirdParty/SCIP  https://projects.coin-or.org/svn/BuildTools/ThirdParty/SCIP/stable/1.2
         10CoinUtils  https://projects.coin-or.org/svn/CoinUtils/releases/2.8.8/CoinUtils
         11Cbc  https://projects.coin-or.org/svn/Cbc/releases/2.7.8/Cbc
         12Cgl  https://projects.coin-or.org/svn/Cgl/releases/0.57.4/Cgl
         13Clp  https://projects.coin-or.org/svn/Clp/releases/1.14.8/Clp
         14Osi  https://projects.coin-or.org/svn/Osi/releases/0.105.7/Osi
         15Ipopt  https://projects.coin-or.org/svn/Ipopt/releases/3.10.3/Ipopt
        1616Bonmin  https://projects.coin-or.org/svn/Bonmin/releases/1.5.3/Bonmin
  • trunk/Couenne/src/cut/sdpcuts/CouenneMatrix.cpp

    r930 r931  
    1818using namespace Couenne;
    1919
     20
     21// copy constructor
     22CouenneSparseVector::CouenneSparseVector (const CouenneSparseVector &rhs) {
     23
     24  for (register std::set <CouenneScalar *, CouenneSparseVector::compare_scalars>::iterator
     25         i  = rhs. elem_. begin ();
     26       i   != rhs. elem_. end   (); ++i)
     27
     28    elem_. insert (new CouenneScalar (**i));
     29}
     30
     31
     32// assignment operator
     33CouenneSparseVector &CouenneSparseVector::operator= (const CouenneSparseVector &rhs) {
     34
     35  for (register std::set <CouenneScalar *, CouenneSparseVector::compare_scalars>::iterator
     36         i  = rhs. elem_. begin ();
     37       i   != rhs. elem_. end   (); ++i)
     38
     39    elem_. insert (new CouenneScalar (**i));
     40
     41  return *this;
     42}
     43
     44#define copy_vectors(from, to) {                                                                                         \
     45  for (std::set <std::pair <int, CouenneSparseVector *>, CouenneExprMatrix::compare_pair_ind>::iterator                  \
     46         rowIt  = from. begin ();                                                                                        \
     47       rowIt   != from. end   (); ++rowIt) {                                                                             \
     48    to . insert (std::pair <int, CouenneSparseVector *> (rowIt -> first, new CouenneSparseVector (*(rowIt -> second)))); \
     49  }                                                                                                                      \
     50}
     51
    2052/// copy constructor
    2153CouenneExprMatrix::CouenneExprMatrix (const CouenneExprMatrix &rhs):
    2254  varIndices_ (rhs.varIndices_) {
    2355
    24   for (std::set <std::pair <int, CouenneSparseVector *>, CouenneExprMatrix::compare_pair_ind>::iterator
    25          rowIt  = rhs. row_. begin ();
    26        rowIt   != rhs. row_. end   (); ++rowIt) {
    27 
    28     row_ . insert (std::pair <int, CouenneSparseVector *> (rowIt -> first, new CouenneSparseVector (*(rowIt -> second))));
    29   }
    30 
    31   for (std::set <std::pair <int, CouenneSparseVector *>, CouenneExprMatrix::compare_pair_ind>::iterator
    32          colIt  = rhs. col_. begin ();
    33        colIt   != rhs. col_. end   (); ++colIt) {
    34 
    35     col_ . insert (std::pair <int, CouenneSparseVector *> (colIt -> first, new CouenneSparseVector (*(colIt -> second))));
    36   }
    37 
     56  copy_vectors(rhs.row_, row_);
     57  copy_vectors(rhs.col_, col_);
     58}
     59
     60/// Assignment operator
     61CouenneExprMatrix &CouenneExprMatrix::operator= (const CouenneExprMatrix &rhs) {
     62
     63  varIndices_ = rhs.varIndices_;
     64
     65  copy_vectors(rhs.row_, row_);
     66  copy_vectors(rhs.col_, col_);
     67
     68  return *this;
    3869}
    3970
     
    6293void CouenneExprMatrix::add_element (int rowInd, int colInd, expression *elem) {
    6394
    64   // don't duplicate, macroize
    65 
    66 #define check_and_insert(indMaj,indMin,vecMaj)                                                       \
     95  // don't duplicate code, macroize
     96
     97#define check_and_insert(indMaj,indMin,vecMaj,elem)                                                  \
    6798  {                                                                                                  \
    6899    std::          pair <int, CouenneSparseVector *> findme (indMaj, NULL);                          \
    69100    std::set <std::pair <int, CouenneSparseVector *>,                                                \
    70               CouenneExprMatrix::compare_pair_ind>::const_iterator check = vecMaj.find (findme);   \
     101              CouenneExprMatrix::compare_pair_ind>::const_iterator check = vecMaj.find (findme);     \
    71102                                                                                                     \
    72103    if (check == vecMaj. end ()) {                                                                   \
     
    77108  }
    78109
    79   check_and_insert (rowInd, colInd, row_);
    80   check_and_insert (colInd, rowInd, col_);
     110  check_and_insert (rowInd, colInd, row_,                elem);
     111  check_and_insert (colInd, rowInd, col_, new exprClone (elem));
    81112}
    82113
     
    162193CouenneExprMatrix::~CouenneExprMatrix () {
    163194
    164  for (std::set <std::pair <int, CouenneSparseVector *>, CouenneExprMatrix::compare_pair_ind>::iterator
    165         i  = row_ . begin ();
    166       i   != row_ . end   (); ++i)
    167 
    168    delete i -> second;
    169 
    170  for (std::set <std::pair <int, CouenneSparseVector *>, CouenneExprMatrix::compare_pair_ind>::iterator
    171         i  = col_ . begin ();
    172       i   != col_ . end   (); ++i)
    173 
    174    delete i -> second;
     195  for (std::set <std::pair <int, CouenneSparseVector *>, CouenneExprMatrix::compare_pair_ind>::iterator
     196         i  = row_ . begin ();
     197       i   != row_ . end   (); ++i)
     198
     199    delete i -> second;
     200
     201  for (std::set <std::pair <int, CouenneSparseVector *>, CouenneExprMatrix::compare_pair_ind>::iterator
     202         i  = col_ . begin ();
     203       i   != col_ . end   (); ++i)
     204
     205    delete i -> second;
    175206}
    176207
     
    187218
    188219CouenneScalar::~CouenneScalar () {
    189   if (elem_ -> Index () < 0) // only delete constants
     220
     221  if (delete_) // only delete constants
    190222    delete elem_;
    191223}
  • trunk/Couenne/src/cut/sdpcuts/CouenneMatrix.hpp

    r930 r931  
    1414#include <vector>
    1515
     16#include "CouenneExprClone.hpp"
     17
    1618namespace Couenne {
    1719
     
    2527  protected:
    2628
    27     int         index_; ///< index of element in vector
    28     expression *elem_;  ///< element
     29    int         index_;  ///< index of element in vector
     30    expression *elem_;   ///< element
     31    bool        delete_; ///< destructor should delete pointer to expression
    2932
    3033  public:
    3134
    3235    CouenneScalar (int index, expression *elem):
    33       index_ (index),
    34       elem_  (elem) {}
     36      index_  (index),
     37      elem_   (elem),
     38      delete_ (elem_ -> code () == COU_EXPRCONST) {}
    3539
    3640    ~CouenneScalar ();
    3741
    3842    CouenneScalar (const CouenneScalar &rhs):
    39       index_ (rhs.index_),
    40       elem_  (rhs.elem_) {}
     43      index_  (rhs.index_),
     44      elem_   (new exprClone (rhs.elem_)),
     45      delete_ (rhs.delete_) {}
    4146
    4247    CouenneScalar &operator= (const CouenneScalar &rhs) {
    43       index_ = rhs.index_;
    44       elem_  = rhs.elem_;
     48      index_  = rhs.index_;
     49      elem_   = new exprClone (rhs.elem_);
     50      delete_ = rhs.delete_;
    4551      return *this;
    4652    }
     
    7884   ~CouenneSparseVector ();
    7985
    80     CouenneSparseVector            (const CouenneSparseVector &rhs) {elem_ = rhs.elem_;}
    81     CouenneSparseVector &operator= (const CouenneSparseVector &rhs) {elem_ = rhs.elem_; return *this;}
     86    CouenneSparseVector            (const CouenneSparseVector &rhs);
     87    CouenneSparseVector &operator= (const CouenneSparseVector &rhs);
    8288    CouenneSparseVector *clone () {return new CouenneSparseVector (*this);}
    8389
     
    8692    void print () const;
    8793
    88     const std::set <CouenneScalar *, compare_scalars> &getElements () {return elem_;}
     94    const std::set <CouenneScalar *, compare_scalars> &getElements () {return elem_;}        ///< returns elements of vector as (ordered) set
    8995
    9096    double               operator *     (const CouenneSparseVector &factor)           const; ///< vector * vector (dot product)
    91     CouenneSparseVector &operator *     (const CouenneExprMatrix &post)             const; ///< vector * matrix
     97    CouenneSparseVector &operator *     (const CouenneExprMatrix   &post)             const; ///< vector * matrix
    9298
    9399    double               multiply_thres (const CouenneSparseVector &v2, double thres) const; ///< stops multiplication if above threshold
     
    119125   ~CouenneExprMatrix ();
    120126
    121     CouenneExprMatrix (const CouenneExprMatrix &rhs);
     127    CouenneExprMatrix            (const CouenneExprMatrix &rhs);
     128    CouenneExprMatrix &operator= (const CouenneExprMatrix &rhs);
    122129
    123130    CouenneExprMatrix *clone () {return new CouenneExprMatrix (*this);}
  • trunk/Couenne/src/cut/sdpcuts/CouenneSdpCuts.cpp

    r930 r931  
    157157  for (std::vector <CouenneExprMatrix *>::iterator
    158158         i  = minors_ . begin ();
    159        i   != minors_ . end   (); ++i) {
    160 
    161     // printf ("\n\n\neliminating\n\n\n");
    162     // (*i) -> print ();
    163     // printf ("\n\nNOW\n\n\n");
     159       i   != minors_ . end   (); ++i)
    164160
    165161    delete (*i);
    166   }
    167162
    168163  // Destroy matrix structures
     
    181176       i   != rhs.minors_ . end   (); ++i)
    182177
    183     minors_ . push_back (*i);
     178    minors_ . push_back (new CouenneExprMatrix (**i));
    184179}
    185180
     
    196191       i   != rhs.minors_ . end   (); ++i)
    197192
    198     minors_ . push_back (*i);
     193    minors_ . push_back (new CouenneExprMatrix (**i));
    199194
    200195  return *this;
     
    202197
    203198
    204 /// Assignment
     199/// clone constructor
    205200CglCutGenerator *CouenneSdpCuts::clone () const
    206201{return new CouenneSdpCuts (*this);}
  • trunk/Dependencies

    r885 r931  
    66ThirdParty/Mumps  https://projects.coin-or.org/svn/BuildTools/ThirdParty/Mumps/stable/1.4
    77ThirdParty/Metis  https://projects.coin-or.org/svn/BuildTools/ThirdParty/Metis/stable/1.2
    8 ThirdParty/SoPlex https://projects.coin-or.org/svn/BuildTools/ThirdParty/SoPlex/trunk
    9 ThirdParty/SCIP   https://projects.coin-or.org/svn/BuildTools/ThirdParty/SCIP/trunk
     8ThirdParty/SoPlex https://projects.coin-or.org/svn/BuildTools/ThirdParty/SoPlex/stable/1.2
     9ThirdParty/SCIP   https://projects.coin-or.org/svn/BuildTools/ThirdParty/SCIP/stable/1.2
    1010CoinUtils         https://projects.coin-or.org/svn/CoinUtils/stable/2.8/CoinUtils
    1111Cbc               https://projects.coin-or.org/svn/Cbc/stable/2.7/Cbc
Note: See TracChangeset for help on using the changeset viewer.