- Timestamp:
- Aug 12, 2007 6:02:34 AM (14 years ago)
- Location:
- trunk/Cbc/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cbc/src/CbcHeuristic.cpp
r741 r747 191 191 model.setMaximumCutPassesAtRoot(CoinMin(20,model_->getMaximumCutPassesAtRoot())); 192 192 model.setParentModel(*model_); 193 model.setOriginalColumns(process.originalColumns()); 193 194 model.branchAndBound(); 194 195 if (logLevel>1) -
trunk/Cbc/src/CbcHeuristicFPump.cpp
r738 r747 17 17 #include "CoinWarmStartBasis.hpp" 18 18 #include "CoinTime.hpp" 19 #include "CbcEventHandler.hpp" 19 20 20 21 … … 273 274 int numberTries=0; 274 275 CoinWarmStartBasis bestBasis; 275 while (true) { 276 bool exitAll=false; 277 double saveBestObjective = model_->getMinimizationObjValue(); 278 while (!exitAll) { 276 279 int numberPasses=0; 277 280 numberTries++; … … 358 361 while (!finished) { 359 362 returnCode=0; 363 if (model_->getCurrentSeconds()>model_->getMaximumSeconds()) { 364 exitAll=true; 365 break; 366 } 360 367 // see what changed 361 368 if (usedColumn) { … … 391 398 newLineNeeded=false; 392 399 if (newSolutionValue<solutionValue) { 393 double saveValue = newSolutionValue;400 double saveValue = solutionValue; 394 401 if (!doGeneral) { 395 402 int numberLeft=0; … … 412 419 returnCode &= ~2; 413 420 } 421 if (returnCode!=1) 422 newSolutionValue=saveValue; 414 423 } 415 424 } 416 425 if (returnCode&&newSolutionValue<saveValue) { 417 426 memcpy(betterSolution,newSolution,numberColumns*sizeof(double)); 427 solutionFound=true; 418 428 CoinWarmStartBasis * basis = 419 429 dynamic_cast<CoinWarmStartBasis *>(solver->getWarmStart()) ; … … 421 431 bestBasis = * basis; 422 432 delete basis; 433 CbcEventHandler * handler = model_->getEventHandler(); 434 if (handler) { 435 double * saveOldSolution = CoinCopyOfArray(model_->bestSolution(),numberColumns); 436 double saveObjectiveValue = model_->getMinimizationObjValue(); 437 model_->setBestSolution(betterSolution,numberColumns,newSolutionValue); 438 int action = handler->event(CbcEventHandler::heuristicSolution); 439 if (saveOldSolution) { 440 model_->setBestSolution(saveOldSolution,numberColumns,saveObjectiveValue); 441 delete [] saveOldSolution; 442 } 443 if (!action||model_->getCurrentSeconds()>model_->getMaximumSeconds()) { 444 exitAll=true; // exit 445 break; 446 } 447 } 423 448 } 424 449 if ((accumulate_&1)!=0) … … 434 459 pumpPrint[0]='\0'; 435 460 } else { 436 sprintf(pumpPrint+strlen(pumpPrint)," - not improved by mini branch and bound");461 sprintf(pumpPrint+strlen(pumpPrint)," - mini branch and bound could not fix general integers"); 437 462 model_->messageHandler()->message(CBC_FPUMP1,model_->messages()) 438 463 << pumpPrint … … 565 590 CoinWarmStartBasis * basis = 566 591 dynamic_cast<CoinWarmStartBasis *>(solver->getWarmStart()) ; 592 solutionFound=true; 567 593 if (basis) { 568 594 bestBasis = * basis; 569 595 delete basis; 596 CbcEventHandler * handler = model_->getEventHandler(); 597 if (handler) { 598 double * saveOldSolution = CoinCopyOfArray(model_->bestSolution(),numberColumns); 599 double saveObjectiveValue = model_->getMinimizationObjValue(); 600 model_->setBestSolution(betterSolution,numberColumns,newSolutionValue); 601 int action = handler->event(CbcEventHandler::heuristicSolution); 602 if (saveOldSolution) { 603 model_->setBestSolution(saveOldSolution,numberColumns,saveObjectiveValue); 604 delete [] saveOldSolution; 605 } 606 if (!action||model_->getCurrentSeconds()>model_->getMaximumSeconds()) { 607 exitAll=true; // exit 608 break; 609 } 610 } 570 611 } 571 612 if ((accumulate_&1)!=0) … … 689 730 scaleFactor *= weightFactor_; 690 731 } // END WHILE 691 if (!solutionFound) {732 if (!solutionFound) 692 733 sprintf(pumpPrint+strlen(pumpPrint),"No solution found this major pass"); 734 if (strlen(pumpPrint)) { 693 735 model_->messageHandler()->message(CBC_FPUMP1,model_->messages()) 694 736 << pumpPrint … … 701 743 delete [] oldSolution; 702 744 delete [] saveObjective; 703 if (usedColumn ) {745 if (usedColumn&&!exitAll) { 704 746 OsiSolverInterface * newSolver = model_->continuousSolver()->clone(); 705 747 const double * colLower = newSolver->getColLower(); … … 829 871 bestBasis = * basis; 830 872 delete basis; 873 CbcEventHandler * handler = model_->getEventHandler(); 874 if (handler) { 875 double * saveOldSolution = CoinCopyOfArray(model_->bestSolution(),numberColumns); 876 double saveObjectiveValue = model_->getMinimizationObjValue(); 877 model_->setBestSolution(betterSolution,numberColumns,newSolutionValue); 878 int action = handler->event(CbcEventHandler::heuristicSolution); 879 if (saveOldSolution) { 880 model_->setBestSolution(saveOldSolution,numberColumns,saveObjectiveValue); 881 delete [] saveOldSolution; 882 } 883 if (!action||model_->getCurrentSeconds()>model_->getMaximumSeconds()) { 884 exitAll=true; // exit 885 break; 886 } 887 } 831 888 } 832 889 } else { … … 842 899 if (solutionFound) finalReturnCode=1; 843 900 cutoff = CoinMin(cutoff,solutionValue); 844 if (numberTries>=maximumRetries_||!solutionFound ) {901 if (numberTries>=maximumRetries_||!solutionFound||exitAll) { 845 902 break; 846 903 } else if (absoluteIncrement_>0.0||relativeIncrement_>0.0) { … … 912 969 if (bestBasis.getNumStructural()) 913 970 model_->setBestSolutionBasis(bestBasis); 971 model_->setMinimizationObjValue(saveBestObjective); 914 972 return finalReturnCode; 915 973 } -
trunk/Cbc/src/CbcModel.cpp
r741 r747 513 513 strongInfo_[2]=0; 514 514 numberStrongIterations_ = 0; 515 // Initialize random seed 516 CoinSeedRandom(1234567); 515 517 #ifndef NDEBUG 516 518 { … … 10087 10089 } 10088 10090 } 10091 // Set original columns as created by preprocessing 10092 void 10093 CbcModel::setOriginalColumns(const int * originalColumns) 10094 { 10095 int numberColumns = getNumCols(); 10096 delete [] originalColumns_; 10097 originalColumns_ = CoinCopyOfArray(originalColumns,numberColumns); 10098 } 10089 10099 // Set the cut modifier method 10090 10100 void -
trunk/Cbc/src/CbcModel.hpp
r738 r747 732 732 inline int howOftenGlobalScan() const 733 733 { return howOftenGlobalScan_;} 734 /// Original columns as created by integerPresolve 734 /// Original columns as created by integerPresolve or preprocessing 735 735 inline int * originalColumns() const 736 736 { return originalColumns_;} 737 /// Set original columns as created by preprocessing 738 void setOriginalColumns(const int * originalColumns) ; 737 739 738 740 /** Set the print frequency. … … 1966 1968 bool ownObjects_; 1967 1969 1968 /// Original columns as created by integerPresolve 1970 /// Original columns as created by integerPresolve or preprocessing 1969 1971 int * originalColumns_; 1970 1972 /// How often to scan global cuts -
trunk/Cbc/src/CbcSolver.cpp
r738 r747 3409 3409 solver2->setHintParam(OsiDoInBranchAndCut,false,OsiHintDo) ; 3410 3410 } 3411 babModel->setOriginalColumns(process.originalColumns()); 3411 3412 #ifdef COIN_HAS_ASL 3412 3413 if (!solver2&&usingAmpl) {
Note: See TracChangeset
for help on using the changeset viewer.