Cbc trunk
|
00001 /* $Id$ */ 00002 // Copyright (C) 2002, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef CbcBranchBase_H 00007 #define CbcBranchBase_H 00008 00009 #include <string> 00010 #include <vector> 00011 #include "OsiBranchingObject.hpp" 00012 00013 enum CbcRangeCompare { 00014 CbcRangeSame, 00015 CbcRangeDisjoint, 00016 CbcRangeSubset, 00017 CbcRangeSuperset, 00018 CbcRangeOverlap 00019 }; 00020 00021 #include "CbcObject.hpp" 00022 #include "CbcBranchingObject.hpp" 00023 #include "CbcBranchDecision.hpp" 00024 #include "CbcConsequence.hpp" 00025 #include "CbcObjectUpdateData.hpp" 00026 00027 //############################################################################## 00028 00035 static inline CbcRangeCompare 00036 CbcCompareRanges(double* thisBd, const double* otherBd, 00037 const bool replaceIfOverlap) 00038 { 00039 const double lbDiff = thisBd[0] - otherBd[0]; 00040 if (lbDiff < 0) { // lb of this < lb of other 00041 if (thisBd[1] >= otherBd[1]) { // ub of this >= ub of other 00042 return CbcRangeSuperset; 00043 } else if (thisBd[1] < otherBd[0]) { 00044 return CbcRangeDisjoint; 00045 } else { 00046 // overlap 00047 if (replaceIfOverlap) { 00048 thisBd[0] = otherBd[0]; 00049 } 00050 return CbcRangeOverlap; 00051 } 00052 } else if (lbDiff > 0) { // lb of this > lb of other 00053 if (thisBd[1] <= otherBd[1]) { // ub of this <= ub of other 00054 return CbcRangeSubset; 00055 } else if (thisBd[0] > otherBd[1]) { 00056 return CbcRangeDisjoint; 00057 } else { 00058 // overlap 00059 if (replaceIfOverlap) { 00060 thisBd[1] = otherBd[1]; 00061 } 00062 return CbcRangeOverlap; 00063 } 00064 } else { // lb of this == lb of other 00065 if (thisBd[1] == otherBd[1]) { 00066 return CbcRangeSame; 00067 } 00068 return thisBd[1] < otherBd[1] ? CbcRangeSubset : CbcRangeSuperset; 00069 } 00070 00071 return CbcRangeSame; // fake return 00072 00073 } 00074 00075 //############################################################################# 00076 00077 #endif 00078