Changeset 1420
 Timestamp:
 Jan 20, 2010 5:48:58 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/sandbox/Cbc/src/CbcNode.cpp
r1409 r1420 2257 2257 anyAction = 2; 2258 2258 break; 2259 } 2260 // Double check looks OK  just look at rows with all integers 2261 if (model>allDynamic()) { 2262 double * solution = CoinCopyOfArray(saveSolution, numberColumns); 2263 for (int i = 0; i < numberColumns; i++) { 2264 if (model>isInteger(i)) 2265 solution[i] = floor(solution[i] + 0.5); 2266 } 2267 int numberRows = solver>getNumRows(); 2268 double * rowActivity = new double [numberRows]; 2269 CoinZeroN(rowActivity, numberRows); 2270 solver>getMatrixByCol()>times(solution, rowActivity); 2271 //const double * element = model>solver()>getMatrixByCol()>getElements(); 2272 const int * row = model>solver()>getMatrixByCol()>getIndices(); 2273 const CoinBigIndex * columnStart = model>solver()>getMatrixByCol()>getVectorStarts(); 2274 const int * columnLength = model>solver()>getMatrixByCol()>getVectorLengths(); 2275 int nFree = 0; 2276 int nFreeNon = 0; 2277 int nFixedNon = 0; 2278 double mostAway = 0.0; 2279 int whichAway = 1; 2280 const double * columnLower = solver>getColLower(); 2281 const double * columnUpper = solver>getColUpper(); 2282 for (int i = 0; i < numberColumns; i++) { 2283 if (!model>isInteger(i)) { 2284 // mark rows as flexible 2285 CoinBigIndex start = columnStart[i]; 2286 CoinBigIndex end = start + columnLength[i]; 2287 for (CoinBigIndex j = start; j < end; j++) { 2288 int iRow = row[j]; 2289 rowActivity[iRow] = COIN_DBL_MAX; 2290 } 2291 } else if (columnLower[i] < columnUpper[i]) { 2292 if (solution[i] != saveSolution[i]) { 2293 nFreeNon++; 2294 if (fabs(solution[i]  saveSolution[i]) > mostAway) { 2295 mostAway = fabs(solution[i]  saveSolution[i]); 2296 whichAway = i; 2297 } 2298 } else { 2299 nFree++; 2300 } 2301 } else if (solution[i] != saveSolution[i]) { 2302 nFixedNon++; 2303 } 2304 } 2305 const double * lower = solver>getRowLower(); 2306 const double * upper = solver>getRowUpper(); 2307 bool satisfied = true; 2308 for (int i = 0; i < numberRows; i++) { 2309 double value = rowActivity[i]; 2310 if (value != COIN_DBL_MAX) { 2311 if (value > upper[i] + 1.0e5  value < lower[i]  1.0e5) { 2312 satisfied = false; 2313 } 2314 } 2315 } 2316 delete [] rowActivity; 2317 delete [] solution; 2318 if (!satisfied) { 2319 #ifdef CLP_INVESTIGATE 2320 printf("%d free ok %d free off target %d fixed off target\n", 2321 nFree, nFreeNon, nFixedNon); 2322 #endif 2323 if (nFreeNon) { 2324 // try branching on these 2325 delete branch_; 2326 for (int i = 0; i < numberObjects; i++) { 2327 OsiObject * object = model>modifiableObject(i); 2328 CbcSimpleIntegerDynamicPseudoCost * obj = 2329 dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ; 2330 assert (obj); 2331 int iColumn = obj>columnNumber(); 2332 if (iColumn == whichAway) { 2333 int preferredWay = (saveSolution[iColumn] > solution[iColumn]) 2334 ? 1 : +1; 2335 usefulInfo.integerTolerance_ = 0.0; 2336 branch_ = obj>createCbcBranch(solver, &usefulInfo, preferredWay); 2337 break; 2338 } 2339 } 2340 anyAction = 0; 2341 break; 2342 } 2343 } 2259 2344 } 2260 2345 } else if (iPass == 1) { … … 3364 3449 } 3365 3450 } 3366 //if (numberUnfinished*10 < numberStrongDone &&3367 //numberStrongIterations*20 < model>getIterationCount()) {3368 //printf("increasing trust\n");3369 //model>synchronizeNumberBeforeTrust(2);3370 //}3451 if (numberUnfinished*10 < numberStrongDone && 3452 numberStrongIterations*20 < model>getIterationCount()) { 3453 //printf("increasing trust\n"); 3454 model>synchronizeNumberBeforeTrust(2); 3455 } 3371 3456 3372 3457 // Set guessed solution value
Note: See TracChangeset
for help on using the changeset viewer.