Changeset 155


Ignore:
Timestamp:
Jun 16, 2009 4:19:39 PM (12 years ago)
Author:
pbelotti
Message:

CouenneProblem::objects_ is now a vector of objects, not of pointers to objects.

Location:
trunk/Couenne/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/branch/CouenneComplObject.cpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    CouenneComplObject.cpp
    44 * Authors: Pietro Belotti, Lehigh University
  • trunk/Couenne/src/branch/CouenneComplObject.hpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    CouenneComplObject.hpp
    44 * Authors: Pietro Belotti, Lehigh University
  • trunk/Couenne/src/branch/CouenneVarObject.cpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    CouenneVarObject.cpp
    44 * Authors: Pietro Belotti, Carnegie Mellon University
     
    114114  for (std::set <int>::iterator i = deplist.begin (); i != deplist.end (); ++i) {
    115115
    116     CouenneObject *obj = problem_ -> Objects () [*i];
     116    const CouenneObject &obj = problem_ -> Objects () [*i];
    117117
    118118    CouNumber improv = 0.;
    119119
    120     assert (obj -> Reference ());
     120    assert (obj. Reference ());
    121121
    122122    if (jnlst_ -> ProduceOutput (J_MATRIX, J_BRANCHING)) {
    123123      printf ("  ** ");
    124       obj -> Reference ()            -> print ();
    125       if (reference_ -> Image ()) {printf (" := "); obj -> Reference () -> Image () -> print ();}
     124      obj. Reference () -> print ();
     125      if (reference_ -> Image ()) {printf (" := "); obj. Reference () -> Image () -> print ();}
    126126      printf ("\n");
    127127    }
    128128
    129     if (obj -> Reference ()) {
    130       if (obj -> Reference () -> Image ())
    131         improv = obj -> Reference () -> Image ()
    132           -> selectBranch (obj, info,                      // input parameters
     129    if (obj. Reference ()) {
     130      if (obj. Reference () -> Image ())
     131        improv = obj. Reference () -> Image ()
     132          -> selectBranch (&obj, info,                      // input parameters
    133133                           brVar, brPts, brDist, whichWay); // result: who, where, distances, direction
    134134      else {
    135         brVar = obj -> Reference ();
     135        brVar = obj. Reference ();
    136136        brPts  = (double *) realloc (brPts, sizeof (double));
    137137        brDist = (double *) realloc (brDist, 2 * sizeof (double));
    138138
    139         double point = info -> solution_ [obj -> Reference () -> Index ()];
     139        double point = info -> solution_ [obj. Reference () -> Index ()];
    140140
    141141        *brPts = point;
     
    165165        (fabs (*brPts) < COU_MAX_COEFF)) { // and branching pt is limited
    166166
    167       criticalObject = problem_ -> Objects () [*i]; // set this object as the branch creator
     167      criticalObject = &(problem_ -> Objects () [*i]); // set this object as the branch creator
    168168
    169169      brdistDn = brDist [0];
     
    273273bool CouenneVarObject::isCuttable () const {
    274274
    275   const std::set <int>                &deplist = problem_ -> Dependence () [reference_ -> Index ()];
    276   const std::vector <CouenneObject *> &objects = problem_ -> Objects ();
     275  const std::set <int>              &deplist = problem_ -> Dependence () [reference_ -> Index ()];
     276  const std::vector <CouenneObject> &objects = problem_ -> Objects ();
    277277
    278278  for (std::set <int>::const_iterator depvar = deplist. begin ();
    279279       depvar != deplist. end (); ++depvar)
    280     if (!(objects [*depvar] -> isCuttable ()))
     280    if (!(objects [*depvar]. isCuttable ()))
    281281      return false;
    282282
  • trunk/Couenne/src/branch/infeasibility.cpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    infeasibility.cpp
    44 * Authors: Pietro Belotti, Carnegie Mellon University
     
    116116    // otherwise, return a nonzero infeasibility, if necessary. It
    117117    // might make sense to branch on it
    118     const CouenneObject *obj = problem_ -> Objects () [reference_ -> Index ()];
     118    const CouenneObject &obj = problem_ -> Objects () [reference_ -> Index ()];
    119119
    120     double retval = (obj -> Reference ()) ?
     120    double retval = (obj. Reference ()) ?
    121121      (1. - 1. / (1. + info -> upper_ [index] - info -> lower_ [index])) *
    122       weiSum * obj -> checkInfeasibility (info) : 0.;
     122      weiSum * obj. checkInfeasibility (info) : 0.;
    123123
    124124    return retval;
     
    140140      // *i is the index of an auxiliary that depends on reference_
    141141
    142       const CouenneObject *obj = problem_ -> Objects () [*i];
    143       CouNumber infeas = (obj -> Reference ()) ? obj -> checkInfeasibility (info) : 0.;
     142      const CouenneObject &obj = problem_ -> Objects () [*i];
     143      CouNumber infeas = (obj. Reference ()) ? obj. checkInfeasibility (info) : 0.;
    144144
    145145      if (infeas > infmax) infmax = infeas;
  • trunk/Couenne/src/branch/infeasibilityVT.cpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    infeasibilityVT.cpp
    44 * Authors: Pietro Belotti, Carnegie Mellon University
     
    103103         i != dependence.end (); ++i) {
    104104
    105       const CouenneObject *obj = problem_ -> Objects () [*i];
    106       assert (obj -> Reference ());
     105      const CouenneObject &obj = problem_ -> Objects () [*i];
     106      assert (obj. Reference ());
    107107
    108108      CouNumber
    109109        left   = xcurr,
    110110        right  = xcurr,
    111         infeas = obj -> checkInfeasibility (info);
     111        infeas = obj. checkInfeasibility (info);
    112112
    113113      if (infeas > maxInf)
     
    121121        // MathProg A: 99, pp. 563-591)
    122122        //if (obj. Reference () -> Image ()) // not needed! obj only has nonlinear objects
    123         obj -> Reference () -> Image () -> closestFeasible
    124           (reference_, obj -> Reference (), left, right);
     123        obj. Reference () -> Image () -> closestFeasible
     124          (reference_, obj. Reference (), left, right);
    125125
    126126        if (left  < lFeas) lFeas = left;
     
    131131        jnlst_ -> Printf (J_MATRIX, J_BRANCHING, "[%g,%g] --> %g - %g = %g (diff = %g - %g = %g): ",
    132132                          left, right, rFeas, lFeas, rFeas - lFeas,
    133                           (obj -> Reference () -> Image ()) ?
    134                           (*(obj -> Reference () -> Image ())) () : 0., 
    135                           (*(obj -> Reference ())) (),
    136                           (obj -> Reference () -> Image ()) ?
    137                           (*(obj -> Reference () -> Image ())) () - (*(obj -> Reference ())) () : 0.);
    138         obj ->Reference () -> print ();
    139         if (obj -> Reference () -> Image ())
    140           {printf (" := "); obj -> Reference() -> Image() -> print();}
     133                          (obj. Reference () -> Image ()) ?
     134                          (*(obj. Reference () -> Image ())) () : 0., 
     135                          (*(obj. Reference ())) (),
     136                          (obj. Reference () -> Image ()) ?
     137                          (*(obj. Reference () -> Image ())) () - (*(obj. Reference ())) () : 0.);
     138        obj. Reference () -> print ();
     139        if (obj. Reference () -> Image ())
     140          {printf (" := "); obj. Reference() -> Image() -> print();}
    141141        printf ("\n");
    142142      }
  • trunk/Couenne/src/expression/exprAux.cpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    exprAux.cpp
    44 * Author:  Pietro Belotti
     
    273273/// return proper object to handle expression associated with this
    274274/// variable (NULL if this is not an auxiliary)
    275 CouenneObject *exprAux::properObject (CouenneProblem *p,
     275CouenneObject &exprAux::properObject (CouenneProblem *p,
    276276                                      Bonmin::BabSetupBase *base,
    277277                                      JnlstPtr jnlst) {
     278
     279  CouenneObject *retp = NULL;
    278280
    279281  /*if (image_ -> code () == COU_EXPRMUL) printf ("OK1\n");
     
    293295    // it's a complementarity constraint object!
    294296
    295     return new CouenneComplObject (p, this, base, jnlst);
    296   else return new CouenneObject (p, this, base, jnlst);
    297 }
     297    return CouenneComplObject (p, this, base, jnlst);
     298  else return CouenneObject (p, this, base, jnlst);
     299
     300  //  return (*retp);
     301}
  • trunk/Couenne/src/expression/exprAux.hpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    exprAux.hpp
    44 * Author:  Pietro Belotti
     
    184184  /// return proper object to handle expression associated with this
    185185  /// variable (NULL if this is not an auxiliary)
    186   CouenneObject *properObject (CouenneProblem *p,
     186  CouenneObject &properObject (CouenneProblem *p,
    187187                               Bonmin::BabSetupBase *base,
    188188                               JnlstPtr jnlst);
  • trunk/Couenne/src/expression/exprVar.cpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    exprVar.cpp
    44 * Author:  Pietro Belotti
     
    1010
    1111#include "CouenneCutGenerator.hpp"
     12#include "CouenneObject.hpp"
    1213#include "exprAux.hpp"
    1314#include "exprVar.hpp"
     
    6465expression *exprVar::Lb () {return new exprLowerBound (varIndex_, domain_);}///< lower bound
    6566expression *exprVar::Ub () {return new exprUpperBound (varIndex_, domain_);}///< upper bound
     67
     68
     69// dummy function -- the real one is in exprAux and returns either a
     70// CouenneObject or a CouenneComplObject
     71CouenneObject &exprVar::properObject (CouenneProblem *p,
     72                                      Bonmin::BabSetupBase *base,
     73                                      JnlstPtr jnlst_) {
     74  return (*(new CouenneObject ()));
     75}
  • trunk/Couenne/src/expression/exprVar.hpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    exprVar.hpp
    44 * Author:  Pietro Belotti
     
    192192  /// return proper object to handle expression associated with this
    193193  /// variable (NULL if this is not an auxiliary)
    194   virtual CouenneObject *properObject (CouenneProblem *p,
     194  virtual CouenneObject &properObject (CouenneProblem *p,
    195195                                       Bonmin::BabSetupBase *base,
    196                                        JnlstPtr jnlst_)
    197   {return NULL;}
     196                                       JnlstPtr jnlst_);
    198197};
    199198
  • trunk/Couenne/src/expression/expression.cpp

    r141 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    expression.cpp
    44 * Author:  Pietro Belotti
  • trunk/Couenne/src/problem/CouenneProblem.hpp

    r154 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    CouenneProblem.hpp
    44 * Author:  Pietro Belotti
     
    159159  /// when finding all objects related to (having as argument) a
    160160  /// single variable
    161   std::vector <CouenneObject *> objects_;
     161  std::vector <CouenneObject> objects_;
    162162
    163163  /// each element is true if variable is integer and, if auxiliary,
     
    455455
    456456  /// return object vector
    457   const std::vector <CouenneObject *> &Objects () const
     457  const std::vector <CouenneObject> &Objects () const
    458458  {return objects_;}
    459459
  • trunk/Couenne/src/problem/CouenneProblemConstructors.cpp

    r154 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    CouenneProblemConstructors.cpp
    44 * Author:  Pietro Belotti
     
    223223  if (unusedOriginalsIndices_)
    224224    free (unusedOriginalsIndices_);
    225 
    226   // clear objects_, but only those elements that were copied from the
    227   // nullObject in fillDependence.cpp
    228   // for (std::vector <CouenneObject *>::iterator i = objects_.begin ();
    229   //        i != objects_. end (); ++i)
    230 //     //if ((*i) && ((*i) -> Reference () == NULL))
    231 //       delete (*i);
    232225}
  • trunk/Couenne/src/problem/fillDependence.cpp

    r154 r155  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    fillDependence.cpp
    44 * Author:  Pietro Belotti
     
    3535        && ((*i) -> Image () -> Linearity () > LINEAR)) {  // and nonlinear
    3636
    37       CouenneObject *infeasObj = (*i) -> properObject (this, base, jnlst_);
     37      CouenneObject &infeasObj = (*i) -> properObject (this, base, jnlst_);
    3838
    39       if (!infeasObj) // found something that will never be infeasible
     39      if (!(infeasObj.Reference ())) // found something that will never be infeasible
    4040        continue;
    4141
     
    5959      }
    6060
    61     } else objects_.push_back (new CouenneObject (nullObject));
     61    } else objects_.push_back (nullObject);
    6262    // null object for original and linear auxiliaries
    6363  }
Note: See TracChangeset for help on using the changeset viewer.