/build/buildd/coinor-cbc-2.5.0/debian/tmp/usr/include/coin/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 ;
00070     virtual bool tighten(OsiSolverInterface * ) ;
00071 
00072 #ifdef JJF_ZERO
00073     // No need to override. Default works fine.
00077     virtual void previousBranch();
00078 #endif
00079 
00080     using CbcBranchingObject::print ;
00083     virtual void print();
00084 
00086     inline const double * downBounds() const {
00087         return down_;
00088     }
00090     inline const double * upBounds() const {
00091         return up_;
00092     }
00094     inline void setDownBounds(const double bounds[2]) {
00095         memcpy(down_, bounds, 2*sizeof(double));
00096     }
00098     inline void setUpBounds(const double bounds[2]) {
00099         memcpy(up_, bounds, 2*sizeof(double));
00100     }
00101 #ifdef FUNNY_BRANCHING
00102 
00104     inline const int * variables() const {
00105         return variables_;
00106     }
00107     // New bound
00108     inline const double * newBounds() const {
00109         return newBounds_;
00110     }
00112     inline int numberExtraChangedBounds() const {
00113         return numberExtraChangedBounds_;
00114     }
00116     int applyExtraBounds(int iColumn, double lower, double upper, int way) ;
00118     void deactivate();
00120     inline bool active() const {
00121         return (down_[1] != -COIN_DBL_MAX);
00122     }
00123 #endif
00124 
00126     virtual CbcBranchObjType type() const {
00127         return SimpleIntegerBranchObj;
00128     }
00129 
00138     virtual CbcRangeCompare compareBranchingObject
00139     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
00140 
00141 protected:
00143     double down_[2];
00145     double up_[2];
00146 #ifdef FUNNY_BRANCHING
00147 
00149     int * variables_;
00150     // New bound
00151     double * newBounds_;
00153     int numberExtraChangedBounds_;
00154 #endif
00155 };
00156 
00158 
00159 
00160 class CbcSimpleInteger : public CbcObject {
00161 
00162 public:
00163 
00164     // Default Constructor
00165     CbcSimpleInteger ();
00166 
00167     // Useful constructor - passed model and index
00168     CbcSimpleInteger (CbcModel * model,  int iColumn, double breakEven = 0.5);
00169 
00170     // Useful constructor - passed model and Osi object
00171     CbcSimpleInteger (CbcModel * model,  const OsiSimpleInteger * object);
00172 
00173     // Copy constructor
00174     CbcSimpleInteger ( const CbcSimpleInteger &);
00175 
00177     virtual CbcObject * clone() const;
00178 
00179     // Assignment operator
00180     CbcSimpleInteger & operator=( const CbcSimpleInteger& rhs);
00181 
00182     // Destructor
00183     virtual ~CbcSimpleInteger ();
00185     OsiSimpleInteger * osiObject() const;
00187     virtual double infeasibility(const OsiBranchingInformation * info,
00188                                  int &preferredWay) const;
00189 
00190     using CbcObject::feasibleRegion ;
00196     virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00197 
00203     virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
00205     void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
00206 
00207     using CbcObject::solverBranch ;
00212     virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00213 
00220     virtual void feasibleRegion();
00221 
00226     virtual int columnNumber() const;
00228     inline void setColumnNumber(int value) {
00229         columnNumber_ = value;
00230     }
00231 
00236     virtual void resetBounds(const OsiSolverInterface * solver) ;
00237 
00240     virtual void resetSequenceEtc(int numberColumns, const int * originalColumns) ;
00242     inline double originalLowerBound() const {
00243         return originalLower_;
00244     }
00245     inline void setOriginalLowerBound(double value) {
00246         originalLower_ = value;
00247     }
00248     inline double originalUpperBound() const {
00249         return originalUpper_;
00250     }
00251     inline void setOriginalUpperBound(double value) {
00252         originalUpper_ = value;
00253     }
00255     inline double breakEven() const {
00256         return breakEven_;
00257     }
00259     inline void setBreakEven(double value) {
00260         breakEven_ = value;
00261     }
00262 
00263 
00264 protected:
00266 
00268     double originalLower_;
00270     double originalUpper_;
00272     double breakEven_;
00274     int columnNumber_;
00276     int preferredWay_;
00277 };
00278 #endif
00279