Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcBranchBase.hpp
Go to the documentation of this file.
1 /* $Id: CbcBranchBase.hpp 1573 2011-01-05 01:12:36Z lou $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CbcBranchBase_H
7 #define CbcBranchBase_H
8 
9 #include <string>
10 #include <vector>
11 #include "OsiBranchingObject.hpp"
12 
19 };
20 
21 #include "CbcObject.hpp"
22 #include "CbcBranchingObject.hpp"
23 #include "CbcBranchDecision.hpp"
24 #include "CbcConsequence.hpp"
25 #include "CbcObjectUpdateData.hpp"
26 
27 //##############################################################################
28 
35 static inline CbcRangeCompare
36 CbcCompareRanges(double* thisBd, const double* otherBd,
37  const bool replaceIfOverlap)
38 {
39  const double lbDiff = thisBd[0] - otherBd[0];
40  if (lbDiff < 0) { // lb of this < lb of other
41  if (thisBd[1] >= otherBd[1]) { // ub of this >= ub of other
42  return CbcRangeSuperset;
43  } else if (thisBd[1] < otherBd[0]) {
44  return CbcRangeDisjoint;
45  } else {
46  // overlap
47  if (replaceIfOverlap) {
48  thisBd[0] = otherBd[0];
49  }
50  return CbcRangeOverlap;
51  }
52  } else if (lbDiff > 0) { // lb of this > lb of other
53  if (thisBd[1] <= otherBd[1]) { // ub of this <= ub of other
54  return CbcRangeSubset;
55  } else if (thisBd[0] > otherBd[1]) {
56  return CbcRangeDisjoint;
57  } else {
58  // overlap
59  if (replaceIfOverlap) {
60  thisBd[1] = otherBd[1];
61  }
62  return CbcRangeOverlap;
63  }
64  } else { // lb of this == lb of other
65  if (thisBd[1] == otherBd[1]) {
66  return CbcRangeSame;
67  }
68  return thisBd[1] < otherBd[1] ? CbcRangeSubset : CbcRangeSuperset;
69  }
70 
71  return CbcRangeSame; // fake return
72 
73 }
74 
75 //#############################################################################
76 
77 #endif
78 
CbcRangeCompare
static CbcRangeCompare CbcCompareRanges(double *thisBd, const double *otherBd, const bool replaceIfOverlap)
Compare two ranges.