/build/buildd/coinor-cbc-2.5.0/debian/tmp/usr/include/coin/CbcBranchingObject.hpp
Go to the documentation of this file.
00001 // Edwin 11/12/2009 carved from CbcBranchBase
00002 #ifndef CbcBranchingObject_H
00003 #define CbcBranchingObject_H
00004 
00005 #include <string>
00006 #include <vector>
00007 #include "CbcBranchBase.hpp"
00008 #include "OsiBranchingObject.hpp"
00009 
00010 
00011 // The types of objects that will be derived from this class.
00012 enum CbcBranchObjType
00013   {
00014     SimpleIntegerBranchObj = 100,
00015     SimpleIntegerDynamicPseudoCostBranchObj = 101,
00016     CliqueBranchObj = 102,
00017     LongCliqueBranchObj = 103,
00018     SoSBranchObj = 104,
00019     NWayBranchObj = 105,
00020     FollowOnBranchObj = 106,
00021     DummyBranchObj = 107,
00022     GeneralDepthBranchObj = 108,
00023     OneGeneralBranchingObj = 110,
00024     CutBranchingObj = 200,
00025     LotsizeBranchObj = 300,
00026     DynamicPseudoCostBranchObj = 400
00027   };
00028 
00047 class CbcBranchingObject : public OsiBranchingObject {
00048 
00049 public:
00050 
00052     CbcBranchingObject ();
00053 
00055     CbcBranchingObject (CbcModel * model, int variable, int way , double value);
00056 
00058     CbcBranchingObject ( const CbcBranchingObject &);
00059 
00061     CbcBranchingObject & operator=( const CbcBranchingObject& rhs);
00062 
00064     virtual CbcBranchingObject * clone() const = 0;
00065 
00067     virtual ~CbcBranchingObject ();
00068 
00073     virtual int fillStrongInfo( CbcStrongInfo & ) {
00074         return 0;
00075     }
00077     inline void resetNumberBranchesLeft() {
00078         branchIndex_ = 0;
00079     }
00081     inline void setNumberBranches(int value) {
00082         branchIndex_ = 0;
00083         numberBranches_ = value;
00084     }
00085 
00092     virtual double branch() = 0;
00099     virtual double branch(OsiSolverInterface * ) {
00100         return branch();
00101     }
00104     virtual void fix(OsiSolverInterface * ,
00105                      double * , double * ,
00106                      int ) const {}
00107 
00110     virtual bool tighten(OsiSolverInterface * ) {return false;}
00111 
00115     virtual void previousBranch() {
00116         assert(branchIndex_ > 0);
00117         branchIndex_--;
00118         way_ = -way_;
00119     }
00120 
00121     using OsiBranchingObject::print ;
00124     virtual void print() const {}
00125 
00137     inline int variable() const {
00138         return variable_;
00139     }
00140 
00148     inline int way() const {
00149         return way_;
00150     }
00151 
00156     inline void way(int way) {
00157         way_ = way;
00158     }
00159 
00161     inline void setModel(CbcModel * model) {
00162         model_ = model;
00163     }
00165     inline CbcModel * model() const {
00166         return  model_;
00167     }
00168 
00170     inline CbcObject * object() const {
00171         return  originalCbcObject_;
00172     }
00174     inline void setOriginalObject(CbcObject * object) {
00175         originalCbcObject_ = object;
00176     }
00177 
00178     // Methods used in heuristics
00179 
00184     virtual CbcBranchObjType type() const = 0;
00185 
00193     virtual int compareOriginalObject(const CbcBranchingObject* brObj) const {
00194         const CbcBranchingObject* br = dynamic_cast<const CbcBranchingObject*>(brObj);
00195         return variable() - br->variable();
00196     }
00197 
00206     virtual CbcRangeCompare compareBranchingObject
00207     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false) = 0;
00208 
00209 protected:
00210 
00212     CbcModel * model_;
00214     CbcObject * originalCbcObject_;
00215 
00217     int variable_;
00218     // was - Way to branch - -1 down (first), 1 up, -2 down (second), 2 up (second)
00226     int way_;
00227 
00228 };
00229 #endif
00230