Changeset 1132 for trunk/Cbc/src/CbcSolver.cpp
 Timestamp:
 Mar 16, 2009 6:30:25 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcSolver.cpp
r1131 r1132 790 790 #endif 791 791 #endif 792 #ifdef CPX_KEEP_RESULTS 793 #define CBC_OTHER_SOLVER 1 794 #endif 795 #ifdef COIN_HAS_CPX 796 #include "OsiCpxSolverInterface.hpp" 797 #endif 798 #ifdef CBC_OTHER_SOLVER 799 #if CBC_OTHER_SOLVER==1 800 #include "OsiCpxSolverInterface.hpp" 801 #endif 802 #undef NEW_STYLE_SOLVER 803 #define NEW_STYLE_SOLVER 0 804 #endif 792 805 //#undef COIN_HAS_ASL 793 806 #ifdef COIN_HAS_ASL … … 849 862 FILE * CbcOrClpReadCommand=stdin; 850 863 static bool noPrinting=false; 864 #ifndef CBC_OTHER_SOLVER 851 865 #if NEW_STYLE_SOLVER 852 866 int * CbcSolver::analyze(OsiClpSolverInterface * solverMod, int & numberChanged, double & increment, … … 1157 1171 } 1158 1172 } 1173 #endif 1159 1174 #if 1 1160 1175 #include "ClpSimplexOther.hpp" … … 3101 3116 void CbcMain0 (CbcModel & model) 3102 3117 { 3118 #ifndef CBC_OTHER_SOLVER 3103 3119 OsiClpSolverInterface * originalSolver = dynamic_cast<OsiClpSolverInterface *> (model.solver()); 3120 #elif CBC_OTHER_SOLVER==1 3121 OsiCpxSolverInterface * originalSolver = dynamic_cast<OsiCpxSolverInterface *> (model.solver()); 3122 // Dummy solvers 3123 OsiClpSolverInterface dummySolver; 3124 ClpSimplex * lpSolver = dummySolver.getModelPtr(); 3125 OsiCpxSolverInterface * clpSolver = originalSolver; 3126 #endif 3104 3127 assert (originalSolver); 3105 3128 CoinMessageHandler * generalMessageHandler = originalSolver>messageHandler(); 3106 3129 generalMessageHandler>setPrefix(true); 3130 #ifndef CBC_OTHER_SOLVER 3107 3131 OsiSolverInterface * solver = model.solver(); 3108 3132 OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver); … … 3110 3134 lpSolver>setPerturbation(50); 3111 3135 lpSolver>messageHandler()>setPrefix(false); 3136 #endif 3112 3137 establishParams(numberParameters,parameters) ; 3113 3138 const char dirsep = CoinFindDirSeparator(); … … 3556 3581 bool cleanModel = !model2.numberIntegers()&&!model2.numberObjects(); 3557 3582 model2.findIntegers(false); 3558 int heurOptions= parameters_[whichParam(HOPTIONS,numberParameters_,parameters_)].intValue()/100;3583 int heurOptions=(parameters_[whichParam(HOPTIONS,numberParameters_,parameters_)].intValue()/100)%100; 3559 3584 if (heurOptions==0heurOptions==2) { 3560 3585 model2.doHeuristicsAtRoot(1); 3561 3586 } else if (heurOptions==1heurOptions==3) { 3562 3587 model2.setMaximumNodes(1); 3563 CbcStrategyDefault strategy( false,5,5);3588 CbcStrategyDefault strategy(0,5,5); 3564 3589 strategy.setupPreProcessing(1,0); 3565 3590 model2.setStrategy(strategy); … … 3721 3746 It should only have one solver known to it. 3722 3747 */ 3748 CoinMessageHandler * generalMessageHandler = model_.messageHandler(); 3749 generalMessageHandler>setPrefix(false); 3750 #ifndef CBC_OTHER_SOLVER 3723 3751 OsiClpSolverInterface * originalSolver = dynamic_cast<OsiClpSolverInterface *> (model_.solver()); 3724 3752 assert (originalSolver); 3725 CoinMessageHandler * generalMessageHandler = model_.messageHandler();3726 generalMessageHandler>setPrefix(false);3727 3753 // Move handler across if not default 3728 3754 if (!originalSolver>defaultHandler()&&originalSolver>getModelPtr()>defaultHandler()) … … 3732 3758 if (originalSolver>getModelPtr()>logLevel()==0) 3733 3759 noPrinting=true; 3760 #elif CBC_OTHER_SOLVER==1 3761 OsiCpxSolverInterface * originalSolver = dynamic_cast<OsiCpxSolverInterface *> (model_.solver()); 3762 assert (originalSolver); 3763 OsiClpSolverInterface dummySolver; 3764 OsiCpxSolverInterface * clpSolver = originalSolver; 3765 CoinMessages generalMessages = dummySolver.getModelPtr()>messages(); 3766 char generalPrint[10000]; 3767 noPrinting=true; 3768 #endif 3734 3769 #if NEW_STYLE_SOLVER==0 3735 3770 bool noPrinting_=noPrinting; … … 3771 3806 int complicatedInteger=0; 3772 3807 OsiSolverInterface * solver = model_.solver(); 3808 if (noPrinting_) 3809 setCbcOrClpPrinting(false); 3810 #ifndef CBC_OTHER_SOLVER 3773 3811 OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver); 3774 3812 ClpSimplex * lpSolver = clpSolver>getModelPtr(); 3775 3813 if (noPrinting_) { 3776 setCbcOrClpPrinting(false);3777 3814 lpSolver>setLogLevel(0); 3778 3815 } 3816 #else 3817 ClpSimplex * lpSolver = NULL; 3818 #endif 3779 3819 // For priorities etc 3780 3820 int * priorities=NULL; … … 3810 3850 goodModel=true; 3811 3851 solver = model_.solver(); 3852 #ifndef CBC_OTHER_SOLVER 3812 3853 clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver); 3813 3854 lpSolver = clpSolver>getModelPtr(); 3855 #endif 3814 3856 } else { 3815 3857 printf("Bad input from user function %s\n",userFunction_[iUser]>name().c_str()); … … 3914 3956 #ifdef COIN_HAS_LINK 3915 3957 } else { 3958 #ifndef CBC_OTHER_SOLVER 3916 3959 // save 3917 3960 saveCoinModel = *coinModel; … … 3971 4014 delete [] whichRow; 3972 4015 } 4016 #endif 3973 4017 } 3974 4018 #endif … … 4036 4080 bool preSolveFile=false; 4037 4081 bool strongChanged=false; 4082 bool pumpChanged=false; 4038 4083 4039 4084 double djFix=1.0e100; … … 4072 4117 int slog = whichParam(SOLVERLOGLEVEL,numberParameters_,parameters_); 4073 4118 int log = whichParam(LOGLEVEL,numberParameters_,parameters_); 4119 #ifndef CBC_OTHER_SOLVER 4074 4120 double normalIncrement=model_.getCutoffIncrement();; 4121 #endif 4075 4122 if (testOsiParameters>=0) { 4076 4123 // trying nonlinear  switch off some stuff … … 4108 4155 CglKnapsackCover knapsackGen; 4109 4156 //knapsackGen.switchOnExpensive(); 4157 //knapsackGen.setMaxInKnapsack(100); 4110 4158 // set default action (0=off,1=on,2=root) 4111 4159 int knapsackAction=3; … … 4181 4229 #ifdef MORE_CUTS 4182 4230 gomoryGen.setAwayAtRoot(0.005); 4231 twomirGen.setAwayAtRoot(0.005); 4232 twomirGen.setAway(0.01); 4183 4233 #else 4184 4234 gomoryGen.setAwayAtRoot(0.01); 4235 twomirGen.setAwayAtRoot(0.01); 4236 twomirGen.setAway(0.01); 4185 4237 #endif 4186 4238 int iParam; … … 4298 4350 if (type==BAB&&goodModel) { 4299 4351 // check if any integers 4352 #ifndef CBC_OTHER_SOLVER 4300 4353 #ifdef COIN_HAS_ASL 4301 4354 if (info.numberSos&&doSOS&&statusUserFunction_[0]) { … … 4308 4361 !clpSolver>numberSOS()&&!model_.numberObjects()&&!clpSolver>numberObjects()) 4309 4362 type=DUALSIMPLEX; 4363 #endif 4310 4364 } 4311 4365 if (type==GENERALQUERY) { … … 4460 4514 case DJFIX: 4461 4515 djFix=value; 4516 #ifndef CBC_OTHER_SOLVER 4462 4517 if (goodModel&&djFix<1.0e20) { 4463 4518 // do some fixing … … 4498 4553 <<CoinMessageEol; 4499 4554 } 4555 #endif 4500 4556 break; 4501 4557 case TIGHTENFACTOR: … … 4562 4618 parameters_[iParam].type()==NUMBERBEFORE) 4563 4619 strongChanged=true; 4620 else if (parameters_[iParam].type()==FPUMPTUNE 4621 parameters_[iParam].type()==FPUMPITS) 4622 pumpChanged=true; 4564 4623 else if (parameters_[iParam].type()==EXPERIMENT) { 4565 4624 if (value>=1) { … … 4586 4645 parameters_[iParam].setIntValue(30); 4587 4646 iParam = whichParam(FPUMPTUNE,numberParameters_,parameters_); 4588 parameters_[iParam].setIntValue( 8043);4647 parameters_[iParam].setIntValue(1005043); 4589 4648 iParam = whichParam(PROCESSTUNE,numberParameters_,parameters_); 4590 4649 parameters_[iParam].setIntValue(6); … … 4887 4946 case LOCALTREE: 4888 4947 case NAIVE: 4948 case CPX: 4889 4949 defaultSettings=false; // user knows what she is doing 4890 4950 break; … … 5193 5253 model_.setProblemStatus(iStatus); 5194 5254 model_.setSecondaryStatus(iStatus2); 5195 assert (lpSolver==clpSolver>getModelPtr());5255 //assert (lpSolver==clpSolver>getModelPtr()); 5196 5256 assert (clpSolver==model_.solver()); 5197 5257 clpSolver>setWarmStart(NULL); … … 5521 5581 int logLevel = parameters_[slog].intValue(); 5522 5582 // Reduce printout 5523 if (logLevel<=1) 5583 if (logLevel<=1) { 5524 5584 model_.solver()>setHintParam(OsiDoReducePrint,true,OsiHintTry); 5525 else5585 } else { 5526 5586 model_.solver()>setHintParam(OsiDoReducePrint,false,OsiHintTry); 5587 } 5527 5588 { 5528 5589 OsiSolverInterface * solver = model_.solver(); 5590 #ifndef CBC_OTHER_SOLVER 5529 5591 OsiClpSolverInterface * si = 5530 5592 dynamic_cast<OsiClpSolverInterface *>(solver) ; 5531 5593 assert (si != NULL); 5532 5594 si>getModelPtr()>scaling(doScaling); 5533 statistics_nrows=si>getNumRows();5534 statistics_ncols=si>getNumCols();5535 statistics_nprocessedrows=si>getNumRows();5536 statistics_nprocessedcols=si>getNumCols();5537 5595 ClpSimplex * lpSolver = si>getModelPtr(); 5538 5596 if (doVector) { … … 5543 5601 } 5544 5602 } 5603 #elif CBC_OTHER_SOLVER==1 5604 OsiCpxSolverInterface * si = 5605 dynamic_cast<OsiCpxSolverInterface *>(solver) ; 5606 assert (si != NULL); 5607 #endif 5608 statistics_nrows=si>getNumRows(); 5609 statistics_ncols=si>getNumCols(); 5610 statistics_nprocessedrows=si>getNumRows(); 5611 statistics_nprocessedcols=si>getNumCols(); 5545 5612 // See if quadratic 5613 #ifndef CBC_OTHER_SOLVER 5546 5614 #ifdef COIN_HAS_LINK 5547 5615 if (!complicatedInteger) { … … 5750 5818 } 5751 5819 #endif 5820 #endif 5752 5821 if (logLevel<=1) 5753 5822 si>setHintParam(OsiDoReducePrint,true,OsiHintTry); 5823 #ifndef CBC_OTHER_SOLVER 5754 5824 si>setSpecialOptions(0x40000000); 5825 #endif 5755 5826 } 5756 5827 if (!miplib) { … … 5762 5833 model_.initialSolve(); 5763 5834 OsiSolverInterface * solver = model_.solver(); 5835 #ifndef CBC_OTHER_SOLVER 5764 5836 OsiClpSolverInterface * si = 5765 5837 dynamic_cast<OsiClpSolverInterface *>(solver) ; … … 5804 5876 } 5805 5877 clpSolver>setSpecialOptions(clpSolver>specialOptions()IN_BRANCH_AND_BOUND); // say is Cbc (and in branch and bound) 5878 #elif CBC_OTHER_SOLVER==1 5879 #endif 5806 5880 if (!noPrinting_) { 5807 5881 sprintf(generalPrint,"Continuous objective value is %g  %.2f seconds", … … 5841 5915 } 5842 5916 } 5917 #ifndef CBC_OTHER_SOLVER 5843 5918 if (!complicatedInteger&&preProcess==0&&clpSolver>tightenPrimalBounds(0.0,0,true)!=0) { 5844 5919 #ifndef DISALLOW_PRINTING … … 5927 6002 } 5928 6003 si>resolve(); // clean up 6004 #endif 5929 6005 } 5930 6006 // If user made settings then use them … … 5933 6009 if (!doScaling) 5934 6010 solver>setHintParam(OsiDoScale,false,OsiHintTry); 6011 #ifndef CBC_OTHER_SOLVER 5935 6012 OsiClpSolverInterface * si = 5936 6013 dynamic_cast<OsiClpSolverInterface *>(solver) ; … … 5958 6035 } 5959 6036 } 6037 #endif 5960 6038 } 5961 6039 // See if we want preprocessing … … 5966 6044 delete babModel_; 5967 6045 babModel_ = new CbcModel(model_); 6046 #ifndef CBC_OTHER_SOLVER 6047 int numberChanged=0; 5968 6048 OsiSolverInterface * solver3 = clpSolver>clone(); 5969 6049 babModel_>assignSolver(solver3); 5970 6050 OsiClpSolverInterface * clpSolver2 = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 5971 int numberChanged=0;5972 6051 if (clpSolver2>messageHandler()>logLevel()) 5973 6052 clpSolver2>messageHandler()>setLogLevel(1); … … 5994 6073 lpSolver>setFactorizationFrequency(CoinMin(maximum,frequency)); 5995 6074 } 6075 #elif CBC_OTHER_SOLVER==1 6076 OsiSolverInterface * solver3 = model_.solver()>clone(); 6077 babModel_>assignSolver(solver3); 6078 #endif 5996 6079 time2 = CoinCpuTime(); 5997 6080 totalTime += time2time1; … … 6013 6096 } 6014 6097 if (preProcess&&type==BAB) { 6098 #ifndef CBC_OTHER_SOLVER 6015 6099 // See if sos from mps file 6016 6100 if (numberSOS==0&&clpSolver>numberSOS()&&doSOS) { … … 6044 6128 } 6045 6129 } 6130 #endif 6046 6131 saveSolver=babModel_>solver()>clone(); 6047 6132 /* Do not try and produce equality cliques and … … 6141 6226 tunePreProcess = tunePreProcess % 1000; 6142 6227 } 6228 #ifndef CBC_OTHER_SOLVER 6143 6229 if (doSprint>0) { 6144 6230 // Sprint for primal solves … … 6161 6247 osiclp>getModelPtr()>setInfeasibilityCost(1.0e11); 6162 6248 } 6249 #endif 6250 #ifndef CBC_OTHER_SOLVER 6163 6251 { 6164 6252 OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (saveSolver); … … 6173 6261 osiclp>getModelPtr()>setPerturbation(savePerturbation); 6174 6262 } 6263 #elif CBC_OTHER_SOLVER==1 6264 solver2 = process.preProcessNonDefault(*saveSolver,translate[preProcess],numberPasses, 6265 tunePreProcess); 6266 #endif 6175 6267 integersOK=false; // We need to redo if CbcObjects exist 6176 6268 // Tell solver we are not in Branch and Cut … … 6265 6357 // now tighten bounds 6266 6358 if (!miplib) { 6359 #ifndef CBC_OTHER_SOLVER 6267 6360 OsiClpSolverInterface * si = 6268 6361 dynamic_cast<OsiClpSolverInterface *>(babModel_>solver()) ; … … 6286 6379 } 6287 6380 si>resolve(); 6381 #elif CBC_OTHER_SOLVER==1 6382 #endif 6288 6383 } 6289 6384 if (debugValues) { … … 6328 6423 saveTightenedModel); 6329 6424 if (solver) { 6425 #ifndef CBC_OTHER_SOLVER 6330 6426 clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver); 6331 6427 assert (clpSolver); 6332 6428 lpSolver = clpSolver>getModelPtr(); 6429 #endif 6333 6430 babModel_>assignSolver(solver); 6334 6431 testOsiOptions=0; … … 6417 6514 // add cut generators if wanted 6418 6515 int switches[20]; 6516 int accuracyFlag[20]; 6419 6517 int numberGenerators=0; 6420 6518 int translate[]={100,1,99,98,1,1001,1099,1,1,1,1}; … … 6444 6542 iAction=1; 6445 6543 babModel_>addCutGenerator(&probingGen,iAction,"Probing"); 6544 accuracyFlag[numberGenerators]=5; 6446 6545 switches[numberGenerators++]=0; 6447 6546 } … … 6476 6575 } 6477 6576 babModel_>addCutGenerator(&gomoryGen,translate[gomoryAction],"Gomory"); 6577 accuracyFlag[numberGenerators]=3; 6478 6578 switches[numberGenerators++]=0; 6479 6579 } … … 6486 6586 if (knapsackAction) { 6487 6587 babModel_>addCutGenerator(&knapsackGen,translate[knapsackAction],"Knapsack"); 6588 accuracyFlag[numberGenerators]=1; 6488 6589 switches[numberGenerators++]=2; 6489 6590 } 6490 6591 if (redsplitAction&&!complicatedInteger) { 6491 6592 babModel_>addCutGenerator(&redsplitGen,translate[redsplitAction],"Reduceandsplit"); 6593 accuracyFlag[numberGenerators]=5; 6492 6594 switches[numberGenerators++]=1; 6493 6595 } 6494 6596 if (cliqueAction) { 6495 6597 babModel_>addCutGenerator(&cliqueGen,translate[cliqueAction],"Clique"); 6598 accuracyFlag[numberGenerators]=0; 6496 6599 switches[numberGenerators++]=0; 6497 6600 } 6498 6601 if (mixedAction) { 6499 6602 babModel_>addCutGenerator(&mixedGen,translate[mixedAction],"MixedIntegerRounding2"); 6603 accuracyFlag[numberGenerators]=2; 6500 6604 switches[numberGenerators++]=0; 6501 6605 } 6502 6606 if (flowAction) { 6503 6607 babModel_>addCutGenerator(&flowGen,translate[flowAction],"FlowCover"); 6608 accuracyFlag[numberGenerators]=2; 6504 6609 switches[numberGenerators++]=1; 6505 6610 } … … 6515 6620 } 6516 6621 babModel_>addCutGenerator(&twomirGen,translate[twomirAction],"TwoMirCuts"); 6622 accuracyFlag[numberGenerators]=4; 6517 6623 switches[numberGenerators++]=1; 6518 6624 } … … 6520 6626 if (landpAction) { 6521 6627 babModel_>addCutGenerator(&landpGen,translate[landpAction],"LiftAndProject"); 6628 accuracyFlag[numberGenerators]=5; 6522 6629 switches[numberGenerators++]=1; 6523 6630 } … … 6525 6632 if (residualCapacityAction) { 6526 6633 babModel_>addCutGenerator(&residualCapacityGen,translate[residualCapacityAction],"ResidualCapacity"); 6634 accuracyFlag[numberGenerators]=5; 6527 6635 switches[numberGenerators++]=1; 6528 6636 } … … 6534 6642 } 6535 6643 babModel_>addCutGenerator(&zerohalfGen,translate[zerohalfAction],"ZeroHalf"); 6536 switches[numberGenerators++]=0; 6644 accuracyFlag[numberGenerators]=5; 6645 switches[numberGenerators++]=2; 6537 6646 } 6538 6647 #endif … … 6549 6658 if (howOften==98howOften==99) 6550 6659 generator>setSwitchOffIfLessThan(switches[iGenerator]); 6660 generator>setInaccuracy(accuracyFlag[iGenerator]); 6551 6661 generator>setTiming(true); 6552 6662 if (cutDepth>=0) … … 6599 6709 babModel_>solver()>setIntParam(OsiMaxNumIterationHotStart, 6600 6710 parameters_[whichParam(MAXHOTITS,numberParameters_,parameters_)].intValue()); 6711 #ifndef CBC_OTHER_SOLVER 6601 6712 OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 6602 6713 // go faster stripes … … 6620 6731 if (!miplib&&increment==normalIncrement) 6621 6732 changed=analyze( osiclp,numberChanged,increment,false,generalMessageHandler); 6733 #elif CBC_OTHER_SOLVER==1 6734 double increment=babModel_>getCutoffIncrement();; 6735 #endif 6622 6736 if (debugValues) { 6623 6737 int numberColumns = babModel_>solver()>getNumCols(); … … 6675 6789 <<CoinMessageEol; 6676 6790 } 6791 #ifndef CBC_OTHER_SOLVER 6677 6792 osiclp>setSpecialOptions(mipOptions); 6793 #elif CBC_OTHER_SOLVER==1 6794 #endif 6678 6795 // probably faster to use a basis to get integer solutions 6679 6796 babModel_>setSpecialOptions(babModel_>specialOptions()2); … … 6684 6801 // try reduced model 6685 6802 babModel_>setSpecialOptions(babModel_>specialOptions()512); 6686 } else if (experimentFlag==3strategyFlag==2) { 6803 } 6804 if (experimentFlag==3strategyFlag==2) { 6687 6805 // try reduced model at root 6688 babModel_>setSpecialOptions(babModel_>specialOptions() 2048);6806 babModel_>setSpecialOptions(babModel_>specialOptions()32768); 6689 6807 } 6690 6808 { … … 6732 6850 if (extra1==7777) 6733 6851 extra1=1; 6852 else if (extra1==8888) 6853 extra1=1; 6734 6854 babModel_>setWhenCuts(extra1); 6735 6855 } else if (extra1<19000) { … … 7361 7481 babModel_>setNumberBeforeTrust(0); 7362 7482 if (useStrategy) { 7363 CbcStrategyDefault strategy( true,babModel_>numberStrong(),babModel_>numberBeforeTrust());7483 CbcStrategyDefault strategy(1,babModel_>numberStrong(),babModel_>numberBeforeTrust()); 7364 7484 strategy.setupPreProcessing(1); 7365 7485 babModel_>setStrategy(strategy); … … 7590 7710 malloc_stats2(); 7591 7711 #endif 7712 #ifndef CBC_OTHER_SOLVER 7592 7713 if (outputFormat==5) { 7593 7714 osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); … … 7595 7716 lpSolver>setPersistenceFlag(1); 7596 7717 } 7718 #endif 7597 7719 #ifdef COIN_HAS_ASL 7598 7720 // add in lotsizing … … 7715 7837 return returnCode; 7716 7838 } 7839 #ifndef CBC_OTHER_SOLVER 7717 7840 osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 7718 7841 lpSolver = osiclp>getModelPtr(); 7842 #elif CBC_OTHER_SOLVER==1 7843 #endif 7719 7844 if (experimentFlag>=1strategyFlag>=2) { 7720 if (lpSolver>numberColumns()<200&&lpSolver>numberRows()<40) 7845 if (babModel_>solver()>getNumCols()<200&& 7846 babModel_>solver()>getNumRows()<40) 7721 7847 babModel_>setFastNodeDepth(9); 7722 7848 } … … 7725 7851 babModel_>setSpecialOptions(babModel_>specialOptions()8192); 7726 7852 7853 #ifndef CBC_OTHER_SOLVER 7727 7854 #ifdef CLP_MULTIPLE_FACTORIZATIONS 7728 7855 int denseCode = parameters_[whichParam(DENSE,numberParameters_,parameters_)].intValue(); … … 7734 7861 smallCode=40; 7735 7862 } 7736 if (denseCode>0) 7863 if (denseCode>0) { 7737 7864 lpSolver>factorization()>setGoDenseThreshold(denseCode); 7865 assert (osiclp==babModel_>solver()); 7866 osiclp>setSpecialOptions(osiclp>specialOptions()1024); 7867 } 7738 7868 if (smallCode>0&&smallCode>denseCode) 7739 7869 lpSolver>factorization()>setGoSmallThreshold(smallCode); … … 7741 7871 //lpSolver>factorization()>goDense(); 7742 7872 //} 7873 #endif 7743 7874 #endif 7744 7875 #ifdef CLIQUE_ANALYSIS … … 7791 7922 exit(1); 7792 7923 #endif 7924 int hOp1 = parameters_[whichParam(HOPTIONS,numberParameters_,parameters_)].intValue()/100000; 7925 if (hOp1%10) { 7926 CbcCompareDefault compare; 7927 compare.setBreadthDepth(hOp1%10); 7928 babModel_>setNodeComparison(compare); 7929 } 7930 #if defined(CBC_OTHER_SOLVER)defined(COIN_HAS_CPX) 7931 if (dynamic_cast<OsiCpxSolverInterface *> (babModel_>solver())) 7932 babModel_>solver()>messageHandler()>setLogLevel(0); 7933 #endif 7934 if (parameters_[whichParam(CPX,numberParameters_,parameters_)].currentOptionAsInteger()) { 7935 babModel_>setSpecialOptions(babModel_>specialOptions()16384); 7936 //if (babModel_>fastNodeDepth()==1) 7937 babModel_>setFastNodeDepth(2); // Use Cplex at root 7938 } 7939 int hOp2 = parameters_[whichParam(HOPTIONS,numberParameters_,parameters_)].intValue()/10000; 7940 if (hOp2%10) { 7941 babModel_>setSpecialOptions(babModel_>specialOptions()16384); 7942 if (babModel_>fastNodeDepth()==1) 7943 babModel_>setFastNodeDepth(2); // Use Cplex at root 7944 } 7793 7945 babModel_>branchAndBound(statistics); 7794 7946 //#define CLP_FACTORIZATION_INSTRUMENT … … 7838 7990 checkSOS(babModel_, babModel_>solver()); 7839 7991 } else if (type==MIPLIB) { 7840 CbcStrategyDefault strategy(true,babModel_>numberStrong(),babModel_>numberBeforeTrust()); 7992 int typeOfCuts = babModel_>numberCutGenerators() ? 1 : 1; 7993 CbcStrategyDefault strategy(typeOfCuts, 7994 babModel_>numberStrong(), 7995 babModel_>numberBeforeTrust()); 7841 7996 // Set up preprocessing 7842 7997 int translate2[]={9999,1,1,3,2,4,5,6,6}; … … 7849 8004 babModel_>setThreadMode(numberThreads/100); 7850 8005 #endif 8006 #ifndef CBC_OTHER_SOLVER 7851 8007 if (outputFormat==5) { 7852 8008 osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); … … 7854 8010 lpSolver>setPersistenceFlag(1); 7855 8011 } 8012 #endif 7856 8013 if (testOsiOptions>=0) { 7857 8014 printf("Testing OsiObject options %d\n",testOsiOptions); … … 7866 8023 } 7867 8024 model_ = *babModel_; 8025 #ifndef CBC_OTHER_SOLVER 8026 { 8027 osiclp = dynamic_cast< OsiClpSolverInterface*> (model_.solver()); 8028 lpSolver = osiclp>getModelPtr(); 8029 lpSolver>setSpecialOptions(lpSolver>specialOptions()IN_BRANCH_AND_BOUND); // say is Cbc (and in branch and bound) 8030 } 8031 #endif 7868 8032 /* LL: this was done in CoinSolve.cpp: main(argc, argv). 7869 8033 I have moved it here so that the miplib directory location … … 7886 8050 stuff[9]=doVector; 7887 8051 stuff[10] = parameters_[whichParam(SMALLFACT,numberParameters_,parameters_)].intValue(); 8052 if (parameters_[whichParam(CPX,numberParameters_,parameters_)].currentOptionAsInteger()) { 8053 model_.setSpecialOptions(model_.specialOptions()16384); 8054 //if (model_.fastNodeDepth()==1) 8055 model_.setFastNodeDepth(2); // Use Cplex at root 8056 } 8057 int hOp2 = parameters_[whichParam(HOPTIONS,numberParameters_,parameters_)].intValue()/10000; 8058 if (hOp2%10) { 8059 model_.setSpecialOptions(model_.specialOptions()16384); 8060 if (model_.fastNodeDepth()==1) 8061 model_.setFastNodeDepth(2); // Use Cplex at root 8062 } 8063 if (!pumpChanged) { 8064 // Make more lightweight 8065 for (int iHeur=0;iHeur<model_.numberHeuristics();iHeur++) { 8066 CbcHeuristic * heuristic = model_.heuristic(iHeur); 8067 CbcHeuristicFPump* pump = 8068 dynamic_cast<CbcHeuristicFPump*>(heuristic); 8069 if (pump) { 8070 CbcHeuristicFPump heuristic4(model_); 8071 heuristic4.setFractionSmall(0.5); 8072 heuristic4.setMaximumPasses(5); 8073 heuristic4.setFeasibilityPumpOptions(30); 8074 heuristic4.setWhen(13); 8075 heuristic4.setHeuristicName("feasibility pump"); 8076 //CbcHeuristicFPump & pump2 = pump; 8077 *pump = heuristic4; 8078 } 8079 } 8080 } 7888 8081 int returnCode=CbcClpUnitTest(model_, dirMiplib, extra1==1,stuff); 7889 8082 babModel_=NULL; … … 7893 8086 } 7894 8087 currentBranchModel = NULL; 8088 #ifndef CBC_OTHER_SOLVER 7895 8089 osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 7896 8090 if (debugFile=="createAfterPre"&&babModel_>bestSolution()) { … … 7901 8095 saveSolution(osiclp>getModelPtr(),"debug.file"); 7902 8096 } 8097 #endif 7903 8098 statistics_cut_time=0.0; 7904 8099 if (!noPrinting_) { … … 7974 8169 n = saveSolver>getNumCols(); 7975 8170 bestSolution = new double [n]; 8171 #ifndef CBC_OTHER_SOLVER 7976 8172 OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 8173 #else 8174 OsiCpxSolverInterface * clpSolver = dynamic_cast< OsiCpxSolverInterface*> (babModel_>solver()); 8175 #endif 7977 8176 // Save bounds on processed model 7978 8177 const int * originalColumns = process.originalColumns(); … … 7995 8194 upper2[jColumn]=columnUpper[i]; 7996 8195 } 8196 #ifndef CBC_OTHER_SOLVER 7997 8197 ClpSimplex * lpSolver = clpSolver>getModelPtr(); 7998 8198 lpSolver>setSpecialOptions(lpSolver>specialOptions()IN_BRANCH_AND_BOUND); // say is Cbc (and in branch and bound) 8199 #endif 7999 8200 process.postProcess(*babModel_>solver()); 8000 8201 // Solution now back in saveSolver … … 8052 8253 assert (saveSolver>isProvenOptimal()); 8053 8254 #if NEW_STYLE_SOLVER==0 8255 #ifndef CBC_OTHER_SOLVER 8054 8256 // and original solver 8055 8257 assert (n>=originalSolver>getNumCols()); … … 8071 8273 assert (originalSolver>isProvenOptimal()); 8072 8274 #endif 8275 #endif 8073 8276 babModel_>assignSolver(saveSolver); 8074 8277 memcpy(bestSolution,babModel_>solver()>getColSolution(),n*sizeof(double)); … … 8084 8287 babModel_>setBestSolution(bestSolution,n,babModel_>getMinimizationObjValue()); 8085 8288 #if NEW_STYLE_SOLVER==0 8289 #ifndef CBC_OTHER_SOLVER 8086 8290 // and put back in very original solver 8087 8291 { … … 8107 8311 } 8108 8312 #endif 8313 #endif 8109 8314 checkSOS(babModel_, babModel_>solver()); 8110 8315 } else if (model_.bestSolution()&&type==BAB&&model_.getMinimizationObjValue()<1.0e50&&preProcess) { … … 8120 8325 memcpy(bestSolution,babModel_>solver()>getColSolution(),n*sizeof(double)); 8121 8326 #if NEW_STYLE_SOLVER==0 8327 #ifndef CBC_OTHER_SOLVER 8122 8328 // and put back in very original solver 8123 8329 { … … 8141 8347 } 8142 8348 #endif 8349 #endif 8143 8350 } 8351 #ifndef CBC_OTHER_SOLVER 8144 8352 if (type==STRENGTHEN&&strengthenedModel) 8145 8353 clpSolver = dynamic_cast< OsiClpSolverInterface*> (strengthenedModel); … … 8156 8364 delete [] changed; 8157 8365 } 8366 #endif 8158 8367 if (type==BAB) { 8368 #ifndef CBC_OTHER_SOLVER 8159 8369 //move best solution (should be there  but ..) 8160 8370 int n = lpSolver>getNumCols(); … … 8171 8381 saveSolution(lpSolver,"debug.file"); 8172 8382 } 8383 #else 8384 if (bestSolution) { 8385 model_.solver()>setColSolution(bestSolution); 8386 } 8387 #endif 8173 8388 delete [] bestSolution; 8174 8389 std::string statusName[]={"Finished","Stopped on ","Difficulties", … … 8283 8498 free(info.primalSolution); 8284 8499 if (!numberKnapsack) { 8285 info.primalSolution = (double *) malloc(n*sizeof(double));8500 info.primalSolution = reinterpret_cast<double *> (malloc(n*sizeof(double))); 8286 8501 CoinCopyN(lpSolver>primalColumnSolution(),n,info.primalSolution); 8287 8502 int numberRows = lpSolver>numberRows(); 8288 8503 free(info.dualSolution); 8289 info.dualSolution = (double *) malloc(numberRows*sizeof(double));8504 info.dualSolution = reinterpret_cast<double *> (malloc(numberRows*sizeof(double))); 8290 8505 CoinCopyN(lpSolver>dualRowSolution(),numberRows,info.dualSolution); 8291 8506 } else { … … 8293 8508 info.dualSolution=NULL; 8294 8509 int numberColumns = saveCoinModel.numberColumns(); 8295 info.primalSolution = (double *) malloc(numberColumns*sizeof(double));8510 info.primalSolution = reinterpret_cast<double *> (malloc(numberColumns*sizeof(double))); 8296 8511 // Fills in original solution (coinModel length) 8297 8512 afterKnapsack(saveTightenedModel, whichColumn, knapsackStart, … … 8449 8664 if (canOpen) { 8450 8665 int status; 8666 #ifndef CBC_OTHER_SOLVER 8451 8667 ClpSimplex * lpSolver = clpSolver>getModelPtr(); 8452 8668 if (!gmpl) { … … 8461 8677 status= lpSolver>readLp(fileName.c_str(),1.0e12); 8462 8678 } 8679 #else 8680 status =clpSolver>readMps(fileName.c_str(),""); 8681 #endif 8463 8682 if (!status(status>0&&allowImportErrors)) { 8683 #ifndef CBC_OTHER_SOLVER 8464 8684 if (keepImportNames&&gmpl<=0) { 8465 8685 lengthName = lpSolver>lengthNames(); … … 8478 8698 clpSolver>setInteger(i); 8479 8699 } 8700 #else 8701 lengthName=0; 8702 goodModel=true; 8703 #endif 8480 8704 time2 = CoinCpuTime(); 8481 8705 totalTime += time2time1; … … 8503 8727 break; 8504 8728 case MODELIN: 8729 #ifndef CBC_OTHER_SOLVER 8505 8730 #ifdef COIN_HAS_LINK 8506 8731 { … … 8586 8811 } 8587 8812 #endif 8813 #endif 8588 8814 break; 8589 8815 case EXPORT: … … 8636 8862 model2>setOptimizationDirection(1.0); 8637 8863 } 8864 #ifndef CBC_OTHER_SOLVER 8638 8865 #ifdef COIN_HAS_ASL 8639 8866 if (info.numberSos&&doSOS&&statusUserFunction_[0]) { … … 8646 8873 clpSolver>setSOSData(numberSOS,info.sosType,sosStart,sosIndices,sosReference); 8647 8874 } 8875 #endif 8648 8876 #endif 8649 8877 if (preSolve) { … … 8773 9001 } 8774 9002 if (canOpen) { 9003 #ifndef CBC_OTHER_SOLVER 8775 9004 int values = lpSolver>readBasis(fileName.c_str()); 8776 9005 if (values==0) … … 8780 9009 assert (lpSolver==clpSolver>getModelPtr()); 8781 9010 clpSolver>setWarmStart(NULL); 9011 #endif 8782 9012 } 8783 9013 } else { … … 9135 9365 if (numberDebugValues<200) { 9136 9366 for (int i=0;i<numberDebugValues;i++) { 9137 if ( lpSolver>isInteger(i)&&debugValues[i])9367 if (clpSolver>isInteger(i)&&debugValues[i]) 9138 9368 printf("%d %g\n",i,debugValues[i]); 9139 9369 } … … 9753 9983 } 9754 9984 if (fp) { 9985 #ifndef CBC_OTHER_SOLVER 9755 9986 if (printMode!=5) { 9756 9987 // Write solution header (suggested by Luigi Poderico) … … 9777 10008 fprintf(fp, "  objective value %15.8g\n", objValue); 9778 10009 } 10010 #endif 9779 10011 // make fancy later on 9780 10012 int iRow; 9781 int numberRows=lpSolver>numberRows(); 9782 double * dualRowSolution = lpSolver>dualRowSolution(); 9783 double * primalRowSolution = 9784 lpSolver>primalRowSolution(); 9785 double * rowLower = lpSolver>rowLower(); 9786 double * rowUpper = lpSolver>rowUpper(); 9787 double primalTolerance = lpSolver>primalTolerance(); 10013 int numberRows=clpSolver>getNumRows(); 10014 const double * dualRowSolution = clpSolver>getRowPrice(); 10015 const double * primalRowSolution = 10016 clpSolver>getRowActivity(); 10017 const double * rowLower = clpSolver>getRowLower(); 10018 const double * rowUpper = clpSolver>getRowUpper(); 10019 double primalTolerance ; 10020 clpSolver>getDblParam(OsiPrimalTolerance,primalTolerance); 9788 10021 char format[6]; 9789 10022 sprintf(format,"%%%ds",CoinMax(lengthName,8)); … … 9912 10145 } 9913 10146 int iColumn; 9914 int numberColumns= lpSolver>numberColumns();9915 double * dualColumnSolution =9916 lpSolver>dualColumnSolution();9917 double * primalColumnSolution =9918 lpSolver>primalColumnSolution();9919 double * columnLower = lpSolver>columnLower();9920 double * columnUpper = lpSolver>columnUpper();10147 int numberColumns=clpSolver>getNumCols(); 10148 const double * dualColumnSolution = 10149 clpSolver>getReducedCost(); 10150 const double * primalColumnSolution = 10151 clpSolver>getColSolution(); 10152 const double * columnLower = clpSolver>getColLower(); 10153 const double * columnUpper = clpSolver>getColUpper(); 9921 10154 if (printMode!=2) { 9922 10155 if (printMode==5) { … … 9939 10172 } 9940 10173 // see if integer 9941 if ((! lpSolver>isInteger(iColumn)fabs(primalColumnSolution[iColumn])<1.0e8)10174 if ((!clpSolver>isInteger(iColumn)fabs(primalColumnSolution[iColumn])<1.0e8) 9942 10175 &&printMode==1) 9943 10176 type=0; … … 10122 10355 if (babModel_) { 10123 10356 model_.moveInfo(*babModel_); 10357 #ifndef CBC_OTHER_SOLVER 10124 10358 OsiClpSolverInterface * clpSolver0 = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 10125 10359 ClpSimplex * lpSolver0 = clpSolver0>getModelPtr(); … … 10129 10363 lpSolver>moveInfo(*lpSolver0); 10130 10364 //babModel_>setModelOwnsSolver(false); 10365 #endif 10131 10366 } 10132 10367 #ifdef CBC_SIG_TRAP … … 10530 10765 if (preProcess) { 10531 10766 strcpy(line[numberLines++],"5 // Preprocessing using CbcStrategy"); 10532 strcpy(line[numberLines++],"5 CbcStrategyDefault strategy( true,5,5);");10767 strcpy(line[numberLines++],"5 CbcStrategyDefault strategy(1,5,5);"); 10533 10768 strcpy(line[numberLines++],"5 strategy.setupPreProcessing(1);"); 10534 10769 strcpy(line[numberLines++],"5 cbcModel>setStrategy(strategy);");
Note: See TracChangeset
for help on using the changeset viewer.