/build/buildd/coinor-cbc-2.5.0/.pc/upstream_changeset_1624_coinor-cbc_fails_after_bad_ub_change.diff/Cbc/src/CbcSimpleInteger.hpp
Go to the documentation of this file.
00001 // Edwin 11/9/2009-- carved out of CbcBranchActual
00002 
00003 #ifndef CbcSimpleInteger_H
00004 #define CbcSimpleInteger_H
00005 
00016 class CbcIntegerBranchingObject : public CbcBranchingObject {
00017 
00018 public:
00019 
00021     CbcIntegerBranchingObject ();
00022 
00030     CbcIntegerBranchingObject (CbcModel *model, int variable,
00031                                int way , double value) ;
00032 
00040     CbcIntegerBranchingObject (CbcModel *model, int variable, int way,
00041                                double lowerValue, double upperValue) ;
00042 
00044     CbcIntegerBranchingObject ( const CbcIntegerBranchingObject &);
00045 
00047     CbcIntegerBranchingObject & operator= (const CbcIntegerBranchingObject& rhs);
00048 
00050     virtual CbcBranchingObject * clone() const;
00051 
00053     virtual ~CbcIntegerBranchingObject ();
00054 
00056     void fillPart ( int variable, int way , double value) ;
00057     using CbcBranchingObject::branch ;
00062     virtual double branch();
00065     virtual void fix(OsiSolverInterface * solver,
00066                      double * lower, double * upper,
00067                      int branchState) const ;
00068 
00069 #ifdef JJF_ZERO
00070     // No need to override. Default works fine.
00074     virtual void previousBranch();
00075 #endif
00076 
00077     using CbcBranchingObject::print ;
00080     virtual void print();
00081 
00083     inline const double * downBounds() const {
00084         return down_;
00085     }
00087     inline const double * upBounds() const {
00088         return up_;
00089     }
00091     inline void setDownBounds(const double bounds[2]) {
00092         memcpy(down_, bounds, 2*sizeof(double));
00093     }
00095     inline void setUpBounds(const double bounds[2]) {
00096         memcpy(up_, bounds, 2*sizeof(double));
00097     }
00098 #ifdef FUNNY_BRANCHING
00099 
00101     inline const int * variables() const {
00102         return variables_;
00103     }
00104     // New bound
00105     inline const double * newBounds() const {
00106         return newBounds_;
00107     }
00109     inline int numberExtraChangedBounds() const {
00110         return numberExtraChangedBounds_;
00111     }
00113     int applyExtraBounds(int iColumn, double lower, double upper, int way) ;
00115     void deactivate();
00117     inline bool active() const {
00118         return (down_[1] != -COIN_DBL_MAX);
00119     }
00120 #endif
00121 
00123     virtual CbcBranchObjType type() const {
00124         return SimpleIntegerBranchObj;
00125     }
00126 
00135     virtual CbcRangeCompare compareBranchingObject
00136     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
00137 
00138 protected:
00140     double down_[2];
00142     double up_[2];
00143 #ifdef FUNNY_BRANCHING
00144 
00146     int * variables_;
00147     // New bound
00148     double * newBounds_;
00150     int numberExtraChangedBounds_;
00151 #endif
00152 };
00153 
00155 
00156 
00157 class CbcSimpleInteger : public CbcObject {
00158 
00159 public:
00160 
00161     // Default Constructor
00162     CbcSimpleInteger ();
00163 
00164     // Useful constructor - passed model and index
00165     CbcSimpleInteger (CbcModel * model,  int iColumn, double breakEven = 0.5);
00166 
00167     // Useful constructor - passed model and Osi object
00168     CbcSimpleInteger (CbcModel * model,  const OsiSimpleInteger * object);
00169 
00170     // Copy constructor
00171     CbcSimpleInteger ( const CbcSimpleInteger &);
00172 
00174     virtual CbcObject * clone() const;
00175 
00176     // Assignment operator
00177     CbcSimpleInteger & operator=( const CbcSimpleInteger& rhs);
00178 
00179     // Destructor
00180     virtual ~CbcSimpleInteger ();
00182     OsiSimpleInteger * osiObject() const;
00184     virtual double infeasibility(const OsiBranchingInformation * info,
00185                                  int &preferredWay) const;
00186 
00187     using CbcObject::feasibleRegion ;
00193     virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00194 
00200     virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
00202     void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
00203 
00204     using CbcObject::solverBranch ;
00209     virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00210 
00217     virtual void feasibleRegion();
00218 
00223     virtual int columnNumber() const;
00225     inline void setColumnNumber(int value) {
00226         columnNumber_ = value;
00227     }
00228 
00233     virtual void resetBounds(const OsiSolverInterface * solver) ;
00236     virtual void resetSequenceEtc(int numberColumns, const int * originalColumns) ;
00238     inline double originalLowerBound() const {
00239         return originalLower_;
00240     }
00241     inline void setOriginalLowerBound(double value) {
00242         originalLower_ = value;
00243     }
00244     inline double originalUpperBound() const {
00245         return originalUpper_;
00246     }
00247     inline void setOriginalUpperBound(double value) {
00248         originalUpper_ = value;
00249     }
00251     inline double breakEven() const {
00252         return breakEven_;
00253     }
00255     inline void setBreakEven(double value) {
00256         breakEven_ = value;
00257     }
00258 
00259 
00260 protected:
00262 
00264     double originalLower_;
00266     double originalUpper_;
00268     double breakEven_;
00270     int columnNumber_;
00272     int preferredWay_;
00273 };
00274 #endif
00275