Changeset 860


Ignore:
Timestamp:
Jan 21, 2008 5:41:00 PM (11 years ago)
Author:
forrest
Message:

fix seg fault on preprocessed problem

Location:
trunk/Cbc/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcHeuristicGreedy.cpp

    r838 r860  
    2929  :CbcHeuristic(model)
    3030{
    31   // Get a copy of original matrix
    32   assert(model.solver());
    33   matrix_ = *model.solver()->getMatrixByCol();
    34   originalNumberRows_=model.solver()->getNumRows();
     31  gutsOfConstructor(&model);
    3532  algorithm_=0;
    3633  numberTimes_=100;
     
    4744{
    4845  return new CbcHeuristicGreedyCover(*this);
     46}
     47// Guts of constructor from a CbcModel
     48void
     49CbcHeuristicGreedyCover::gutsOfConstructor(CbcModel * model)
     50{
     51  model_=model;
     52  // Get a copy of original matrix
     53  assert(model->solver());
     54  matrix_ = *model->solver()->getMatrixByCol();
     55  originalNumberRows_=model->solver()->getNumRows();
    4956}
    5057// Create C++ lines to get to current state
     
    349356void CbcHeuristicGreedyCover::setModel(CbcModel * model)
    350357{
    351 #define SLOPPY
    352 #ifndef SLOPPY
    353   model_ = model;
    354   assert(model_->solver());
    355   *this = CbcHeuristicGreedyCover(*model);
    356 #else
    357   if (model_&&model!=model_) {
    358     model_ = model;
    359     assert(model_->solver());
    360     *this = CbcHeuristicGreedyCover(*model);
    361   }
    362 #endif
     358  gutsOfConstructor(model);
    363359  validate();
    364360}
     
    367363CbcHeuristicGreedyCover::resetModel(CbcModel * model)
    368364{
    369 #ifndef SLOPPY
    370   model_ = model;
    371   assert(model_->solver());
    372   *this = CbcHeuristicGreedyCover(*model);
    373 #else
    374   // switch off
    375   model_ = NULL;
    376   matrix_ = CoinPackedMatrix();
    377 #endif
     365  gutsOfConstructor(model);
    378366}
    379367// Validate model i.e. sets when_ to 0 if necessary (may be NULL)
     
    435423{
    436424  // Get a copy of original matrix
    437   assert(model.solver());
    438   matrix_ = *model.solver()->getMatrixByCol();
     425  gutsOfConstructor(&model);
    439426  fraction_=1.0; // no branch and bound
    440   originalNumberRows_=model.solver()->getNumRows();
    441427  algorithm_=0;
    442428  numberTimes_=100;
     
    453439{
    454440  return new CbcHeuristicGreedyEquality(*this);
     441}
     442// Guts of constructor from a CbcModel
     443void
     444CbcHeuristicGreedyEquality::gutsOfConstructor(CbcModel * model)
     445{
     446  model_=model;
     447  // Get a copy of original matrix
     448  assert(model->solver());
     449  matrix_ = *model->solver()->getMatrixByCol();
     450  originalNumberRows_=model->solver()->getNumRows();
    455451}
    456452// Create C++ lines to get to current state
     
    784780void CbcHeuristicGreedyEquality::setModel(CbcModel * model)
    785781{
    786 #define SLOPPY
    787 #ifndef SLOPPY
    788   model_ = model;
    789   assert(model_->solver());
    790   *this = CbcHeuristicGreedyEquality(*model);
    791 #else
    792   if (model_&&model!=model_) {
    793     model_ = model;
    794     assert(model_->solver());
    795     *this = CbcHeuristicGreedyEquality(*model);
    796   }
    797 #endif
     782  gutsOfConstructor(model);
    798783  validate();
    799784}
     
    802787CbcHeuristicGreedyEquality::resetModel(CbcModel * model)
    803788{
    804 #ifndef SLOPPY
    805   model_ = model;
    806   assert(model_->solver());
    807   *this = CbcHeuristicGreedyEquality(*model);
    808 #else
    809   // switch off
    810   model_ = NULL;
    811   matrix_ = CoinPackedMatrix();
    812 #endif
     789  gutsOfConstructor(model);
    813790}
    814791// Validate model i.e. sets when_ to 0 if necessary (may be NULL)
  • trunk/Cbc/src/CbcHeuristicGreedy.hpp

    r765 r860  
    6969
    7070protected:
     71  /// Guts of constructor from a CbcModel
     72  void gutsOfConstructor(CbcModel * model);
    7173  // Data
    7274
     
    152154  { numberTimes_=value; }
    153155protected:
     156  /// Guts of constructor from a CbcModel
     157  void gutsOfConstructor(CbcModel * model);
    154158  // Data
    155159
Note: See TracChangeset for help on using the changeset viewer.