CbcNodeInfo.hpp
Go to the documentation of this file.
1 // Edwin 11/24/09 carved from CbcNode
2 #ifndef CbcNodeInfo_H
3 #define CbcNodeInfo_H
4 
5 #include <string>
6 #include <vector>
7 
8 #include "CoinWarmStartBasis.hpp"
9 #include "CoinSearchTree.hpp"
10 #include "CbcBranchBase.hpp"
11 
12 class OsiSolverInterface;
13 class OsiSolverBranch;
14 
15 class OsiCuts;
16 class OsiRowCut;
17 class OsiRowCutDebugger;
18 class CoinWarmStartBasis;
19 class CbcCountRowCut;
20 class CbcModel;
21 class CbcNode;
22 class CbcSubProblem;
23 class CbcGeneralBranchingObject;
24 
25 //#############################################################################
62 class CbcNodeInfo {
63 
64 public:
65 
72  CbcNodeInfo ();
73 
75  CbcNodeInfo ( const CbcNodeInfo &);
76 
77 #ifdef JJF_ZERO
78 
84 #endif
85 
90  CbcNodeInfo (CbcNodeInfo * parent, CbcNode * owner);
91 
97  virtual ~CbcNodeInfo();
99 
100 
106  virtual void applyToModel (CbcModel *model, CoinWarmStartBasis *&basis,
108  int &currentNumberCuts) const = 0 ;
110  virtual int applyBounds(int iColumn, double & lower, double & upper, int force) = 0;
111 
116  virtual CbcNodeInfo * buildRowBasis(CoinWarmStartBasis & basis) const = 0;
118  virtual CbcNodeInfo * clone() const = 0;
120  virtual void allBranchesGone() {}
121 #ifndef JJF_ONE
122  inline void increment(int amount = 1) {
124  numberPointingToThis_ += amount;/*printf("CbcNodeInfo %x incremented by %d to %d\n",this,amount,numberPointingToThis_);*/
125  }
126 
128  inline int decrement(int amount = 1) {
129  numberPointingToThis_ -= amount;/*printf("CbcNodeInfo %x decremented by %d to %d\n",this,amount,numberPointingToThis_);*/
130  return numberPointingToThis_;
131  }
132 #else
133  void increment(int amount = 1);
136  int decrement(int amount = 1);
137 #endif
138 
143  inline void initializeInfo(int number) {
144  numberPointingToThis_ = number;
145  numberBranchesLeft_ = number;
146  }
147 
149  inline int numberBranchesLeft() const {
150  return numberBranchesLeft_;
151  }
152 
154  inline void setNumberBranchesLeft(int value) {
155  numberBranchesLeft_ = value;
156  }
157 
159  inline int numberPointingToThis() const {
160  return numberPointingToThis_;
161  }
162 
164  inline void setNumberPointingToThis(int number) {
165  numberPointingToThis_ = number;
166  }
167 
171  }
172 
174  inline int branchedOn() {
177  return numberBranchesLeft_;
178  }
179 
181  inline void throwAway() {
184  }
185 
187  CbcNodeInfo * parent() const {
188  return parent_;
189  }
191  inline void nullParent() {
192  parent_ = NULL;
193  }
194 
195  void addCuts(OsiCuts & cuts, int numberToBranch, //int * whichGenerator,
197  void addCuts(int numberCuts, CbcCountRowCut ** cuts, int numberToBranch);
201  void deleteCuts(int numberToDelete, CbcCountRowCut ** cuts);
202  void deleteCuts(int numberToDelete, int * which);
203 
205  void deleteCut(int whichOne);
206 
208  void decrementCuts(int change = 1);
209 
211  void incrementCuts(int change = 1);
212 
214  void decrementParentCuts(CbcModel * model, int change = 1);
215 
217  void incrementParentCuts(CbcModel * model, int change = 1);
218 
220  inline CbcCountRowCut ** cuts() const {
221  return cuts_;
222  }
223 
225  inline int numberCuts() const {
226  return numberCuts_;
227  }
228  inline void setNumberCuts(int value) {
229  numberCuts_ = value;
230  }
231 
233  inline void nullOwner() {
234  owner_ = NULL;
235  }
236  const inline CbcNode * owner() const {
237  return owner_;
238  }
239  inline CbcNode * mutableOwner() const {
240  return owner_;
241  }
243  inline int nodeNumber() const {
244  return nodeNumber_;
245  }
246  inline void setNodeNumber(int node) {
247  nodeNumber_ = node;
248  }
254  void deactivate(int mode = 3);
256  inline bool allActivated() const {
257  return (active_ == 7);
258  }
260  inline bool marked() const {
261  return ((active_&8) != 0);
262  }
264  inline void mark() {
265  active_ |= 8;
266  }
268  inline void unmark() {
269  active_ &= ~8;
270  }
271 
273  inline const OsiBranchingObject * parentBranch() const {
274  return parentBranch_;
275  }
277  void unsetParentBasedData();
278 protected:
279 
288 
291 
293  OsiBranchingObject * parentBranch_;
294 
297 
300 
303 
306 
310 
323  int active_;
324 
325 private:
326 
328  CbcNodeInfo & operator=(const CbcNodeInfo& rhs);
329 
331  void setParentBasedData();
332 };
333 
334 #endif // CbcNodeInfo_H
335 
void incrementParentCuts(CbcModel *model, int change=1)
Increment all active cut counts in parent chain.
virtual CbcNodeInfo * clone() const =0
Clone.
void deleteCuts(int numberToDelete, CbcCountRowCut **cuts)
Delete cuts (decrements counts) Slow unless cuts in same order as saved.
CbcNodeInfo()
Default Constructor.
void incrementNumberPointingToThis()
Increment number of objects pointing to this.
void setNumberBranchesLeft(int value)
Set number of branches left in object.
void setNumberPointingToThis(int number)
Set number of objects pointing to this.
void increment(int amount=1)
Increment number of references.
void unmark()
Unmark.
CbcNode * mutableOwner() const
OsiBranchingObject * parentBranch_
Copy of the branching object of the parent when the node is created.
int numberPointingToThis_
Number of other nodes pointing to this node.
CbcNode * owner_
Owner.
int numberPointingToThis() const
Return number of objects pointing to this.
void setNumberCuts(int value)
Information required to recreate the subproblem at this node.
Definition: CbcNodeInfo.hpp:62
void mark()
Mark.
virtual int applyBounds(int iColumn, double &lower, double &upper, int force)=0
Just apply bounds to one variable - force means overwrite by lower,upper (1=>infeasible) ...
CbcNodeInfo * parent() const
Parent of this.
int nodeNumber() const
The node number.
virtual ~CbcNodeInfo()
Destructor.
int numberCuts() const
Number of row cuts (this node)
void addCuts(OsiCuts &cuts, int numberToBranch, int numberPointingToThis)
bool marked() const
Say if marked.
CbcCountRowCut ** cuts() const
Array of pointers to cuts.
int numberBranchesLeft() const
Return number of branches left in object.
virtual void allBranchesGone()
Called when number branches left down to zero.
void incrementCuts(int change=1)
Increment active cut counts.
void deleteCut(int whichOne)
Really delete a cut.
void unsetParentBasedData()
If we need to take off parent based data.
int numberBranchesLeft_
Number of branch arms left to explore at this node.
void decrementParentCuts(CbcModel *model, int change=1)
Decrement all active cut counts in chain starting at parent.
bool allActivated() const
Say if normal.
void setNodeNumber(int node)
int branchedOn()
Say one branch taken.
virtual void applyToModel(CbcModel *model, CoinWarmStartBasis *&basis, CbcCountRowCut **addCuts, int &currentNumberCuts) const =0
Modify model according to information at node.
int nodeNumber_
The node number.
int numberCuts_
Number of row cuts (this node)
const CbcNode * owner() const
CbcNodeInfo & operator=(const CbcNodeInfo &rhs)
Illegal Assignment operator.
const OsiBranchingObject * parentBranch() const
Branching object for the parent.
int active_
Active node information.
virtual CbcNodeInfo * buildRowBasis(CoinWarmStartBasis &basis) const =0
Builds up row basis backwards (until original model).
CbcNodeInfo * parent_
parent
CbcCountRowCut ** cuts_
Array of pointers to cuts.
Information required while the node is live.
Definition: CbcNode.hpp:47
void throwAway()
Say thrown away.
OsiRowCut augmented with bookkeeping.
int decrement(int amount=1)
Decrement number of references and return number left.
void initializeInfo(int number)
Initialize reference counts.
void deactivate(int mode=3)
Deactivate node information.
void nullOwner()
Set owner null.
void decrementCuts(int change=1)
Decrement active cut counts.
Simple Branch and bound class.
Definition: CbcModel.hpp:98
void nullParent()
Set parent null.
void setParentBasedData()
routine common to constructors
int numberRows_
Number of rows in problem (before these cuts).