source: trunk/Cbc/src/CbcBranchBase.hpp

Last change on this file was 2833, checked in by stefan, 3 days ago

merge branch autotools-update

  • exclude travis and appveyor updates
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: CbcBranchBase.hpp 2833 2020-01-16 10:30:36Z stefan $ */
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
13enum CbcRangeCompare {
14  CbcRangeSame,
15  CbcRangeDisjoint,
16  CbcRangeSubset,
17  CbcRangeSuperset,
18  CbcRangeOverlap
19};
20
21#include "CbcConfig.h"
22#include "CbcObject.hpp"
23#include "CbcBranchingObject.hpp"
24#include "CbcBranchDecision.hpp"
25#include "CbcConsequence.hpp"
26#include "CbcObjectUpdateData.hpp"
27
28//##############################################################################
29
30/** Compare two ranges. The two bounds arrays are both of size two and
31    describe closed intervals. Return the appropriate CbcRangeCompare value
32    (first argument being the sub/superset if that's the case). In case of
33    overlap (and if \c replaceIfOverlap is true) replace the content of thisBd
34    with the intersection of the ranges.
35*/
36static inline CbcRangeCompare
37CbcCompareRanges(double *thisBd, const double *otherBd,
38  const bool replaceIfOverlap)
39{
40  const double lbDiff = thisBd[0] - otherBd[0];
41  if (lbDiff < 0) { // lb of this < lb of other
42    if (thisBd[1] >= otherBd[1]) { // ub of this >= ub of other
43      return CbcRangeSuperset;
44    } else if (thisBd[1] < otherBd[0]) {
45      return CbcRangeDisjoint;
46    } else {
47      // overlap
48      if (replaceIfOverlap) {
49        thisBd[0] = otherBd[0];
50      }
51      return CbcRangeOverlap;
52    }
53  } else if (lbDiff > 0) { // lb of this > lb of other
54    if (thisBd[1] <= otherBd[1]) { // ub of this <= ub of other
55      return CbcRangeSubset;
56    } else if (thisBd[0] > otherBd[1]) {
57      return CbcRangeDisjoint;
58    } else {
59      // overlap
60      if (replaceIfOverlap) {
61        thisBd[1] = otherBd[1];
62      }
63      return CbcRangeOverlap;
64    }
65  } else { // lb of this == lb of other
66    if (thisBd[1] == otherBd[1]) {
67      return CbcRangeSame;
68    }
69    return thisBd[1] < otherBd[1] ? CbcRangeSubset : CbcRangeSuperset;
70  }
71
72  return CbcRangeSame; // fake return
73}
74
75//#############################################################################
76
77#endif
78
79/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
80*/
Note: See TracBrowser for help on using the repository browser.