Changeset 137
 Timestamp:
 May 19, 2005 3:02:30 PM (15 years ago)
 Location:
 trunk
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

trunk/CbcBranchDynamic.cpp
r135 r137 237 237 below = above 1; 238 238 } 239 #define INFEAS 240 #ifdef INFEAS 241 double distanceToCutoff=0.0; 239 242 double objectiveValue = solver>getObjSense()*solver>getObjValue(); 240 d ouble distanceToCutoff = model_>getCutoff()<1.0e20 objectiveValue;243 distanceToCutoff = model_>getCutoff()  objectiveValue; 241 244 if (distanceToCutoff<1.0e20) 242 245 distanceToCutoff *= 10.0; 243 246 else 244 247 distanceToCutoff = 1.0e2 + fabs(objectiveValue); 248 #endif 245 249 double sum; 246 250 int number; … … 248 252 sum = sumDownCost(); 249 253 number = numberTimesDown(); 254 #ifdef INFEAS 250 255 sum += numberTimesDownInfeasible()*(distanceToCutoff/(downCost+1.0e12)); 256 #endif 251 257 if (number>0) 252 258 downCost *= sum / (double) number; … … 256 262 sum = sumUpCost(); 257 263 number = numberTimesUp(); 264 #ifdef INFEAS 258 265 sum += numberTimesUpInfeasible()*(distanceToCutoff/(upCost+1.0e12)); 266 #endif 259 267 if (number>0) 260 268 upCost *= sum / (double) number; … … 391 399 } 392 400 double objectiveValue = solver>getObjSense()*solver>getObjValue(); 393 double distanceToCutoff = model_>getCutoff() <1.0e20 objectiveValue;401 double distanceToCutoff = model_>getCutoff()  objectiveValue; 394 402 if (distanceToCutoff<1.0e20) 395 403 distanceToCutoff *= 10.0; 
trunk/CbcModel.cpp
r136 r137 548 548 int numberOldActiveCuts = 0 ; 549 549 int numberNewCuts = 0 ; 550 // Array to mark solution 551 usedInSolution_ = new int[numberColumns]; 552 CoinZeroN(usedInSolution_,numberColumns); 550 553 { int iObject ; 551 554 int preferredWay ; … … 680 683 if (newNode) 681 684 { continuousObjective_ = newNode>objectiveValue() ; 685 continuousSolution_ = CoinCopyOfArray(solver_>getColSolution(), 686 numberColumns); 682 687 continuousInfeasibilities_ = newNode>numberUnsatisfied() ; } 683 688 /* … … 1056 1061 { double saveValue = heurValue ; 1057 1062 int ifSol = heuristic_[iHeur]>solution(heurValue,newSolution) ; 1058 if (ifSol > 0) // new solution found 1059 { found = iHeur ; } 1063 if (ifSol > 0) { 1064 // new solution found 1065 found = iHeur ; 1066 incrementUsed(newSolution); 1067 } 1060 1068 else 1061 1069 if (ifSol < 0) // just returning an estimate … … 1079 1087 setBestSolution(CBC_SOLUTION,objectiveValue, 1080 1088 solver_>getColSolution()) ; 1089 incrementUsed(solver_>getColSolution()); 1081 1090 assert(nodeInfo>numberPointingToThis() <= 2) ; 1082 1091 // avoid accidental pruning, if newNode was final branch arm … … 1297 1306 currentNode_(NULL), 1298 1307 integerVariable_(NULL), 1308 continuousSolution_(NULL), 1309 usedInSolution_(NULL), 1299 1310 specialOptions_(0), 1300 1311 subTreeModel_(NULL), … … 1303 1314 numberStrong_(5), 1304 1315 numberBeforeTrust_(0), 1316 numberInfeasibleNodes_(0), 1305 1317 problemType_(0), 1306 1318 printFrequency_(0), … … 1382 1394 numberStrong_(5), 1383 1395 numberBeforeTrust_(0), 1396 numberInfeasibleNodes_(0), 1384 1397 problemType_(0), 1385 1398 printFrequency_(0), … … 1433 1446 // Space for current solution 1434 1447 currentSolution_ = new double[numberColumns]; 1448 continuousSolution_ = new double[numberColumns]; 1449 usedInSolution_ = new int[numberColumns]; 1435 1450 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1436 1451 if( solver_>isInteger(iColumn)) … … 1440 1455 // empty model 1441 1456 currentSolution_=NULL; 1457 continuousSolution_=NULL; 1458 usedInSolution_=NULL; 1442 1459 } 1443 1460 testSolution_=currentSolution_; … … 1544 1561 numberStrong_(rhs.numberStrong_), 1545 1562 numberBeforeTrust_(rhs.numberBeforeTrust_), 1563 numberInfeasibleNodes_(rhs.numberInfeasibleNodes_), 1546 1564 problemType_(rhs.problemType_), 1547 1565 printFrequency_(rhs.printFrequency_), … … 1646 1664 bestSolution_=NULL; 1647 1665 } 1648 if ( rhs.currentSolution_&&!noTree) {1666 if (!noTree) { 1649 1667 int numberColumns = solver_>getNumCols(); 1650 currentSolution_ = new double[numberColumns]; 1651 memcpy(currentSolution_,rhs.currentSolution_,numberColumns*sizeof(double)); 1668 currentSolution_ = CoinCopyOfArray(rhs.currentSolution_,numberColumns); 1669 continuousSolution_ = CoinCopyOfArray(rhs.continuousSolution_,numberColumns); 1670 usedInSolution_ = CoinCopyOfArray(rhs.usedInSolution_,numberColumns); 1652 1671 } else { 1653 1672 currentSolution_=NULL; 1673 continuousSolution_=NULL; 1674 usedInSolution_=NULL; 1654 1675 } 1655 1676 testSolution_=currentSolution_; … … 1744 1765 bestSolution_=NULL; 1745 1766 } 1746 if (rhs.currentSolution_) { 1747 int numberColumns = rhs.getNumCols(); 1748 currentSolution_ = new double[numberColumns]; 1749 memcpy(currentSolution_,rhs.currentSolution_,numberColumns*sizeof(double)); 1750 } else { 1751 currentSolution_=NULL; 1752 } 1767 int numberColumns = solver_>getNumCols(); 1768 currentSolution_ = CoinCopyOfArray(rhs.currentSolution_,numberColumns); 1769 continuousSolution_ = CoinCopyOfArray(rhs.continuousSolution_,numberColumns); 1770 usedInSolution_ = CoinCopyOfArray(rhs.usedInSolution_,numberColumns); 1753 1771 testSolution_=currentSolution_; 1754 1772 minimumDrop_ = rhs.minimumDrop_; … … 1766 1784 numberStrong_ = rhs.numberStrong_; 1767 1785 numberBeforeTrust_ = rhs.numberBeforeTrust_; 1786 numberInfeasibleNodes_ = rhs.numberInfeasibleNodes_; 1768 1787 problemType_ = rhs.problemType_; 1769 1788 printFrequency_ = rhs.printFrequency_; … … 2405 2424 } 2406 2425 2407 if (!feasible) return (false) ; 2426 if (!feasible) { 2427 numberInfeasibleNodes_++; 2428 return (false) ; 2429 } 2408 2430 sumChangeObjective1_ += solver_>getObjValue()*solver_>getObjSense() 2409 2431  objectiveValue ; … … 2597 2619 // better solution found 2598 2620 found = i ; 2621 incrementUsed(newSolution); 2599 2622 } else if (ifSol<0) { 2600 2623 heuristicValue = saveValue ; … … 2675 2698 // better solution found 2676 2699 found = i ; 2700 incrementUsed(newSolution); 2677 2701 } else { 2678 2702 heuristicValue = saveValue ; … … 2689 2713 { 2690 2714 phase_=4; 2715 incrementUsed(newSolution); 2691 2716 setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ; } 2692 2717 delete [] newSolution ; … … 2953 2978 // better solution found 2954 2979 found = i ; 2980 incrementUsed(newSolution); 2955 2981 } else { 2956 2982 heuristicValue = saveValue ; … … 2960 2986 if (found >= 0) { 2961 2987 phase_=4; 2988 incrementUsed(newSolution); 2962 2989 setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ; 2963 2990 } … … 4848 4875 // better solution found 4849 4876 found=iHeuristic; 4877 incrementUsed(newSolution); 4850 4878 } else if (ifSol<0) { 4851 4879 heuristicValue = saveValue; … … 5542 5570 strategy_ = strategy.clone(); 5543 5571 } 5572 // Increases usedInSolution for nonzeros 5573 void 5574 CbcModel::incrementUsed(const double * solution) 5575 { 5576 // might as well mark all including continuous 5577 int numberColumns = solver_>getNumCols(); 5578 for (int i=0;i<numberColumns;i++) { 5579 if (solution[i]) 5580 usedInSolution_[i]++; 5581 } 5582 } 
trunk/CbcNode.cpp
r135 r137 1358 1358 newObjectiveValue, 1359 1359 solver>getColSolution()) ; 1360 model>incrementUsed(solver>getColSolution()); 1360 1361 if (newObjectiveValue >= model>getCutoff()) // *new* cutoff 1361 1362 objectiveChange = 1.0e100 ; … … 1441 1442 newObjectiveValue, 1442 1443 solver>getColSolution()) ; 1444 model>incrementUsed(solver>getColSolution()); 1443 1445 if (newObjectiveValue >= model>getCutoff()) // *new* cutoff 1444 1446 objectiveChange = 1.0e100 ; … … 1958 1960 int canSkip = choice.possibleBranch>fillStrongInfo(choice); 1959 1961 // For now always do 1960 canSkip=false;1962 //canSkip=false; 1961 1963 if (model>messageHandler()>logLevel()>3) 1962 1964 dynamicObject>print(1,choice.possibleBranch>value()); … … 2006 2008 newObjectiveValue, 2007 2009 solver>getColSolution()) ; 2010 model>incrementUsed(solver>getColSolution()); 2008 2011 if (newObjectiveValue >= model>getCutoff()) // *new* cutoff 2009 2012 objectiveChange = 1.0e100 ; … … 2063 2066 newObjectiveValue, 2064 2067 solver>getColSolution()) ; 2068 model>incrementUsed(solver>getColSolution()); 2065 2069 if (newObjectiveValue >= model>getCutoff()) // *new* cutoff 2066 2070 objectiveChange = 1.0e100 ; 
trunk/include/CbcModel.hpp
r135 r137 747 747 /**@name Methods related to querying the solution */ 748 748 //@{ 749 /// Holds solution at continuous (after cuts) 750 inline double * continuousSolution() const 751 { return continuousSolution_;}; 752 /** Array marked whenever a solution is found if nonzero. 753 Code marks if heuristic returns better so heuristic 754 need only mark if it wants to on solutions which 755 are worse than current */ 756 inline int * usedInSolution() const 757 { return usedInSolution_;}; 758 /// Increases usedInSolution for nonzeros 759 void incrementUsed(const double * solution); 749 760 /// Record a new incumbent solution and update objectiveValue 750 761 void setBestSolution(CBC_Message how, … … 1342 1353 /// Indices of integer variables 1343 1354 int * integerVariable_; 1355 /// Holds solution at continuous (after cuts) 1356 double * continuousSolution_; 1357 /// Array marked whenever a solution is found if nonzero 1358 int * usedInSolution_; 1344 1359 /// 0 bit  check if cuts valid (if on list) 1345 1360 int specialOptions_; … … 1374 1389 in dynamic strong branching. (0 off) */ 1375 1390 int numberBeforeTrust_; 1391 /// Number of nodes infeasible by normal branching (before cuts) 1392 int numberInfeasibleNodes_; 1376 1393 /** Problem type as set by user or found by analysis. This will be extended 1377 1394 0  not known
Note: See TracChangeset
for help on using the changeset viewer.