Changeset 968 for stable/2.1
 Timestamp:
 Jun 6, 2008 9:53:27 AM (13 years ago)
 Location:
 stable/2.1/Cbc
 Files:

 1 added
 3 edited
Legend:
 Unmodified
 Added
 Removed

stable/2.1/Cbc/src/CbcBranchLotsize.cpp
r912 r968 495 495 if (rangeType_==1) { 496 496 nearest = bound_[range_]; 497 assert (nearest>=lower[columnNumber_]&& 498 nearest<=upper[columnNumber_]); 497 499 solver>setColLower(columnNumber_,nearest); 498 500 solver>setColUpper(columnNumber_,nearest); 499 501 } else { 500 502 // ranges 501 solver>setColLower(columnNumber_,bound_[2*range_]); 502 solver>setColUpper(columnNumber_,bound_[2*range_+1]); 503 solver>setColLower(columnNumber_,CoinMax(lower[columnNumber_], 504 bound_[2*range_])); 505 solver>setColUpper(columnNumber_,CoinMin(upper[columnNumber_], 506 bound_[2*range_+1])); 503 507 if (value>bound_[2*range_+1]) 504 508 nearest=bound_[2*range_+1]; 
stable/2.1/Cbc/src/CbcBranchLotsize.hpp
r912 r968 93 93 double tolerance) const; 94 94 95 /// Model column number95 /// Get model column number 96 96 inline int modelSequence() const 97 97 {return columnNumber_;} 98 /// Set model column number 99 inline void setModelSequence(int value) 100 {columnNumber_ = value;} 98 101 99 102 /** Column number if single column object 1 otherwise, 
stable/2.1/Cbc/src/CbcSolver.cpp
r960 r968 3524 3524 CbcModel * babModel_ = NULL; 3525 3525 int returnMode=1; 3526 CbcOrClpRead_mode=1; 3526 3527 int statusUserFunction_[1]; 3527 3528 int numberUserFunctions_=1; // to allow for ampl … … 6362 6363 CbcSimpleInteger * obj = 6363 6364 dynamic_cast <CbcSimpleInteger *>(oldObjects[iObj]) ; 6364 assert (obj); 6365 obj>setColumnNumber(iColumn); 6365 if (obj) { 6366 obj>setColumnNumber(iColumn); 6367 } else { 6368 // only other case allowed is lotsizing 6369 CbcLotsize * obj2 = 6370 dynamic_cast <CbcLotsize *>(oldObjects[iObj]) ; 6371 assert (obj2); 6372 obj2>setModelSequence(iColumn); 6373 } 6366 6374 oldObjects[n++]=oldObjects[iObj]; 6367 6375 } else { … … 7335 7343 bestSolution = new double [n]; 7336 7344 OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 7345 // Save bounds on processed model 7346 const int * originalColumns = process.originalColumns(); 7347 int numberColumns2 = clpSolver>getNumCols(); 7348 double * solution2 = new double[n]; 7349 double * lower2 = new double [n]; 7350 double * upper2 = new double [n]; 7351 for (int i=0;i<n;i++) { 7352 solution2[i]=COIN_DBL_MAX; 7353 lower2[i]=COIN_DBL_MAX; 7354 upper2[i]=COIN_DBL_MAX; 7355 } 7356 const double *columnLower = clpSolver>getColLower() ; 7357 const double * columnUpper = clpSolver>getColUpper() ; 7358 const double * solution = babModel_>bestSolution(); 7359 for (int i=0;i<numberColumns2;i++) { 7360 int jColumn = originalColumns[i]; 7361 solution2[jColumn]=solution[i]; 7362 lower2[jColumn]=columnLower[i]; 7363 upper2[jColumn]=columnUpper[i]; 7364 } 7337 7365 ClpSimplex * lpSolver = clpSolver>getModelPtr(); 7338 7366 lpSolver>setSpecialOptions(lpSolver>specialOptions()IN_BRANCH_AND_BOUND); // say is Cbc (and in branch and bound) 7339 7367 process.postProcess(*babModel_>solver()); 7340 7368 // Solution now back in saveSolver 7369 // Double check bounds 7370 columnLower = saveSolver>getColLower() ; 7371 columnUpper = saveSolver>getColUpper() ; 7372 solution = saveSolver>getColSolution(); 7373 int numberChanged=0; 7374 for (int i=0;i<n;i++) { 7375 if (lower2[i]!=COIN_DBL_MAX) { 7376 if (lower2[i]!=columnLower[i] 7377 upper2[i]!=columnUpper[i]) { 7378 if (lower2[i]<columnLower[i] 7379 upper2[i]>columnUpper[i]) { 7380 #ifdef COIN_DEVELOP 7381 printf("odd bounds tighter"); 7382 printf("%d bab bounds %g %g now %g %g\n", 7383 i,lower2[i],upper2[i],columnLower[i], 7384 columnUpper[i]); 7385 #endif 7386 } else { 7387 #ifdef COIN_DEVELOP 7388 printf("%d bab bounds %g %g now %g %g\n", 7389 i,lower2[i],upper2[i],columnLower[i], 7390 columnUpper[i]); 7391 #endif 7392 numberChanged++; 7393 saveSolver>setColLower(i,lower2[i]); 7394 saveSolver>setColUpper(i,upper2[i]); 7395 } 7396 } 7397 } 7398 } 7399 delete [] solution2; 7400 delete [] lower2; 7401 delete [] upper2; 7402 if (numberChanged) { 7403 sprintf(generalPrint,"%d bounds tightened after postprocessing\n", 7404 numberChanged); 7405 generalMessageHandler>message(CLP_GENERAL,generalMessages) 7406 << generalPrint 7407 <<CoinMessageEol; 7408 saveSolver>resolve(); 7409 assert (saveSolver>isProvenOptimal()); 7410 } 7411 #ifndef NEW_STYLE_SOLVER 7412 // and original solver 7413 assert (n==originalSolver>getNumCols()); 7414 originalSolver>setColLower(saveSolver>getColLower()); 7415 originalSolver>setColUpper(saveSolver>getColUpper()); 7416 // basis 7417 CoinWarmStartBasis * basis = dynamic_cast<CoinWarmStartBasis *> (babModel_>solver()>getWarmStart()); 7418 originalSolver>setBasis(*basis); 7419 delete basis; 7420 originalSolver>resolve(); 7421 assert (originalSolver>isProvenOptimal()); 7422 #endif 7341 7423 babModel_>assignSolver(saveSolver); 7342 7424 memcpy(bestSolution,babModel_>solver()>getColSolution(),n*sizeof(double)); … … 7359 7441 double * solution = original>primalColumnSolution(); 7360 7442 int n = original>numberColumns(); 7361 //assert (!nn==babModel_>solver()>getNumCols());7443 assert (!nn==babModel_>solver()>getNumCols()); 7362 7444 for (int i=0;i<n;i++) { 7363 7445 solution[i]=bestSolution[i]; … … 7371 7453 originalSolver>setBasis(*basis); 7372 7454 delete basis; 7455 originalSolver>resolve(); 7456 assert (originalSolver>isProvenOptimal()); 7373 7457 } 7374 7458 #endif
Note: See TracChangeset
for help on using the changeset viewer.