Cbc  2.9.9
CbcBranchingObject.hpp
Go to the documentation of this file.
1 // $Id: CbcBranchingObject.hpp 1899 2013-04-09 18:12:08Z stefan $
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 
17 // The types of objects that will be derived from this class.
19  {
24  SoSBranchObj = 104,
33  };
34 
53 class CbcBranchingObject : public OsiBranchingObject {
54 
55 public:
56 
59 
61  CbcBranchingObject (CbcModel * model, int variable, int way , double value);
62 
65 
68 
70  virtual CbcBranchingObject * clone() const = 0;
71 
73  virtual ~CbcBranchingObject ();
74 
79  virtual int fillStrongInfo( CbcStrongInfo & ) {
80  return 0;
81  }
83  inline void resetNumberBranchesLeft() {
84  branchIndex_ = 0;
85  }
87  inline void setNumberBranches(int value) {
88  branchIndex_ = 0;
89  numberBranches_ = value;
90  }
91 
98  virtual double branch() = 0;
105  virtual double branch(OsiSolverInterface * ) {
106  return branch();
107  }
110  virtual void fix(OsiSolverInterface * ,
111  double * , double * ,
112  int ) const {}
113 
116  virtual bool tighten(OsiSolverInterface * ) {return false;}
117 
121  virtual void previousBranch() {
122  assert(branchIndex_ > 0);
123  branchIndex_--;
124  way_ = -way_;
125  }
126 
127  using OsiBranchingObject::print ;
130  virtual void print() const {}
131 
143  inline int variable() const {
144  return variable_;
145  }
146 
154  inline int way() const {
155  return way_;
156  }
157 
162  inline void way(int way) {
163  way_ = way;
164  }
165 
167  inline void setModel(CbcModel * model) {
168  model_ = model;
169  }
171  inline CbcModel * model() const {
172  return model_;
173  }
174 
176  inline CbcObject * object() const {
177  return originalCbcObject_;
178  }
180  inline void setOriginalObject(CbcObject * object) {
182  }
183 
184  // Methods used in heuristics
185 
190  virtual CbcBranchObjType type() const = 0;
191 
199  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const {
200  const CbcBranchingObject* br = dynamic_cast<const CbcBranchingObject*>(brObj);
201  return variable() - br->variable();
202  }
203 
213  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false) = 0;
214 
215 protected:
216 
221 
224  // was - Way to branch - -1 down (first), 1 up, -2 down (second), 2 up (second)
232  int way_;
233 
234 };
235 #endif
236 
CbcBranchingObject::CbcBranchingObject
CbcBranchingObject(CbcModel *model, int variable, int way, double value)
Constructor.
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:154
CbcBranchingObject::fillStrongInfo
virtual int fillStrongInfo(CbcStrongInfo &)
Some branchingObjects may claim to be able to skip strong branching.
Definition: CbcBranchingObject.hpp:79
SoSBranchObj
@ SoSBranchObj
Definition: CbcBranchingObject.hpp:24
CbcBranchingObject::variable
int variable() const
Index identifying the associated CbcObject within its class.
Definition: CbcBranchingObject.hpp:143
CbcBranchingObject::CbcBranchingObject
CbcBranchingObject(const CbcBranchingObject &)
Copy constructor.
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:121
DummyBranchObj
@ DummyBranchObj
Definition: CbcBranchingObject.hpp:27
CbcBranchingObject::branch
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object,...
CbcBranchingObject::originalCbcObject_
CbcObject * originalCbcObject_
Pointer back to object which created.
Definition: CbcBranchingObject.hpp:220
CbcBranchingObject::fix
virtual void fix(OsiSolverInterface *, double *, double *, int) const
Update bounds in solver as in 'branch' and update given bounds.
Definition: CbcBranchingObject.hpp:110
CbcBranchingObject::setModel
void setModel(CbcModel *model)
update model
Definition: CbcBranchingObject.hpp:167
SimpleIntegerBranchObj
@ SimpleIntegerBranchObj
Definition: CbcBranchingObject.hpp:20
CbcBranchingObject::setNumberBranches
void setNumberBranches(int value)
Set number of branches to do.
Definition: CbcBranchingObject.hpp:87
CbcBranchingObject::~CbcBranchingObject
virtual ~CbcBranchingObject()
Destructor.
FollowOnBranchObj
@ FollowOnBranchObj
Definition: CbcBranchingObject.hpp:26
GeneralDepthBranchObj
@ GeneralDepthBranchObj
Definition: CbcBranchingObject.hpp:28
CbcBranchingObject::object
CbcObject * object() const
Return pointer back to object which created.
Definition: CbcBranchingObject.hpp:176
CbcBranchingObject::resetNumberBranchesLeft
void resetNumberBranchesLeft()
Reset number of branches left to original.
Definition: CbcBranchingObject.hpp:83
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:101
SimpleIntegerDynamicPseudoCostBranchObj
@ SimpleIntegerDynamicPseudoCostBranchObj
Definition: CbcBranchingObject.hpp:21
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:199
CbcBranchingObject::variable_
int variable_
Branching variable (0 is first integer)
Definition: CbcBranchingObject.hpp:223
CliqueBranchObj
@ CliqueBranchObj
Definition: CbcBranchingObject.hpp:22
CbcBranchingObject::print
virtual void print() const
Print something about branch - only if log level high.
Definition: CbcBranchingObject.hpp:130
CbcBranchingObject
Abstract branching object base class Now just difference with OsiBranchingObject.
Definition: CbcBranchingObject.hpp:53
CbcObject
Definition: CbcObject.hpp:67
LotsizeBranchObj
@ LotsizeBranchObj
Definition: CbcBranchingObject.hpp:31
CbcBranchBase.hpp
CbcBranchingObject::way
void way(int way)
Set the state of the branching object.
Definition: CbcBranchingObject.hpp:162
OneGeneralBranchingObj
@ OneGeneralBranchingObj
Definition: CbcBranchingObject.hpp:29
CbcBranchingObject::setOriginalObject
void setOriginalObject(CbcObject *object)
Set pointer back to object which created.
Definition: CbcBranchingObject.hpp:180
CbcBranchingObject::model_
CbcModel * model_
The model that owns this branching object.
Definition: CbcBranchingObject.hpp:218
CbcBranchingObject::CbcBranchingObject
CbcBranchingObject()
Default Constructor.
CbcBranchingObject::tighten
virtual bool tighten(OsiSolverInterface *)
Change (tighten) bounds in object to reflect bounds in solver.
Definition: CbcBranchingObject.hpp:116
CbcRangeCompare
CbcRangeCompare
Definition: CbcBranchBase.hpp:13
CbcStrongInfo
Abstract base class for ‘objects’.
Definition: CbcObject.hpp:51
LongCliqueBranchObj
@ LongCliqueBranchObj
Definition: CbcBranchingObject.hpp:23
NWayBranchObj
@ NWayBranchObj
Definition: CbcBranchingObject.hpp:25
CbcBranchObjType
CbcBranchObjType
Definition: CbcBranchingObject.hpp:19
CbcBranchingObject::clone
virtual CbcBranchingObject * clone() const =0
Clone.
CbcBranchingObject::model
CbcModel * model() const
Return model.
Definition: CbcBranchingObject.hpp:171
CutBranchingObj
@ CutBranchingObj
Definition: CbcBranchingObject.hpp:30
DynamicPseudoCostBranchObj
@ DynamicPseudoCostBranchObj
Definition: CbcBranchingObject.hpp:32
CbcBranchingObject::way_
int way_
The state of the branching object.
Definition: CbcBranchingObject.hpp:232