Cbc  2.9.9
 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 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 
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;
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 
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 
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:101
void resetNumberBranchesLeft()
Reset number of branches left to original.