Changeset 293


Ignore:
Timestamp:
Mar 30, 2006 6:16:54 AM (14 years ago)
Author:
forrest
Message:

mainly memory leak

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcBranchActual.cpp

    r248 r293  
    712712  else
    713713    preferredWay=-1;
     714  if (preferredWay_)
     715    preferredWay=preferredWay_;
    714716  double weight = fabs(value-nearest);
    715717  // normalize so weight is 0.5 at break even
     
    786788      value = targetValue+0.1;
    787789  }
    788   return new CbcIntegerBranchingObject(model_,sequence_,way,
     790  CbcBranchingObject * branch = new CbcIntegerBranchingObject(model_,sequence_,way,
    789791                                             value);
     792  branch->setOriginalObject(this);
     793  return branch;
    790794}
    791795
     
    11581162  //changeInGuessed += 1.0e8; // bias to stay up
    11591163  newObject->setChangeInGuessed(changeInGuessed);
     1164  newObject->setOriginalObject(this);
    11601165  return newObject;
    11611166}
     
    11971202    preferredWay = (value-below>=upDownSeparator_) ? 1 : -1;
    11981203  }
     1204  if (preferredWay_)
     1205    preferredWay=preferredWay_;
    11991206  if (fabs(value-nearest)<=integerTolerance) {
    12001207    return 0.0;
     
    19681975    bestNumberDown_ = numInfDn;
    19691976    bestObject_=thisOne;
     1977    // See if user is overriding way
     1978    if (thisOne->object()&&thisOne->object()->preferredWay())
     1979      betterWay = thisOne->object()->preferredWay();
    19701980  }
    19711981  return betterWay;
     
    22372247    }
    22382248    // set way in best
    2239     if (whichObject>=0)
    2240       objects[whichObject]->way(bestWay);
     2249    if (whichObject>=0) {
     2250      CbcBranchingObject * bestObject = objects[whichObject];
     2251      if (bestObject->object()&&bestObject->object()->preferredWay())
     2252        bestWay = bestObject->object()->preferredWay();
     2253      bestObject->way(bestWay);
     2254    } else {
     2255      printf("debug\n");
     2256    }
    22412257  }
    22422258  return whichObject;
     
    29212937  CbcBranchingObject * branch;
    29222938  branch = new CbcNWayBranchingObject(model_,this,numberFree,list);
     2939  branch->setOriginalObject(this);
    29232940  delete [] list;
    29242941  delete [] sort;
  • trunk/CbcBranchBase.cpp

    r222 r293  
    2020  :model_(NULL),
    2121   id_(-1),
    22    priority_(1000)
     22   priority_(1000),
     23   preferredWay_(0)
    2324{
    2425}
     
    2930  model_(model),
    3031  id_(-1),
    31   priority_(1000)
     32  priority_(1000),
     33  preferredWay_(0)
    3234{
    3335}
     
    4547  id_ = rhs.id_;
    4648  priority_ = rhs.priority_;
     49  preferredWay_ = rhs.preferredWay_;
    4750}
    4851
     
    5558    id_ = rhs.id_;
    5659    priority_ = rhs.priority_;
     60    preferredWay_ = rhs.preferredWay_;
    5761  }
    5862  return *this;
     
    105109{
    106110  model_=NULL;
     111  originalObject_=NULL;
    107112  variable_=-1;
    108113  way_=0;
     
    115120{
    116121  model_= model;
     122  originalObject_=NULL;
    117123  variable_=variable;
    118124  way_=way;
     
    125131{
    126132  model_=rhs.model_;
     133  originalObject_=rhs.originalObject_;
    127134  variable_=rhs.variable_;
    128135  way_=rhs.way_;
     
    137144  if (this != &rhs) {
    138145    model_=rhs.model_;
     146    originalObject_=rhs.originalObject_;
    139147    variable_=rhs.variable_;
    140148    way_=rhs.way_;
     
    192200    }
    193201    // set way in best
    194     if (whichObject>=0)
     202    if (whichObject>=0) 
    195203      objects[whichObject]->way(bestWay);
    196     else
    197       printf("debug\n");
    198204  }
    199205  return whichObject;
  • trunk/CbcBranchDynamic.cpp

    r231 r293  
    270270  //changeInGuessed += 1.0e8; // bias to stay up
    271271  newObject->setChangeInGuessed(changeInGuessed);
     272  newObject->setOriginalObject(this);
    272273  return newObject;
    273274}
     
    364365    preferredWay = (value-below>=upDownSeparator_) ? 1 : -1;
    365366  }
     367  if (preferredWay_)
     368    preferredWay=preferredWay_;
    366369  // weight at 1.0 is max min
    367370#define WEIGHT_AFTER 0.9
     
    885888    bestNumberDown_ = numInfDown;
    886889    bestObject_=thisOne;
     890    // See if user is overriding way
     891    if (thisOne->object()&&thisOne->object()->preferredWay())
     892      betterWay = thisOne->object()->preferredWay();
    887893  }
    888894  return betterWay;
  • trunk/CbcNode.cpp

    r277 r293  
    26122612        if (((numberTest2<=0&&numberTest<=0)||skipAll)&&sort[iDo]>distanceToCutoff) {
    26132613          canSkip=1; // always skip
    2614           if (iDo>20)
     2614          if (iDo>20) {
     2615            delete choice.possibleBranch;
     2616            choice.possibleBranch=NULL;
    26152617            break; // give up anyway
     2618          }
    26162619        }
    26172620        if (model->messageHandler()->logLevel()>3&&numberBeforeTrust)
     
    29252928            } else {
    29262929              delete choice.possibleBranch;
     2930              choice.possibleBranch=NULL;
    29272931              if (iDo>=2*numberStrong) {
    29282932                delete ws;
     
    29312935              }
    29322936              if (!dynamicObject||dynamicObject->numberTimesUp()>1) {
    2933                 if (iDo-whichChoice>=numberStrong)
     2937                if (iDo-whichChoice>=numberStrong) {
     2938                  delete choice.possibleBranch;
     2939                  choice.possibleBranch=NULL;
    29342940                  break; // give up
     2941                }
    29352942              } else {
    29362943                if (iDo-whichChoice>=2*numberStrong) {
    29372944                  delete ws;
    29382945                  ws=NULL;
     2946                  delete choice.possibleBranch;
     2947                  choice.possibleBranch=NULL;
    29392948                  break; // give up
    29402949                }
     
    29512960              choice.possibleBranch->branch();
    29522961              delete choice.possibleBranch;
     2962              choice.possibleBranch=NULL;
    29532963              delete ws;
    29542964              ws=NULL;
     
    29572967              choice.fix=1;
    29582968              fixObject[numberToFix++]=choice;
     2969              choice.possibleBranch=NULL;
    29592970#define FIXNOW
    29602971#ifdef FIXNOW
     
    29792990              choice.possibleBranch->branch();
    29802991              delete choice.possibleBranch;
     2992              choice.possibleBranch=NULL;
    29812993              delete ws;
    29822994              ws=NULL;
     
    29852997              choice.fix=-1;
    29862998              fixObject[numberToFix++]=choice;
     2999              choice.possibleBranch=NULL;
    29873000#ifdef FIXNOW
    29883001              double value = floor(saveSolution[iColumn]);
     
    29983011            anyAction=-2;
    29993012            delete choice.possibleBranch;
     3013            choice.possibleBranch=NULL;
    30003014            //printf("Both infeasible for choice %d sequence %d\n",i,
    30013015            // model->object(choice.objectNumber)->columnNumber());
     
    30213035          distanceToCutoff=-COIN_DBL_MAX;
    30223036        }
     3037        delete choice.possibleBranch;
    30233038      }
    30243039      double averageChange = model->sumChangeObjective()/((double) model->getNodeCount());
     
    35273542        solver->writeMps("bad");
    35283543        numberToFix=-1;
     3544        delete choice.possibleBranch;
     3545        choice.possibleBranch=NULL;
    35293546        break;
    35303547      }
  • trunk/include/CbcBranchBase.hpp

    r222 r293  
    178178  /// Return "down" estimate (default 1.0e-5)
    179179  virtual double downEstimate() const;
     180  /// If -1 down always chosen first, +1 up always, 0 normal
     181  inline int preferredWay() const
     182  { return preferredWay_;};
     183  /// Set -1 down always chosen first, +1 up always, 0 normal
     184  inline void setPreferredWay(int value)
     185  { preferredWay_=value;};
    180186 
    181187protected:
     
    188194  /// Priority
    189195  int priority_;
     196  /// If -1 down always chosen first, +1 up always, 0 normal
     197  int preferredWay_;
    190198
    191199};
     
    306314  {return  model_;};
    307315
     316  /// Return pointer back to object which created
     317  inline CbcObject * object() const
     318  {return  originalObject_;};
     319  /// Set pointer back to object which created
     320  inline void setOriginalObject(CbcObject * object)
     321  {originalObject_=object;};
     322
    308323protected:
    309324
    310325  /// The model that owns this branching object
    311326  CbcModel * model_;
     327  /// Pointer back to object which created
     328  CbcObject * originalObject_;
    312329
    313330  /// Branching variable (0 is first integer)
Note: See TracChangeset for help on using the changeset viewer.