CbcBranchingObject.hpp
Go to the documentation of this file.
1 // Edwin 11/12/2009 carved from CbcBranchBase
2 #ifndef CbcBranchingObject_H
3 #define CbcBranchingObject_H
4 
5 #include <string>
6 #include <vector>
7 #include "CbcBranchBase.hpp"
8 #include "OsiBranchingObject.hpp"
9 
10 
11 // The types of objects that will be derived from this class.
13  {
18  SoSBranchObj = 104,
27  };
28 
47 class CbcBranchingObject : public OsiBranchingObject {
48 
49 public:
50 
53 
55  CbcBranchingObject (CbcModel * model, int variable, int way , double value);
56 
59 
62 
64  virtual CbcBranchingObject * clone() const = 0;
65 
67  virtual ~CbcBranchingObject ();
68 
73  virtual int fillStrongInfo( CbcStrongInfo & ) {
74  return 0;
75  }
77  inline void resetNumberBranchesLeft() {
78  branchIndex_ = 0;
79  }
81  inline void setNumberBranches(int value) {
82  branchIndex_ = 0;
83  numberBranches_ = value;
84  }
85 
92  virtual double branch() = 0;
99  virtual double branch(OsiSolverInterface * ) {
100  return branch();
101  }
104  virtual void fix(OsiSolverInterface * ,
105  double * , double * ,
106  int ) const {}
107 
110  virtual bool tighten(OsiSolverInterface * ) {return false;}
111 
115  virtual void previousBranch() {
116  assert(branchIndex_ > 0);
117  branchIndex_--;
118  way_ = -way_;
119  }
120 
121  using OsiBranchingObject::print ;
124  virtual void print() const {}
125 
137  inline int variable() const {
138  return variable_;
139  }
140 
148  inline int way() const {
149  return way_;
150  }
151 
156  inline void way(int way) {
157  way_ = way;
158  }
159 
161  inline void setModel(CbcModel * model) {
162  model_ = model;
163  }
165  inline CbcModel * model() const {
166  return model_;
167  }
168 
170  inline CbcObject * object() const {
171  return originalCbcObject_;
172  }
174  inline void setOriginalObject(CbcObject * object) {
176  }
177 
178  // Methods used in heuristics
179 
184  virtual CbcBranchObjType type() const = 0;
185 
193  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const {
194  const CbcBranchingObject* br = dynamic_cast<const CbcBranchingObject*>(brObj);
195  return variable() - br->variable();
196  }
197 
207  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false) = 0;
208 
209 protected:
210 
215 
218  // was - Way to branch - -1 down (first), 1 up, -2 down (second), 2 up (second)
226  int way_;
227 
228 };
229 #endif
230 
virtual CbcBranchingObject * clone() const =0
Clone.
Abstract branching object base class Now just difference with OsiBranchingObject. ...
virtual bool tighten(OsiSolverInterface *)
Change (tighten) bounds in object to reflect bounds in solver.
CbcRangeCompare
virtual int fillStrongInfo(CbcStrongInfo &)
Some branchingObjects may claim to be able to skip strong branching.
void setModel(CbcModel *model)
update model
virtual void print() const
Print something about branch - only if log level high.
virtual ~CbcBranchingObject()
Destructor.
virtual CbcBranchObjType type() const =0
Return the type (an integer identifier) of this.
CbcBranchingObject()
Default Constructor.
CbcBranchObjType
void setNumberBranches(int value)
Set number of branches to do.
int variable() const
Index identifying the associated CbcObject within its class.
void resetNumberBranchesLeft()
Reset number of branches left to original.
int way_
The state of the branching object.
void way(int way)
Set the state of the branching object.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)=0
Compare the this with brObj.
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
int way() const
Get the state of the branching object.
CbcBranchingObject & operator=(const CbcBranchingObject &rhs)
Assignment operator.
virtual void fix(OsiSolverInterface *, double *, double *, int) const
Update bounds in solver as in 'branch' and update given bounds.
CbcModel * model_
The model that owns this branching object.
virtual double branch(OsiSolverInterface *)
Execute the actions required to branch, as specified by the current state of the branching object...
CbcObject * object() const
Return pointer back to object which created.
CbcObject * originalCbcObject_
Pointer back to object which created.
int variable_
Branching variable (0 is first integer)
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
Abstract base class for `objects'.
Definition: CbcObject.hpp:45
CbcModel * model() const
Return model.
Simple Branch and bound class.
Definition: CbcModel.hpp:98
void setOriginalObject(CbcObject *object)
Set pointer back to object which created.
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...