Changeset 395
 Timestamp:
 Jul 3, 2006 7:07:32 AM (14 years ago)
 Location:
 trunk/Cbc/src
 Files:

 5 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcCutGenerator.cpp
r310 r395 29 29 atSolution_(false), 30 30 whenInfeasible_(false), 31 mustCallAgain_(false), 32 switchedOff_(false), 31 33 timing_(false), 32 34 timeInCutGenerator_(0.0), … … 47 49 depthCutGenerator_(whatDepth), 48 50 depthCutGeneratorInSub_(whatDepthInSub), 51 mustCallAgain_(false), 52 switchedOff_(false), 49 53 timing_(false), 50 54 timeInCutGenerator_(0.0), … … 84 88 atSolution_=rhs.atSolution_; 85 89 whenInfeasible_=rhs.whenInfeasible_; 90 mustCallAgain_ = rhs.mustCallAgain_; 91 switchedOff_ = rhs.switchedOff_; 86 92 timing_ = rhs.timing_; 87 93 timeInCutGenerator_ = rhs.timeInCutGenerator_; … … 111 117 atSolution_=rhs.atSolution_; 112 118 whenInfeasible_=rhs.whenInfeasible_; 119 mustCallAgain_ = rhs.mustCallAgain_; 120 switchedOff_ = rhs.switchedOff_; 113 121 timing_ = rhs.timing_; 114 122 timeInCutGenerator_ = rhs.timeInCutGenerator_; 
trunk/Cbc/src/CbcCutGenerator.hpp
r259 r395 215 215 inline bool needsOptimalBasis() const 216 216 { return generator_>needsOptimalBasis();}; 217 /// Whether generator MUST be called again if any cuts (i.e. ignore break from loop) 218 inline bool mustCallAgain() const 219 { return mustCallAgain_;}; 220 /// Set whether generator MUST be called again if any cuts (i.e. ignore break from loop) 221 inline void setMustCallAgain(bool yesNo) 222 { mustCallAgain_=yesNo;}; 223 /// Whether generator switched off for moment 224 inline bool switchedOff() const 225 { return switchedOff_;}; 226 /// Set whether generator switched off for moment 227 inline void setSwitchedOff(bool yesNo) 228 { switchedOff_=yesNo;}; 217 229 //@} 218 230 … … 258 270 /// Whether to call generator when a subproblem is found to be infeasible 259 271 bool whenInfeasible_; 272 /// Whether generator MUST be called again if any cuts (i.e. ignore break from loop) 273 bool mustCallAgain_; 274 /// Temporary switch off marker 275 bool switchedOff_; 260 276 /// Whether call generator being timed 261 277 bool timing_; 
trunk/Cbc/src/CbcModel.cpp
r391 r395 619 619 */ 620 620 synchronizeModel() ; 621 assert (!solverCharacteristics_); 622 OsiBabSolver * solverCharacteristics = dynamic_cast<OsiBabSolver *> (solver_>getAuxiliaryInfo()); 623 if (solverCharacteristics) { 624 solverCharacteristics_ = solverCharacteristics; 625 } else { 626 // replace in solver 627 OsiBabSolver defaultC; 628 solver_>setAuxiliaryInfo(&defaultC); 629 solverCharacteristics_ = dynamic_cast<OsiBabSolver *> (solver_>getAuxiliaryInfo()); 621 if (!solverCharacteristics_) { 622 OsiBabSolver * solverCharacteristics = dynamic_cast<OsiBabSolver *> (solver_>getAuxiliaryInfo()); 623 if (solverCharacteristics) { 624 solverCharacteristics_ = solverCharacteristics; 625 } else { 626 // replace in solver 627 OsiBabSolver defaultC; 628 solver_>setAuxiliaryInfo(&defaultC); 629 solverCharacteristics_ = dynamic_cast<OsiBabSolver *> (solver_>getAuxiliaryInfo()); 630 } 630 631 } 631 632 solverCharacteristics_>setSolver(solver_); … … 641 642 bool feasible; 642 643 // If NLP then we assume already solved outside branchAndbound 643 if (!solverCharacteristics_>solverType() ) {644 if (!solverCharacteristics_>solverType()solverCharacteristics_>solverType()==4) { 644 645 feasible=resolve(NULL,0) != 0 ; 645 646 } else { … … 831 832 // replace solverType 832 833 if(solverCharacteristics_>tryCuts()) { 834 833 835 if (numberUnsatisfied) { 834 836 feasible = solveWithCuts(cuts,maximumCutPassesAtRoot_, 835 837 NULL); 836 } else if (solverCharacteristics_>solutionAddsCuts()) { 838 } else if (solverCharacteristics_>solutionAddsCuts() 839 solverCharacteristics_>alwaysTryCutsAtRootNode()) { 837 840 // may generate cuts and turn the solution 838 841 //to an infeasible one … … 1896 1899 public methods. 1897 1900 */ 1898 if (bestSolution_&& solverCharacteristics_>solverType()<2)1901 if (bestSolution_&&(solverCharacteristics_>solverType()<2solverCharacteristics_>solverType()==4)) 1899 1902 { setCutoff(1.0e50) ; // As best solution should be worse than cutoff 1900 1903 phase_=5; … … 3678 3681 currentPassNumber_ = 0 ; 3679 3682 double primalTolerance = 1.0e7 ; 3683 // We may need to keep going on 3684 bool keepGoing=false; 3680 3685 /* 3681 3686 Begin cut generation loop. Cuts generated during each iteration are … … 3694 3699 { currentPassNumber_++ ; 3695 3700 numberTries ; 3701 if (numberTries<0&&keepGoing) { 3702 // switch off all normal ones 3703 for (int i = 0;i<numberCutGenerators_;i++) { 3704 if (!generator_[i]>mustCallAgain()) 3705 generator_[i]>setSwitchedOff(true); 3706 } 3707 } 3708 keepGoing=false; 3696 3709 OsiCuts theseCuts ; 3697 3710 /* … … 3788 3801 if (generator_[i]>needsOptimalBasis()&&!solver_>basisIsAvailable()) 3789 3802 generate=false; 3803 if (generator_[i]>switchedOff()) 3804 generate=false;; 3790 3805 if (generate) { 3791 3806 bool mustResolve = 3792 3807 generator_[i]>generateCuts(theseCuts,fullScan,node) ; 3808 if(numberRowCutsBefore < theseCuts.sizeRowCuts() && 3809 generator_[i]>mustCallAgain()) 3810 keepGoing=true; // say must go round 3793 3811 #ifdef CBC_DEBUG 3794 3812 { … … 4178 4196 lastNumberCuts = numberNewCuts_ ; 4179 4197 if (direction*solver_>getObjValue() < lastObjective+minimumDrop && 4180 currentPassNumber_ >= 3 )4198 currentPassNumber_ >= 3 && !keepGoing) 4181 4199 { numberTries = 0 ; } 4182 4200 if (numberRowCuts+numberColumnCuts == 0  cutIterations == 0) … … 4204 4222 numberTries = 0 ; 4205 4223 } 4206 } while (numberTries>0) ; 4224 } while (numberTries>0keepGoing) ; 4225 { 4226 // switch on 4227 for (int i = 0;i<numberCutGenerators_;i++) 4228 generator_[i]>setSwitchedOff(false); 4229 } 4207 4230 //check feasibility. 4208 4231 //If solution seems to be integer feasible calling setBestSolution … … 7633 7656 return CoinCpuTime()getDblParam(CbcStartSeconds); 7634 7657 } 7658 /* 7659 For advanced applications you may wish to modify the behavior of Cbc 7660 e.g. if the solver is a NLP solver then you may not have an exact 7661 optimum solution at each step. Information could be built into 7662 OsiSolverInterface but this is an alternative so that that interface 7663 does not have to be changed. If something similar is useful to 7664 enough solvers then it could be migrated. 7665 You can also pass in by using solver>setAuxiliaryInfo. 7666 You should do that if solver is odd  if solver is normal simplex 7667 then use this 7668 */ 7669 void 7670 CbcModel::passInSolverCharacteristics(OsiBabSolver * solverCharacteristics) 7671 { 7672 solverCharacteristics_ = solverCharacteristics; 7673 } 7635 7674 // Create C++ lines to get to current state 7636 7675 void 
trunk/Cbc/src/CbcModel.hpp
r356 r395 1248 1248 does not have to be changed. If something similar is useful to 1249 1249 enough solvers then it could be migrated 1250 You can also pass in by using solver>setAuxiliaryInfo. 1251 You should do that if solver is odd  if solver is normal simplex 1252 then use this. 1253 NOTE  characteristics are not cloned 1250 1254 */ 1251 1255 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics); 1256 /// Get solver characteristics 1257 inline const OsiBabSolver * solverCharacteristics() const 1258 { return solverCharacteristics_;}; 1252 1259 //@} 1253 1260 
trunk/Cbc/src/CbcNode.cpp
r356 r395 1887 1887 const OsiAuxInfo * auxInfo = solver>getAuxiliaryInfo(); 1888 1888 const OsiBabSolver * auxiliaryInfo = dynamic_cast<const OsiBabSolver *> (auxInfo); 1889 if (!auxiliaryInfo) { 1890 // use one from CbcModel 1891 auxiliaryInfo = model>solverCharacteristics(); 1892 } 1893 assert (auxiliaryInfo); 1889 1894 //assert(objectiveValue_ == solver>getObjSense()*solver>getObjValue()); 1890 1895 double cutoff =model>getCutoff();
Note: See TracChangeset
for help on using the changeset viewer.