Changeset 1212 for trunk/Cbc/src/CbcSolver.cpp
 Timestamp:
 Aug 21, 2009 12:19:13 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcSolver.cpp
r1211 r1212 521 521 parameters_[whichParam(GREEDY,numberParameters_,parameters_)].setCurrentOption("on"); 522 522 parameters_[whichParam(COMBINE,numberParameters_,parameters_)].setCurrentOption("on"); 523 parameters_[whichParam(CROSSOVER2,numberParameters_,parameters_)].setCurrentOption("off"); 523 524 parameters_[whichParam(PIVOTANDFIX,numberParameters_,parameters_)].setCurrentOption("off"); 524 525 parameters_[whichParam(RANDROUND,numberParameters_,parameters_)].setCurrentOption("off"); … … 867 868 int CbcOrClpRead_mode=1; 868 869 FILE * CbcOrClpReadCommand=stdin; 870 extern int CbcOrClpEnvironmentIndex; 869 871 static bool noPrinting=false; 870 872 #ifndef CBC_OTHER_SOLVER … … 3261 3263 parameters[whichParam(GREEDY,numberParameters,parameters)].setCurrentOption("on"); 3262 3264 parameters[whichParam(COMBINE,numberParameters,parameters)].setCurrentOption("on"); 3265 parameters[whichParam(CROSSOVER2,numberParameters,parameters)].setCurrentOption("off"); 3263 3266 parameters[whichParam(PIVOTANDFIX,numberParameters,parameters)].setCurrentOption("off"); 3264 3267 parameters[whichParam(RANDROUND,numberParameters,parameters)].setCurrentOption("off"); … … 3297 3300 int useGreedy = parameters_[whichParam(GREEDY,numberParameters_,parameters_)].currentOptionAsInteger(); 3298 3301 int useCombine = parameters_[whichParam(COMBINE,numberParameters_,parameters_)].currentOptionAsInteger(); 3302 int useCrossover = parameters_[whichParam(CROSSOVER2,numberParameters_,parameters_)].currentOptionAsInteger(); 3299 3303 int usePivot = parameters_[whichParam(PIVOTANDFIX,numberParameters_,parameters_)].currentOptionAsInteger(); 3300 3304 int useRand = parameters_[whichParam(RANDROUND,numberParameters_,parameters_)].currentOptionAsInteger(); … … 3475 3479 anyToDo=true; 3476 3480 } 3477 if (useCombine>=type&&useCombine>=kType&&useCombine<=kType+1) {3478 CbcHeuristicLocal heuristic2(*model);3479 heuristic2.setHeuristicName("combine solutions");3480 heuristic2.setFractionSmall(0.5);3481 heuristic2.setSearchType(1);3482 model>addHeuristic(&heuristic2);3483 anyToDo=true;3484 }3485 3481 if (useGreedy>=type&&useGreedy>=kType&&useGreedy<=kType+1) { 3486 3482 CbcHeuristicGreedyCover heuristic3(*model); … … 3638 3634 anyToDo=true; 3639 3635 } 3636 if (useCombine>=type&&useCombine>=kType&&useCombine<=kType+1) { 3637 CbcHeuristicLocal heuristic2(*model); 3638 heuristic2.setHeuristicName("combine solutions"); 3639 heuristic2.setFractionSmall(0.5); 3640 heuristic2.setSearchType(1); 3641 model>addHeuristic(&heuristic2); 3642 anyToDo=true; 3643 } 3644 if (useCrossover>=kType&&useCrossover<=kType+1) { 3645 CbcHeuristicCrossover heuristic2a(*model); 3646 heuristic2a.setHeuristicName("crossover"); 3647 heuristic2a.setFractionSmall(0.3); 3648 // just fix at lower 3649 heuristic2a.setWhen(11); 3650 model>addHeuristic(&heuristic2a); 3651 model>setMaximumSavedSolutions(5); 3652 anyToDo=true; 3653 } 3640 3654 int heurSwitches=parameters_[whichParam(HOPTIONS,numberParameters_,parameters_)].intValue()%100; 3641 3655 if (heurSwitches) { … … 3703 3717 3704 3718 int CbcClpUnitTest (const CbcModel & saveModel, 3705 std::string& dirMiplib, bool unitTestOnly,3719 std::string& dirMiplib, int testSwitch, 3706 3720 double * stuff); 3707 3721 #if NEW_STYLE_SOLVER … … 6834 6848 if (howOften==98howOften==99) 6835 6849 generator>setSwitchOffIfLessThan(switches[iGenerator]); 6850 // Use if any at root as more likely later and fairly cheap 6851 //if (switches[iGenerator]==2) 6852 //generator>setWhetherToUse(true); 6836 6853 generator>setInaccuracy(accuracyFlag[iGenerator]); 6837 6854 generator>setTiming(true); … … 8238 8255 says miplib 8239 8256 */ 8240 int extra 1 = parameters_[whichParam(EXTRA1,numberParameters_,parameters_)].intValue();8257 int extra2 = parameters_[whichParam(EXTRA2,numberParameters_,parameters_)].intValue(); 8241 8258 double stuff[11]; 8242 8259 stuff[0]=parameters_[whichParam(FAKEINCREMENT,numberParameters_,parameters_)].doubleValue(); … … 8283 8300 } 8284 8301 } 8285 int returnCode=CbcClpUnitTest(model_, dirMiplib, extra 1==1,stuff);8302 int returnCode=CbcClpUnitTest(model_, dirMiplib, extra2,stuff); 8286 8303 babModel_=NULL; 8287 8304 return returnCode; … … 8407 8424 for (int i=0;i<numberColumns2;i++) { 8408 8425 int jColumn = originalColumns[i]; 8409 solution2[jColumn]=solution[i]; 8410 lower2[jColumn]=columnLower[i]; 8411 upper2[jColumn]=columnUpper[i]; 8426 if (jColumn<n) { 8427 solution2[jColumn]=solution[i]; 8428 lower2[jColumn]=columnLower[i]; 8429 upper2[jColumn]=columnUpper[i]; 8430 } 8412 8431 } 8413 8432 #ifndef CBC_OTHER_SOLVER … … 8416 8435 #endif 8417 8436 process.postProcess(*babModel_>solver()); 8437 #ifdef COIN_DEVELOP 8438 if (model_.bestSolution()&&fabs(model_.getMinimizationObjValue() 8439 babModel_>getMinimizationObjValue())<1.0e8) { 8440 const double * b1 =model_.bestSolution(); 8441 const double * b2 = saveSolver>getColSolution(); 8442 const double * columnLower = saveSolver>getColLower() ; 8443 const double * columnUpper = saveSolver>getColUpper() ; 8444 for (int i=0;i<n;i++) { 8445 if (fabs(b1[i]b2[i])>1.0e7) { 8446 printf("%d %g %g %g %g\n",i,b1[i],b2[i], 8447 columnLower[i],columnUpper[i]); 8448 } 8449 } 8450 } 8451 #endif 8418 8452 // Solution now back in saveSolver 8419 8453 // Double check bounds … … 8423 8457 int numberChanged=0; 8424 8458 for (int i=0;i<n;i++) { 8459 if (!saveSolver>isInteger(i)) 8460 continue; 8425 8461 if (lower2[i]!=COIN_DBL_MAX) { 8426 8462 if (lower2[i]!=columnLower[i] … … 8443 8479 saveSolver>setColLower(i,lower2[i]); 8444 8480 saveSolver>setColUpper(i,upper2[i]); 8481 } 8482 } 8483 } 8484 } 8485 // See if sos so we can fix 8486 OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (saveSolver); 8487 if (osiclp&&osiclp>numberSOS()) { 8488 // SOS 8489 numberSOS = osiclp>numberSOS(); 8490 const CoinSet * setInfo = osiclp>setInfo(); 8491 int i; 8492 for ( i=0;i<numberSOS;i++) { 8493 int type = setInfo[i].setType(); 8494 int n=setInfo[i].numberEntries(); 8495 const int * which = setInfo[i].which(); 8496 int first=1; 8497 int last=1; 8498 for (int j=0;j<n;j++) { 8499 int iColumn = which[j]; 8500 if (fabs(solution[iColumn])>1.0e7) { 8501 last=j; 8502 if (first<0) 8503 first=j; 8504 } 8505 } 8506 assert (lastfirst<type); 8507 for (int j=0;j<n;j++) { 8508 if (j<firstj>last) { 8509 int iColumn = which[j]; 8510 saveSolver>setColLower(iColumn,0.0); 8511 saveSolver>setColUpper(iColumn,0.0); 8445 8512 } 8446 8513 } … … 8472 8539 #ifndef CBC_OTHER_SOLVER 8473 8540 // and original solver 8541 originalSolver>setDblParam(OsiDualObjectiveLimit,COIN_DBL_MAX); 8474 8542 assert (n>=originalSolver>getNumCols()); 8475 8543 n=originalSolver>getNumCols(); … … 8499 8567 } 8500 8568 #if NEW_STYLE_SOLVER==0 8501 if (returnMode==1) 8569 if (returnMode==1) { 8570 model_.deleteSolutions(); 8502 8571 model_.setBestSolution(bestSolution,n,babModel_>getMinimizationObjValue()); 8503 #endif 8572 } 8573 #endif 8574 babModel_>deleteSolutions(); 8504 8575 babModel_>setBestSolution(bestSolution,n,babModel_>getMinimizationObjValue()); 8505 8576 #if NEW_STYLE_SOLVER==0 … … 8545 8616 bestSolution = new double [n]; 8546 8617 // Put solution now back in saveSolver 8618 saveSolver>setColSolution(model_.bestSolution()); 8547 8619 babModel_>assignSolver(saveSolver); 8548 saveSolver>setColSolution(model_.bestSolution());8620 babModel_>setMinimizationObjValue(model_.getMinimizationObjValue()); 8549 8621 memcpy(bestSolution,babModel_>solver()>getColSolution(),n*sizeof(double)); 8550 8622 #if NEW_STYLE_SOLVER==0 … … 9917 9989 case UNITTEST: 9918 9990 { 9919 CbcClpUnitTest(model_, dirSample, true,NULL);9991 CbcClpUnitTest(model_, dirSample, 2,NULL); 9920 9992 } 9921 9993 break; … … 10564 10636 case DUMMY: 10565 10637 break; 10638 case ENVIRONMENT: 10639 CbcOrClpEnvironmentIndex=0; 10640 break; 10566 10641 default: 10567 10642 abort();
Note: See TracChangeset
for help on using the changeset viewer.