Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcBranchingObject.hpp
Go to the documentation of this file.
1 // $Id: CbcBranchingObject.hpp 2467 2019-01-03 21:26:29Z unxusr $
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 // Edwin 11/12/2009 carved from CbcBranchBase
7 
8 #ifndef CbcBranchingObject_H
9 #define CbcBranchingObject_H
10 
11 #include <string>
12 #include <vector>
13 #include "CbcBranchBase.hpp"
14 #include "OsiBranchingObject.hpp"
15 
16 // The types of objects that will be derived from this class.
22  SoSBranchObj = 104,
31 };
32 
52 
53 public:
56 
58  CbcBranchingObject(CbcModel *model, int variable, int way, double value);
59 
62 
65 
67  virtual CbcBranchingObject *clone() const = 0;
68 
70  virtual ~CbcBranchingObject();
71 
77  {
78  return 0;
79  }
82  {
83  branchIndex_ = 0;
84  }
86  inline void setNumberBranches(int value)
87  {
88  branchIndex_ = 0;
90  }
91 
98  virtual double branch() = 0;
105  virtual double branch(OsiSolverInterface *)
106  {
107  return branch();
108  }
111  virtual void fix(OsiSolverInterface *,
112  double *, double *,
113  int) const {}
114 
117  virtual bool tighten(OsiSolverInterface *) { return false; }
118 
122  virtual void previousBranch()
123  {
124  assert(branchIndex_ > 0);
125  branchIndex_--;
126  way_ = -way_;
127  }
128 
132  virtual void print() const {}
133 
145  inline int variable() const
146  {
147  return variable_;
148  }
149 
157  inline int way() const
158  {
159  return way_;
160  }
161 
166  inline void way(int way)
167  {
168  way_ = way;
169  }
170 
172  inline void setModel(CbcModel *model)
173  {
174  model_ = model;
175  }
177  inline CbcModel *model() const
178  {
179  return model_;
180  }
181 
183  inline CbcObject *object() const
184  {
185  return originalCbcObject_;
186  }
188  inline void setOriginalObject(CbcObject *object)
189  {
191  }
192 
193  // Methods used in heuristics
194 
199  virtual CbcBranchObjType type() const = 0;
200 
208  virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
209  {
210  const CbcBranchingObject *br = dynamic_cast< const CbcBranchingObject * >(brObj);
211  return variable() - br->variable();
212  }
213 
222  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false) = 0;
223 
224 protected:
229 
232  // was - Way to branch - -1 down (first), 1 up, -2 down (second), 2 up (second)
240  int way_;
241 };
242 #endif
243 
244 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
245 */
virtual void fix(OsiSolverInterface *, double *, double *, int) const
Update bounds in solver as in &#39;branch&#39; and update given bounds.
virtual bool tighten(OsiSolverInterface *)
Change (tighten) bounds in object to reflect bounds in solver.
void way(int way)
Set the state of the branching object.
void setModel(CbcModel *model)
update model
CbcModel * model_
The model that owns this branching object.
short branchIndex_
The state of the branching object.
void setOriginalObject(CbcObject *object)
Set pointer back to object which created.
Abstract base class for `objects&#39;.
Definition: CbcObject.hpp:51
void setNumberBranches(int value)
Set number of branches to do.
CbcRangeCompare
CbcBranchingObject()
Default Constructor.
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
Abstract branching object base class.
double value() const
Current value.
Abstract Base Class for describing an interface to a solver.
virtual CbcBranchingObject * clone() const =0
Clone.
virtual void print(const OsiSolverInterface *=NULL) const
Print something about branch - only if log level high.
virtual double branch(OsiSolverInterface *)
Execute the actions required to branch, as specified by the current state of the branching object...
int numberBranches_
Number of branches.
int variable() const
Index identifying the associated CbcObject within its class.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)=0
Compare the this with brObj.
int way() const
Get the state of the branching object.
Abstract branching object base class Now just difference with OsiBranchingObject. ...
CbcBranchingObject & operator=(const CbcBranchingObject &rhs)
Assignment operator.
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
CbcBranchObjType
CbcModel * model() const
Return model.
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...
virtual CbcBranchObjType type() const =0
Return the type (an integer identifier) of this.
virtual void print() const
Print something about branch - only if log level high.
CbcObject * object() const
Return pointer back to object which created.
int way_
The state of the branching object.
CbcObject * originalCbcObject_
Pointer back to object which created.
virtual int fillStrongInfo(CbcStrongInfo &)
Some branchingObjects may claim to be able to skip strong branching.
virtual ~CbcBranchingObject()
Destructor.
int variable_
Branching variable (0 is first integer)
Simple Branch and bound class.
Definition: CbcModel.hpp:100
void resetNumberBranchesLeft()
Reset number of branches left to original.