/build/buildd/coinor-cbc-2.5.0/.pc/upstream_changeset_1624_coinor-cbc_fails_after_bad_ub_change.diff/Cbc/src/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 
00111     virtual void previousBranch() {
00112         assert(branchIndex_ > 0);
00113         branchIndex_--;
00114         way_ = -way_;
00115     }
00116 
00117     using OsiBranchingObject::print ;
00120     virtual void print() const {}
00121 
00133     inline int variable() const {
00134         return variable_;
00135     }
00136 
00144     inline int way() const {
00145         return way_;
00146     }
00147 
00152     inline void way(int way) {
00153         way_ = way;
00154     }
00155 
00157     inline void setModel(CbcModel * model) {
00158         model_ = model;
00159     }
00161     inline CbcModel * model() const {
00162         return  model_;
00163     }
00164 
00166     inline CbcObject * object() const {
00167         return  originalCbcObject_;
00168     }
00170     inline void setOriginalObject(CbcObject * object) {
00171         originalCbcObject_ = object;
00172     }
00173 
00174     // Methods used in heuristics
00175 
00180     virtual CbcBranchObjType type() const = 0;
00181 
00189     virtual int compareOriginalObject(const CbcBranchingObject* brObj) const {
00190         const CbcBranchingObject* br = dynamic_cast<const CbcBranchingObject*>(brObj);
00191         return variable() - br->variable();
00192     }
00193 
00202     virtual CbcRangeCompare compareBranchingObject
00203     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false) = 0;
00204 
00205 protected:
00206 
00208     CbcModel * model_;
00210     CbcObject * originalCbcObject_;
00211 
00213     int variable_;
00214     // was - Way to branch - -1 down (first), 1 up, -2 down (second), 2 up (second)
00222     int way_;
00223 
00224 };
00225 #endif
00226