source: trunk/Cbc/src/CbcBranchBase.hpp @ 1433

Last change on this file since 1433 was 1400, checked in by lou, 10 years ago

Add a final blank line; hudson test server seems to want it.

  • 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 1400 2009-12-11 14:14:06Z tkr $ */
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcBranchBase_H
5#define CbcBranchBase_H
6
7#include <string>
8#include <vector>
9#include "OsiBranchingObject.hpp"
10
11enum CbcRangeCompare {
12    CbcRangeSame,
13    CbcRangeDisjoint,
14    CbcRangeSubset,
15    CbcRangeSuperset,
16    CbcRangeOverlap
17};
18
19#include "CbcObject.hpp"
20#include "CbcBranchingObject.hpp"
21#include "CbcBranchDecision.hpp"
22#include "CbcConsequence.hpp"
23#include "CbcObjectUpdateData.hpp"
24
25//##############################################################################
26
27/** Compare two ranges. The two bounds arrays are both of size two and
28    describe closed intervals. Return the appropriate CbcRangeCompare value
29    (first argument being the sub/superset if that's the case). In case of
30    overlap (and if \c replaceIfOverlap is true) replace the content of thisBd
31    with the intersection of the ranges.
32*/
33static inline CbcRangeCompare
34CbcCompareRanges(double* thisBd, const double* otherBd,
35                 const bool replaceIfOverlap)
36{
37    const double lbDiff = thisBd[0] - otherBd[0];
38    if (lbDiff < 0) { // lb of this < lb of other
39        if (thisBd[1] >= otherBd[1]) { // ub of this >= ub of other
40            return CbcRangeSuperset;
41        } else if (thisBd[1] < otherBd[0]) {
42            return CbcRangeDisjoint;
43        } else {
44            // overlap
45            if (replaceIfOverlap) {
46                thisBd[0] = otherBd[0];
47            }
48            return CbcRangeOverlap;
49        }
50    } else if (lbDiff > 0) { // lb of this > lb of other
51        if (thisBd[1] <= otherBd[1]) { // ub of this <= ub of other
52            return CbcRangeSubset;
53        } else if (thisBd[0] > otherBd[1]) {
54            return CbcRangeDisjoint;
55        } else {
56            // overlap
57            if (replaceIfOverlap) {
58                thisBd[1] = otherBd[1];
59            }
60            return CbcRangeOverlap;
61        }
62    } else { // lb of this == lb of other
63        if (thisBd[1] == otherBd[1]) {
64            return CbcRangeSame;
65        }
66        return thisBd[1] < otherBd[1] ? CbcRangeSubset : CbcRangeSuperset;
67    }
68
69    return CbcRangeSame; // fake return
70
71}
72
73//#############################################################################
74
75#endif
76
Note: See TracBrowser for help on using the repository browser.