Cbc  2.10.10
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcBranchingObject.hpp
Go to the documentation of this file.
1 // $Id$
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 
51 class CbcBranchingObject : public OsiBranchingObject {
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;
89  numberBranches_ = value;
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 
129  using OsiBranchingObject::print;
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 */
CbcBranchingObject::compareBranchingObject
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)=0
Compare the this with brObj.
CbcBranchingObject::way
int way() const
Get the state of the branching object.
Definition: CbcBranchingObject.hpp:157
CbcBranchingObject::fillStrongInfo
virtual int fillStrongInfo(CbcStrongInfo &)
Some branchingObjects may claim to be able to skip strong branching.
Definition: CbcBranchingObject.hpp:76
SoSBranchObj
@ SoSBranchObj
Definition: CbcBranchingObject.hpp:22
CbcBranchingObject::variable
int variable() const
Index identifying the associated CbcObject within its class.
Definition: CbcBranchingObject.hpp:145
CbcBranchingObject::operator=
CbcBranchingObject & operator=(const CbcBranchingObject &rhs)
Assignment operator.
CbcBranchingObject::previousBranch
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child.
Definition: CbcBranchingObject.hpp:122
DummyBranchObj
@ DummyBranchObj
Definition: CbcBranchingObject.hpp:25
CbcBranchingObject::branch
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object,...
CbcBranchingObject::branch
virtual double branch(OsiSolverInterface *)
Execute the actions required to branch, as specified by the current state of the branching object,...
Definition: CbcBranchingObject.hpp:105
CbcBranchingObject::originalCbcObject_
CbcObject * originalCbcObject_
Pointer back to object which created.
Definition: CbcBranchingObject.hpp:228
CbcBranchingObject::fix
virtual void fix(OsiSolverInterface *, double *, double *, int) const
Update bounds in solver as in 'branch' and update given bounds.
Definition: CbcBranchingObject.hpp:111
CbcBranchingObject::setModel
void setModel(CbcModel *model)
update model
Definition: CbcBranchingObject.hpp:172
SimpleIntegerBranchObj
@ SimpleIntegerBranchObj
Definition: CbcBranchingObject.hpp:18
CbcBranchingObject::setNumberBranches
void setNumberBranches(int value)
Set number of branches to do.
Definition: CbcBranchingObject.hpp:86
CbcBranchingObject::~CbcBranchingObject
virtual ~CbcBranchingObject()
Destructor.
FollowOnBranchObj
@ FollowOnBranchObj
Definition: CbcBranchingObject.hpp:24
GeneralDepthBranchObj
@ GeneralDepthBranchObj
Definition: CbcBranchingObject.hpp:26
CbcBranchingObject::object
CbcObject * object() const
Return pointer back to object which created.
Definition: CbcBranchingObject.hpp:183
CbcBranchingObject::resetNumberBranchesLeft
void resetNumberBranchesLeft()
Reset number of branches left to original.
Definition: CbcBranchingObject.hpp:81
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:100
SimpleIntegerDynamicPseudoCostBranchObj
@ SimpleIntegerDynamicPseudoCostBranchObj
Definition: CbcBranchingObject.hpp:19
CbcBranchingObject::type
virtual CbcBranchObjType type() const =0
Return the type (an integer identifier) of this.
CbcBranchingObject::compareOriginalObject
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
Definition: CbcBranchingObject.hpp:208
CbcBranchingObject::variable_
int variable_
Branching variable (0 is first integer)
Definition: CbcBranchingObject.hpp:231
CliqueBranchObj
@ CliqueBranchObj
Definition: CbcBranchingObject.hpp:20
CbcBranchingObject::print
virtual void print() const
Print something about branch - only if log level high.
Definition: CbcBranchingObject.hpp:132
CbcBranchingObject
Abstract branching object base class Now just difference with OsiBranchingObject.
Definition: CbcBranchingObject.hpp:51
CbcObject
Definition: CbcObject.hpp:67
LotsizeBranchObj
@ LotsizeBranchObj
Definition: CbcBranchingObject.hpp:29
CbcBranchBase.hpp
CbcBranchingObject::way
void way(int way)
Set the state of the branching object.
Definition: CbcBranchingObject.hpp:166
OneGeneralBranchingObj
@ OneGeneralBranchingObj
Definition: CbcBranchingObject.hpp:27
CbcBranchingObject::setOriginalObject
void setOriginalObject(CbcObject *object)
Set pointer back to object which created.
Definition: CbcBranchingObject.hpp:188
CbcBranchingObject::model_
CbcModel * model_
The model that owns this branching object.
Definition: CbcBranchingObject.hpp:226
CbcBranchingObject::CbcBranchingObject
CbcBranchingObject()
Default Constructor.
CbcBranchingObject::tighten
virtual bool tighten(OsiSolverInterface *)
Change (tighten) bounds in object to reflect bounds in solver.
Definition: CbcBranchingObject.hpp:117
CbcRangeCompare
CbcRangeCompare
Definition: CbcBranchBase.hpp:13
CbcStrongInfo
Abstract base class for ‘objects’.
Definition: CbcObject.hpp:51
LongCliqueBranchObj
@ LongCliqueBranchObj
Definition: CbcBranchingObject.hpp:21
NWayBranchObj
@ NWayBranchObj
Definition: CbcBranchingObject.hpp:23
CbcBranchObjType
CbcBranchObjType
Definition: CbcBranchingObject.hpp:17
CbcBranchingObject::clone
virtual CbcBranchingObject * clone() const =0
Clone.
CbcBranchingObject::model
CbcModel * model() const
Return model.
Definition: CbcBranchingObject.hpp:177
CutBranchingObj
@ CutBranchingObj
Definition: CbcBranchingObject.hpp:28
DynamicPseudoCostBranchObj
@ DynamicPseudoCostBranchObj
Definition: CbcBranchingObject.hpp:30
CbcBranchingObject::way_
int way_
The state of the branching object.
Definition: CbcBranchingObject.hpp:240