Changeset 1418
- Timestamp:
- Jan 20, 2010 4:48:56 AM (10 years ago)
- Location:
- trunk/Cbc/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cbc/src/CbcModel.cpp
r1407 r1418 10211 10211 //obj2->setNumberBeforeTrust(numberBeforeTrust_); 10212 10212 } 10213 obj1 = dynamic_cast <CbcSimpleInteger *>(object_[iObject]) ; 10214 if (obj1) 10215 obj1->setPosition(iObject); 10213 10216 } 10214 10217 if (branchingMethod_) { -
trunk/Cbc/src/CbcNode.cpp
r1268 r1418 3108 3108 break; 3109 3109 } 3110 // Double check looks OK - just look at rows with all integers 3111 if (model->allDynamic()) { 3112 double * solution = CoinCopyOfArray(saveSolution,numberColumns); 3113 for (int i=0;i<numberColumns;i++) { 3114 if (model->isInteger(i)) 3115 solution[i]=floor(solution[i]+0.5); 3116 } 3117 int numberRows = solver->getNumRows(); 3118 double * rowActivity = new double [numberRows]; 3119 CoinZeroN(rowActivity,numberRows); 3120 solver->getMatrixByCol()->times(solution,rowActivity); 3121 //const double * element = model->solver()->getMatrixByCol()->getElements(); 3122 const int * row = model->solver()->getMatrixByCol()->getIndices(); 3123 const CoinBigIndex * columnStart = model->solver()->getMatrixByCol()->getVectorStarts(); 3124 const int * columnLength = model->solver()->getMatrixByCol()->getVectorLengths(); 3125 int nFree=0; 3126 int nFreeNon=0; 3127 int nFixedNon=0; 3128 double mostAway=0.0; 3129 int whichAway=-1; 3130 const double * columnLower = solver->getColLower(); 3131 const double * columnUpper = solver->getColUpper(); 3132 for (int i=0;i<numberColumns;i++) { 3133 if (!model->isInteger(i)) { 3134 // mark rows as flexible 3135 CoinBigIndex start = columnStart[i]; 3136 CoinBigIndex end = start + columnLength[i]; 3137 for (CoinBigIndex j=start;j<end;j++) { 3138 int iRow = row[j]; 3139 rowActivity[iRow]=COIN_DBL_MAX; 3140 } 3141 } else if (columnLower[i]<columnUpper[i]) { 3142 if (solution[i]!=saveSolution[i]) { 3143 nFreeNon++; 3144 if (fabs(solution[i]-saveSolution[i])>mostAway) { 3145 mostAway=fabs(solution[i]-saveSolution[i]); 3146 whichAway=i; 3147 } 3148 } else { 3149 nFree++; 3150 } 3151 } else if (solution[i]!=saveSolution[i]) { 3152 nFixedNon++; 3153 } 3154 } 3155 const double * lower = solver->getRowLower(); 3156 const double * upper = solver->getRowUpper(); 3157 bool satisfied=true; 3158 for (int i=0;i<numberRows;i++) { 3159 double value = rowActivity[i]; 3160 if (value!=COIN_DBL_MAX) { 3161 if (value>upper[i]+1.0e-5||value<lower[i]-1.0e-5) { 3162 satisfied=false; 3163 } 3164 } 3165 } 3166 delete [] rowActivity; 3167 delete [] solution; 3168 if (!satisfied) { 3169 #ifdef CLP_INVESTIGATE 3170 printf("%d free ok %d free off target %d fixed off target\n", 3171 nFree,nFreeNon,nFixedNon); 3172 #endif 3173 if (nFreeNon) { 3174 // try branching on these 3175 delete branch_; 3176 for (int i = 0; i < numberObjects; i++) { 3177 OsiObject * object = model->modifiableObject(i); 3178 CbcSimpleIntegerDynamicPseudoCost * obj = 3179 dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ; 3180 assert (obj); 3181 int iColumn = obj->columnNumber(); 3182 if (iColumn==whichAway) { 3183 int preferredWay = (saveSolution[iColumn]>solution[iColumn]) 3184 ? -1 : +1; 3185 usefulInfo.integerTolerance_=0.0; 3186 branch_ = obj->createCbcBranch(solver, &usefulInfo, preferredWay); 3187 break; 3188 } 3189 } 3190 anyAction=0; 3191 break; 3192 delete [] saveLower; 3193 delete [] saveUpper; 3194 delete [] saveSolution; 3195 return 0; 3196 } 3197 } 3198 } 3110 3199 } else if (iPass==1) { 3111 3200 // looks like a solution - get paranoid -
trunk/Cbc/src/CbcSolver.cpp
r1407 r1418 10369 10369 fp=stderr; 10370 10370 } else { 10371 if (field[0]=='/'||field[0]=='\\') { 10371 bool absolutePath; 10372 if (dirsep=='/') { 10373 // non Windows (or cygwin) 10374 absolutePath=(field[0]=='/'); 10375 } else { 10376 //Windows (non cycgwin) 10377 absolutePath=(field[0]=='\\'); 10378 // but allow for : 10379 if (strchr(field.c_str(),':')) 10380 absolutePath=true; 10381 } 10382 if (absolutePath) { 10372 10383 fileName = field; 10373 10384 } else if (field[0]=='~') {
Note: See TracChangeset
for help on using the changeset viewer.