Changeset 1347 for branches/sandbox/Cbc/src/CbcSimpleInteger.hpp
 Timestamp:
 Dec 3, 2009 5:11:02 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/sandbox/Cbc/src/CbcSimpleInteger.hpp
r1293 r1347 4 4 #define CbcSimpleInteger_H 5 5 6 #include "CbcIntegerBranchingObject.hpp" 6 /** Simple branching object for an integer variable 7 8 This object can specify a twoway branch on an integer variable. For each 9 arm of the branch, the upper and lower bounds on the variable can be 10 independently specified. 11 12 Variable_ holds the index of the integer variable in the integerVariable_ 13 array of the model. 14 */ 15 16 class CbcIntegerBranchingObject : public CbcBranchingObject { 17 18 public: 19 20 /// Default constructor 21 CbcIntegerBranchingObject (); 22 23 /** Create a standard floor/ceiling branch object 24 25 Specifies a simple twoway branch. Let \p value = x*. One arm of the 26 branch will be lb <= x <= floor(x*), the other ceil(x*) <= x <= ub. 27 Specify way = 1 to set the object state to perform the down arm first, 28 way = 1 for the up arm. 29 */ 30 CbcIntegerBranchingObject (CbcModel *model, int variable, 31 int way , double value) ; 32 33 /** Create a degenerate branch object 34 35 Specifies a `oneway branch'. Calling branch() for this object will 36 always result in lowerValue <= x <= upperValue. Used to fix a variable 37 when lowerValue = upperValue. 38 */ 39 40 CbcIntegerBranchingObject (CbcModel *model, int variable, int way, 41 double lowerValue, double upperValue) ; 42 43 /// Copy constructor 44 CbcIntegerBranchingObject ( const CbcIntegerBranchingObject &); 45 46 /// Assignment operator 47 CbcIntegerBranchingObject & operator= (const CbcIntegerBranchingObject& rhs); 48 49 /// Clone 50 virtual CbcBranchingObject * clone() const; 51 52 /// Destructor 53 virtual ~CbcIntegerBranchingObject (); 54 55 /// Does part of constructor 56 void fillPart ( int variable, int way , double value) ; 57 using CbcBranchingObject::branch ; 58 /** \brief Sets the bounds for the variable according to the current arm 59 of the branch and advances the object state to the next arm. 60 Returns change in guessed objective on next branch 61 */ 62 virtual double branch(); 63 /** Update bounds in solver as in 'branch' and update given bounds. 64 branchState is 1 for 'down' +1 for 'up' */ 65 virtual void fix(OsiSolverInterface * solver, 66 double * lower, double * upper, 67 int branchState) const ; 68 69 #if 0 70 // No need to override. Default works fine. 71 /** Reset every information so that the branching object appears to point to 72 the previous child. This method does not need to modify anything in any 73 solver. */ 74 virtual void previousBranch(); 75 #endif 76 77 using CbcBranchingObject::print ; 78 /** \brief Print something about branch  only if log level high 79 */ 80 virtual void print(); 81 82 /// Lower and upper bounds for down branch 83 inline const double * downBounds() const { 84 return down_; 85 } 86 /// Lower and upper bounds for up branch 87 inline const double * upBounds() const { 88 return up_; 89 } 90 /// Set lower and upper bounds for down branch 91 inline void setDownBounds(const double bounds[2]) { 92 memcpy(down_, bounds, 2*sizeof(double)); 93 } 94 /// Set lower and upper bounds for up branch 95 inline void setUpBounds(const double bounds[2]) { 96 memcpy(up_, bounds, 2*sizeof(double)); 97 } 98 #ifdef FUNNY_BRANCHING 99 /** Which variable (top bit if upper bound changing, 100 next bit if on down branch */ 101 inline const int * variables() const { 102 return variables_; 103 } 104 // New bound 105 inline const double * newBounds() const { 106 return newBounds_; 107 } 108 /// Number of bound changes 109 inline int numberExtraChangedBounds() const { 110 return numberExtraChangedBounds_; 111 } 112 /// Just apply extra bounds to one variable  COIN_DBL_MAX ignore 113 int applyExtraBounds(int iColumn, double lower, double upper, int way) ; 114 /// Deactivate bounds for branching 115 void deactivate(); 116 /// Are active bounds for branching 117 inline bool active() const { 118 return (down_[1] != COIN_DBL_MAX); 119 } 120 #endif 121 122 /** Return the type (an integer identifier) of \c this */ 123 virtual int type() const { 124 return 100; 125 } 126 127 /** Compare the \c this with \c brObj. \c this and \c brObj must be os the 128 same type and must have the same original object, but they may have 129 different feasible regions. 130 Return the appropriate CbcRangeCompare value (first argument being the 131 sub/superset if that's the case). In case of overlap (and if \c 132 replaceIfOverlap is true) replace the current branching object with one 133 whose feasible region is the overlap. 134 */ 135 virtual CbcRangeCompare compareBranchingObject 136 (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false); 137 138 protected: 139 /// Lower [0] and upper [1] bounds for the down arm (way_ = 1) 140 double down_[2]; 141 /// Lower [0] and upper [1] bounds for the up arm (way_ = 1) 142 double up_[2]; 143 #ifdef FUNNY_BRANCHING 144 /** Which variable (top bit if upper bound changing) 145 next bit if changing on down branch only */ 146 int * variables_; 147 // New bound 148 double * newBounds_; 149 /// Number of Extra bound changes 150 int numberExtraChangedBounds_; 151 #endif 152 }; 153 7 154 /// Define a single integer class 8 155
Note: See TracChangeset
for help on using the changeset viewer.