 Timestamp:
 Jun 5, 2005 4:09:15 AM (15 years ago)
 Location:
 trunk
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

trunk/CbcMessage.cpp
r84 r143 20 20 {CBC_MAXTIME,20,1,"Exiting on maximum time"}, 21 21 {CBC_MAXSOLS,19,1,"Exiting on maximum solutions"}, 22 {CBC_EVENT,27,1,"Exiting on user event"}, 22 23 {CBC_SOLUTION,4,1,"Integer solution of %g found after %d iterations and %d nodes"}, 23 24 {CBC_END,5,1,"Partial search  best objective %g (best possible %g), took %d iterations and %d nodes"}, 
trunk/CbcModel.cpp
r141 r143 36 36 // include Presolve from Clp 37 37 #include "ClpPresolve.hpp" 38 // Temporary39 38 #include "OsiClpSolverInterface.hpp" 39 #include "ClpEventHandler.hpp" 40 40 #endif 41 41 … … 386 386 strategy_>setupOther(*this); 387 387 } 388 bool eventHappened=false; 389 ClpEventHandler * eventHandler=NULL; 390 #ifdef COIN_USE_CLP 391 { 392 OsiClpSolverInterface * clpSolver 393 = dynamic_cast<OsiClpSolverInterface *> (solver_); 394 if (clpSolver) { 395 ClpSimplex * clpSimplex = clpSolver>getModelPtr(); 396 eventHandler = clpSimplex>eventHandler(); 397 } 398 } 399 #endif 388 400 if (!nodeCompare_) 389 401 nodeCompare_=new CbcCompareDefault();; … … 753 765 while (!tree_>empty()) 754 766 { if (cutoff > getCutoff()) { 767 if (eventHandler) { 768 if (!eventHandler>event(ClpEventHandler::solution)) { 769 eventHappened=true; // exit 770 } 771 } 755 772 // Do from deepest 756 773 tree_>cleanTree(this, getCutoff(),bestPossibleObjective_) ; … … 787 804 << numberNodes_<< nNodes<< bestObjective_<< bestPossibleObjective_ 788 805 << CoinMessageEol ; 806 if (eventHandler) { 807 if (!eventHandler>event(ClpEventHandler::treeStatus)) { 808 eventHappened=true; // exit 809 } 810 } 789 811 } 790 812 // If no solution but many nodes  signal change in strategy … … 911 933 numberSolutions_ < intParam_[CbcMaxNumSol] && 912 934 totalTime < dblParam_[CbcMaximumSeconds] && 913 !stoppedOnGap )935 !stoppedOnGap&&!eventHappened) 914 936 { 915 937 /* … … 928 950 */ 929 951 if (onOptimalPath) 930 assert (feasible);952 assert (feasible); 931 953 if (feasible) 932 954 { newNode = new CbcNode ; … … 946 968 anyAction = newNode>chooseBranch(this,node,numberPassesLeft) ; 947 969 } else { 948 anyAction = newNode>chooseDynamicBranch(this, node,numberPassesLeft) ;970 anyAction = newNode>chooseDynamicBranch(this,NULL,numberPassesLeft) ; 949 971 if (anyAction==3) 950 972 anyAction = newNode>chooseBranch(this,node,numberPassesLeft) ; // dynamic did nothing 951 973 } 952 //if (onOptimalPath)953 //assert (anyAction!=2); // can be useful but gives false positives on strong974 if (onOptimalPath) 975 assert (anyAction!=2); // can be useful but gives false positives on strong 954 976 numberPassesLeft; 955 977 if (numberPassesLeft<=1) { … … 1036 1058 Clearly I need to look more carefully. 1037 1059 */ 1060 if (eventHandler) { 1061 if (!eventHandler>event(ClpEventHandler::node)) { 1062 eventHappened=true; // exit 1063 } 1064 } 1038 1065 assert (!newNode  newNode>objectiveValue() <= getCutoff()) ; 1039 1066 if (newNode) … … 1130 1157 status_ = 1 ; } 1131 1158 else 1159 if (eventHappened) 1160 { handler_>message(CBC_EVENT,messages_) << CoinMessageEol ; 1161 status_ = 5 ; } 1162 else 1132 1163 { handler_>message(CBC_MAXSOLS,messages_) << CoinMessageEol ; 1133 1164 status_ = 1 ; } … … 1317 1348 numberStrong_(5), 1318 1349 numberBeforeTrust_(0), 1350 numberPenalties_(20), 1351 penaltyScaleFactor_(3.0), 1319 1352 numberInfeasibleNodes_(0), 1320 1353 problemType_(0), … … 1397 1430 numberStrong_(5), 1398 1431 numberBeforeTrust_(0), 1432 numberPenalties_(20), 1433 penaltyScaleFactor_(3.0), 1399 1434 numberInfeasibleNodes_(0), 1400 1435 problemType_(0), … … 1564 1599 numberStrong_(rhs.numberStrong_), 1565 1600 numberBeforeTrust_(rhs.numberBeforeTrust_), 1601 numberPenalties_(rhs.numberPenalties_), 1602 penaltyScaleFactor_(penaltyScaleFactor_), 1566 1603 numberInfeasibleNodes_(rhs.numberInfeasibleNodes_), 1567 1604 problemType_(rhs.problemType_), … … 1787 1824 numberStrong_ = rhs.numberStrong_; 1788 1825 numberBeforeTrust_ = rhs.numberBeforeTrust_; 1826 numberPenalties_ = rhs.numberPenalties_; 1827 penaltyScaleFactor_ = penaltyScaleFactor_; 1789 1828 numberInfeasibleNodes_ = rhs.numberInfeasibleNodes_; 1790 1829 problemType_ = rhs.problemType_; … … 2021 2060 } else { 2022 2061 numberBeforeTrust_=number; 2023 numberStrong_ = CoinMax(numberStrong_,1); 2062 //numberStrong_ = CoinMax(numberStrong_,1); 2063 } 2064 } 2065 void 2066 CbcModel::setNumberPenalties(int number) 2067 { 2068 if (number<=0) { 2069 numberPenalties_=0; 2070 } else { 2071 numberPenalties_=number; 2072 } 2073 } 2074 void 2075 CbcModel::setPenaltyScaleFactor(double value) 2076 { 2077 if (value<=0) { 2078 penaltyScaleFactor_=3.0; 2079 } else { 2080 penaltyScaleFactor_=value; 2024 2081 } 2025 2082 } … … 2437 2494 sumChangeObjective1_ += solver_>getObjValue()*solver_>getObjSense() 2438 2495  objectiveValue ; 2496 if ( CoinCpuTime()dblParam_[CbcStartSeconds] > dblParam_[CbcMaximumSeconds] ) 2497 numberTries=0; // exit 2439 2498 //if ((numberNodes_%100)==0) 2440 2499 //printf("XXa sum obj changed by %g\n",sumChangeObjective1_); … … 2887 2946 "solveWithCuts","CbcModel") ; } } 2888 2947 feasible = resolve() ; 2948 if ( CoinCpuTime()dblParam_[CbcStartSeconds] > dblParam_[CbcMaximumSeconds] ) 2949 numberTries=0; // exit 2889 2950 # ifdef CBC_DEBUG 2890 2951 printf("Obj value after cuts %g %d rows\n",solver_>getObjValue(), … … 2925 2986 if (feasible) 2926 2987 { int cutIterations = solver_>getIterationCount() ; 2927 takeOffCuts(cuts,whichGenerator,numberOldActiveCuts,numberNewCuts,resolveAfterTakeOffCuts_) ; 2928 if (solver_>isDualObjectiveLimitReached()&&resolveAfterTakeOffCuts_) 2929 { feasible = false ; 2988 if (numberOldActiveCuts+numberNewCuts) { 2989 takeOffCuts(cuts,whichGenerator,numberOldActiveCuts, 2990 numberNewCuts,resolveAfterTakeOffCuts_) ; 2991 if (solver_>isDualObjectiveLimitReached()&&resolveAfterTakeOffCuts_) 2992 { feasible = false ; 2930 2993 # ifdef CBC_DEBUG 2931 2932 2933 2934 2994 double z = solver_>getObjValue() ; 2995 double cut = getCutoff() ; 2996 printf("Lost feasibility by %g in takeOffCuts; z = %g, cutoff = %g\n", 2997 zcut,z,cut) ; 2935 2998 # endif 2999 } 2936 3000 } 2937 3001 if (feasible) 2938 { numberRowsAtStart = numberOldActiveCuts+numberRowsAtContinuous_ ;2939 2940 2941 2942 2943 2944 2945 2946 3002 { numberRowsAtStart = numberOldActiveCuts+numberRowsAtContinuous_ ; 3003 lastNumberCuts = numberNewCuts ; 3004 if (direction*solver_>getObjValue() < lastObjective+minimumDrop && 3005 currentPassNumber_ >= 3) 3006 { numberTries = 0 ; } 3007 if (numberRowCuts+numberColumnCuts == 0  cutIterations == 0) 3008 { break ; } 3009 if (numberTries > 0) 3010 { reducedCostFix() ; 2947 3011 lastObjective = direction*solver_>getObjValue() ; 2948 3012 lower = solver_>getColLower() ; … … 2969 3033 } 2970 3034 } while (numberTries>0) ; 3035 // Reduced cost fix at end 3036 //reducedCostFix(); 2971 3037 // If at root node do heuristics 2972 3038 if (!numberNodes_) { … … 3110 3176 // update size of problem 3111 3177 numberRowsAtContinuous_ = solver_>getNumRows() ; 3178 //#ifdef COIN_USE_CLP 3179 #if 0 3180 OsiClpSolverInterface * clpSolver 3181 = dynamic_cast<OsiClpSolverInterface *> (solver_); 3182 if (clpSolver) { 3183 // Maybe solver might like to know only column bounds will change 3184 int options = clpSolver>specialOptions(); 3185 clpSolver>setSpecialOptions(options128); 3186 clpSolver>synchronizeModel(); 3187 } 3188 #endif 3112 3189 } else { 3113 3190 #ifdef COIN_USE_CLP … … 3117 3194 // make sure factorization can't carry over 3118 3195 int options = clpSolver>specialOptions(); 3119 if (options>=0) 3120 clpSolver>setSpecialOptions(clpSolver>specialOptions()&(~8)); 3196 clpSolver>setSpecialOptions(options&(~8)); 3121 3197 } 3122 3198 #endif 
trunk/include/CbcMessage.hpp
r84 r143 25 25 CBC_MAXTIME, 26 26 CBC_MAXSOLS, 27 CBC_EVENT, 27 28 CBC_SOLUTION, 28 29 CBC_END, 
trunk/include/CbcModel.hpp
r137 r143 552 552 inline int numberBeforeTrust() const 553 553 { return numberBeforeTrust_;}; 554 /** Set the number of variables for which to compute penalties 555 in dynamic strong branching. 556 557 A value of 0 disables penalties. 558 */ 559 void setNumberPenalties(int number); 560 /** get the number of variables for which to compute penalties 561 in dynamic strong branching. */ 562 inline int numberPenalties() const 563 { return numberPenalties_;}; 564 /** Get scale factor to make penalties match strong. 565 Should/will be computed */ 566 inline double penaltyScaleFactor() const 567 { return penaltyScaleFactor_;}; 568 /** Set scale factor to make penalties match strong. 569 Should/will be computed */ 570 void setPenaltyScaleFactor(double value); 554 571 /** Problem type as set by user or found by analysis. This will be extended 555 572 0  not known … … 557 574 2  Set partitioning == 558 575 3  Set covering 576 4  all + 1 or all +1 and odd 559 577 */ 560 578 void inline setProblemType(int number) … … 1389 1407 in dynamic strong branching. (0 off) */ 1390 1408 int numberBeforeTrust_; 1409 /** The number of variable sfor which to compute penalties 1410 in dynamic strong branching. (0 off) */ 1411 int numberPenalties_; 1412 /** Scale factor to make penalties match strong. 1413 Should/will be computed */ 1414 double penaltyScaleFactor_; 1391 1415 /// Number of nodes infeasible by normal branching (before cuts) 1392 1416 int numberInfeasibleNodes_;
Note: See TracChangeset
for help on using the changeset viewer.