Changeset 871 for trunk/Cbc/src/CbcHeuristicDiveVectorLength.cpp
 Timestamp:
 Feb 13, 2008 3:52:57 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcHeuristicDiveVectorLength.cpp
r868 r871 28 28 // Get a copy of original matrix 29 29 assert(model.solver()); 30 matrix_ = *model.solver()>getMatrixByCol(); 31 validate(); 30 downLocks_ =NULL; 31 upLocks_ = NULL; 32 // model may have empty matrix  wait until setModel 33 const CoinPackedMatrix * matrix = model.solver()>getMatrixByCol(); 34 if (matrix) { 35 matrix_ = *matrix; 36 } 32 37 percentageToFix_ = 0.2; 33 38 maxIterations_ = 100; … … 58 63 CbcHeuristic::generateCpp(fp,"heuristicDiveVectorLength"); 59 64 if (percentageToFix_!=other.percentageToFix_) 60 fprintf(fp,"3 heuristicDiveVectorLength.setPercentageToFix(% d);\n",percentageToFix_);65 fprintf(fp,"3 heuristicDiveVectorLength.setPercentageToFix(%.2f);\n",percentageToFix_); 61 66 else 62 fprintf(fp,"4 heuristicDiveVectorLength.setPercentageToFix(% d);\n",percentageToFix_);67 fprintf(fp,"4 heuristicDiveVectorLength.setPercentageToFix(%.2f);\n",percentageToFix_); 63 68 if (maxIterations_!=other.maxIterations_) 64 69 fprintf(fp,"3 heuristicDiveVectorLength.setMaxIterations(%d);\n",maxIterations_); … … 66 71 fprintf(fp,"4 heuristicDiveVectorLength.setMaxIterations(%d);\n",maxIterations_); 67 72 if (maxTime_!=other.maxTime_) 68 fprintf(fp,"3 heuristicDiveVectorLength.setMaxTime(% d);\n",maxTime_);73 fprintf(fp,"3 heuristicDiveVectorLength.setMaxTime(%.2f);\n",maxTime_); 69 74 else 70 fprintf(fp,"4 heuristicDiveVectorLength.setMaxTime(% d);\n",maxTime_);75 fprintf(fp,"4 heuristicDiveVectorLength.setMaxTime(%.2f);\n",maxTime_); 71 76 fprintf(fp,"3 cbcModel>addHeuristic(&heuristicDiveVectorLength);\n"); 72 77 } … … 81 86 maxTime_(rhs.maxTime_) 82 87 { 83 int numberIntegers = model_>numberIntegers(); 84 downLocks_ = CoinCopyOfArray(rhs.downLocks_,numberIntegers); 85 upLocks_ = CoinCopyOfArray(rhs.upLocks_,numberIntegers); 88 if (rhs.downLocks_) { 89 int numberIntegers = model_>numberIntegers(); 90 downLocks_ = CoinCopyOfArray(rhs.downLocks_,numberIntegers); 91 upLocks_ = CoinCopyOfArray(rhs.upLocks_,numberIntegers); 92 } else { 93 downLocks_ = NULL; 94 upLocks_ = NULL; 95 } 86 96 } 87 97 … … 99 109 delete [] upLocks_; 100 110 int numberIntegers = model_>numberIntegers(); 101 downLocks_ = CoinCopyOfArray(rhs.downLocks_,numberIntegers); 102 upLocks_ = CoinCopyOfArray(rhs.upLocks_,numberIntegers); 111 if (rhs.downLocks_) { 112 downLocks_ = CoinCopyOfArray(rhs.downLocks_,numberIntegers); 113 upLocks_ = CoinCopyOfArray(rhs.upLocks_,numberIntegers); 114 } else { 115 downLocks_ = NULL; 116 upLocks_ = NULL; 117 } 103 118 } 104 119 return *this; … … 112 127 // Get a copy of original matrix 113 128 assert(model_>solver()); 114 matrix_ = *model_>solver()>getMatrixByCol(); 115 validate(); 129 // model may have empty matrix  wait until setModel 130 const CoinPackedMatrix * matrix = model_>solver()>getMatrixByCol(); 131 if (matrix) { 132 matrix_ = *matrix; 133 validate(); 134 } 116 135 } 117 136 … … 165 184 bool * fixedAtLowerBound = new bool [numberIntegers]; 166 185 167 const int maxNumberAtBoundToFix = floor(percentageToFix_ * numberIntegers);186 const int maxNumberAtBoundToFix = (int) floor(percentageToFix_ * numberIntegers); 168 187 169 188 // count how many fractional variables … … 411 430 // Get a copy of original matrix (and by row for rounding); 412 431 assert(model_>solver()); 413 matrix_ = *model_>solver()>getMatrixByCol(); 414 // matrixByRow_ = *model_>solver()>getMatrixByRow(); 415 // make sure model okay for heuristic 416 validate(); 432 const CoinPackedMatrix * matrix = model_>solver()>getMatrixByCol(); 433 if (matrix) { 434 matrix_ = *matrix; 435 // make sure model okay for heuristic 436 validate(); 437 } 417 438 } 418 439 … … 429 450 int numberIntegers = model_>numberIntegers(); 430 451 const int * integerVariable = model_>integerVariable(); 452 delete [] downLocks_; 453 delete [] upLocks_; 431 454 downLocks_ = new unsigned short [numberIntegers]; 432 455 upLocks_ = new unsigned short [numberIntegers];
Note: See TracChangeset
for help on using the changeset viewer.