Changeset 889
 Timestamp:
 Mar 5, 2008 1:47:07 PM (13 years ago)
 Location:
 branches/heur/Cbc/src
 Files:

 7 edited
Legend:
 Unmodified
 Added
 Removed

branches/heur/Cbc/src/CbcBranchActual.cpp
r886 r889 18 18 #include "CoinSort.hpp" 19 19 #include "CoinError.hpp" 20 21 //##############################################################################22 23 /** Compare two ranges. The two bounds arrays are both of size two and24 describe closed intervals. Return the appropriate CbcRangeCompare value25 (first argument being the sub/superset if that's the case). In case of26 overlap (and if \c replaceIfOverlap is true) replace the content of thisBd27 with the intersection of the ranges.28 */29 static inline CbcRangeCompare30 CbcCompareRanges(double* thisBd, const double* otherBd,31 const bool replaceIfOverlap)32 {33 const double lbDiff = thisBd[0]  otherBd[0];34 if (lbDiff < 0) { // lb of this < lb of other35 if (thisBd[1] >= otherBd[1]) { // ub of this >= ub of other36 return CbcRangeSuperset;37 } else if (thisBd[1] < otherBd[0]) {38 return CbcRangeDisjoint;39 } else {40 // overlap41 if (replaceIfOverlap) {42 thisBd[0] = otherBd[0];43 }44 return CbcRangeOverlap;45 }46 } else if (lbDiff > 0) { // lb of this > lb of other47 if (thisBd[1] <= otherBd[1]) { // ub of this <= ub of other48 return CbcRangeSubset;49 } else if (thisBd[0] > otherBd[1]) {50 return CbcRangeDisjoint;51 } else {52 // overlap53 if (replaceIfOverlap) {54 thisBd[1] = otherBd[1];55 }56 return CbcRangeOverlap;57 }58 } else { // lb of this == lb of other59 if (thisBd[1] == otherBd[1]) {60 return CbcRangeSame;61 }62 return thisBd[1] < otherBd[1] ? CbcRangeSubset : CbcRangeSuperset;63 }64 65 return CbcRangeSame; // fake return66 67 }68 20 69 21 //############################################################################## 
branches/heur/Cbc/src/CbcBranchBase.hpp
r886 r889 594 594 }; 595 595 596 //############################################################################## 597 598 /** Compare two ranges. The two bounds arrays are both of size two and 599 describe closed intervals. Return the appropriate CbcRangeCompare value 600 (first argument being the sub/superset if that's the case). In case of 601 overlap (and if \c replaceIfOverlap is true) replace the content of thisBd 602 with the intersection of the ranges. 603 */ 604 static inline CbcRangeCompare 605 CbcCompareRanges(double* thisBd, const double* otherBd, 606 const bool replaceIfOverlap) 607 { 608 const double lbDiff = thisBd[0]  otherBd[0]; 609 if (lbDiff < 0) { // lb of this < lb of other 610 if (thisBd[1] >= otherBd[1]) { // ub of this >= ub of other 611 return CbcRangeSuperset; 612 } else if (thisBd[1] < otherBd[0]) { 613 return CbcRangeDisjoint; 614 } else { 615 // overlap 616 if (replaceIfOverlap) { 617 thisBd[0] = otherBd[0]; 618 } 619 return CbcRangeOverlap; 620 } 621 } else if (lbDiff > 0) { // lb of this > lb of other 622 if (thisBd[1] <= otherBd[1]) { // ub of this <= ub of other 623 return CbcRangeSubset; 624 } else if (thisBd[0] > otherBd[1]) { 625 return CbcRangeDisjoint; 626 } else { 627 // overlap 628 if (replaceIfOverlap) { 629 thisBd[1] = otherBd[1]; 630 } 631 return CbcRangeOverlap; 632 } 633 } else { // lb of this == lb of other 634 if (thisBd[1] == otherBd[1]) { 635 return CbcRangeSame; 636 } 637 return thisBd[1] < otherBd[1] ? CbcRangeSubset : CbcRangeSuperset; 638 } 639 640 return CbcRangeSame; // fake return 641 642 } 643 596 644 //############################################################################# 597 645 
branches/heur/Cbc/src/CbcBranchCut.cpp
r640 r889 284 284 return false; 285 285 } 286 287 /** Compare the original object of \c this with the original object of \c 288 brObj. Assumes that there is an ordering of the original objects. 289 This method should be invoked only if \c this and brObj are of the same 290 type. 291 Return negative/0/positive depending on whether \c this is 292 smaller/same/larger than the argument. 293 */ 294 int 295 CbcCutBranchingObject::compareOriginalObject 296 (const CbcBranchingObject* brObj) const 297 { 298 const CbcCutBranchingObject* br = 299 dynamic_cast<const CbcCutBranchingObject*>(brObj); 300 assert(br); 301 const OsiRowCut& r0 = way_ == 1 ? down_ : up_; 302 const OsiRowCut& r1 = br>way_ == 1 ? br>down_ : br>up_; 303 return r0.row().compare(r1.row()); 304 } 305 306 /** Compare the \c this with \c brObj. \c this and \c brObj must be os the 307 same type and must have the same original object, but they may have 308 different feasible regions. 309 Return the appropriate CbcRangeCompare value (first argument being the 310 sub/superset if that's the case). In case of overlap (and if \c 311 replaceIfOverlap is true) replace the current branching object with one 312 whose feasible region is the overlap. 313 */ 314 315 CbcRangeCompare 316 CbcCutBranchingObject::compareBranchingObject 317 (const CbcBranchingObject* brObj, const bool replaceIfOverlap) 318 { 319 const CbcCutBranchingObject* br = 320 dynamic_cast<const CbcCutBranchingObject*>(brObj); 321 assert(br); 322 OsiRowCut& r0 = way_ == 1 ? down_ : up_; 323 const OsiRowCut& r1 = br>way_ == 1 ? br>down_ : br>up_; 324 double thisBd[2]; 325 thisBd[0] = r0.lb(); 326 thisBd[1] = r0.ub(); 327 double otherBd[2]; 328 otherBd[0] = r1.lb(); 329 otherBd[1] = r1.ub(); 330 CbcRangeCompare comp = CbcCompareRanges(thisBd, otherBd, replaceIfOverlap); 331 if (comp != CbcRangeOverlap  (comp==CbcRangeOverlap && !replaceIfOverlap)) { 332 return comp; 333 } 334 r0.setLb(thisBd[0]); 335 r0.setUb(thisBd[1]); 336 return comp; 337 } 338 339 //############################################################################## 286 340 287 341 /** Default Constructor 
branches/heur/Cbc/src/CbcBranchCut.hpp
r886 r889 150 150 /** Return the type (an integer identifier) of \c this */ 151 151 virtual int type() const { return 200; } 152 153 /** Compare the original object of \c this with the original object of \c 154 brObj. Assumes that there is an ordering of the original objects. 155 This method should be invoked only if \c this and brObj are of the same 156 type. 157 Return negative/0/positive depending on whether \c this is 158 smaller/same/larger than the argument. 159 */ 160 virtual int compareOriginalObject(const CbcBranchingObject* brObj) const; 152 161 153 162 /** Compare the \c this with \c brObj. \c this and \c brObj must be os the 
branches/heur/Cbc/src/CbcBranchDynamic.hpp
r886 r889 397 397 virtual int type() const { return 400; } 398 398 399 /** Compare the \c this with \c brObj. \c this and \c brObj must be os the 400 same type and must have the same original object, but they may have 401 different feasible regions. 402 Return the appropriate CbcRangeCompare value (first argument being the 403 sub/superset if that's the case). In case of overlap (and if \c 404 replaceIfOverlap is true) replace the current branching object with one 405 whose feasible region is the overlap. 406 */ 407 virtual CbcRangeCompare compareBranchingObject 408 (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false); 399 // LL: compareOriginalObject and compareBranchingObject are inherited from 400 // CbcIntegerBranchingObject thus need not be declared/defined here. After 401 // all, this kind of branching object is simply using pseudocosts to make 402 // decisions, but once the decisions are made they are the same kind as in 403 // the underlying class. 409 404 410 405 protected: 
branches/heur/Cbc/src/CbcBranchLotsize.cpp
r640 r889 778 778 } 779 779 } 780 781 /** Compare the \c this with \c brObj. \c this and \c brObj must be os the 782 same type and must have the same original object, but they may have 783 different feasible regions. 784 Return the appropriate CbcRangeCompare value (first argument being the 785 sub/superset if that's the case). In case of overlap (and if \c 786 replaceIfOverlap is true) replace the current branching object with one 787 whose feasible region is the overlap. 788 */ 789 CbcRangeCompare 790 CbcLotsizeBranchingObject::compareBranchingObject 791 (const CbcBranchingObject* brObj, const bool replaceIfOverlap) 792 { 793 const CbcLotsizeBranchingObject* br = 794 dynamic_cast<const CbcLotsizeBranchingObject*>(brObj); 795 assert(br); 796 double* thisBd = way_ == 1 ? down_ : up_; 797 const double* otherBd = br>way_ == 1 ? br>down_ : br>up_; 798 return CbcCompareRanges(thisBd, otherBd, replaceIfOverlap); 799 } 
branches/heur/Cbc/src/CbcBranchLotsize.hpp
r886 r889 205 205 virtual int type() const { return 300; } 206 206 207 // LL: compareOriginalObject can be inherited from the CbcBranchingObject 208 // since variable_ uniquely defines the lot sizing object. 209 207 210 /** Compare the \c this with \c brObj. \c this and \c brObj must be os the 208 211 same type and must have the same original object, but they may have
Note: See TracChangeset
for help on using the changeset viewer.