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 // Edwin 11/9/2009-- carved out of CbcBranchActual 00007 00008 #ifndef CbcSimpleInteger_H 00009 #define CbcSimpleInteger_H 00010 00021 class CbcIntegerBranchingObject : public CbcBranchingObject { 00022 00023 public: 00024 00026 CbcIntegerBranchingObject (); 00027 00035 CbcIntegerBranchingObject (CbcModel *model, int variable, 00036 int way , double value) ; 00037 00045 CbcIntegerBranchingObject (CbcModel *model, int variable, int way, 00046 double lowerValue, double upperValue) ; 00047 00049 CbcIntegerBranchingObject ( const CbcIntegerBranchingObject &); 00050 00052 CbcIntegerBranchingObject & operator= (const CbcIntegerBranchingObject& rhs); 00053 00055 virtual CbcBranchingObject * clone() const; 00056 00058 virtual ~CbcIntegerBranchingObject (); 00059 00061 void fillPart ( int variable, int way , double value) ; 00062 using CbcBranchingObject::branch ; 00067 virtual double branch(); 00070 virtual void fix(OsiSolverInterface * solver, 00071 double * lower, double * upper, 00072 int branchState) const ; 00075 virtual bool tighten(OsiSolverInterface * ) ; 00076 00077 #ifdef JJF_ZERO 00078 // No need to override. Default works fine. 00082 virtual void previousBranch(); 00083 #endif 00084 00085 using CbcBranchingObject::print ; 00088 virtual void print(); 00089 00091 inline const double * downBounds() const { 00092 return down_; 00093 } 00095 inline const double * upBounds() const { 00096 return up_; 00097 } 00099 inline void setDownBounds(const double bounds[2]) { 00100 memcpy(down_, bounds, 2*sizeof(double)); 00101 } 00103 inline void setUpBounds(const double bounds[2]) { 00104 memcpy(up_, bounds, 2*sizeof(double)); 00105 } 00106 #ifdef FUNNY_BRANCHING 00107 00109 inline const int * variables() const { 00110 return variables_; 00111 } 00112 // New bound 00113 inline const double * newBounds() const { 00114 return newBounds_; 00115 } 00117 inline int numberExtraChangedBounds() const { 00118 return numberExtraChangedBounds_; 00119 } 00121 int applyExtraBounds(int iColumn, double lower, double upper, int way) ; 00123 void deactivate(); 00125 inline bool active() const { 00126 return (down_[1] != -COIN_DBL_MAX); 00127 } 00128 #endif 00129 00131 virtual CbcBranchObjType type() const { 00132 return SimpleIntegerBranchObj; 00133 } 00134 00143 virtual CbcRangeCompare compareBranchingObject 00144 (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false); 00145 00146 protected: 00148 double down_[2]; 00150 double up_[2]; 00151 #ifdef FUNNY_BRANCHING 00152 00154 int * variables_; 00155 // New bound 00156 double * newBounds_; 00158 int numberExtraChangedBounds_; 00159 #endif 00160 }; 00161 00163 00164 00165 class CbcSimpleInteger : public CbcObject { 00166 00167 public: 00168 00169 // Default Constructor 00170 CbcSimpleInteger (); 00171 00172 // Useful constructor - passed model and index 00173 CbcSimpleInteger (CbcModel * model, int iColumn, double breakEven = 0.5); 00174 00175 // Useful constructor - passed model and Osi object 00176 CbcSimpleInteger (CbcModel * model, const OsiSimpleInteger * object); 00177 00178 // Copy constructor 00179 CbcSimpleInteger ( const CbcSimpleInteger &); 00180 00182 virtual CbcObject * clone() const; 00183 00184 // Assignment operator 00185 CbcSimpleInteger & operator=( const CbcSimpleInteger& rhs); 00186 00187 // Destructor 00188 virtual ~CbcSimpleInteger (); 00190 OsiSimpleInteger * osiObject() const; 00192 virtual double infeasibility(const OsiBranchingInformation * info, 00193 int &preferredWay) const; 00194 00195 using CbcObject::feasibleRegion ; 00201 virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const; 00202 00208 virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ; 00210 void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ; 00211 00212 using CbcObject::solverBranch ; 00217 virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const; 00218 00225 virtual void feasibleRegion(); 00226 00231 virtual int columnNumber() const; 00233 inline void setColumnNumber(int value) { 00234 columnNumber_ = value; 00235 } 00236 00241 virtual void resetBounds(const OsiSolverInterface * solver) ; 00242 00245 virtual void resetSequenceEtc(int numberColumns, const int * originalColumns) ; 00247 inline double originalLowerBound() const { 00248 return originalLower_; 00249 } 00250 inline void setOriginalLowerBound(double value) { 00251 originalLower_ = value; 00252 } 00253 inline double originalUpperBound() const { 00254 return originalUpper_; 00255 } 00256 inline void setOriginalUpperBound(double value) { 00257 originalUpper_ = value; 00258 } 00260 inline double breakEven() const { 00261 return breakEven_; 00262 } 00264 inline void setBreakEven(double value) { 00265 breakEven_ = value; 00266 } 00267 00268 00269 protected: 00271 00273 double originalLower_; 00275 double originalUpper_; 00277 double breakEven_; 00279 int columnNumber_; 00281 int preferredWay_; 00282 }; 00283 #endif 00284