Changeset 357


Ignore:
Timestamp:
Feb 23, 2007 6:36:13 PM (13 years ago)
Author:
pbelotti
Message:

fixed some memory leaks

Location:
branches/Couenne/Couenne/src
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • branches/Couenne/Couenne/src/convex/CouenneCutGenerator.cpp

    r340 r357  
    5353  }
    5454
    55   if (!pool_)
     55  if (pool_)
    5656    free (pool_);
    5757
  • branches/Couenne/Couenne/src/convex/generateCuts.cpp

    r356 r357  
    4141      // if there exists violation, add constraint
    4242
     43      OsiRowCut *orc = createCut (0., 0, con -> Body () -> Index (), 1.);
     44
     45      /*
    4346      OsiRowCut *orc   = new OsiRowCut;
    4447      CouNumber *coeff = new CouNumber [1];
     
    4952
    5053      orc -> setRow (1, index, coeff);
     54      */
    5155
    52       if (lb > - COUENNE_INFINITY + 1) orc -> setLb (lb);
    53       if (ub <   COUENNE_INFINITY - 1) orc -> setUb (ub);
     56      if (orc) {
     57        if (lb > - COUENNE_INFINITY + 1) orc -> setLb (lb);
     58        if (ub <   COUENNE_INFINITY - 1) orc -> setUb (ub);
     59       
     60        cs.insert (orc);
    5461
    55       cs.insert (orc);
     62        delete orc;
     63      }
     64      //      delete [] coeff;
     65      //      delete [] index;
    5666    }
    5767  }
  • branches/Couenne/Couenne/src/convex/operators/conv-exprAbs.cpp

    r309 r357  
    7777      }
    7878    }
     79
     80  delete lbe;
     81  delete ube;
    7982}
  • branches/Couenne/Couenne/src/convex/operators/conv-exprDiv.cpp

    r312 r357  
    102102      && (cut = cg -> createCut (yu*wl, +1, xi, CouNumber (-1.), wi, yu, yi, wl)))
    103103    cs.insert (cut);
     104
     105  delete yle; delete yue;
     106  delete wle; delete wue;
     107  delete xle; delete xue;
    104108}
  • branches/Couenne/Couenne/src/convex/operators/conv-exprInv.cpp

    r307 r357  
    112112
    113113  cg -> addEnvelope (cs, sign, inv, oppInvSqr, w_ind, x_ind, x, l, u);
     114
     115  delete xle;
     116  delete xue;
    114117}
  • branches/Couenne/Couenne/src/convex/operators/conv-exprLog.cpp

    r306 r357  
    6969
    7070  cg -> addEnvelope (cs, -1, log, inv, w_ind, x_ind, x, l, u, true);
     71
     72  delete le;
     73  delete ue;
    7174}
  • branches/Couenne/Couenne/src/convex/operators/conv-exprMul.cpp

    r306 r357  
    212212                                 x_ind, yu, y_ind, xl)))
    213213    cs.insert (cut);
    214 }
     214
     215  delete xle; delete xue;
     216  delete yle; delete yue;
     217  delete wle; delete wue;
     218}
  • branches/Couenne/Couenne/src/convex/operators/conv-exprPow.cpp

    r310 r357  
    207207    addPowEnvelope (cg, cs, w_ind, x_ind, x, k, l, u, sign);
    208208  }
     209
     210  delete xle; delete xue;
     211  delete wle; delete wue;
    209212}
  • branches/Couenne/Couenne/src/convex/operators/conv-exprSinCos.cpp

    r306 r357  
    109109                              x_ind, CouNumber (1.))))
    110110    cs.insert (cut);
     111
     112  delete lbe;
     113  delete ube;
    111114}
  • branches/Couenne/Couenne/src/convex/update_conv.cpp

    r356 r357  
    6868  }
    6969  */
     70
    7071  if (!bonCs_) {
    7172
     
    8283    bonOs_ = new OsiClpSolverInterface;
    8384
    84     int nvars = problem_ -> nVars () + problem_ -> nAuxs ();
     85    int nvars = problem_ -> nVars () +
     86                problem_ -> nAuxs ();
    8587
    8688    for (int i=0; i < nvars; i++)
     
    108110  generateCuts (*bonOs_, *bonCs_);
    109111
     112  // give the possibly shrunken variable bounds to the caller problem
    110113
    111114  CouNumber *lb = const_cast <CouNumber *>(bonOs_ -> getColLower ()),
     
    116119    curub [i] = ub [i];
    117120  }
    118 
    119121
    120122  /*
     
    136138
    137139  /*
    138 
    139140  for (int i=0; i<problem_ -> nVars (); i++) {
    140141    printf ("%4d:  %12.3f [%12.3f %12.3f]\n",
     
    165166  }
    166167  */
     168
    167169  return ncuts_;
    168170}
  • branches/Couenne/Couenne/src/include/exprBound.h

    r304 r357  
    4141  // Constructors, destructor
    4242  exprLowerBound  (int varIndex): exprVar (varIndex) {}
    43   ~exprLowerBound () {}
     43  //  ~exprLowerBound () {}
    4444
    4545  // string equivalent
     
    8181  exprUpperBound  (int varIndex):
    8282    exprVar (varIndex) {}
    83   ~exprUpperBound () {}
     83  //  ~exprUpperBound () {}
    8484
    8585  // string equivalent
  • branches/Couenne/Couenne/src/include/exprClone.h

    r340 r357  
    2828
    2929  /// destructor
    30   ~exprClone () {}
     30  //  ~exprClone () {}
    3131
    3232  /// copy constructor
  • branches/Couenne/Couenne/src/include/exprConst.h

    r340 r357  
    3636
    3737  // Destructor
    38   ~exprConst () {}
     38  //  ~exprConst () {}
    3939
    4040  // Copy constructor
  • branches/Couenne/Couenne/src/include/exprCopy.h

    r340 r357  
    3434  exprCopy  (expression *copy):
    3535    copy_ (copy) {}
    36   ~exprCopy () {}
     36  //  ~exprCopy () {}
    3737
    3838  // copy constructor
  • branches/Couenne/Couenne/src/include/exprIVar.h

    r310 r357  
    3232
    3333  // destructor
    34   ~exprIVar () {}
     34  //  ~exprIVar () {}
    3535
    3636  // copy constructor
  • branches/Couenne/Couenne/src/include/exprOp.h

    r342 r357  
    4646    {arglist_ [0] = arg0; arglist_ [1] = arg1;}
    4747
    48  ~exprOp ();
     48  ~exprOp ();
    4949
    5050  // copy constructor
  • branches/Couenne/Couenne/src/include/exprVar.h

    r330 r357  
    3939
    4040  // destructor
    41   ~exprVar () {}
     41  virtual  ~exprVar () {}
    4242
    4343  // copy constructor
  • branches/Couenne/Couenne/src/include/operators/exprAbs.h

    r342 r357  
    2525  exprAbs  (expression *al):
    2626    exprUnary (al) {} //< non-leaf expression, with argument list
    27   ~exprAbs () {}
     27  //  ~exprAbs () {}
    2828
    2929  /// the operator's function
  • branches/Couenne/Couenne/src/include/operators/exprBDiv.h

    r342 r357  
    2424    exprOp (al, n) {} //< non-leaf expression, with argument list
    2525
    26   ~exprLBDiv () {}
     26  //  ~exprLBDiv () {}
    2727
    2828  // cloning method
     
    7878    exprOp (al, n) {} //< non-leaf expression, with argument list
    7979
    80   ~exprUBDiv () {}
     80  //  ~exprUBDiv () {}
    8181
    8282  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprBMul.h

    r342 r357  
    2424    exprOp (al, n) {} //< non-leaf expression, with argument list
    2525
    26   ~exprLBMul () {}
     26  //  ~exprLBMul () {}
    2727
    2828  // cloning method
     
    8282    exprOp (al, n) {} //< non-leaf expression, with argument list
    8383
    84   ~exprUBMul () {}
     84  //  ~exprUBMul () {}
    8585
    8686  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprCos.h

    r342 r357  
    2727    exprUnary (al) {}
    2828
    29   ~exprCos () {}
     29  //  ~exprCos () {}
    3030
    3131  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprDiv.h

    r342 r357  
    2727    exprOp (arg0, arg1) {}
    2828
    29   ~exprDiv () {}
     29  //  ~exprDiv () {}
    3030
    3131  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprExp.h

    r342 r357  
    2222  exprExp  (expression *al):
    2323    exprUnary (al) {} //< non-leaf expression, with argument list
    24   ~exprExp () {}
     24  //  ~exprExp () {}
    2525
    2626  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprInv.h

    r342 r357  
    2828  exprInv  (expression *al):
    2929    exprUnary (al) {} //< non-leaf expression, with argument list
    30   ~exprInv () {}
     30  //  ~exprInv () {}
    3131
    3232  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprLog.h

    r342 r357  
    2525    exprUnary (al) {} //< non-leaf expression, with argument list
    2626
    27   ~exprLog () {}
     27  //  ~exprLog () {}
    2828
    2929  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprMax.h

    r342 r357  
    2929  }
    3030
    31   ~exprMax () {}
     31  //  ~exprMax () {}
    3232
    3333  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprMin.h

    r342 r357  
    2929  }
    3030
    31   ~exprMin () {}
     31  //  ~exprMin () {}
    3232
    3333  // cloning method
  • branches/Couenne/Couenne/src/include/operators/exprMul.h

    r342 r357  
    2727    exprOp (arg0, arg1) {}
    2828
    29   ~exprMul () {}
     29  //  ~exprMul () {}
    3030
    3131  // cloning method
  • branches/Couenne/Couenne/src/problem/problem.cpp

    r352 r357  
    178178
    179179CouenneProblem::~CouenneProblem () {
    180   /*
    181   free (x_);
    182   free (lb_);
    183   free (ub_);
    184   */
     180
     181  if (x_) {
     182    free (x_);
     183    free (lb_);
     184    free (ub_);
     185  }
     186
    185187  // delete objectives
    186188  for (std::vector <Objective *>::iterator i  = objectives_ . begin ();
     
    208210
    209211void CouenneProblem::update (CouNumber *x, CouNumber *l, CouNumber *u) {
    210 
     212  /*
    211213  x_  = x;
    212214  lb_ = l;
    213215  ub_ = u;
    214 
    215   /*
     216  */
     217
    216218  static int curr_size = -1;
    217219
     
    232234    ub_ [i] = u [i];
    233235  }
    234   */
     236
    235237  expression::update (x_, lb_, ub_);
    236238}
  • branches/Couenne/Couenne/src/readnl/readnl.cpp

    r348 r357  
    307307  // initial x ////////////////////////////////////////////////////////////////////
    308308
    309   if (X0)
    310     for (int i=n_var; i--;)
    311       x_ [i] = (havex0 [i]) ? X0 [i] : 0;
    312   else
    313     for (int i=n_var; i--;) {
     309  for (int i=n_var; i--;)
     310    if (X0 && havex0 [i])
     311      x_ [i] = X0 [i];
     312    else {
     313      //    for (int i=n_var; i--;) {
    314314
    315315      CouNumber x, l = lb_ [i], u = ub_ [i];
     
    331331  delete [] alists;
    332332
     333  // restore groups for use by Ipopt: constraints
     334
    333335  for (int k=0; k<n_con; k++)
    334336    if ((asl -> P. cps [k]. nb) || (asl -> P. cps [k]. ng)) {
     
    339341    }
    340342
     343  // and objectives
     344
    341345  for (int k=0; k<n_obj; k++)
    342346    if ((asl -> P. ops [k]. nb) || (asl -> P. ops [k]. ng)) {
  • branches/Couenne/Couenne/src/simplify/simplifiers.cpp

    r293 r357  
    11/*
    2  * Name:    simplifiers.C
     2 * Name:    simplifiers.cpp
    33 * Author:  Pietro Belotti
    44 * Purpose: simplifiers for main operators (+,*,-)
     
    9595
    9696  nargs_ = j;
    97   /*
    98   printf ("////////////////////////////// nargs=%d, %d, %d\n", nargs_,
    9997
    100           ((fabs (c - null_element) < COUENNE_EPS) || !one_fun),
    101           ((nargs_ == 1) && ((fabs (c - null_element) > COUENNE_EPS) || !one_fun)));
    102   */
    103   // since C++ has no corresponding to realloc(), copy arglist_ to a
    104   // smaller array and delete it
    105   /*
    106   expression ** new_arglist = new expression * [nargs_];
    107 
    108   for (i=nargs_; i--;)
    109     new_arglist [i] = arglist_ [i];
    110 
    111   delete [] arglist_;
    112 
    113   arglist_ = new_arglist;
    114   */
    11598  // only say shrinking simplified arg list if there is just the
    11699  // constant
Note: See TracChangeset for help on using the changeset viewer.